]>
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 | 33 | @beginEventTable{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 FM |
39 | The current folder of the file control has been changed |
40 | @endEventTable | |
41 | ||
23324ae1 | 42 | @library{wxbase} |
0ce6d6c8 | 43 | @category{miscwnd} |
5f12fb35 FM |
44 | @appearance{filectrl.png} |
45 | ||
46 | @nativeimpl{wxgtk} | |
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 |
76e9224e FM |
63 | The initial directory shown in the control. |
64 | Must be a valid path to a directory or the empty string. | |
4cc4bfaf | 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. |
76e9224e | 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, | |
a44f3b5a | 91 | const wxString& name = wxFileCtrlNameStr); |
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, | |
43c48e1e FM |
99 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, |
100 | long style = wxFC_DEFAULT_STYLE, const wxPoint& pos = wxDefaultPosition, | |
23324ae1 | 101 | const wxSize& size = wxDefaultSize, |
43c48e1e | 102 | const wxString& name = wxFileCtrlNameStr); |
23324ae1 FM |
103 | |
104 | /** | |
0ce6d6c8 | 105 | Returns the current directory of the file control (i.e. the directory shown by it). |
23324ae1 | 106 | */ |
adaaa686 | 107 | virtual wxString GetDirectory() const; |
23324ae1 FM |
108 | |
109 | /** | |
110 | Returns the currently selected filename. | |
0ce6d6c8 FM |
111 | |
112 | For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead. | |
23324ae1 | 113 | */ |
adaaa686 | 114 | virtual wxString GetFilename() const; |
23324ae1 FM |
115 | |
116 | /** | |
0ce6d6c8 FM |
117 | Fills the array @a filenames with the filenames only of selected items. |
118 | ||
119 | This function should only be used with the controls having the @c wxFC_MULTIPLE | |
120 | style, use GetFilename() for the others. | |
3c4f71cc | 121 | |
23324ae1 FM |
122 | @remarks filenames is emptied first. |
123 | */ | |
adaaa686 | 124 | virtual void GetFilenames(wxArrayString& filenames) const; |
23324ae1 FM |
125 | |
126 | /** | |
127 | Returns the zero-based index of the currently selected filter. | |
128 | */ | |
adaaa686 | 129 | virtual int GetFilterIndex() const; |
23324ae1 FM |
130 | |
131 | /** | |
132 | Returns the full path (directory and filename) of the currently selected file. | |
0ce6d6c8 | 133 | For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead. |
23324ae1 | 134 | */ |
adaaa686 | 135 | virtual wxString GetPath() const; |
23324ae1 FM |
136 | |
137 | /** | |
0ce6d6c8 FM |
138 | Fills the array @a paths with the full paths of the files chosen. |
139 | ||
140 | This function should be used with the controls having the @c wxFC_MULTIPLE style, | |
23324ae1 | 141 | use GetPath() otherwise. |
3c4f71cc | 142 | |
23324ae1 FM |
143 | @remarks paths is emptied first. |
144 | */ | |
adaaa686 | 145 | virtual void GetPaths(wxArrayString& paths) const; |
23324ae1 FM |
146 | |
147 | /** | |
148 | Returns the current wildcard. | |
149 | */ | |
adaaa686 | 150 | virtual wxString GetWildcard() const; |
23324ae1 FM |
151 | |
152 | /** | |
153 | Sets(changes) the current directory displayed in the control. | |
3c4f71cc | 154 | |
d29a9a8a | 155 | @return Returns @true on success, @false otherwise. |
23324ae1 | 156 | */ |
adaaa686 | 157 | virtual bool SetDirectory(const wxString& directory); |
23324ae1 FM |
158 | |
159 | /** | |
160 | Selects a certain file. | |
3c4f71cc | 161 | |
d29a9a8a | 162 | @return Returns @true on success, @false otherwise |
23324ae1 | 163 | */ |
adaaa686 | 164 | virtual bool SetFilename(const wxString& filename); |
23324ae1 FM |
165 | |
166 | /** | |
167 | Sets the current filter index, starting from zero. | |
168 | */ | |
adaaa686 | 169 | virtual void SetFilterIndex(int filterIndex); |
23324ae1 FM |
170 | |
171 | /** | |
172 | Sets the wildcard, which can contain multiple file types, for example: | |
23324ae1 FM |
173 | "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" |
174 | */ | |
adaaa686 | 175 | virtual void SetWildcard(const wxString& wildCard); |
23324ae1 FM |
176 | |
177 | /** | |
178 | Sets whether hidden files and folders are shown or not. | |
179 | */ | |
43c48e1e | 180 | virtual void ShowHidden(bool show); |
23324ae1 FM |
181 | }; |
182 | ||
183 | ||
e54c96f1 | 184 | |
23324ae1 FM |
185 | /** |
186 | @class wxFileCtrlEvent | |
7c913512 | 187 | |
23324ae1 FM |
188 | A file control event holds information about events associated with |
189 | wxFileCtrl objects. | |
7c913512 | 190 | |
0ce6d6c8 | 191 | @beginEventTable{wxFileCtrlEvent} |
8c6791e4 | 192 | @event{EVT_FILECTRL_FILEACTIVATED(id, func)} |
0ce6d6c8 | 193 | The user activated a file(by double-clicking or pressing Enter) |
8c6791e4 | 194 | @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)} |
0ce6d6c8 | 195 | The user changed the current selection(by selecting or deselecting a file) |
8c6791e4 | 196 | @event{EVT_FILECTRL_FOLDERCHANGED(id, func)} |
0ce6d6c8 FM |
197 | The current folder of the file control has been changed |
198 | @endEventTable | |
199 | ||
23324ae1 | 200 | @library{wxbase} |
0ce6d6c8 | 201 | @category{events} |
23324ae1 FM |
202 | */ |
203 | class wxFileCtrlEvent : public wxCommandEvent | |
204 | { | |
205 | public: | |
206 | /** | |
207 | Constructor. | |
208 | */ | |
a44f3b5a | 209 | wxFileCtrlEvent(wxEventType type, wxObject *evtObject, int id); |
23324ae1 FM |
210 | |
211 | /** | |
212 | Returns the current directory. | |
0ce6d6c8 | 213 | |
23324ae1 FM |
214 | In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new |
215 | directory. | |
216 | */ | |
328f5751 | 217 | wxString GetDirectory() const; |
23324ae1 FM |
218 | |
219 | /** | |
0ce6d6c8 | 220 | Returns the file selected (assuming it is only one file). |
23324ae1 | 221 | */ |
328f5751 | 222 | wxString GetFile() const; |
23324ae1 FM |
223 | |
224 | /** | |
225 | Returns the files selected. | |
0ce6d6c8 | 226 | |
23324ae1 FM |
227 | In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the |
228 | files selected after the event. | |
229 | */ | |
328f5751 | 230 | wxArrayString GetFiles() const; |
23324ae1 FM |
231 | |
232 | /** | |
233 | Sets the files changed by this event. | |
234 | */ | |
43c48e1e | 235 | void SetFiles(const wxArrayString& files); |
0ce6d6c8 FM |
236 | |
237 | ||
238 | /** | |
239 | Sets the directory of this event. | |
240 | */ | |
241 | void SetDirectory( const wxString &directory ); | |
23324ae1 | 242 | }; |
e54c96f1 | 243 |