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