]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/filepicker.h
fix printf() argument type in GetOsInfo()
[wxWidgets.git] / include / wx / gtk / filepicker.h
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
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
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(); \
43 }
44
45
46 //-----------------------------------------------------------------------------
47 // wxFileButton
48 //-----------------------------------------------------------------------------
49
50 class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
51 {
52 public:
53 wxFileButton() { m_dialog = NULL; }
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 {
66 m_dialog = NULL;
67 Create(parent, id, label, path, message, wildcard,
68 pos, size, style, validator, name);
69 }
70
71 virtual ~wxFileButton();
72
73
74 public: // 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
92 public: // some overrides
93
94 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
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
98 {
99 return (wxGenericFileButton::GetDialogStyle() &
100 ~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
101 }
102
103 virtual void SetPath(const wxString &str);
104
105 // see macro defined above
106 FILEDIRBTN_OVERRIDES
107
108 protected:
109 wxDialog *m_dialog;
110
111 private:
112 DECLARE_DYNAMIC_CLASS(wxFileButton)
113 };
114
115
116 //-----------------------------------------------------------------------------
117 // wxDirButton
118 //-----------------------------------------------------------------------------
119
120 class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
121 {
122 public:
123 wxDirButton() { Init(); }
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 {
135 Init();
136
137 Create(parent, id, label, path, message, wxEmptyString,
138 pos, size, style, validator, name);
139 }
140
141 virtual ~wxDirButton();
142
143
144 public: // 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
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
166 virtual void SetPath(const wxString &str);
167
168 // see macro defined above
169 FILEDIRBTN_OVERRIDES
170
171 protected:
172 // common part of all ctors
173 void Init()
174 {
175 m_dialog = NULL;
176 m_bIgnoreNextChange = false;
177 }
178
179 wxDialog *m_dialog;
180
181 public: // 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
188 private:
189 DECLARE_DYNAMIC_CLASS(wxDirButton)
190 };
191
192 #undef FILEDIRBTN_OVERRIDES
193
194 #endif // _WX_GTK_FILEPICKER_H_
195