]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: filectrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxFileCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxFileCtrl | |
7c913512 | 11 | |
0ce6d6c8 FM |
12 | This control allows the user to select a file. |
13 | ||
14 | Two implemetations exist, one for Gtk and another generic one for anything | |
15 | other than Gtk. It is only available if @c wxUSE_FILECTRL is set to 1. | |
7c913512 | 16 | |
23324ae1 | 17 | @beginStyleTable |
8c6791e4 | 18 | @style{wxFC_DEFAULT_STYLE} |
23324ae1 | 19 | The default style: wxFC_OPEN |
8c6791e4 | 20 | @style{wxFC_OPEN} |
23324ae1 FM |
21 | Creates an file control suitable for opening files. Cannot be |
22 | combined with wxFC_SAVE. | |
8c6791e4 | 23 | @style{wxFC_SAVE} |
23324ae1 FM |
24 | Creates an file control suitable for saving files. Cannot be |
25 | combined with wxFC_OPEN. | |
8c6791e4 | 26 | @style{wxFC_MULTIPLE} |
23324ae1 FM |
27 | For open control only, Allows selecting multiple files. Cannot be |
28 | combined with wxFC_SAVE | |
8c6791e4 | 29 | @style{wxFC_NOSHOWHIDDEN} |
23324ae1 FM |
30 | Hides the "Show Hidden Files" checkbox (Generic only) |
31 | @endStyleTable | |
7c913512 | 32 | |
3051a44a | 33 | @beginEventEmissionTable{wxFileCtrlEvent} |
8c6791e4 | 34 | @event{EVT_FILECTRL_FILEACTIVATED(id, func)} |
0ce6d6c8 | 35 | The user activated a file(by double-clicking or pressing Enter) |
8c6791e4 | 36 | @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)} |
0ce6d6c8 | 37 | The user changed the current selection(by selecting or deselecting a file) |
8c6791e4 | 38 | @event{EVT_FILECTRL_FOLDERCHANGED(id, func)} |
0ce6d6c8 | 39 | The current folder of the file control has been changed |
6305f044 VZ |
40 | @event{EVT_FILECTRL_FILTERCHANGED(id, func)} |
41 | The current file filter of the file control has been changed. | |
42 | @since 2.9.1 | |
0ce6d6c8 FM |
43 | @endEventTable |
44 | ||
23324ae1 | 45 | @library{wxbase} |
3c99e2fd | 46 | @category{ctrl} |
5f12fb35 FM |
47 | @appearance{filectrl.png} |
48 | ||
49 | @nativeimpl{wxgtk} | |
7c913512 | 50 | |
e54c96f1 | 51 | @see wxGenericDirCtrl |
23324ae1 | 52 | */ |
3c99e2fd | 53 | class wxFileCtrl : public wxControl |
23324ae1 FM |
54 | { |
55 | public: | |
0ce6d6c8 FM |
56 | wxFileCtrl(); |
57 | ||
23324ae1 | 58 | /** |
0ce6d6c8 FM |
59 | Constructs the window. |
60 | ||
7c913512 | 61 | @param parent |
4cc4bfaf | 62 | Parent window, must not be non-@NULL. |
7c913512 | 63 | @param id |
4cc4bfaf | 64 | The identifier for the control. |
7c913512 | 65 | @param defaultDirectory |
76e9224e FM |
66 | The initial directory shown in the control. |
67 | Must be a valid path to a directory or the empty string. | |
4cc4bfaf | 68 | In case it is the empty string, the current working directory is used. |
7c913512 | 69 | @param defaultFilename |
4cc4bfaf | 70 | The default filename, or the empty string. |
76e9224e | 71 | @param wildCard |
4cc4bfaf FM |
72 | A wildcard specifying which files can be selected, |
73 | such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif". | |
7c913512 | 74 | @param style |
4cc4bfaf | 75 | The window style, see wxFC_* flags. |
7c913512 | 76 | @param pos |
4cc4bfaf | 77 | Initial position. |
7c913512 | 78 | @param size |
4cc4bfaf | 79 | Initial size. |
7c913512 | 80 | @param name |
4cc4bfaf | 81 | Control name. |
3c4f71cc | 82 | |
d29a9a8a | 83 | @return @true if the control was successfully created or @false if |
4cc4bfaf | 84 | creation failed. |
23324ae1 | 85 | */ |
0ce6d6c8 | 86 | |
4cc4bfaf | 87 | wxFileCtrl(wxWindow* parent, wxWindowID id, |
7c913512 FM |
88 | const wxString& defaultDirectory = wxEmptyString, |
89 | const wxString& defaultFilename = wxEmptyString, | |
90 | const wxPoint& wildCard = wxFileSelectorDefaultWildcardStr, | |
91 | long style = wxFC_DEFAULT_STYLE, | |
92 | const wxPoint& pos = wxDefaultPosition, | |
93 | const wxSize& size = wxDefaultSize, | |
a44f3b5a | 94 | const wxString& name = wxFileCtrlNameStr); |
23324ae1 FM |
95 | |
96 | /** | |
97 | Create function for two-step construction. See wxFileCtrl() for details. | |
98 | */ | |
4cc4bfaf | 99 | bool Create(wxWindow* parent, wxWindowID id, |
23324ae1 FM |
100 | const wxString& defaultDirectory = wxEmptyString, |
101 | const wxString& defaultFilename = wxEmptyString, | |
43c48e1e FM |
102 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, |
103 | long style = wxFC_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition, | |
23324ae1 | 104 | const wxSize& size = wxDefaultSize, |
43c48e1e | 105 | const wxString& name = wxFileCtrlNameStr); |
23324ae1 FM |
106 | |
107 | /** | |
0ce6d6c8 | 108 | Returns the current directory of the file control (i.e. the directory shown by it). |
23324ae1 | 109 | */ |
adaaa686 | 110 | virtual wxString GetDirectory() const; |
23324ae1 FM |
111 | |
112 | /** | |
113 | Returns the currently selected filename. | |
0ce6d6c8 FM |
114 | |
115 | For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead. | |
23324ae1 | 116 | */ |
adaaa686 | 117 | virtual wxString GetFilename() const; |
23324ae1 FM |
118 | |
119 | /** | |
0ce6d6c8 FM |
120 | Fills the array @a filenames with the filenames only of selected items. |
121 | ||
122 | This function should only be used with the controls having the @c wxFC_MULTIPLE | |
123 | style, use GetFilename() for the others. | |
3c4f71cc | 124 | |
23324ae1 FM |
125 | @remarks filenames is emptied first. |
126 | */ | |
adaaa686 | 127 | virtual void GetFilenames(wxArrayString& filenames) const; |
23324ae1 FM |
128 | |
129 | /** | |
130 | Returns the zero-based index of the currently selected filter. | |
131 | */ | |
adaaa686 | 132 | virtual int GetFilterIndex() const; |
23324ae1 FM |
133 | |
134 | /** | |
135 | Returns the full path (directory and filename) of the currently selected file. | |
0ce6d6c8 | 136 | For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead. |
23324ae1 | 137 | */ |
adaaa686 | 138 | virtual wxString GetPath() const; |
23324ae1 FM |
139 | |
140 | /** | |
0ce6d6c8 FM |
141 | Fills the array @a paths with the full paths of the files chosen. |
142 | ||
143 | This function should be used with the controls having the @c wxFC_MULTIPLE style, | |
23324ae1 | 144 | use GetPath() otherwise. |
3c4f71cc | 145 | |
23324ae1 FM |
146 | @remarks paths is emptied first. |
147 | */ | |
adaaa686 | 148 | virtual void GetPaths(wxArrayString& paths) const; |
23324ae1 FM |
149 | |
150 | /** | |
151 | Returns the current wildcard. | |
152 | */ | |
adaaa686 | 153 | virtual wxString GetWildcard() const; |
23324ae1 FM |
154 | |
155 | /** | |
156 | Sets(changes) the current directory displayed in the control. | |
3c4f71cc | 157 | |
d29a9a8a | 158 | @return Returns @true on success, @false otherwise. |
23324ae1 | 159 | */ |
adaaa686 | 160 | virtual bool SetDirectory(const wxString& directory); |
23324ae1 FM |
161 | |
162 | /** | |
163 | Selects a certain file. | |
3c4f71cc | 164 | |
d29a9a8a | 165 | @return Returns @true on success, @false otherwise |
23324ae1 | 166 | */ |
adaaa686 | 167 | virtual bool SetFilename(const wxString& filename); |
23324ae1 FM |
168 | |
169 | /** | |
170 | Sets the current filter index, starting from zero. | |
171 | */ | |
adaaa686 | 172 | virtual void SetFilterIndex(int filterIndex); |
23324ae1 FM |
173 | |
174 | /** | |
175 | Sets the wildcard, which can contain multiple file types, for example: | |
23324ae1 FM |
176 | "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" |
177 | */ | |
adaaa686 | 178 | virtual void SetWildcard(const wxString& wildCard); |
23324ae1 FM |
179 | |
180 | /** | |
181 | Sets whether hidden files and folders are shown or not. | |
182 | */ | |
43c48e1e | 183 | virtual void ShowHidden(bool show); |
23324ae1 FM |
184 | }; |
185 | ||
186 | ||
e54c96f1 | 187 | |
23324ae1 FM |
188 | /** |
189 | @class wxFileCtrlEvent | |
7c913512 | 190 | |
23324ae1 FM |
191 | A file control event holds information about events associated with |
192 | wxFileCtrl objects. | |
7c913512 | 193 | |
0ce6d6c8 | 194 | @beginEventTable{wxFileCtrlEvent} |
8c6791e4 | 195 | @event{EVT_FILECTRL_FILEACTIVATED(id, func)} |
0ce6d6c8 | 196 | The user activated a file(by double-clicking or pressing Enter) |
8c6791e4 | 197 | @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)} |
0ce6d6c8 | 198 | The user changed the current selection(by selecting or deselecting a file) |
8c6791e4 | 199 | @event{EVT_FILECTRL_FOLDERCHANGED(id, func)} |
0ce6d6c8 | 200 | The current folder of the file control has been changed |
6305f044 VZ |
201 | @event{EVT_FILECTRL_FILTERCHANGED(id, func)} |
202 | The current file filter of the file control has been changed | |
0ce6d6c8 FM |
203 | @endEventTable |
204 | ||
23324ae1 | 205 | @library{wxbase} |
0ce6d6c8 | 206 | @category{events} |
23324ae1 FM |
207 | */ |
208 | class wxFileCtrlEvent : public wxCommandEvent | |
209 | { | |
210 | public: | |
211 | /** | |
212 | Constructor. | |
213 | */ | |
a44f3b5a | 214 | wxFileCtrlEvent(wxEventType type, wxObject *evtObject, int id); |
23324ae1 FM |
215 | |
216 | /** | |
217 | Returns the current directory. | |
0ce6d6c8 | 218 | |
23324ae1 FM |
219 | In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new |
220 | directory. | |
221 | */ | |
328f5751 | 222 | wxString GetDirectory() const; |
23324ae1 FM |
223 | |
224 | /** | |
0ce6d6c8 | 225 | Returns the file selected (assuming it is only one file). |
23324ae1 | 226 | */ |
328f5751 | 227 | wxString GetFile() const; |
23324ae1 FM |
228 | |
229 | /** | |
230 | Returns the files selected. | |
0ce6d6c8 | 231 | |
23324ae1 FM |
232 | In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the |
233 | files selected after the event. | |
234 | */ | |
328f5751 | 235 | wxArrayString GetFiles() const; |
23324ae1 | 236 | |
6305f044 VZ |
237 | /** |
238 | Returns the current file filter index. | |
239 | ||
240 | For a @b EVT_FILECTRL_FILTERCHANGED event, this method returns the new | |
241 | file filter index. | |
242 | ||
243 | @since 2.9.1 | |
244 | */ | |
245 | int GetFilterIndex() const; | |
246 | ||
23324ae1 FM |
247 | /** |
248 | Sets the files changed by this event. | |
249 | */ | |
43c48e1e | 250 | void SetFiles(const wxArrayString& files); |
0ce6d6c8 FM |
251 | |
252 | ||
253 | /** | |
254 | Sets the directory of this event. | |
255 | */ | |
256 | void SetDirectory( const wxString &directory ); | |
6305f044 VZ |
257 | |
258 | /** | |
259 | Sets the filter index changed by this event. | |
260 | ||
261 | @since 2.9.1 | |
262 | */ | |
263 | void SetFilterIndex(int index); | |
23324ae1 | 264 | }; |
e54c96f1 | 265 |