]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/filepicker.h
Allow custom wxDataViewCtrl renderers to easily use attributes.
[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 { \
dee059c4
JS
39 if (m_dialog) \
40 m_dialog->Destroy(); \
1029169f 41 return wxButton::Destroy(); \
64321998
RR
42 } \
43 \
44 /* even if wx derive from wxGenericFileButton, i.e. from wxButton, our */ \
45 /* native GTK+ widget does not derive from GtkButton thus *all* uses */ \
46 /* GTK_BUTTON(m_widget) macro done by wxButton must be bypassed to */ \
47 /* avoid bunch of GTK+ warnings like: */ \
48 /* invalid cast from `GtkFileChooserButton' to `GtkButton' */ \
49 /* so, override wxButton::GTKGetWindow and return NULL as GTK+ doesn't */ \
50 /* give us access to the internal GdkWindow of a GtkFileChooserButton */ \
bc48a5d7 51protected: \
e4161a2a
VZ
52 virtual GdkWindow * \
53 GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const \
64321998 54 { return NULL; }
556151f5
MW
55
56
ec376c8f
VZ
57//-----------------------------------------------------------------------------
58// wxFileButton
59//-----------------------------------------------------------------------------
60
61class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
62{
63public:
556151f5 64 wxFileButton() { m_dialog = NULL; }
ec376c8f
VZ
65 wxFileButton(wxWindow *parent,
66 wxWindowID id,
67 const wxString& label = wxFilePickerWidgetLabel,
68 const wxString &path = wxEmptyString,
69 const wxString &message = wxFileSelectorPromptStr,
70 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = wxFILEBTN_DEFAULT_STYLE,
74 const wxValidator& validator = wxDefaultValidator,
75 const wxString& name = wxFilePickerWidgetNameStr)
76 {
556151f5 77 m_dialog = NULL;
ec376c8f
VZ
78 Create(parent, id, label, path, message, wildcard,
79 pos, size, style, validator, name);
80 }
81
556151f5 82 virtual ~wxFileButton();
ec376c8f
VZ
83
84
85public: // overrides
86
87 bool Create(wxWindow *parent,
88 wxWindowID id,
89 const wxString& label = wxFilePickerWidgetLabel,
90 const wxString &path = wxEmptyString,
91 const wxString &message = wxFileSelectorPromptStr,
92 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
93 const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize,
95 long style = 0,
96 const wxValidator& validator = wxDefaultValidator,
97 const wxString& name = wxFilePickerWidgetNameStr);
98
99 // event handler for the click
100 void OnDialogOK(wxCommandEvent &);
101
58772e49
VZ
102 virtual void SetPath(const wxString &str);
103
556151f5
MW
104 // see macro defined above
105 FILEDIRBTN_OVERRIDES
106
107protected:
92153555
VZ
108 virtual bool GTKShouldConnectSizeRequest() const { return false; }
109
556151f5 110 wxDialog *m_dialog;
ec376c8f 111
ec376c8f
VZ
112 DECLARE_DYNAMIC_CLASS(wxFileButton)
113};
114
115
116//-----------------------------------------------------------------------------
117// wxDirButton
118//-----------------------------------------------------------------------------
119
120class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
121{
122public:
58772e49 123 wxDirButton() { Init(); }
ec376c8f
VZ
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 {
58772e49
VZ
135 Init();
136
ec376c8f
VZ
137 Create(parent, id, label, path, message, wxEmptyString,
138 pos, size, style, validator, name);
139 }
140
141 virtual ~wxDirButton();
142
143
144public: // 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
ec376c8f
VZ
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
58772e49
VZ
166 virtual void SetPath(const wxString &str);
167
556151f5
MW
168 // see macro defined above
169 FILEDIRBTN_OVERRIDES
170
171protected:
58772e49
VZ
172 // common part of all ctors
173 void Init()
174 {
175 m_dialog = NULL;
176 m_bIgnoreNextChange = false;
177 }
178
556151f5
MW
179 wxDialog *m_dialog;
180
58772e49
VZ
181public: // used by the GTK callback only
182
183 bool m_bIgnoreNextChange;
184
21d96807
BP
185 void GTKUpdatePath(const char *gtkpath);
186
ec376c8f
VZ
187private:
188 DECLARE_DYNAMIC_CLASS(wxDirButton)
189};
190
556151f5
MW
191#undef FILEDIRBTN_OVERRIDES
192
ec376c8f
VZ
193#endif // _WX_GTK_FILEPICKER_H_
194