]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: filepicker.h | |
e54c96f1 | 3 | // Purpose: interface of wxFilePickerCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
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 FM |
39 | Change current working directory on each user file selection change. |
40 | @endStyleTable | |
7c913512 | 41 | |
0b70c946 FM |
42 | |
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). | |
49 | @endEventTable | |
50 | ||
23324ae1 | 51 | @library{wxcore} |
d18d9f60 | 52 | @category{pickers} |
0c7fe6f2 | 53 | <!-- @appearance{filepickerctrl.png} --> |
7c913512 | 54 | |
e54c96f1 | 55 | @see wxFileDialog, wxFileDirPickerEvent |
23324ae1 FM |
56 | */ |
57 | class wxFilePickerCtrl : public wxPickerBase | |
58 | { | |
59 | public: | |
60 | /** | |
61 | Initializes the object and calls Create() with | |
62 | all the parameters. | |
63 | */ | |
4cc4bfaf | 64 | wxFilePickerCtrl(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
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"); | |
73 | ||
74 | /** | |
0b70c946 FM |
75 | Creates this widget with the given parameters. |
76 | ||
7c913512 | 77 | @param parent |
4cc4bfaf | 78 | Parent window, must not be non-@NULL. |
7c913512 | 79 | @param id |
4cc4bfaf | 80 | The identifier for the control. |
7c913512 | 81 | @param path |
4cc4bfaf | 82 | The initial file shown in the control. Must be a valid path to a file or |
0b70c946 | 83 | the empty string. |
7c913512 | 84 | @param message |
4cc4bfaf | 85 | The message shown to the user in the wxFileDialog shown by the control. |
7c913512 | 86 | @param wildcard |
4cc4bfaf | 87 | A wildcard which defines user-selectable files (use the same syntax as for |
0b70c946 | 88 | wxFileDialog's wildcards). |
7c913512 | 89 | @param pos |
4cc4bfaf | 90 | Initial position. |
7c913512 | 91 | @param size |
4cc4bfaf | 92 | Initial size. |
7c913512 | 93 | @param style |
4cc4bfaf | 94 | The window style, see wxFLP_* flags. |
7c913512 | 95 | @param validator |
4cc4bfaf | 96 | Validator which can be used for additional date checks. |
7c913512 | 97 | @param name |
4cc4bfaf | 98 | Control name. |
3c4f71cc | 99 | |
d29a9a8a | 100 | @return @true if the control was successfully created or @false if |
0b70c946 | 101 | creation failed. |
23324ae1 | 102 | */ |
4cc4bfaf | 103 | bool Create(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
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"); | |
112 | ||
113 | /** | |
0b70c946 FM |
114 | Similar to GetPath() but returns the path of the currently selected |
115 | file as a wxFileName object. | |
23324ae1 | 116 | */ |
328f5751 | 117 | wxFileName GetFileName() const; |
23324ae1 FM |
118 | |
119 | /** | |
120 | Returns the absolute path of the currently selected file. | |
121 | */ | |
328f5751 | 122 | wxString GetPath() const; |
23324ae1 FM |
123 | |
124 | /** | |
0b70c946 FM |
125 | This method does the same thing as SetPath() but takes a wxFileName |
126 | object instead of a string. | |
23324ae1 | 127 | */ |
4cc4bfaf | 128 | void SetFileName(const wxFileName& filename); |
23324ae1 FM |
129 | |
130 | /** | |
0b70c946 FM |
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. | |
23324ae1 | 133 | */ |
4cc4bfaf | 134 | void SetPath(const wxString& filename); |
23324ae1 FM |
135 | }; |
136 | ||
137 | ||
e54c96f1 | 138 | |
23324ae1 FM |
139 | /** |
140 | @class wxDirPickerCtrl | |
7c913512 | 141 | |
23324ae1 | 142 | This control allows the user to select a directory. The generic implementation |
0b70c946 | 143 | is a button which brings up a wxDirDialog when clicked. Native implementation |
23324ae1 | 144 | may differ but this is usually a (small) widget which give access to the |
0b70c946 | 145 | dir-chooser dialog. |
23324ae1 | 146 | It is only available if @c wxUSE_DIRPICKERCTRL is set to 1 (the default). |
7c913512 | 147 | |
23324ae1 | 148 | @beginStyleTable |
8c6791e4 | 149 | @style{wxDIRP_DEFAULT_STYLE} |
23324ae1 FM |
150 | The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW |
151 | only, wxDIRP_USE_TEXTCTRL. | |
8c6791e4 | 152 | @style{wxDIRP_USE_TEXTCTRL} |
23324ae1 FM |
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. | |
8c6791e4 | 158 | @style{wxDIRP_DIR_MUST_EXIST} |
23324ae1 FM |
159 | Creates a picker which allows to select only existing directories. |
160 | wxGTK control always adds this flag internally as it does not | |
161 | support its absence. | |
8c6791e4 | 162 | @style{wxDIRP_CHANGE_DIR} |
0b70c946 | 163 | Change current working directory on each user directory selection change. |
23324ae1 | 164 | @endStyleTable |
7c913512 | 165 | |
0b70c946 FM |
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). | |
172 | @endEventTable | |
173 | ||
174 | ||
23324ae1 | 175 | @library{wxcore} |
d18d9f60 | 176 | @category{pickers} |
0c7fe6f2 | 177 | <!-- @appearance{dirpickerctrl.png} --> |
7c913512 | 178 | |
e54c96f1 | 179 | @see wxDirDialog, wxFileDirPickerEvent |
23324ae1 FM |
180 | */ |
181 | class wxDirPickerCtrl : public wxPickerBase | |
182 | { | |
183 | public: | |
184 | /** | |
185 | Initializes the object and calls Create() with | |
186 | all the parameters. | |
187 | */ | |
4cc4bfaf | 188 | wxDirPickerCtrl(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
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"); | |
196 | ||
197 | /** | |
0b70c946 FM |
198 | Creates the widgets with the given parameters. |
199 | ||
7c913512 | 200 | @param parent |
4cc4bfaf | 201 | Parent window, must not be non-@NULL. |
7c913512 | 202 | @param id |
4cc4bfaf | 203 | The identifier for the control. |
7c913512 | 204 | @param path |
4cc4bfaf | 205 | The initial directory shown in the control. Must be a valid path to a |
0b70c946 | 206 | directory or the empty string. |
7c913512 | 207 | @param message |
4cc4bfaf | 208 | The message shown to the user in the wxDirDialog shown by the control. |
7c913512 | 209 | @param pos |
4cc4bfaf | 210 | Initial position. |
7c913512 | 211 | @param size |
4cc4bfaf | 212 | Initial size. |
7c913512 | 213 | @param style |
4cc4bfaf | 214 | The window style, see wxDIRP_* flags. |
7c913512 | 215 | @param validator |
4cc4bfaf | 216 | Validator which can be used for additional date checks. |
7c913512 | 217 | @param name |
4cc4bfaf | 218 | Control name. |
3c4f71cc | 219 | |
d29a9a8a | 220 | @return @true if the control was successfully created or @false if |
0b70c946 | 221 | creation failed. |
23324ae1 | 222 | */ |
4cc4bfaf | 223 | bool Create(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
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"); | |
231 | ||
232 | /** | |
0b70c946 FM |
233 | Returns the absolute path of the currently selected directory as a |
234 | wxFileName object. | |
235 | This function is equivalent to GetPath(). | |
23324ae1 | 236 | */ |
328f5751 | 237 | wxFileName GetDirName() const; |
23324ae1 FM |
238 | |
239 | /** | |
240 | Returns the absolute path of the currently selected directory. | |
241 | */ | |
328f5751 | 242 | wxString GetPath() const; |
23324ae1 FM |
243 | |
244 | /** | |
0b70c946 | 245 | Just like SetPath() but this function takes a wxFileName object. |
23324ae1 | 246 | */ |
4cc4bfaf | 247 | void SetDirName(const wxFileName& dirname); |
23324ae1 FM |
248 | |
249 | /** | |
250 | Sets the absolute path of (the default converter uses current locale's | |
0b70c946 FM |
251 | charset)the currently selected directory. |
252 | This must be a valid directory if @c wxDIRP_DIR_MUST_EXIST style was given. | |
23324ae1 | 253 | */ |
4cc4bfaf | 254 | void SetPath(const wxString& dirname); |
23324ae1 FM |
255 | }; |
256 | ||
257 | ||
e54c96f1 | 258 | |
23324ae1 FM |
259 | /** |
260 | @class wxFileDirPickerEvent | |
7c913512 | 261 | |
23324ae1 FM |
262 | This event class is used for the events generated by |
263 | wxFilePickerCtrl and by wxDirPickerCtrl. | |
7c913512 | 264 | |
674d80a7 FM |
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. | |
270 | @endEventTable | |
271 | ||
23324ae1 | 272 | @library{wxcore} |
0b70c946 | 273 | @category{events} |
7c913512 | 274 | |
0b70c946 | 275 | @see wxFilePickerCtrl, wxDirPickerCtrl |
23324ae1 FM |
276 | */ |
277 | class wxFileDirPickerEvent : public wxCommandEvent | |
278 | { | |
279 | public: | |
280 | /** | |
281 | The constructor is not normally used by the user code. | |
282 | */ | |
4cc4bfaf | 283 | wxFileDirPickerEvent(wxEventType type, wxObject* generator, |
23324ae1 FM |
284 | int id, |
285 | const wxString path); | |
286 | ||
287 | /** | |
288 | Retrieve the absolute path of the file/directory the user has just selected. | |
289 | */ | |
328f5751 | 290 | wxString GetPath() const; |
23324ae1 FM |
291 | |
292 | /** | |
293 | Set the absolute path of the file/directory associated with the event. | |
294 | */ | |
4cc4bfaf | 295 | void SetPath(const wxString& path); |
23324ae1 | 296 | }; |
e54c96f1 | 297 |