]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/filepicker.h
Document wxKill(wxSIGTERM) reliance on having an open window in wxMSW.
[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 \
64321998
RR
37 /* even if wx derive from wxGenericFileButton, i.e. from wxButton, our */ \
38 /* native GTK+ widget does not derive from GtkButton thus *all* uses */ \
39 /* GTK_BUTTON(m_widget) macro done by wxButton must be bypassed to */ \
40 /* avoid bunch of GTK+ warnings like: */ \
41 /* invalid cast from `GtkFileChooserButton' to `GtkButton' */ \
42 /* so, override wxButton::GTKGetWindow and return NULL as GTK+ doesn't */ \
43 /* give us access to the internal GdkWindow of a GtkFileChooserButton */ \
bc48a5d7 44protected: \
e4161a2a
VZ
45 virtual GdkWindow * \
46 GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const \
64321998 47 { return NULL; }
556151f5
MW
48
49
ec376c8f
VZ
50//-----------------------------------------------------------------------------
51// wxFileButton
52//-----------------------------------------------------------------------------
53
54class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
55{
56public:
459128ac 57 wxFileButton() { Init(); }
ec376c8f
VZ
58 wxFileButton(wxWindow *parent,
59 wxWindowID id,
60 const wxString& label = wxFilePickerWidgetLabel,
61 const wxString &path = wxEmptyString,
62 const wxString &message = wxFileSelectorPromptStr,
63 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
64 const wxPoint& pos = wxDefaultPosition,
65 const wxSize& size = wxDefaultSize,
66 long style = wxFILEBTN_DEFAULT_STYLE,
67 const wxValidator& validator = wxDefaultValidator,
68 const wxString& name = wxFilePickerWidgetNameStr)
69 {
459128ac
VZ
70 Init();
71 m_pickerStyle = style;
ec376c8f
VZ
72 Create(parent, id, label, path, message, wildcard,
73 pos, size, style, validator, name);
74 }
75
556151f5 76 virtual ~wxFileButton();
ec376c8f
VZ
77
78
79public: // 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
58772e49 96 virtual void SetPath(const wxString &str);
75cb911c 97 virtual void SetInitialDirectory(const wxString& dir);
58772e49 98
556151f5
MW
99 // see macro defined above
100 FILEDIRBTN_OVERRIDES
101
102protected:
103 wxDialog *m_dialog;
ec376c8f 104
459128ac
VZ
105private:
106 // common part of all ctors
107 void Init() { m_dialog = NULL; }
108
ec376c8f
VZ
109 DECLARE_DYNAMIC_CLASS(wxFileButton)
110};
111
112
113//-----------------------------------------------------------------------------
114// wxDirButton
115//-----------------------------------------------------------------------------
116
117class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
118{
119public:
58772e49 120 wxDirButton() { Init(); }
ec376c8f
VZ
121 wxDirButton(wxWindow *parent,
122 wxWindowID id,
123 const wxString& label = wxFilePickerWidgetLabel,
124 const wxString &path = wxEmptyString,
125 const wxString &message = wxFileSelectorPromptStr,
126 const wxPoint& pos = wxDefaultPosition,
127 const wxSize& size = wxDefaultSize,
128 long style = wxDIRBTN_DEFAULT_STYLE,
129 const wxValidator& validator = wxDefaultValidator,
130 const wxString& name = wxFilePickerWidgetNameStr)
131 {
58772e49
VZ
132 Init();
133
459128ac
VZ
134 m_pickerStyle = style;
135
ec376c8f
VZ
136 Create(parent, id, label, path, message, wxEmptyString,
137 pos, size, style, validator, name);
138 }
139
140 virtual ~wxDirButton();
141
142
143public: // overrides
144
145 bool Create(wxWindow *parent,
146 wxWindowID id,
147 const wxString& label = wxFilePickerWidgetLabel,
148 const wxString &path = wxEmptyString,
149 const wxString &message = wxFileSelectorPromptStr,
150 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
151 const wxPoint& pos = wxDefaultPosition,
152 const wxSize& size = wxDefaultSize,
153 long style = 0,
154 const wxValidator& validator = wxDefaultValidator,
155 const wxString& name = wxFilePickerWidgetNameStr);
156
ec376c8f
VZ
157
158 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER
159 // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given
160 long GetDialogStyle() const
161 {
162 return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
163 }
164
58772e49 165 virtual void SetPath(const wxString &str);
75cb911c 166 virtual void SetInitialDirectory(const wxString& dir);
58772e49 167
556151f5
MW
168 // see macro defined above
169 FILEDIRBTN_OVERRIDES
170
171protected:
172 wxDialog *m_dialog;
173
58772e49
VZ
174public: // used by the GTK callback only
175
176 bool m_bIgnoreNextChange;
177
21d96807
BP
178 void GTKUpdatePath(const char *gtkpath);
179
ec376c8f 180private:
95dc31e0
PC
181 void Init()
182 {
183 m_dialog = NULL;
184 m_bIgnoreNextChange = false;
185 }
186
ec376c8f
VZ
187 DECLARE_DYNAMIC_CLASS(wxDirButton)
188};
189
556151f5
MW
190#undef FILEDIRBTN_OVERRIDES
191
ec376c8f
VZ
192#endif // _WX_GTK_FILEPICKER_H_
193