1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFileCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 This control allows the user to select a file.
14 Two implementations of this class exist, one for Gtk and another generic
15 one for all the other ports.
17 This class is only available if @c wxUSE_FILECTRL is set to 1.
20 @style{wxFC_DEFAULT_STYLE}
21 The default style: wxFC_OPEN
23 Creates an file control suitable for opening files. Cannot be
24 combined with wxFC_SAVE.
26 Creates an file control suitable for saving files. Cannot be
27 combined with wxFC_OPEN.
29 For open control only, Allows selecting multiple files. Cannot be
30 combined with wxFC_SAVE
31 @style{wxFC_NOSHOWHIDDEN}
32 Hides the "Show Hidden Files" checkbox (Generic only)
35 @beginEventEmissionTable{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
42 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
43 The current file filter of the file control has been changed.
50 @appearance{filectrl.png}
56 class wxFileCtrl
: public wxControl
62 Constructs the window.
65 Parent window, must not be non-@NULL.
67 The identifier for the control.
68 @param defaultDirectory
69 The initial directory shown in the control.
70 Must be a valid path to a directory or the empty string.
71 In case it is the empty string, the current working directory is used.
72 @param defaultFilename
73 The default filename, or the empty string.
75 A wildcard specifying which files can be selected,
76 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
78 The window style, see wxFC_* flags.
86 @return @true if the control was successfully created or @false if
90 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
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
,
97 const wxString
& name
= wxFileCtrlNameStr
);
100 Create function for two-step construction. See wxFileCtrl() for details.
102 bool Create(wxWindow
* parent
, wxWindowID id
,
103 const wxString
& defaultDirectory
= wxEmptyString
,
104 const wxString
& defaultFilename
= wxEmptyString
,
105 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
106 long style
= wxFC_DEFAULT_STYLE
, const wxPoint
& pos
= wxDefaultPosition
,
107 const wxSize
& size
= wxDefaultSize
,
108 const wxString
& name
= wxFileCtrlNameStr
);
111 Returns the current directory of the file control (i.e. the directory shown by it).
113 virtual wxString
GetDirectory() const;
116 Returns the currently selected filename.
118 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
120 virtual wxString
GetFilename() const;
123 Fills the array @a filenames with the filenames only of selected items.
125 This function should only be used with the controls having the @c wxFC_MULTIPLE
126 style, use GetFilename() for the others.
128 @remarks filenames is emptied first.
130 virtual void GetFilenames(wxArrayString
& filenames
) const;
133 Returns the zero-based index of the currently selected filter.
135 virtual int GetFilterIndex() const;
138 Returns the full path (directory and filename) of the currently selected file.
139 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
141 virtual wxString
GetPath() const;
144 Fills the array @a paths with the full paths of the files chosen.
146 This function should be used with the controls having the @c wxFC_MULTIPLE style,
147 use GetPath() otherwise.
149 @remarks paths is emptied first.
151 virtual void GetPaths(wxArrayString
& paths
) const;
154 Returns the current wildcard.
156 virtual wxString
GetWildcard() const;
159 Sets(changes) the current directory displayed in the control.
161 @return Returns @true on success, @false otherwise.
163 virtual bool SetDirectory(const wxString
& directory
);
166 Selects a certain file.
168 @return Returns @true on success, @false otherwise
170 virtual bool SetFilename(const wxString
& filename
);
173 Sets the current filter index, starting from zero.
175 virtual void SetFilterIndex(int filterIndex
);
178 Sets the wildcard, which can contain multiple file types, for example:
179 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
181 virtual void SetWildcard(const wxString
& wildCard
);
184 Sets whether hidden files and folders are shown or not.
186 virtual void ShowHidden(bool show
);
192 @class wxFileCtrlEvent
194 A file control event holds information about events associated with
197 @beginEventTable{wxFileCtrlEvent}
198 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
199 The user activated a file(by double-clicking or pressing Enter)
200 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
201 The user changed the current selection(by selecting or deselecting a file)
202 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
203 The current folder of the file control has been changed
204 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
205 The current file filter of the file control has been changed
211 class wxFileCtrlEvent
: public wxCommandEvent
217 wxFileCtrlEvent(wxEventType type
, wxObject
*evtObject
, int id
);
220 Returns the current directory.
222 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
225 wxString
GetDirectory() const;
228 Returns the file selected (assuming it is only one file).
230 wxString
GetFile() const;
233 Returns the files selected.
235 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
236 files selected after the event.
238 wxArrayString
GetFiles() const;
241 Returns the current file filter index.
243 For a @b EVT_FILECTRL_FILTERCHANGED event, this method returns the new
248 int GetFilterIndex() const;
251 Sets the files changed by this event.
253 void SetFiles(const wxArrayString
& files
);
257 Sets the directory of this event.
259 void SetDirectory( const wxString
&directory
);
262 Sets the filter index changed by this event.
266 void SetFilterIndex(int index
);