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