]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/filepicker.h
Blind wxTinderbox fix.
[wxWidgets.git] / include / wx / gtk / filepicker.h
CommitLineData
ec376c8f
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/filedirpicker.h
3// Purpose: wxFileButton, wxDirButton header
4// Author: Francesco Montorsi
5// Modified by:
6// Created: 14/4/2006
7// Copyright: (c) Francesco Montorsi
8// RCS-ID: $Id$
9// Licence: wxWindows Licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GTK_FILEPICKER_H_
13#define _WX_GTK_FILEPICKER_H_
14
15// since GtkColorButton is available only for GTK+ >= 2.4,
16// we need to use generic versions if we detect (at runtime)
17// that GTK+ < 2.4
18#include "wx/generic/filepickerg.h"
19
556151f5
MW
20
21
22//-----------------------------------------------------------------------------
23// wxFileButton and wxDirButton shared code
24// (cannot be a base class since they need to derive from wxGenericFileButton
25// and from wxGenericDirButton classes !)
26//-----------------------------------------------------------------------------
27
1029169f
VS
28#define FILEDIRBTN_OVERRIDES \
29 /* NULL is because of a problem with destruction order which happens */ \
30 /* if we pass GetParent(): in fact, this GTK native implementation */ \
31 /* needs to create the dialog in ::Create() and not for each user */ \
32 /* request in response to the user click as the generic implementation */ \
33 /* does. */ \
34 virtual wxWindow *GetDialogParent() \
35 { \
36 return NULL; \
37 } \
38 \
39 virtual bool Destroy() \
40 { \
41 m_dialog->Destroy(); \
42 return wxButton::Destroy(); \
556151f5
MW
43 }
44
45
ec376c8f
VZ
46//-----------------------------------------------------------------------------
47// wxFileButton
48//-----------------------------------------------------------------------------
49
50class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
51{
52public:
556151f5 53 wxFileButton() { m_dialog = NULL; }
ec376c8f
VZ
54 wxFileButton(wxWindow *parent,
55 wxWindowID id,
56 const wxString& label = wxFilePickerWidgetLabel,
57 const wxString &path = wxEmptyString,
58 const wxString &message = wxFileSelectorPromptStr,
59 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize,
62 long style = wxFILEBTN_DEFAULT_STYLE,
63 const wxValidator& validator = wxDefaultValidator,
64 const wxString& name = wxFilePickerWidgetNameStr)
65 {
556151f5 66 m_dialog = NULL;
ec376c8f
VZ
67 Create(parent, id, label, path, message, wildcard,
68 pos, size, style, validator, name);
69 }
70
556151f5 71 virtual ~wxFileButton();
ec376c8f
VZ
72
73
74public: // overrides
75
76 bool Create(wxWindow *parent,
77 wxWindowID id,
78 const wxString& label = wxFilePickerWidgetLabel,
79 const wxString &path = wxEmptyString,
80 const wxString &message = wxFileSelectorPromptStr,
81 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
82 const wxPoint& pos = wxDefaultPosition,
83 const wxSize& size = wxDefaultSize,
84 long style = 0,
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = wxFilePickerWidgetNameStr);
87
88 // event handler for the click
89 void OnDialogOK(wxCommandEvent &);
90
91
556151f5
MW
92public: // some overrides
93
ec376c8f 94 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
556151f5
MW
95 // so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
96 // is not supported, wxFD_OVERWRITE_PROMPT isn't too...
97 virtual long GetDialogStyle() const
ec376c8f 98 {
556151f5
MW
99 return (wxGenericFileButton::GetDialogStyle() &
100 ~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
ec376c8f
VZ
101 }
102
58772e49
VZ
103 virtual void SetPath(const wxString &str);
104
556151f5
MW
105 // see macro defined above
106 FILEDIRBTN_OVERRIDES
107
108protected:
109 wxDialog *m_dialog;
ec376c8f
VZ
110
111private:
112 DECLARE_DYNAMIC_CLASS(wxFileButton)
113};
114
115
116//-----------------------------------------------------------------------------
117// wxDirButton
118//-----------------------------------------------------------------------------
119
120class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
121{
122public:
58772e49 123 wxDirButton() { Init(); }
ec376c8f
VZ
124 wxDirButton(wxWindow *parent,
125 wxWindowID id,
126 const wxString& label = wxFilePickerWidgetLabel,
127 const wxString &path = wxEmptyString,
128 const wxString &message = wxFileSelectorPromptStr,
129 const wxPoint& pos = wxDefaultPosition,
130 const wxSize& size = wxDefaultSize,
131 long style = wxDIRBTN_DEFAULT_STYLE,
132 const wxValidator& validator = wxDefaultValidator,
133 const wxString& name = wxFilePickerWidgetNameStr)
134 {
58772e49
VZ
135 Init();
136
ec376c8f
VZ
137 Create(parent, id, label, path, message, wxEmptyString,
138 pos, size, style, validator, name);
139 }
140
141 virtual ~wxDirButton();
142
143
144public: // overrides
145
146 bool Create(wxWindow *parent,
147 wxWindowID id,
148 const wxString& label = wxFilePickerWidgetLabel,
149 const wxString &path = wxEmptyString,
150 const wxString &message = wxFileSelectorPromptStr,
151 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 long style = 0,
155 const wxValidator& validator = wxDefaultValidator,
156 const wxString& name = wxFilePickerWidgetNameStr);
157
ec376c8f
VZ
158
159 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER
160 // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given
161 long GetDialogStyle() const
162 {
163 return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
164 }
165
58772e49
VZ
166 virtual void SetPath(const wxString &str);
167
556151f5
MW
168 // see macro defined above
169 FILEDIRBTN_OVERRIDES
170
171protected:
58772e49
VZ
172 // common part of all ctors
173 void Init()
174 {
175 m_dialog = NULL;
176 m_bIgnoreNextChange = false;
177 }
178
556151f5
MW
179 wxDialog *m_dialog;
180
58772e49
VZ
181public: // used by the GTK callback only
182
183 bool m_bIgnoreNextChange;
184
185 void UpdatePath(const char *gtkpath)
186 { m_path = wxString::FromAscii(gtkpath); }
187
ec376c8f
VZ
188private:
189 DECLARE_DYNAMIC_CLASS(wxDirButton)
190};
191
556151f5
MW
192#undef FILEDIRBTN_OVERRIDES
193
ec376c8f
VZ
194#endif // _WX_GTK_FILEPICKER_H_
195