]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/filepicker.h
use ZIP entry modification time, not the (inexistent) file modification time
[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
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(); \
556151f5
MW
42 }
43
44
ec376c8f
VZ
45//-----------------------------------------------------------------------------
46// wxFileButton
47//-----------------------------------------------------------------------------
48
49class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
50{
51public:
556151f5 52 wxFileButton() { m_dialog = NULL; }
ec376c8f
VZ
53 wxFileButton(wxWindow *parent,
54 wxWindowID id,
55 const wxString& label = wxFilePickerWidgetLabel,
56 const wxString &path = wxEmptyString,
57 const wxString &message = wxFileSelectorPromptStr,
58 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize,
61 long style = wxFILEBTN_DEFAULT_STYLE,
62 const wxValidator& validator = wxDefaultValidator,
63 const wxString& name = wxFilePickerWidgetNameStr)
64 {
556151f5 65 m_dialog = NULL;
ec376c8f
VZ
66 Create(parent, id, label, path, message, wildcard,
67 pos, size, style, validator, name);
68 }
69
556151f5 70 virtual ~wxFileButton();
ec376c8f
VZ
71
72
73public: // overrides
74
75 bool Create(wxWindow *parent,
76 wxWindowID id,
77 const wxString& label = wxFilePickerWidgetLabel,
78 const wxString &path = wxEmptyString,
79 const wxString &message = wxFileSelectorPromptStr,
80 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
83 long style = 0,
84 const wxValidator& validator = wxDefaultValidator,
85 const wxString& name = wxFilePickerWidgetNameStr);
86
87 // event handler for the click
88 void OnDialogOK(wxCommandEvent &);
89
90
556151f5
MW
91public: // some overrides
92
ec376c8f 93 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
556151f5
MW
94 // so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
95 // is not supported, wxFD_OVERWRITE_PROMPT isn't too...
96 virtual long GetDialogStyle() const
ec376c8f 97 {
556151f5
MW
98 return (wxGenericFileButton::GetDialogStyle() &
99 ~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
ec376c8f
VZ
100 }
101
58772e49
VZ
102 virtual void SetPath(const wxString &str);
103
556151f5
MW
104 // see macro defined above
105 FILEDIRBTN_OVERRIDES
106
107protected:
108 wxDialog *m_dialog;
ec376c8f
VZ
109
110private:
111 DECLARE_DYNAMIC_CLASS(wxFileButton)
112};
113
114
115//-----------------------------------------------------------------------------
116// wxDirButton
117//-----------------------------------------------------------------------------
118
119class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
120{
121public:
58772e49 122 wxDirButton() { Init(); }
ec376c8f
VZ
123 wxDirButton(wxWindow *parent,
124 wxWindowID id,
125 const wxString& label = wxFilePickerWidgetLabel,
126 const wxString &path = wxEmptyString,
127 const wxString &message = wxFileSelectorPromptStr,
128 const wxPoint& pos = wxDefaultPosition,
129 const wxSize& size = wxDefaultSize,
130 long style = wxDIRBTN_DEFAULT_STYLE,
131 const wxValidator& validator = wxDefaultValidator,
132 const wxString& name = wxFilePickerWidgetNameStr)
133 {
58772e49
VZ
134 Init();
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
VZ
165 virtual void SetPath(const wxString &str);
166
556151f5
MW
167 // see macro defined above
168 FILEDIRBTN_OVERRIDES
169
170protected:
58772e49
VZ
171 // common part of all ctors
172 void Init()
173 {
174 m_dialog = NULL;
175 m_bIgnoreNextChange = false;
176 }
177
556151f5
MW
178 wxDialog *m_dialog;
179
58772e49
VZ
180public: // used by the GTK callback only
181
182 bool m_bIgnoreNextChange;
183
184 void UpdatePath(const char *gtkpath)
185 { m_path = wxString::FromAscii(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