1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFileCtrl
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
12 wxFC_MULTIPLE
= 0x0004,
13 wxFC_NOSHOWHIDDEN
= 0x0008
16 #define wxFC_DEFAULT_STYLE wxFC_OPEN
21 This control allows the user to select a file.
23 Two implementations of this class exist, one for Gtk and another generic
24 one for all the other ports.
26 This class is only available if @c wxUSE_FILECTRL is set to 1.
29 @style{wxFC_DEFAULT_STYLE}
30 The default style: wxFC_OPEN
32 Creates an file control suitable for opening files. Cannot be
33 combined with wxFC_SAVE.
35 Creates an file control suitable for saving files. Cannot be
36 combined with wxFC_OPEN.
38 For open control only, Allows selecting multiple files. Cannot be
39 combined with wxFC_SAVE
40 @style{wxFC_NOSHOWHIDDEN}
41 Hides the "Show Hidden Files" checkbox (Generic only)
44 @beginEventEmissionTable{wxFileCtrlEvent}
45 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
46 The user activated a file(by double-clicking or pressing Enter)
47 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
48 The user changed the current selection(by selecting or deselecting a file)
49 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
50 The current folder of the file control has been changed
51 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
52 The current file filter of the file control has been changed.
65 class wxFileCtrl
: public wxControl
71 Constructs the window.
74 Parent window, must not be non-@NULL.
76 The identifier for the control.
77 @param defaultDirectory
78 The initial directory shown in the control.
79 Must be a valid path to a directory or the empty string.
80 In case it is the empty string, the current working directory is used.
81 @param defaultFilename
82 The default filename, or the empty string.
84 A wildcard specifying which files can be selected,
85 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
87 The window style, see wxFC_* flags.
95 @return @true if the control was successfully created or @false if
99 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
100 const wxString
& defaultDirectory
= wxEmptyString
,
101 const wxString
& defaultFilename
= wxEmptyString
,
102 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
103 long style
= wxFC_DEFAULT_STYLE
,
104 const wxPoint
& pos
= wxDefaultPosition
,
105 const wxSize
& size
= wxDefaultSize
,
106 const wxString
& name
= wxFileCtrlNameStr
);
109 Create function for two-step construction. See wxFileCtrl() for details.
111 bool Create(wxWindow
* parent
, wxWindowID id
,
112 const wxString
& defaultDirectory
= wxEmptyString
,
113 const wxString
& defaultFilename
= wxEmptyString
,
114 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
115 long style
= wxFC_DEFAULT_STYLE
, const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
,
117 const wxString
& name
= wxFileCtrlNameStr
);
120 Returns the current directory of the file control (i.e.\ the directory shown by it).
122 virtual wxString
GetDirectory() const;
125 Returns the currently selected filename.
127 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
129 virtual wxString
GetFilename() const;
132 Fills the array @a filenames with the filenames only of selected items.
134 This function should only be used with the controls having the @c wxFC_MULTIPLE
135 style, use GetFilename() for the others.
137 @remarks filenames is emptied first.
139 virtual void GetFilenames(wxArrayString
& filenames
) const;
142 Returns the zero-based index of the currently selected filter.
144 virtual int GetFilterIndex() const;
147 Returns the full path (directory and filename) of the currently selected file.
148 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
150 virtual wxString
GetPath() const;
153 Fills the array @a paths with the full paths of the files chosen.
155 This function should be used with the controls having the @c wxFC_MULTIPLE style,
156 use GetPath() otherwise.
158 @remarks paths is emptied first.
160 virtual void GetPaths(wxArrayString
& paths
) const;
163 Returns the current wildcard.
165 virtual wxString
GetWildcard() const;
168 Sets(changes) the current directory displayed in the control.
170 @return Returns @true on success, @false otherwise.
172 virtual bool SetDirectory(const wxString
& directory
);
175 Selects a certain file.
177 @return Returns @true on success, @false otherwise
179 virtual bool SetFilename(const wxString
& filename
);
182 Changes to a certain directory and selects a certain file.
184 In case the filename specified isn't found/couldn't be shown with
185 currently selected filter, false is returned.
187 @return Returns @true on success, @false otherwise
189 virtual bool SetPath(const wxString
& path
);
192 Sets the current filter index, starting from zero.
194 virtual void SetFilterIndex(int filterIndex
);
197 Sets the wildcard, which can contain multiple file types, for example:
198 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
200 virtual void SetWildcard(const wxString
& wildCard
);
203 Sets whether hidden files and folders are shown or not.
205 virtual void ShowHidden(bool show
);
209 wxEventType wxEVT_FILECTRL_SELECTIONCHANGED
;
210 wxEventType wxEVT_FILECTRL_FILEACTIVATED
;
211 wxEventType wxEVT_FILECTRL_FOLDERCHANGED
;
212 wxEventType wxEVT_FILECTRL_FILTERCHANGED
;
216 @class wxFileCtrlEvent
218 A file control event holds information about events associated with
221 @beginEventTable{wxFileCtrlEvent}
222 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
223 The user activated a file(by double-clicking or pressing Enter)
224 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
225 The user changed the current selection(by selecting or deselecting a file)
226 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
227 The current folder of the file control has been changed
228 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
229 The current file filter of the file control has been changed
235 class wxFileCtrlEvent
: public wxCommandEvent
241 wxFileCtrlEvent(wxEventType type
, wxObject
*evtObject
, int id
);
244 Returns the current directory.
246 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
249 wxString
GetDirectory() const;
252 Returns the file selected (assuming it is only one file).
254 wxString
GetFile() const;
257 Returns the files selected.
259 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
260 files selected after the event.
262 wxArrayString
GetFiles() const;
265 Returns the current file filter index.
267 For a @b EVT_FILECTRL_FILTERCHANGED event, this method returns the new
272 int GetFilterIndex() const;
275 Sets the files changed by this event.
277 void SetFiles(const wxArrayString
& files
);
281 Sets the directory of this event.
283 void SetDirectory( const wxString
&directory
);
286 Sets the filter index changed by this event.
290 void SetFilterIndex(int index
);