1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFilePickerCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxFilePickerCtrl
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
16 It is only available if @c wxUSE_FILEPICKERCTRL is set to 1 (the default).
19 @style{wxFLP_DEFAULT_STYLE}
20 The default style: includes wxFLP_OPEN | wxFLP_FILE_MUST_EXIST and,
21 under wxMSW only, wxFLP_USE_TEXTCTRL.
22 @style{wxFLP_USE_TEXTCTRL}
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.
29 Creates a picker which allows the user to select a file to open.
31 Creates a picker which allows the user to select a file to save.
32 @style{wxFLP_OVERWRITE_PROMPT}
33 Can be combined with wxFLP_SAVE only: ask confirmation to the user
34 before selecting a file.
35 @style{wxFLP_FILE_MUST_EXIST}
36 Can be combined with wxFLP_OPEN only: the selected file must be an
38 @style{wxFLP_CHANGE_DIR}
39 Change current working directory on each user file selection change.
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.
46 @beginEventEmissionTable{wxFileDirPickerEvent}
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).
56 @appearance{filepickerctrl.png}
58 @see wxFileDialog, wxFileDirPickerEvent
60 class wxFilePickerCtrl
: public wxPickerBase
64 Initializes the object and calls Create() with
67 wxFilePickerCtrl(wxWindow
* parent
, wxWindowID id
,
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
= wxFLP_DEFAULT_STYLE
,
74 const wxValidator
& validator
= wxDefaultValidator
,
75 const wxString
& name
= wxFilePickerCtrlNameStr
);
78 Creates this widget with the given parameters.
81 Parent window, must not be non-@NULL.
83 The identifier for the control.
85 The initial file shown in the control. Must be a valid path to a file or
88 The message shown to the user in the wxFileDialog shown by the control.
90 A wildcard which defines user-selectable files (use the same syntax as for
91 wxFileDialog's wildcards).
97 The window style, see wxFLP_* flags.
99 Validator which can be used for additional data checks.
103 @return @true if the control was successfully created or @false if
106 bool Create(wxWindow
* parent
, wxWindowID id
,
107 const wxString
& path
= wxEmptyString
,
108 const wxString
& message
= wxFileSelectorPromptStr
,
109 const wxString
& wildcard
= wxFileSelectorDefaultWildcardStr
,
110 const wxPoint
& pos
= wxDefaultPosition
,
111 const wxSize
& size
= wxDefaultSize
,
112 long style
= wxFLP_DEFAULT_STYLE
,
113 const wxValidator
& validator
= wxDefaultValidator
,
114 const wxString
& name
= wxFilePickerCtrlNameStr
);
117 Similar to GetPath() but returns the path of the currently selected
118 file as a wxFileName object.
120 wxFileName
GetFileName() const;
123 Returns the absolute path of the currently selected file.
125 wxString
GetPath() const;
128 This method does the same thing as SetPath() but takes a wxFileName
129 object instead of a string.
131 void SetFileName(const wxFileName
& filename
);
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.
137 void SetPath(const wxString
& filename
);
143 @class wxDirPickerCtrl
145 This control allows the user to select a directory. The generic implementation
146 is a button which brings up a wxDirDialog when clicked. Native implementation
147 may differ but this is usually a (small) widget which give access to the
149 It is only available if @c wxUSE_DIRPICKERCTRL is set to 1 (the default).
152 @style{wxDIRP_DEFAULT_STYLE}
153 The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW
154 only, wxDIRP_USE_TEXTCTRL.
155 @style{wxDIRP_USE_TEXTCTRL}
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.
161 @style{wxDIRP_DIR_MUST_EXIST}
162 Creates a picker which allows to select only existing directories.
163 wxGTK control always adds this flag internally as it does not
165 @style{wxDIRP_CHANGE_DIR}
166 Change current working directory on each user directory selection change.
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.
172 @beginEventEmissionTable{wxFileDirPickerEvent}
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).
183 @appearance{dirpickerctrl.png}
185 @see wxDirDialog, wxFileDirPickerEvent
187 class wxDirPickerCtrl
: public wxPickerBase
191 Initializes the object and calls Create() with
194 wxDirPickerCtrl(wxWindow
* parent
, wxWindowID id
,
195 const wxString
& path
= wxEmptyString
,
196 const wxString
& message
= wxDirSelectorPromptStr
,
197 const wxPoint
& pos
= wxDefaultPosition
,
198 const wxSize
& size
= wxDefaultSize
,
199 long style
= wxDIRP_DEFAULT_STYLE
,
200 const wxValidator
& validator
= wxDefaultValidator
,
201 const wxString
& name
= wxDirPickerCtrlNameStr
);
204 Creates the widgets with the given parameters.
207 Parent window, must not be non-@NULL.
209 The identifier for the control.
211 The initial directory shown in the control. Must be a valid path to a
212 directory or the empty string.
214 The message shown to the user in the wxDirDialog shown by the control.
220 The window style, see wxDIRP_* flags.
222 Validator which can be used for additional date checks.
226 @return @true if the control was successfully created or @false if
229 bool Create(wxWindow
* parent
, wxWindowID id
,
230 const wxString
& path
= wxEmptyString
,
231 const wxString
& message
= wxDirSelectorPromptStr
,
232 const wxPoint
& pos
= wxDefaultPosition
,
233 const wxSize
& size
= wxDefaultSize
,
234 long style
= wxDIRP_DEFAULT_STYLE
,
235 const wxValidator
& validator
= wxDefaultValidator
,
236 const wxString
& name
= wxDirPickerCtrlNameStr
);
239 Returns the absolute path of the currently selected directory as a
241 This function is equivalent to GetPath().
243 wxFileName
GetDirName() const;
246 Returns the absolute path of the currently selected directory.
248 wxString
GetPath() const;
251 Just like SetPath() but this function takes a wxFileName object.
253 void SetDirName(const wxFileName
& dirname
);
256 Sets the absolute path of (the default converter uses current locale's
257 charset)the currently selected directory.
258 This must be a valid directory if @c wxDIRP_DIR_MUST_EXIST style was given.
260 void SetPath(const wxString
& dirname
);
266 @class wxFileDirPickerEvent
268 This event class is used for the events generated by
269 wxFilePickerCtrl and by wxDirPickerCtrl.
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.
281 @see wxFilePickerCtrl, wxDirPickerCtrl
283 class wxFileDirPickerEvent
: public wxCommandEvent
287 The constructor is not normally used by the user code.
289 wxFileDirPickerEvent(wxEventType type
, wxObject
* generator
,
291 const wxString
& path
);
294 Retrieve the absolute path of the file/directory the user has just selected.
296 wxString
GetPath() const;
299 Set the absolute path of the file/directory associated with the event.
301 void SetPath(const wxString
& path
);