1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxFileCtrl class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This control allows the user to select a file. two implemetations exist, one
14 for Gtk and another generic one for anything other than Gtk.
15 It is only available if @c wxUSE_FILECTRL is set to 1.
18 @style{wxFC_DEFAULT_STYLE}:
19 The default style: wxFC_OPEN
21 Creates an file control suitable for opening files. Cannot be
22 combined with 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)
39 class wxFileCtrl
: public wxWindow
45 Parent window, must not be non-@NULL.
48 The identifier for the control.
50 @param defaultDirectory
51 The initial directory shown in the control. Must be
52 a valid path to a directory or the empty string.
53 In case it is the empty string, the current working directory is used.
55 @param defaultFilename
56 The default filename, or the empty string.
59 A wildcard specifying which files can be selected,
60 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
63 The window style, see wxFC_* flags.
74 @returns @true if the control was successfully created or @false if
78 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
79 const wxString
& defaultDirectory
= wxEmptyString
,
80 const wxString
& defaultFilename
= wxEmptyString
,
81 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
82 long style
= wxFC_DEFAULT_STYLE
,
83 const wxPoint
& pos
= wxDefaultPosition
,
84 const wxSize
& size
= wxDefaultSize
,
85 const wxString
& name
= "filectrl");
89 Create function for two-step construction. See wxFileCtrl() for details.
91 bool Create(wxWindow
* parent
, wxWindowID id
,
92 const wxString
& defaultDirectory
= wxEmptyString
,
93 const wxString
& defaultFilename
= wxEmptyString
,
94 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
95 long style
= wxFC_DEFAULT_STYLE
,
96 const wxPoint
& pos
= wxDefaultPosition
,
97 const wxSize
& size
= wxDefaultSize
,
98 const wxString
& name
= "filectrl");
101 Returns the current directory of the file control (i.e. the directory shown by
104 wxString
GetDirectory();
107 Returns the currently selected filename.
108 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames()
111 wxString
GetFilename();
114 Fills the array @e filenames with the filenames only of selected items. This
115 function should only be used with the controls having the @c wxFC_MULTIPLE
117 use GetFilename() for the others.
119 @remarks filenames is emptied first.
121 void GetFilenames(wxArrayString
& filenames
);
124 Returns the zero-based index of the currently selected filter.
126 int GetFilterIndex();
129 Returns the full path (directory and filename) of the currently selected file.
130 For the controls having the @c wxFC_MULTIPLE style, use GetPaths()
136 Fills the array @e paths with the full paths of the files chosen. This
137 function should be used with the controls having the @c wxFC_MULTIPLE style,
138 use GetPath() otherwise.
140 @remarks paths is emptied first.
142 void GetPaths(wxArrayString
& paths
);
145 Returns the current wildcard.
147 wxString
GetWildcard();
150 Sets(changes) the current directory displayed in the control.
152 @returns Returns @true on success, @false otherwise.
154 bool SetDirectory(const wxString
& directory
);
157 Selects a certain file.
159 @returns Returns @true on success, @false otherwise
161 bool SetFilename(const wxString
& filename
);
164 Sets the current filter index, starting from zero.
166 void SetFilterIndex(int filterIndex
);
169 Sets the wildcard, which can contain multiple file types, for example:
171 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
173 void SetWildcard(const wxString
& wildCard
);
176 Sets whether hidden files and folders are shown or not.
178 void ShowHidden(const bool show
);
183 @class wxFileCtrlEvent
184 @wxheader{filectrl.h}
186 A file control event holds information about events associated with
192 class wxFileCtrlEvent
: public wxCommandEvent
198 wxFileCtrlEvent(wxEventType type
, wxObject evtObject
, int id
);
201 Returns the current directory.
202 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
205 wxString
GetDirectory();
208 Returns the file selected(assuming it is only one file).
213 Returns the files selected.
214 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
215 files selected after the event.
217 wxArrayString
GetFiles();
220 Sets the files changed by this event.
222 wxFileCtrlEvent::SetFiles(const wxArrayString files
);