]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/filepicker.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFilePickerCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
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.
43 @beginEventTable{wxFileDirPickerEvent}
44 @event{EVT_FILEPICKER_CHANGED(id, func)}
45 The user changed the file selected in the control either using the
46 button or using text control (see wxFLP_USE_TEXTCTRL; note that in
47 this case the event is fired only if the user's input is valid,
48 e.g. an existing file path if wxFLP_FILE_MUST_EXIST was given).
53 @appearance{filepickerctrl.png}
55 @see wxFileDialog, wxFileDirPickerEvent
57 class wxFilePickerCtrl
: public wxPickerBase
61 Initializes the object and calls Create() with
64 wxFilePickerCtrl(wxWindow
* parent
, wxWindowID id
,
65 const wxString
& path
= wxEmptyString
,
66 const wxString
& message
= "Select a file",
67 const wxString
& wildcard
= ".",
68 const wxPoint
& pos
= wxDefaultPosition
,
69 const wxSize
& size
= wxDefaultSize
,
70 long style
= wxFLP_DEFAULT_STYLE
,
71 const wxValidator
& validator
= wxDefaultValidator
,
72 const wxString
& name
= "filepickerctrl");
75 Creates this widget with the given parameters.
78 Parent window, must not be non-@NULL.
80 The identifier for the control.
82 The initial file shown in the control. Must be a valid path to a file or
85 The message shown to the user in the wxFileDialog shown by the control.
87 A wildcard which defines user-selectable files (use the same syntax as for
88 wxFileDialog's wildcards).
94 The window style, see wxFLP_* flags.
96 Validator which can be used for additional data checks.
100 @return @true if the control was successfully created or @false if
103 bool Create(wxWindow
* parent
, wxWindowID id
,
104 const wxString
& path
= wxEmptyString
,
105 const wxString
& message
= "Select a file",
106 const wxString
& wildcard
= ".",
107 const wxPoint
& pos
= wxDefaultPosition
,
108 const wxSize
& size
= wxDefaultSize
,
109 long style
= wxFLP_DEFAULT_STYLE
,
110 const wxValidator
& validator
= wxDefaultValidator
,
111 const wxString
& name
= "filepickerctrl");
114 Similar to GetPath() but returns the path of the currently selected
115 file as a wxFileName object.
117 wxFileName
GetFileName() const;
120 Returns the absolute path of the currently selected file.
122 wxString
GetPath() const;
125 This method does the same thing as SetPath() but takes a wxFileName
126 object instead of a string.
128 void SetFileName(const wxFileName
& filename
);
131 Sets the absolute path of the currently selected file.
132 This must be a valid file if the @c wxFLP_FILE_MUST_EXIST style was given.
134 void SetPath(const wxString
& filename
);
140 @class wxDirPickerCtrl
142 This control allows the user to select a directory. The generic implementation
143 is a button which brings up a wxDirDialog when clicked. Native implementation
144 may differ but this is usually a (small) widget which give access to the
146 It is only available if @c wxUSE_DIRPICKERCTRL is set to 1 (the default).
149 @style{wxDIRP_DEFAULT_STYLE}
150 The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW
151 only, wxDIRP_USE_TEXTCTRL.
152 @style{wxDIRP_USE_TEXTCTRL}
153 Creates a text control to the left of the picker button which is
154 completely managed by the wxDirPickerCtrl and which can be used by
155 the user to specify a path (see SetPath). The text control is
156 automatically synchronized with button's value. Use functions
157 defined in wxPickerBase to modify the text control.
158 @style{wxDIRP_DIR_MUST_EXIST}
159 Creates a picker which allows to select only existing directories.
160 wxGTK control always adds this flag internally as it does not
162 @style{wxDIRP_CHANGE_DIR}
163 Change current working directory on each user directory selection change.
166 @beginEventTable{wxFileDirPickerEvent}
167 @event{EVT_DIRPICKER_CHANGED(id, func)}
168 The user changed the directory selected in the control either using the
169 button or using text control (see wxDIRP_USE_TEXTCTRL; note that in this
170 case the event is fired only if the user's input is valid, e.g. an
171 existing directory path).
177 @appearance{dirpickerctrl.png}
179 @see wxDirDialog, wxFileDirPickerEvent
181 class wxDirPickerCtrl
: public wxPickerBase
185 Initializes the object and calls Create() with
188 wxDirPickerCtrl(wxWindow
* parent
, wxWindowID id
,
189 const wxString
& path
= wxEmptyString
,
190 const wxString
& message
= "Select a folder",
191 const wxPoint
& pos
= wxDefaultPosition
,
192 const wxSize
& size
= wxDefaultSize
,
193 long style
= wxDIRP_DEFAULT_STYLE
,
194 const wxValidator
& validator
= wxDefaultValidator
,
195 const wxString
& name
= "dirpickerctrl");
198 Creates the widgets with the given parameters.
201 Parent window, must not be non-@NULL.
203 The identifier for the control.
205 The initial directory shown in the control. Must be a valid path to a
206 directory or the empty string.
208 The message shown to the user in the wxDirDialog shown by the control.
214 The window style, see wxDIRP_* flags.
216 Validator which can be used for additional date checks.
220 @return @true if the control was successfully created or @false if
223 bool Create(wxWindow
* parent
, wxWindowID id
,
224 const wxString
& path
= wxEmptyString
,
225 const wxString
& message
= "Select a folder",
226 const wxPoint
& pos
= wxDefaultPosition
,
227 const wxSize
& size
= wxDefaultSize
,
228 long style
= wxDIRP_DEFAULT_STYLE
,
229 const wxValidator
& validator
= wxDefaultValidator
,
230 const wxString
& name
= "dirpickerctrl");
233 Returns the absolute path of the currently selected directory as a
235 This function is equivalent to GetPath().
237 wxFileName
GetDirName() const;
240 Returns the absolute path of the currently selected directory.
242 wxString
GetPath() const;
245 Just like SetPath() but this function takes a wxFileName object.
247 void SetDirName(const wxFileName
& dirname
);
250 Sets the absolute path of (the default converter uses current locale's
251 charset)the currently selected directory.
252 This must be a valid directory if @c wxDIRP_DIR_MUST_EXIST style was given.
254 void SetPath(const wxString
& dirname
);
260 @class wxFileDirPickerEvent
262 This event class is used for the events generated by
263 wxFilePickerCtrl and by wxDirPickerCtrl.
265 @beginEventTable{wxFileDirPickerEvent}
266 @event{EVT_FILEPICKER_CHANGED(id, func)}
267 Generated whenever the selected file changes.
268 @event{EVT_DIRPICKER_CHANGED(id, func)}
269 Generated whenever the selected directory changes.
275 @see wxFilePickerCtrl, wxDirPickerCtrl
277 class wxFileDirPickerEvent
: public wxCommandEvent
281 The constructor is not normally used by the user code.
283 wxFileDirPickerEvent(wxEventType type
, wxObject
* generator
,
285 const wxString path
);
288 Retrieve the absolute path of the file/directory the user has just selected.
290 wxString
GetPath() const;
293 Set the absolute path of the file/directory associated with the event.
295 void SetPath(const wxString
& path
);