]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/filepicker.h
add a header placeholder
[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(); \
64321998
RR
43 } \
44 \
45 /* even if wx derive from wxGenericFileButton, i.e. from wxButton, our */ \
46 /* native GTK+ widget does not derive from GtkButton thus *all* uses */ \
47 /* GTK_BUTTON(m_widget) macro done by wxButton must be bypassed to */ \
48 /* avoid bunch of GTK+ warnings like: */ \
49 /* invalid cast from `GtkFileChooserButton' to `GtkButton' */ \
50 /* so, override wxButton::GTKGetWindow and return NULL as GTK+ doesn't */ \
51 /* give us access to the internal GdkWindow of a GtkFileChooserButton */ \
52 virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const \
53 { return NULL; }
556151f5
MW
54
55
ec376c8f
VZ
56//-----------------------------------------------------------------------------
57// wxFileButton
58//-----------------------------------------------------------------------------
59
60class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
61{
62public:
556151f5 63 wxFileButton() { m_dialog = NULL; }
ec376c8f
VZ
64 wxFileButton(wxWindow *parent,
65 wxWindowID id,
66 const wxString& label = wxFilePickerWidgetLabel,
67 const wxString &path = wxEmptyString,
68 const wxString &message = wxFileSelectorPromptStr,
69 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
70 const wxPoint& pos = wxDefaultPosition,
71 const wxSize& size = wxDefaultSize,
72 long style = wxFILEBTN_DEFAULT_STYLE,
73 const wxValidator& validator = wxDefaultValidator,
74 const wxString& name = wxFilePickerWidgetNameStr)
75 {
556151f5 76 m_dialog = NULL;
ec376c8f
VZ
77 Create(parent, id, label, path, message, wildcard,
78 pos, size, style, validator, name);
79 }
80
556151f5 81 virtual ~wxFileButton();
ec376c8f
VZ
82
83
84public: // overrides
85
86 bool Create(wxWindow *parent,
87 wxWindowID id,
88 const wxString& label = wxFilePickerWidgetLabel,
89 const wxString &path = wxEmptyString,
90 const wxString &message = wxFileSelectorPromptStr,
91 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 long style = 0,
95 const wxValidator& validator = wxDefaultValidator,
96 const wxString& name = wxFilePickerWidgetNameStr);
97
98 // event handler for the click
99 void OnDialogOK(wxCommandEvent &);
100
101
556151f5
MW
102public: // some overrides
103
ec376c8f 104 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
556151f5
MW
105 // so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
106 // is not supported, wxFD_OVERWRITE_PROMPT isn't too...
107 virtual long GetDialogStyle() const
ec376c8f 108 {
556151f5
MW
109 return (wxGenericFileButton::GetDialogStyle() &
110 ~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
ec376c8f
VZ
111 }
112
58772e49
VZ
113 virtual void SetPath(const wxString &str);
114
556151f5
MW
115 // see macro defined above
116 FILEDIRBTN_OVERRIDES
117
118protected:
119 wxDialog *m_dialog;
ec376c8f
VZ
120
121private:
122 DECLARE_DYNAMIC_CLASS(wxFileButton)
123};
124
125
126//-----------------------------------------------------------------------------
127// wxDirButton
128//-----------------------------------------------------------------------------
129
130class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
131{
132public:
58772e49 133 wxDirButton() { Init(); }
ec376c8f
VZ
134 wxDirButton(wxWindow *parent,
135 wxWindowID id,
136 const wxString& label = wxFilePickerWidgetLabel,
137 const wxString &path = wxEmptyString,
138 const wxString &message = wxFileSelectorPromptStr,
139 const wxPoint& pos = wxDefaultPosition,
140 const wxSize& size = wxDefaultSize,
141 long style = wxDIRBTN_DEFAULT_STYLE,
142 const wxValidator& validator = wxDefaultValidator,
143 const wxString& name = wxFilePickerWidgetNameStr)
144 {
58772e49
VZ
145 Init();
146
ec376c8f
VZ
147 Create(parent, id, label, path, message, wxEmptyString,
148 pos, size, style, validator, name);
149 }
150
151 virtual ~wxDirButton();
152
153
154public: // overrides
155
156 bool Create(wxWindow *parent,
157 wxWindowID id,
158 const wxString& label = wxFilePickerWidgetLabel,
159 const wxString &path = wxEmptyString,
160 const wxString &message = wxFileSelectorPromptStr,
161 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
162 const wxPoint& pos = wxDefaultPosition,
163 const wxSize& size = wxDefaultSize,
164 long style = 0,
165 const wxValidator& validator = wxDefaultValidator,
166 const wxString& name = wxFilePickerWidgetNameStr);
167
ec376c8f
VZ
168
169 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER
170 // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given
171 long GetDialogStyle() const
172 {
173 return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
174 }
175
58772e49
VZ
176 virtual void SetPath(const wxString &str);
177
556151f5
MW
178 // see macro defined above
179 FILEDIRBTN_OVERRIDES
180
181protected:
58772e49
VZ
182 // common part of all ctors
183 void Init()
184 {
185 m_dialog = NULL;
186 m_bIgnoreNextChange = false;
187 }
188
556151f5
MW
189 wxDialog *m_dialog;
190
58772e49
VZ
191public: // used by the GTK callback only
192
193 bool m_bIgnoreNextChange;
194
195 void UpdatePath(const char *gtkpath)
196 { m_path = wxString::FromAscii(gtkpath); }
197
ec376c8f
VZ
198private:
199 DECLARE_DYNAMIC_CLASS(wxDirButton)
200};
201
556151f5
MW
202#undef FILEDIRBTN_OVERRIDES
203
ec376c8f
VZ
204#endif // _WX_GTK_FILEPICKER_H_
205