]>
Commit | Line | Data |
---|---|---|
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 | |
ec376c8f VZ |
8 | // Licence: wxWindows Licence |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_GTK_FILEPICKER_H_ | |
12 | #define _WX_GTK_FILEPICKER_H_ | |
13 | ||
14 | // since GtkColorButton is available only for GTK+ >= 2.4, | |
15 | // we need to use generic versions if we detect (at runtime) | |
16 | // that GTK+ < 2.4 | |
17 | #include "wx/generic/filepickerg.h" | |
18 | ||
556151f5 MW |
19 | //----------------------------------------------------------------------------- |
20 | // wxFileButton and wxDirButton shared code | |
21 | // (cannot be a base class since they need to derive from wxGenericFileButton | |
22 | // and from wxGenericDirButton classes !) | |
23 | //----------------------------------------------------------------------------- | |
24 | ||
1029169f VS |
25 | #define FILEDIRBTN_OVERRIDES \ |
26 | /* NULL is because of a problem with destruction order which happens */ \ | |
27 | /* if we pass GetParent(): in fact, this GTK native implementation */ \ | |
28 | /* needs to create the dialog in ::Create() and not for each user */ \ | |
29 | /* request in response to the user click as the generic implementation */ \ | |
30 | /* does. */ \ | |
31 | virtual wxWindow *GetDialogParent() \ | |
32 | { \ | |
33 | return NULL; \ | |
34 | } \ | |
35 | \ | |
64321998 RR |
36 | /* even if wx derive from wxGenericFileButton, i.e. from wxButton, our */ \ |
37 | /* native GTK+ widget does not derive from GtkButton thus *all* uses */ \ | |
38 | /* GTK_BUTTON(m_widget) macro done by wxButton must be bypassed to */ \ | |
39 | /* avoid bunch of GTK+ warnings like: */ \ | |
40 | /* invalid cast from `GtkFileChooserButton' to `GtkButton' */ \ | |
41 | /* so, override wxButton::GTKGetWindow and return NULL as GTK+ doesn't */ \ | |
42 | /* give us access to the internal GdkWindow of a GtkFileChooserButton */ \ | |
bc48a5d7 | 43 | protected: \ |
e4161a2a VZ |
44 | virtual GdkWindow * \ |
45 | GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const \ | |
64321998 | 46 | { return NULL; } |
556151f5 MW |
47 | |
48 | ||
ec376c8f VZ |
49 | //----------------------------------------------------------------------------- |
50 | // wxFileButton | |
51 | //----------------------------------------------------------------------------- | |
52 | ||
53 | class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton | |
54 | { | |
55 | public: | |
459128ac | 56 | wxFileButton() { Init(); } |
ec376c8f VZ |
57 | wxFileButton(wxWindow *parent, |
58 | wxWindowID id, | |
59 | const wxString& label = wxFilePickerWidgetLabel, | |
60 | const wxString &path = wxEmptyString, | |
61 | const wxString &message = wxFileSelectorPromptStr, | |
62 | const wxString &wildcard = wxFileSelectorDefaultWildcardStr, | |
63 | const wxPoint& pos = wxDefaultPosition, | |
64 | const wxSize& size = wxDefaultSize, | |
65 | long style = wxFILEBTN_DEFAULT_STYLE, | |
66 | const wxValidator& validator = wxDefaultValidator, | |
67 | const wxString& name = wxFilePickerWidgetNameStr) | |
68 | { | |
459128ac VZ |
69 | Init(); |
70 | m_pickerStyle = style; | |
ec376c8f VZ |
71 | Create(parent, id, label, path, message, wildcard, |
72 | pos, size, style, validator, name); | |
73 | } | |
74 | ||
556151f5 | 75 | virtual ~wxFileButton(); |
ec376c8f VZ |
76 | |
77 | ||
78 | public: // overrides | |
79 | ||
80 | bool Create(wxWindow *parent, | |
81 | wxWindowID id, | |
82 | const wxString& label = wxFilePickerWidgetLabel, | |
83 | const wxString &path = wxEmptyString, | |
84 | const wxString &message = wxFileSelectorPromptStr, | |
85 | const wxString &wildcard = wxFileSelectorDefaultWildcardStr, | |
86 | const wxPoint& pos = wxDefaultPosition, | |
87 | const wxSize& size = wxDefaultSize, | |
88 | long style = 0, | |
89 | const wxValidator& validator = wxDefaultValidator, | |
90 | const wxString& name = wxFilePickerWidgetNameStr); | |
91 | ||
92 | // event handler for the click | |
93 | void OnDialogOK(wxCommandEvent &); | |
94 | ||
58772e49 | 95 | virtual void SetPath(const wxString &str); |
75cb911c | 96 | virtual void SetInitialDirectory(const wxString& dir); |
58772e49 | 97 | |
556151f5 MW |
98 | // see macro defined above |
99 | FILEDIRBTN_OVERRIDES | |
100 | ||
101 | protected: | |
102 | wxDialog *m_dialog; | |
ec376c8f | 103 | |
459128ac VZ |
104 | private: |
105 | // common part of all ctors | |
106 | void Init() { m_dialog = NULL; } | |
107 | ||
ec376c8f VZ |
108 | DECLARE_DYNAMIC_CLASS(wxFileButton) |
109 | }; | |
110 | ||
111 | ||
112 | //----------------------------------------------------------------------------- | |
113 | // wxDirButton | |
114 | //----------------------------------------------------------------------------- | |
115 | ||
116 | class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton | |
117 | { | |
118 | public: | |
58772e49 | 119 | wxDirButton() { Init(); } |
ec376c8f VZ |
120 | wxDirButton(wxWindow *parent, |
121 | wxWindowID id, | |
122 | const wxString& label = wxFilePickerWidgetLabel, | |
123 | const wxString &path = wxEmptyString, | |
124 | const wxString &message = wxFileSelectorPromptStr, | |
125 | const wxPoint& pos = wxDefaultPosition, | |
126 | const wxSize& size = wxDefaultSize, | |
127 | long style = wxDIRBTN_DEFAULT_STYLE, | |
128 | const wxValidator& validator = wxDefaultValidator, | |
129 | const wxString& name = wxFilePickerWidgetNameStr) | |
130 | { | |
58772e49 VZ |
131 | Init(); |
132 | ||
459128ac VZ |
133 | m_pickerStyle = style; |
134 | ||
ec376c8f VZ |
135 | Create(parent, id, label, path, message, wxEmptyString, |
136 | pos, size, style, validator, name); | |
137 | } | |
138 | ||
139 | virtual ~wxDirButton(); | |
140 | ||
141 | ||
142 | public: // overrides | |
143 | ||
144 | bool Create(wxWindow *parent, | |
145 | wxWindowID id, | |
146 | const wxString& label = wxFilePickerWidgetLabel, | |
147 | const wxString &path = wxEmptyString, | |
148 | const wxString &message = wxFileSelectorPromptStr, | |
149 | const wxString &wildcard = wxFileSelectorDefaultWildcardStr, | |
150 | const wxPoint& pos = wxDefaultPosition, | |
151 | const wxSize& size = wxDefaultSize, | |
152 | long style = 0, | |
153 | const wxValidator& validator = wxDefaultValidator, | |
154 | const wxString& name = wxFilePickerWidgetNameStr); | |
155 | ||
ec376c8f VZ |
156 | |
157 | // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER | |
158 | // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given | |
159 | long GetDialogStyle() const | |
160 | { | |
161 | return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST); | |
162 | } | |
163 | ||
58772e49 | 164 | virtual void SetPath(const wxString &str); |
75cb911c | 165 | virtual void SetInitialDirectory(const wxString& dir); |
58772e49 | 166 | |
556151f5 MW |
167 | // see macro defined above |
168 | FILEDIRBTN_OVERRIDES | |
169 | ||
170 | protected: | |
171 | wxDialog *m_dialog; | |
172 | ||
58772e49 VZ |
173 | public: // used by the GTK callback only |
174 | ||
175 | bool m_bIgnoreNextChange; | |
176 | ||
21d96807 BP |
177 | void GTKUpdatePath(const char *gtkpath); |
178 | ||
ec376c8f | 179 | private: |
95dc31e0 PC |
180 | void Init() |
181 | { | |
182 | m_dialog = NULL; | |
183 | m_bIgnoreNextChange = false; | |
184 | } | |
185 | ||
ec376c8f VZ |
186 | DECLARE_DYNAMIC_CLASS(wxDirButton) |
187 | }; | |
188 | ||
556151f5 MW |
189 | #undef FILEDIRBTN_OVERRIDES |
190 | ||
ec376c8f VZ |
191 | #endif // _WX_GTK_FILEPICKER_H_ |
192 |