]>
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
17 It is only available if @c wxUSE_FILEPICKERCTRL is set to 1 (the default).
20 @style{wxFLP_DEFAULT_STYLE}
21 The default style: includes wxFLP_OPEN | wxFLP_FILE_MUST_EXIST and,
22 under wxMSW only, wxFLP_USE_TEXTCTRL.
23 @style{wxFLP_USE_TEXTCTRL}
24 Creates a text control to the left of the picker button which is
25 completely managed by the wxFilePickerCtrl and which can be used by
26 the user to specify a path (see SetPath). The text control is
27 automatically synchronized with button's value. Use functions
28 defined in wxPickerBase to modify the text control.
30 Creates a picker which allows the user to select a file to open.
32 Creates a picker which allows the user to select a file to save.
33 @style{wxFLP_OVERWRITE_PROMPT}
34 Can be combined with wxFLP_SAVE only: ask confirmation to the user
35 before selecting a file.
36 @style{wxFLP_FILE_MUST_EXIST}
37 Can be combined with wxFLP_OPEN only: the selected file must be an
39 @style{wxFLP_CHANGE_DIR}
40 Change current working directory on each user file selection change.
45 <!-- @appearance{filepickerctrl.png} -->
47 @see wxFileDialog, wxFileDirPickerEvent
49 class wxFilePickerCtrl
: public wxPickerBase
53 Initializes the object and calls Create() with
56 wxFilePickerCtrl(wxWindow
* parent
, wxWindowID id
,
57 const wxString
& path
= wxEmptyString
,
58 const wxString
& message
= "Select a file",
59 const wxString
& wildcard
= ".",
60 const wxPoint
& pos
= wxDefaultPosition
,
61 const wxSize
& size
= wxDefaultSize
,
62 long style
= wxFLP_DEFAULT_STYLE
,
63 const wxValidator
& validator
= wxDefaultValidator
,
64 const wxString
& name
= "filepickerctrl");
68 Parent window, must not be non-@NULL.
70 The identifier for the control.
72 The initial file shown in the control. Must be a valid path to a file or
75 The message shown to the user in the wxFileDialog shown by the control.
77 A wildcard which defines user-selectable files (use the same syntax as for
78 wxFileDialog's wildcards).
84 The window style, see wxFLP_* flags.
86 Validator which can be used for additional date checks.
90 @return @true if the control was successfully created or @false if
93 bool Create(wxWindow
* parent
, wxWindowID id
,
94 const wxString
& path
= wxEmptyString
,
95 const wxString
& message
= "Select a file",
96 const wxString
& wildcard
= ".",
97 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxSize
& size
= wxDefaultSize
,
99 long style
= wxFLP_DEFAULT_STYLE
,
100 const wxValidator
& validator
= wxDefaultValidator
,
101 const wxString
& name
= "filepickerctrl");
104 Similar to GetPath() but returns the path of
105 the currently selected file as a wxFileName object.
107 wxFileName
GetFileName() const;
110 Returns the absolute path of the currently selected file.
112 wxString
GetPath() const;
115 This method does the same thing as SetPath() but
116 takes a wxFileName object instead of a string.
118 void SetFileName(const wxFileName
& filename
);
121 Sets the absolute path of the currently selected file. This must be a valid
123 the @c wxFLP_FILE_MUST_EXIST style was given.
125 void SetPath(const wxString
& filename
);
131 @class wxDirPickerCtrl
133 This control allows the user to select a directory. The generic implementation
135 a button which brings up a wxDirDialog when clicked. Native implementation
136 may differ but this is usually a (small) widget which give access to the
139 It is only available if @c wxUSE_DIRPICKERCTRL is set to 1 (the default).
142 @style{wxDIRP_DEFAULT_STYLE}
143 The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW
144 only, wxDIRP_USE_TEXTCTRL.
145 @style{wxDIRP_USE_TEXTCTRL}
146 Creates a text control to the left of the picker button which is
147 completely managed by the wxDirPickerCtrl and which can be used by
148 the user to specify a path (see SetPath). The text control is
149 automatically synchronized with button's value. Use functions
150 defined in wxPickerBase to modify the text control.
151 @style{wxDIRP_DIR_MUST_EXIST}
152 Creates a picker which allows to select only existing directories.
153 wxGTK control always adds this flag internally as it does not
155 @style{wxDIRP_CHANGE_DIR}
156 Change current working directory on each user directory selection
162 <!-- @appearance{dirpickerctrl.png} -->
164 @see wxDirDialog, wxFileDirPickerEvent
166 class wxDirPickerCtrl
: public wxPickerBase
170 Initializes the object and calls Create() with
173 wxDirPickerCtrl(wxWindow
* parent
, wxWindowID id
,
174 const wxString
& path
= wxEmptyString
,
175 const wxString
& message
= "Select a folder",
176 const wxPoint
& pos
= wxDefaultPosition
,
177 const wxSize
& size
= wxDefaultSize
,
178 long style
= wxDIRP_DEFAULT_STYLE
,
179 const wxValidator
& validator
= wxDefaultValidator
,
180 const wxString
& name
= "dirpickerctrl");
184 Parent window, must not be non-@NULL.
186 The identifier for the control.
188 The initial directory shown in the control. Must be a valid path to a
189 directory or the empty string.
191 The message shown to the user in the wxDirDialog shown by the control.
197 The window style, see wxDIRP_* flags.
199 Validator which can be used for additional date checks.
203 @return @true if the control was successfully created or @false if
206 bool Create(wxWindow
* parent
, wxWindowID id
,
207 const wxString
& path
= wxEmptyString
,
208 const wxString
& message
= "Select a folder",
209 const wxPoint
& pos
= wxDefaultPosition
,
210 const wxSize
& size
= wxDefaultSize
,
211 long style
= wxDIRP_DEFAULT_STYLE
,
212 const wxValidator
& validator
= wxDefaultValidator
,
213 const wxString
& name
= "dirpickerctrl");
216 Returns the absolute path of the currently selected directory as a wxFileName
218 This function is equivalent to GetPath()
220 wxFileName
GetDirName() const;
223 Returns the absolute path of the currently selected directory.
225 wxString
GetPath() const;
228 Just like SetPath() but this function takes a
231 void SetDirName(const wxFileName
& dirname
);
234 Sets the absolute path of (the default converter uses current locale's
235 charset)the currently selected directory. This must be a valid directory if
236 @c wxDIRP_DIR_MUST_EXIST style was given.
238 void SetPath(const wxString
& dirname
);
244 @class wxFileDirPickerEvent
246 This event class is used for the events generated by
247 wxFilePickerCtrl and by wxDirPickerCtrl.
252 @see wxfilepickerctrl()
254 class wxFileDirPickerEvent
: public wxCommandEvent
258 The constructor is not normally used by the user code.
260 wxFileDirPickerEvent(wxEventType type
, wxObject
* generator
,
262 const wxString path
);
265 Retrieve the absolute path of the file/directory the user has just selected.
267 wxString
GetPath() const;
270 Set the absolute path of the file/directory associated with the event.
272 void SetPath(const wxString
& path
);