1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFileCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This control allows the user to select a file.
15 Two implemetations exist, one for Gtk and another generic one for anything
16 other than Gtk. It is only available if @c wxUSE_FILECTRL is set to 1.
19 @style{wxFC_DEFAULT_STYLE}
20 The default style: wxFC_OPEN
22 Creates an file control suitable for opening files. Cannot be
23 combined with wxFC_SAVE.
25 Creates an file control suitable for saving files. Cannot be
26 combined with wxFC_OPEN.
28 For open control only, Allows selecting multiple files. Cannot be
29 combined with wxFC_SAVE
30 @style{wxFC_NOSHOWHIDDEN}
31 Hides the "Show Hidden Files" checkbox (Generic only)
35 @beginEventTable{wxFileCtrlEvent}
36 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
37 The user activated a file(by double-clicking or pressing Enter)
38 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
39 The user changed the current selection(by selecting or deselecting a file)
40 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
41 The current folder of the file control has been changed
51 class wxFileCtrl
: public wxWindow
57 Constructs the window.
60 Parent window, must not be non-@NULL.
62 The identifier for the control.
63 @param defaultDirectory
64 The initial directory shown in the control. Must be
65 a valid path to a directory or the empty string.
66 In case it is the empty string, the current working directory is used.
67 @param defaultFilename
68 The default filename, or the empty string.
70 A wildcard specifying which files can be selected,
71 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
73 The window style, see wxFC_* flags.
81 @returns @true if the control was successfully created or @false if
85 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
86 const wxString
& defaultDirectory
= wxEmptyString
,
87 const wxString
& defaultFilename
= wxEmptyString
,
88 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
89 long style
= wxFC_DEFAULT_STYLE
,
90 const wxPoint
& pos
= wxDefaultPosition
,
91 const wxSize
& size
= wxDefaultSize
,
92 const wxString
& name
= "filectrl");
95 Create function for two-step construction. See wxFileCtrl() for details.
97 bool Create(wxWindow
* parent
, wxWindowID id
,
98 const wxString
& defaultDirectory
= wxEmptyString
,
99 const wxString
& defaultFilename
= wxEmptyString
,
100 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
101 long style
= wxFC_DEFAULT_STYLE
,
102 const wxPoint
& pos
= wxDefaultPosition
,
103 const wxSize
& size
= wxDefaultSize
,
104 const wxString
& name
= "filectrl");
107 Returns the current directory of the file control (i.e. the directory shown by it).
109 wxString
GetDirectory() const;
112 Returns the currently selected filename.
114 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
116 wxString
GetFilename() const;
119 Fills the array @a filenames with the filenames only of selected items.
121 This function should only be used with the controls having the @c wxFC_MULTIPLE
122 style, use GetFilename() for the others.
124 @remarks filenames is emptied first.
126 void GetFilenames(wxArrayString
& filenames
) const;
129 Returns the zero-based index of the currently selected filter.
131 int GetFilterIndex() const;
134 Returns the full path (directory and filename) of the currently selected file.
135 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
137 wxString
GetPath() const;
140 Fills the array @a paths with the full paths of the files chosen.
142 This function should be used with the controls having the @c wxFC_MULTIPLE style,
143 use GetPath() otherwise.
145 @remarks paths is emptied first.
147 void GetPaths(wxArrayString
& paths
) const;
150 Returns the current wildcard.
152 wxString
GetWildcard() const;
155 Sets(changes) the current directory displayed in the control.
157 @returns Returns @true on success, @false otherwise.
159 bool SetDirectory(const wxString
& directory
);
162 Selects a certain file.
164 @returns Returns @true on success, @false otherwise
166 bool SetFilename(const wxString
& filename
);
169 Sets the current filter index, starting from zero.
171 void SetFilterIndex(int filterIndex
);
174 Sets the wildcard, which can contain multiple file types, for example:
175 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
177 void SetWildcard(const wxString
& wildCard
);
180 Sets whether hidden files and folders are shown or not.
182 void ShowHidden(const bool show
);
188 @class wxFileCtrlEvent
189 @wxheader{filectrl.h}
191 A file control event holds information about events associated with
194 @beginEventTable{wxFileCtrlEvent}
195 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
196 The user activated a file(by double-clicking or pressing Enter)
197 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
198 The user changed the current selection(by selecting or deselecting a file)
199 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
200 The current folder of the file control has been changed
206 class wxFileCtrlEvent
: public wxCommandEvent
212 wxFileCtrlEvent(wxEventType type
, wxObject evtObject
, int id
);
215 Returns the current directory.
217 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
220 wxString
GetDirectory() const;
223 Returns the file selected (assuming it is only one file).
225 wxString
GetFile() const;
228 Returns the files selected.
230 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
231 files selected after the event.
233 wxArrayString
GetFiles() const;
236 Sets the files changed by this event.
238 void SetFiles(const wxArrayString files
);
242 Sets the directory of this event.
244 void SetDirectory( const wxString
&directory
);