]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/filepicker.h
Make IsOfClass out-of-line to defend against gcc 3.4.[56] bug:
[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 request */ \
32 /* in response to the user click as the generic implementation does */ \
33 virtual wxWindow *GetDialogParent() \
34 { \
35 return NULL; \
36 } \
37 \
38 virtual bool Destroy() \
39 { \
40 m_dialog->Destroy(); \
41 return wxButton::Destroy(); \
42 } \
43 \
44 virtual void SetPath(const wxString &str) \
45 { \
46 m_path=str; \
47 UpdateDialogPath(m_dialog); \
48 }
49
50
51 //-----------------------------------------------------------------------------
52 // wxFileButton
53 //-----------------------------------------------------------------------------
54
55 class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
56 {
57 public:
58 wxFileButton() { m_dialog = NULL; }
59 wxFileButton(wxWindow *parent,
60 wxWindowID id,
61 const wxString& label = wxFilePickerWidgetLabel,
62 const wxString &path = wxEmptyString,
63 const wxString &message = wxFileSelectorPromptStr,
64 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
65 const wxPoint& pos = wxDefaultPosition,
66 const wxSize& size = wxDefaultSize,
67 long style = wxFILEBTN_DEFAULT_STYLE,
68 const wxValidator& validator = wxDefaultValidator,
69 const wxString& name = wxFilePickerWidgetNameStr)
70 {
71 m_dialog = NULL;
72 Create(parent, id, label, path, message, wildcard,
73 pos, size, style, validator, name);
74 }
75
76 virtual ~wxFileButton();
77
78
79 public: // overrides
80
81 bool Create(wxWindow *parent,
82 wxWindowID id,
83 const wxString& label = wxFilePickerWidgetLabel,
84 const wxString &path = wxEmptyString,
85 const wxString &message = wxFileSelectorPromptStr,
86 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& size = wxDefaultSize,
89 long style = 0,
90 const wxValidator& validator = wxDefaultValidator,
91 const wxString& name = wxFilePickerWidgetNameStr);
92
93 // event handler for the click
94 void OnDialogOK(wxCommandEvent &);
95
96
97 public: // some overrides
98
99 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
100 // so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
101 // is not supported, wxFD_OVERWRITE_PROMPT isn't too...
102 virtual long GetDialogStyle() const
103 {
104 return (wxGenericFileButton::GetDialogStyle() &
105 ~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
106 }
107
108 // see macro defined above
109 FILEDIRBTN_OVERRIDES
110
111 protected:
112 wxDialog *m_dialog;
113
114 private:
115 DECLARE_DYNAMIC_CLASS(wxFileButton)
116 };
117
118
119 //-----------------------------------------------------------------------------
120 // wxDirButton
121 //-----------------------------------------------------------------------------
122
123 class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
124 {
125 public:
126 wxDirButton() { m_dialog = NULL;}
127 wxDirButton(wxWindow *parent,
128 wxWindowID id,
129 const wxString& label = wxFilePickerWidgetLabel,
130 const wxString &path = wxEmptyString,
131 const wxString &message = wxFileSelectorPromptStr,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 long style = wxDIRBTN_DEFAULT_STYLE,
135 const wxValidator& validator = wxDefaultValidator,
136 const wxString& name = wxFilePickerWidgetNameStr)
137 {
138 m_dialog = NULL;
139 Create(parent, id, label, path, message, wxEmptyString,
140 pos, size, style, validator, name);
141 }
142
143 virtual ~wxDirButton();
144
145
146 public: // overrides
147
148 bool Create(wxWindow *parent,
149 wxWindowID id,
150 const wxString& label = wxFilePickerWidgetLabel,
151 const wxString &path = wxEmptyString,
152 const wxString &message = wxFileSelectorPromptStr,
153 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
154 const wxPoint& pos = wxDefaultPosition,
155 const wxSize& size = wxDefaultSize,
156 long style = 0,
157 const wxValidator& validator = wxDefaultValidator,
158 const wxString& name = wxFilePickerWidgetNameStr);
159
160 // used by the GTK callback only
161 void UpdatePath(char *gtkpath)
162 { m_path = wxString::FromAscii(gtkpath); }
163
164 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER
165 // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given
166 long GetDialogStyle() const
167 {
168 return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
169 }
170
171 // see macro defined above
172 FILEDIRBTN_OVERRIDES
173
174 protected:
175 wxDialog *m_dialog;
176
177 private:
178 DECLARE_DYNAMIC_CLASS(wxDirButton)
179 };
180
181 #undef FILEDIRBTN_OVERRIDES
182
183 #endif // _WX_GTK_FILEPICKER_H_
184