]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/filepicker.h
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / interface / wx / filepicker.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: filepicker.h
e54c96f1 3// Purpose: interface of wxFilePickerCtrl
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
575821fa
RD
9#define wxFLP_OPEN 0x0400
10#define wxFLP_SAVE 0x0800
11#define wxFLP_OVERWRITE_PROMPT 0x1000
12#define wxFLP_FILE_MUST_EXIST 0x2000
13#define wxFLP_CHANGE_DIR 0x4000
14#define wxFLP_SMALL wxPB_SMALL
15#define wxFLP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
16#define wxFLP_DEFAULT_STYLE (wxFLP_OPEN|wxFLP_FILE_MUST_EXIST)
17
18#define wxDIRP_DIR_MUST_EXIST 0x0008
19#define wxDIRP_CHANGE_DIR 0x0010
20#define wxDIRP_SMALL wxPB_SMALL
21#define wxDIRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
22#define wxDIRP_DEFAULT_STYLE (wxDIRP_DIR_MUST_EXIST)
23
24wxEventType wxEVT_COMMAND_FILEPICKER_CHANGED;
25wxEventType wxEVT_COMMAND_DIRPICKER_CHANGED;
26
27
23324ae1
FM
28/**
29 @class wxFilePickerCtrl
7c913512 30
23324ae1
FM
31 This control allows the user to select a file. The generic implementation is
32 a button which brings up a wxFileDialog when clicked. Native implementation
33 may differ but this is usually a (small) widget which give access to the
0b70c946 34 file-chooser dialog.
23324ae1 35 It is only available if @c wxUSE_FILEPICKERCTRL is set to 1 (the default).
7c913512 36
23324ae1 37 @beginStyleTable
8c6791e4 38 @style{wxFLP_DEFAULT_STYLE}
23324ae1
FM
39 The default style: includes wxFLP_OPEN | wxFLP_FILE_MUST_EXIST and,
40 under wxMSW only, wxFLP_USE_TEXTCTRL.
8c6791e4 41 @style{wxFLP_USE_TEXTCTRL}
23324ae1
FM
42 Creates a text control to the left of the picker button which is
43 completely managed by the wxFilePickerCtrl and which can be used by
44 the user to specify a path (see SetPath). The text control is
45 automatically synchronized with button's value. Use functions
46 defined in wxPickerBase to modify the text control.
8c6791e4 47 @style{wxFLP_OPEN}
23324ae1 48 Creates a picker which allows the user to select a file to open.
8c6791e4 49 @style{wxFLP_SAVE}
23324ae1 50 Creates a picker which allows the user to select a file to save.
8c6791e4 51 @style{wxFLP_OVERWRITE_PROMPT}
23324ae1
FM
52 Can be combined with wxFLP_SAVE only: ask confirmation to the user
53 before selecting a file.
8c6791e4 54 @style{wxFLP_FILE_MUST_EXIST}
23324ae1
FM
55 Can be combined with wxFLP_OPEN only: the selected file must be an
56 existing file.
8c6791e4 57 @style{wxFLP_CHANGE_DIR}
23324ae1 58 Change current working directory on each user file selection change.
75bc8b34
VZ
59 @style{wxFLP_SMALL}
60 Use smaller version of the control with a small "..." button instead
61 of the normal "Browse" one. This flag is new since wxWidgets 2.9.3.
23324ae1 62 @endStyleTable
7c913512 63
0b70c946 64
3051a44a 65 @beginEventEmissionTable{wxFileDirPickerEvent}
0b70c946
FM
66 @event{EVT_FILEPICKER_CHANGED(id, func)}
67 The user changed the file selected in the control either using the
68 button or using text control (see wxFLP_USE_TEXTCTRL; note that in
69 this case the event is fired only if the user's input is valid,
70 e.g. an existing file path if wxFLP_FILE_MUST_EXIST was given).
71 @endEventTable
72
23324ae1 73 @library{wxcore}
d18d9f60 74 @category{pickers}
ce154616 75 @appearance{filepickerctrl}
7c913512 76
e54c96f1 77 @see wxFileDialog, wxFileDirPickerEvent
23324ae1
FM
78*/
79class wxFilePickerCtrl : public wxPickerBase
80{
81public:
575821fa
RD
82 wxFilePickerCtrl();
83
23324ae1
FM
84 /**
85 Initializes the object and calls Create() with
86 all the parameters.
87 */
4cc4bfaf 88 wxFilePickerCtrl(wxWindow* parent, wxWindowID id,
23324ae1 89 const wxString& path = wxEmptyString,
a44f3b5a
FM
90 const wxString& message = wxFileSelectorPromptStr,
91 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
23324ae1
FM
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 long style = wxFLP_DEFAULT_STYLE,
95 const wxValidator& validator = wxDefaultValidator,
a44f3b5a 96 const wxString& name = wxFilePickerCtrlNameStr);
23324ae1
FM
97
98 /**
0b70c946
FM
99 Creates this widget with the given parameters.
100
7c913512 101 @param parent
4cc4bfaf 102 Parent window, must not be non-@NULL.
7c913512 103 @param id
4cc4bfaf 104 The identifier for the control.
7c913512 105 @param path
4cc4bfaf 106 The initial file shown in the control. Must be a valid path to a file or
0b70c946 107 the empty string.
7c913512 108 @param message
4cc4bfaf 109 The message shown to the user in the wxFileDialog shown by the control.
7c913512 110 @param wildcard
4cc4bfaf 111 A wildcard which defines user-selectable files (use the same syntax as for
0b70c946 112 wxFileDialog's wildcards).
7c913512 113 @param pos
4cc4bfaf 114 Initial position.
7c913512 115 @param size
4cc4bfaf 116 Initial size.
7c913512 117 @param style
4cc4bfaf 118 The window style, see wxFLP_* flags.
7c913512 119 @param validator
77bfb902 120 Validator which can be used for additional data checks.
7c913512 121 @param name
4cc4bfaf 122 Control name.
3c4f71cc 123
d29a9a8a 124 @return @true if the control was successfully created or @false if
0b70c946 125 creation failed.
23324ae1 126 */
4cc4bfaf 127 bool Create(wxWindow* parent, wxWindowID id,
23324ae1 128 const wxString& path = wxEmptyString,
43c48e1e
FM
129 const wxString& message = wxFileSelectorPromptStr,
130 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
23324ae1
FM
131 const wxPoint& pos = wxDefaultPosition,
132 const wxSize& size = wxDefaultSize,
133 long style = wxFLP_DEFAULT_STYLE,
134 const wxValidator& validator = wxDefaultValidator,
43c48e1e 135 const wxString& name = wxFilePickerCtrlNameStr);
23324ae1
FM
136
137 /**
0b70c946
FM
138 Similar to GetPath() but returns the path of the currently selected
139 file as a wxFileName object.
23324ae1 140 */
328f5751 141 wxFileName GetFileName() const;
23324ae1
FM
142
143 /**
144 Returns the absolute path of the currently selected file.
145 */
328f5751 146 wxString GetPath() const;
23324ae1
FM
147
148 /**
0b70c946
FM
149 This method does the same thing as SetPath() but takes a wxFileName
150 object instead of a string.
23324ae1 151 */
4cc4bfaf 152 void SetFileName(const wxFileName& filename);
23324ae1 153
75cb911c
VZ
154 /**
155 Set the directory to show when starting to browse for files.
156
157 This function is mostly useful for the file picker controls which have
158 no selection initially to configure the directory that should be shown
159 if the user starts browsing for files as otherwise the directory of
160 initially selected file is used, which is usually the desired
161 behaviour and so the directory specified by this function is ignored in
162 this case.
163
164 @since 2.9.4
165 */
166 void SetInitialDirectory(const wxString& dir);
167
23324ae1 168 /**
0b70c946
FM
169 Sets the absolute path of the currently selected file.
170 This must be a valid file if the @c wxFLP_FILE_MUST_EXIST style was given.
23324ae1 171 */
4cc4bfaf 172 void SetPath(const wxString& filename);
23324ae1
FM
173};
174
175
e54c96f1 176
23324ae1
FM
177/**
178 @class wxDirPickerCtrl
7c913512 179
23324ae1 180 This control allows the user to select a directory. The generic implementation
0b70c946 181 is a button which brings up a wxDirDialog when clicked. Native implementation
23324ae1 182 may differ but this is usually a (small) widget which give access to the
0b70c946 183 dir-chooser dialog.
23324ae1 184 It is only available if @c wxUSE_DIRPICKERCTRL is set to 1 (the default).
7c913512 185
23324ae1 186 @beginStyleTable
8c6791e4 187 @style{wxDIRP_DEFAULT_STYLE}
23324ae1
FM
188 The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW
189 only, wxDIRP_USE_TEXTCTRL.
8c6791e4 190 @style{wxDIRP_USE_TEXTCTRL}
23324ae1
FM
191 Creates a text control to the left of the picker button which is
192 completely managed by the wxDirPickerCtrl and which can be used by
193 the user to specify a path (see SetPath). The text control is
194 automatically synchronized with button's value. Use functions
195 defined in wxPickerBase to modify the text control.
8c6791e4 196 @style{wxDIRP_DIR_MUST_EXIST}
23324ae1
FM
197 Creates a picker which allows to select only existing directories.
198 wxGTK control always adds this flag internally as it does not
199 support its absence.
8c6791e4 200 @style{wxDIRP_CHANGE_DIR}
0b70c946 201 Change current working directory on each user directory selection change.
75bc8b34
VZ
202 @style{wxDIRP_SMALL}
203 Use smaller version of the control with a small "..." button instead
204 of the normal "Browse" one. This flag is new since wxWidgets 2.9.3.
23324ae1 205 @endStyleTable
7c913512 206
3051a44a 207 @beginEventEmissionTable{wxFileDirPickerEvent}
0b70c946
FM
208 @event{EVT_DIRPICKER_CHANGED(id, func)}
209 The user changed the directory selected in the control either using the
210 button or using text control (see wxDIRP_USE_TEXTCTRL; note that in this
211 case the event is fired only if the user's input is valid, e.g. an
212 existing directory path).
213 @endEventTable
214
215
23324ae1 216 @library{wxcore}
d18d9f60 217 @category{pickers}
ce154616 218 @appearance{dirpickerctrl}
7c913512 219
e54c96f1 220 @see wxDirDialog, wxFileDirPickerEvent
23324ae1
FM
221*/
222class wxDirPickerCtrl : public wxPickerBase
223{
224public:
575821fa
RD
225 wxDirPickerCtrl();
226
23324ae1
FM
227 /**
228 Initializes the object and calls Create() with
229 all the parameters.
230 */
4cc4bfaf 231 wxDirPickerCtrl(wxWindow* parent, wxWindowID id,
23324ae1 232 const wxString& path = wxEmptyString,
408776d0 233 const wxString& message = wxDirSelectorPromptStr,
23324ae1
FM
234 const wxPoint& pos = wxDefaultPosition,
235 const wxSize& size = wxDefaultSize,
236 long style = wxDIRP_DEFAULT_STYLE,
237 const wxValidator& validator = wxDefaultValidator,
408776d0 238 const wxString& name = wxDirPickerCtrlNameStr);
23324ae1
FM
239
240 /**
0b70c946
FM
241 Creates the widgets with the given parameters.
242
7c913512 243 @param parent
4cc4bfaf 244 Parent window, must not be non-@NULL.
7c913512 245 @param id
4cc4bfaf 246 The identifier for the control.
7c913512 247 @param path
4cc4bfaf 248 The initial directory shown in the control. Must be a valid path to a
0b70c946 249 directory or the empty string.
7c913512 250 @param message
4cc4bfaf 251 The message shown to the user in the wxDirDialog shown by the control.
7c913512 252 @param pos
4cc4bfaf 253 Initial position.
7c913512 254 @param size
4cc4bfaf 255 Initial size.
7c913512 256 @param style
4cc4bfaf 257 The window style, see wxDIRP_* flags.
7c913512 258 @param validator
4cc4bfaf 259 Validator which can be used for additional date checks.
7c913512 260 @param name
4cc4bfaf 261 Control name.
3c4f71cc 262
d29a9a8a 263 @return @true if the control was successfully created or @false if
0b70c946 264 creation failed.
23324ae1 265 */
4cc4bfaf 266 bool Create(wxWindow* parent, wxWindowID id,
23324ae1 267 const wxString& path = wxEmptyString,
43c48e1e 268 const wxString& message = wxDirSelectorPromptStr,
23324ae1
FM
269 const wxPoint& pos = wxDefaultPosition,
270 const wxSize& size = wxDefaultSize,
271 long style = wxDIRP_DEFAULT_STYLE,
272 const wxValidator& validator = wxDefaultValidator,
43c48e1e 273 const wxString& name = wxDirPickerCtrlNameStr);
23324ae1
FM
274
275 /**
0b70c946
FM
276 Returns the absolute path of the currently selected directory as a
277 wxFileName object.
278 This function is equivalent to GetPath().
23324ae1 279 */
328f5751 280 wxFileName GetDirName() const;
23324ae1
FM
281
282 /**
283 Returns the absolute path of the currently selected directory.
284 */
328f5751 285 wxString GetPath() const;
23324ae1
FM
286
287 /**
0b70c946 288 Just like SetPath() but this function takes a wxFileName object.
23324ae1 289 */
4cc4bfaf 290 void SetDirName(const wxFileName& dirname);
23324ae1 291
75cb911c
VZ
292 /**
293 Set the directory to show when starting to browse for directories.
294
295 This function is mostly useful for the directory picker controls which
296 have no selection initially to configure the directory that should be
297 shown if the user starts browsing for directories as otherwise the
298 initially selected directory is used, which is usually the desired
299 behaviour and so the directory specified by this function is ignored in
300 this case.
301
302 @since 2.9.4
303 */
304 void SetInitialDirectory(const wxString& dir);
305
23324ae1
FM
306 /**
307 Sets the absolute path of (the default converter uses current locale's
0b70c946
FM
308 charset)the currently selected directory.
309 This must be a valid directory if @c wxDIRP_DIR_MUST_EXIST style was given.
23324ae1 310 */
4cc4bfaf 311 void SetPath(const wxString& dirname);
23324ae1
FM
312};
313
314
e54c96f1 315
23324ae1
FM
316/**
317 @class wxFileDirPickerEvent
7c913512 318
23324ae1
FM
319 This event class is used for the events generated by
320 wxFilePickerCtrl and by wxDirPickerCtrl.
7c913512 321
674d80a7
FM
322 @beginEventTable{wxFileDirPickerEvent}
323 @event{EVT_FILEPICKER_CHANGED(id, func)}
324 Generated whenever the selected file changes.
325 @event{EVT_DIRPICKER_CHANGED(id, func)}
326 Generated whenever the selected directory changes.
327 @endEventTable
328
23324ae1 329 @library{wxcore}
0b70c946 330 @category{events}
7c913512 331
0b70c946 332 @see wxFilePickerCtrl, wxDirPickerCtrl
23324ae1
FM
333*/
334class wxFileDirPickerEvent : public wxCommandEvent
335{
336public:
575821fa
RD
337 wxFileDirPickerEvent();
338
23324ae1
FM
339 /**
340 The constructor is not normally used by the user code.
341 */
4cc4bfaf 342 wxFileDirPickerEvent(wxEventType type, wxObject* generator,
23324ae1 343 int id,
a44f3b5a 344 const wxString& path);
23324ae1
FM
345
346 /**
347 Retrieve the absolute path of the file/directory the user has just selected.
348 */
328f5751 349 wxString GetPath() const;
23324ae1
FM
350
351 /**
352 Set the absolute path of the file/directory associated with the event.
353 */
4cc4bfaf 354 void SetPath(const wxString& path);
23324ae1 355};
e54c96f1 356