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