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