]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/filectrl.h
Removed wxPG_EX_LEGACY_VALIDATORS
[wxWidgets.git] / interface / wx / filectrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: filectrl.h
3 // Purpose: interface of wxFileCtrl
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxFileCtrl
11
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.
16
17 @beginStyleTable
18 @style{wxFC_DEFAULT_STYLE}
19 The default style: wxFC_OPEN
20 @style{wxFC_OPEN}
21 Creates an file control suitable for opening files. Cannot be
22 combined with wxFC_SAVE.
23 @style{wxFC_SAVE}
24 Creates an file control suitable for saving files. Cannot be
25 combined with wxFC_OPEN.
26 @style{wxFC_MULTIPLE}
27 For open control only, Allows selecting multiple files. Cannot be
28 combined with wxFC_SAVE
29 @style{wxFC_NOSHOWHIDDEN}
30 Hides the "Show Hidden Files" checkbox (Generic only)
31 @endStyleTable
32
33
34 @beginEventTable{wxFileCtrlEvent}
35 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
36 The user activated a file(by double-clicking or pressing Enter)
37 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
38 The user changed the current selection(by selecting or deselecting a file)
39 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
40 The current folder of the file control has been changed
41 @endEventTable
42
43 @nativeimpl{wxgtk}
44
45 @library{wxbase}
46 @category{miscwnd}
47
48 @see wxGenericDirCtrl
49 */
50 class wxFileCtrl : public wxWindow
51 {
52 public:
53 wxFileCtrl();
54
55 /**
56 Constructs the window.
57
58 @param parent
59 Parent window, must not be non-@NULL.
60 @param id
61 The identifier for the control.
62 @param defaultDirectory
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.
66 @param defaultFilename
67 The default filename, or the empty string.
68 @param wildcard
69 A wildcard specifying which files can be selected,
70 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
71 @param style
72 The window style, see wxFC_* flags.
73 @param pos
74 Initial position.
75 @param size
76 Initial size.
77 @param name
78 Control name.
79
80 @return @true if the control was successfully created or @false if
81 creation failed.
82 */
83
84 wxFileCtrl(wxWindow* parent, wxWindowID id,
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");
92
93 /**
94 Create function for two-step construction. See wxFileCtrl() for details.
95 */
96 bool Create(wxWindow* parent, wxWindowID id,
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 /**
106 Returns the current directory of the file control (i.e. the directory shown by it).
107 */
108 virtual wxString GetDirectory() const;
109
110 /**
111 Returns the currently selected filename.
112
113 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
114 */
115 virtual wxString GetFilename() const;
116
117 /**
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.
122
123 @remarks filenames is emptied first.
124 */
125 virtual void GetFilenames(wxArrayString& filenames) const;
126
127 /**
128 Returns the zero-based index of the currently selected filter.
129 */
130 virtual int GetFilterIndex() const;
131
132 /**
133 Returns the full path (directory and filename) of the currently selected file.
134 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
135 */
136 virtual wxString GetPath() const;
137
138 /**
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,
142 use GetPath() otherwise.
143
144 @remarks paths is emptied first.
145 */
146 virtual void GetPaths(wxArrayString& paths) const;
147
148 /**
149 Returns the current wildcard.
150 */
151 virtual wxString GetWildcard() const;
152
153 /**
154 Sets(changes) the current directory displayed in the control.
155
156 @return Returns @true on success, @false otherwise.
157 */
158 virtual bool SetDirectory(const wxString& directory);
159
160 /**
161 Selects a certain file.
162
163 @return Returns @true on success, @false otherwise
164 */
165 virtual bool SetFilename(const wxString& filename);
166
167 /**
168 Sets the current filter index, starting from zero.
169 */
170 virtual void SetFilterIndex(int filterIndex);
171
172 /**
173 Sets the wildcard, which can contain multiple file types, for example:
174 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
175 */
176 virtual void SetWildcard(const wxString& wildCard);
177
178 /**
179 Sets whether hidden files and folders are shown or not.
180 */
181 void ShowHidden(const bool show);
182 };
183
184
185
186 /**
187 @class wxFileCtrlEvent
188
189 A file control event holds information about events associated with
190 wxFileCtrl objects.
191
192 @beginEventTable{wxFileCtrlEvent}
193 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
194 The user activated a file(by double-clicking or pressing Enter)
195 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
196 The user changed the current selection(by selecting or deselecting a file)
197 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
198 The current folder of the file control has been changed
199 @endEventTable
200
201 @library{wxbase}
202 @category{events}
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.
214
215 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
216 directory.
217 */
218 wxString GetDirectory() const;
219
220 /**
221 Returns the file selected (assuming it is only one file).
222 */
223 wxString GetFile() const;
224
225 /**
226 Returns the files selected.
227
228 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
229 files selected after the event.
230 */
231 wxArrayString GetFiles() const;
232
233 /**
234 Sets the files changed by this event.
235 */
236 void SetFiles(const wxArrayString files);
237
238
239 /**
240 Sets the directory of this event.
241 */
242 void SetDirectory( const wxString &directory );
243 };
244