]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/filepicker.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / gtk / filepicker.h
... / ...
CommitLineData
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// 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
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
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 \
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 */ \
43protected: \
44 virtual GdkWindow * \
45 GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const \
46 { return NULL; }
47
48
49//-----------------------------------------------------------------------------
50// wxFileButton
51//-----------------------------------------------------------------------------
52
53class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
54{
55public:
56 wxFileButton() { Init(); }
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 {
69 Init();
70 m_pickerStyle = style;
71 Create(parent, id, label, path, message, wildcard,
72 pos, size, style, validator, name);
73 }
74
75 virtual ~wxFileButton();
76
77
78public: // 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
95 virtual void SetPath(const wxString &str);
96 virtual void SetInitialDirectory(const wxString& dir);
97
98 // see macro defined above
99 FILEDIRBTN_OVERRIDES
100
101protected:
102 wxDialog *m_dialog;
103
104private:
105 // common part of all ctors
106 void Init() { m_dialog = NULL; }
107
108 DECLARE_DYNAMIC_CLASS(wxFileButton)
109};
110
111
112//-----------------------------------------------------------------------------
113// wxDirButton
114//-----------------------------------------------------------------------------
115
116class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
117{
118public:
119 wxDirButton() { Init(); }
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 {
131 Init();
132
133 m_pickerStyle = style;
134
135 Create(parent, id, label, path, message, wxEmptyString,
136 pos, size, style, validator, name);
137 }
138
139 virtual ~wxDirButton();
140
141
142public: // 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
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
164 virtual void SetPath(const wxString &str);
165 virtual void SetInitialDirectory(const wxString& dir);
166
167 // see macro defined above
168 FILEDIRBTN_OVERRIDES
169
170protected:
171 wxDialog *m_dialog;
172
173public: // used by the GTK callback only
174
175 bool m_bIgnoreNextChange;
176
177 void GTKUpdatePath(const char *gtkpath);
178
179private:
180 void Init()
181 {
182 m_dialog = NULL;
183 m_bIgnoreNextChange = false;
184 }
185
186 DECLARE_DYNAMIC_CLASS(wxDirButton)
187};
188
189#undef FILEDIRBTN_OVERRIDES
190
191#endif // _WX_GTK_FILEPICKER_H_
192