1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFileCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 This control allows the user to select a file.
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.
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.
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)
33 @beginEventEmissionTable{wxFileCtrlEvent}
34 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
35 The user activated a file(by double-clicking or pressing Enter)
36 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
37 The user changed the current selection(by selecting or deselecting a file)
38 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
39 The current folder of the file control has been changed
40 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
41 The current file filter of the file control has been changed.
47 @appearance{filectrl.png}
53 class wxFileCtrl
: public wxControl
59 Constructs the window.
62 Parent window, must not be non-@NULL.
64 The identifier for the control.
65 @param defaultDirectory
66 The initial directory shown in the control.
67 Must be a valid path to a directory or the empty string.
68 In case it is the empty string, the current working directory is used.
69 @param defaultFilename
70 The default filename, or the empty string.
72 A wildcard specifying which files can be selected,
73 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
75 The window style, see wxFC_* flags.
83 @return @true if the control was successfully created or @false if
87 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
88 const wxString
& defaultDirectory
= wxEmptyString
,
89 const wxString
& defaultFilename
= wxEmptyString
,
90 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
91 long style
= wxFC_DEFAULT_STYLE
,
92 const wxPoint
& pos
= wxDefaultPosition
,
93 const wxSize
& size
= wxDefaultSize
,
94 const wxString
& name
= wxFileCtrlNameStr
);
97 Create function for two-step construction. See wxFileCtrl() for details.
99 bool Create(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
, const wxPoint
& pos
= wxDefaultPosition
,
104 const wxSize
& size
= wxDefaultSize
,
105 const wxString
& name
= wxFileCtrlNameStr
);
108 Returns the current directory of the file control (i.e. the directory shown by it).
110 virtual wxString
GetDirectory() const;
113 Returns the currently selected filename.
115 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
117 virtual wxString
GetFilename() const;
120 Fills the array @a filenames with the filenames only of selected items.
122 This function should only be used with the controls having the @c wxFC_MULTIPLE
123 style, use GetFilename() for the others.
125 @remarks filenames is emptied first.
127 virtual void GetFilenames(wxArrayString
& filenames
) const;
130 Returns the zero-based index of the currently selected filter.
132 virtual int GetFilterIndex() const;
135 Returns the full path (directory and filename) of the currently selected file.
136 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
138 virtual wxString
GetPath() const;
141 Fills the array @a paths with the full paths of the files chosen.
143 This function should be used with the controls having the @c wxFC_MULTIPLE style,
144 use GetPath() otherwise.
146 @remarks paths is emptied first.
148 virtual void GetPaths(wxArrayString
& paths
) const;
151 Returns the current wildcard.
153 virtual wxString
GetWildcard() const;
156 Sets(changes) the current directory displayed in the control.
158 @return Returns @true on success, @false otherwise.
160 virtual bool SetDirectory(const wxString
& directory
);
163 Selects a certain file.
165 @return Returns @true on success, @false otherwise
167 virtual bool SetFilename(const wxString
& filename
);
170 Sets the current filter index, starting from zero.
172 virtual void SetFilterIndex(int filterIndex
);
175 Sets the wildcard, which can contain multiple file types, for example:
176 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
178 virtual void SetWildcard(const wxString
& wildCard
);
181 Sets whether hidden files and folders are shown or not.
183 virtual void ShowHidden(bool show
);
189 @class wxFileCtrlEvent
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
201 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
202 The current file filter of the file control has been changed
208 class wxFileCtrlEvent
: public wxCommandEvent
214 wxFileCtrlEvent(wxEventType type
, wxObject
*evtObject
, int id
);
217 Returns the current directory.
219 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
222 wxString
GetDirectory() const;
225 Returns the file selected (assuming it is only one file).
227 wxString
GetFile() const;
230 Returns the files selected.
232 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
233 files selected after the event.
235 wxArrayString
GetFiles() const;
238 Returns the current file filter index.
240 For a @b EVT_FILECTRL_FILTERCHANGED event, this method returns the new
245 int GetFilterIndex() const;
248 Sets the files changed by this event.
250 void SetFiles(const wxArrayString
& files
);
254 Sets the directory of this event.
256 void SetDirectory( const wxString
&directory
);
259 Sets the filter index changed by this event.
263 void SetFilterIndex(int index
);