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