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