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