1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFileCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
13 wxFC_MULTIPLE
= 0x0004,
14 wxFC_NOSHOWHIDDEN
= 0x0008
17 #define wxFC_DEFAULT_STYLE wxFC_OPEN
22 This control allows the user to select a file.
24 Two implementations of this class exist, one for Gtk and another generic
25 one for all the other ports.
27 This class is only available if @c wxUSE_FILECTRL is set to 1.
30 @style{wxFC_DEFAULT_STYLE}
31 The default style: wxFC_OPEN
33 Creates an file control suitable for opening files. Cannot be
34 combined with wxFC_SAVE.
36 Creates an file control suitable for saving files. Cannot be
37 combined with wxFC_OPEN.
39 For open control only, Allows selecting multiple files. Cannot be
40 combined with wxFC_SAVE
41 @style{wxFC_NOSHOWHIDDEN}
42 Hides the "Show Hidden Files" checkbox (Generic only)
45 @beginEventEmissionTable{wxFileCtrlEvent}
46 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
47 The user activated a file(by double-clicking or pressing Enter)
48 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
49 The user changed the current selection(by selecting or deselecting a file)
50 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
51 The current folder of the file control has been changed
52 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
53 The current file filter of the file control has been changed.
66 class wxFileCtrl
: public wxControl
72 Constructs the window.
75 Parent window, must not be non-@NULL.
77 The identifier for the control.
78 @param defaultDirectory
79 The initial directory shown in the control.
80 Must be a valid path to a directory or the empty string.
81 In case it is the empty string, the current working directory is used.
82 @param defaultFilename
83 The default filename, or the empty string.
85 A wildcard specifying which files can be selected,
86 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
88 The window style, see wxFC_* flags.
96 @return @true if the control was successfully created or @false if
100 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
101 const wxString
& defaultDirectory
= wxEmptyString
,
102 const wxString
& defaultFilename
= wxEmptyString
,
103 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
104 long style
= wxFC_DEFAULT_STYLE
,
105 const wxPoint
& pos
= wxDefaultPosition
,
106 const wxSize
& size
= wxDefaultSize
,
107 const wxString
& name
= wxFileCtrlNameStr
);
110 Create function for two-step construction. See wxFileCtrl() for details.
112 bool Create(wxWindow
* parent
, wxWindowID id
,
113 const wxString
& defaultDirectory
= wxEmptyString
,
114 const wxString
& defaultFilename
= wxEmptyString
,
115 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
116 long style
= wxFC_DEFAULT_STYLE
, const wxPoint
& pos
= wxDefaultPosition
,
117 const wxSize
& size
= wxDefaultSize
,
118 const wxString
& name
= wxFileCtrlNameStr
);
121 Returns the current directory of the file control (i.e.\ the directory shown by it).
123 virtual wxString
GetDirectory() const;
126 Returns the currently selected filename.
128 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
130 virtual wxString
GetFilename() const;
133 Fills the array @a filenames with the filenames only of selected items.
135 This function should only be used with the controls having the @c wxFC_MULTIPLE
136 style, use GetFilename() for the others.
138 @remarks filenames is emptied first.
140 virtual void GetFilenames(wxArrayString
& filenames
) const;
143 Returns the zero-based index of the currently selected filter.
145 virtual int GetFilterIndex() const;
148 Returns the full path (directory and filename) of the currently selected file.
149 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
151 virtual wxString
GetPath() const;
154 Fills the array @a paths with the full paths of the files chosen.
156 This function should be used with the controls having the @c wxFC_MULTIPLE style,
157 use GetPath() otherwise.
159 @remarks paths is emptied first.
161 virtual void GetPaths(wxArrayString
& paths
) const;
164 Returns the current wildcard.
166 virtual wxString
GetWildcard() const;
169 Sets(changes) the current directory displayed in the control.
171 @return Returns @true on success, @false otherwise.
173 virtual bool SetDirectory(const wxString
& directory
);
176 Selects a certain file.
178 @return Returns @true on success, @false otherwise
180 virtual bool SetFilename(const wxString
& filename
);
183 Changes to a certain directory and selects a certain file.
185 In case the filename specified isn't found/couldn't be shown with
186 currently selected filter, false is returned.
188 @return Returns @true on success, @false otherwise
190 virtual bool SetPath(const wxString
& path
);
193 Sets the current filter index, starting from zero.
195 virtual void SetFilterIndex(int filterIndex
);
198 Sets the wildcard, which can contain multiple file types, for example:
199 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
201 virtual void SetWildcard(const wxString
& wildCard
);
204 Sets whether hidden files and folders are shown or not.
206 virtual void ShowHidden(bool show
);
210 wxEventType wxEVT_FILECTRL_SELECTIONCHANGED
;
211 wxEventType wxEVT_FILECTRL_FILEACTIVATED
;
212 wxEventType wxEVT_FILECTRL_FOLDERCHANGED
;
213 wxEventType wxEVT_FILECTRL_FILTERCHANGED
;
217 @class wxFileCtrlEvent
219 A file control event holds information about events associated with
222 @beginEventTable{wxFileCtrlEvent}
223 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
224 The user activated a file(by double-clicking or pressing Enter)
225 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
226 The user changed the current selection(by selecting or deselecting a file)
227 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
228 The current folder of the file control has been changed
229 @event{EVT_FILECTRL_FILTERCHANGED(id, func)}
230 The current file filter of the file control has been changed
236 class wxFileCtrlEvent
: public wxCommandEvent
242 wxFileCtrlEvent(wxEventType type
, wxObject
*evtObject
, int id
);
245 Returns the current directory.
247 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
250 wxString
GetDirectory() const;
253 Returns the file selected (assuming it is only one file).
255 wxString
GetFile() const;
258 Returns the files selected.
260 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
261 files selected after the event.
263 wxArrayString
GetFiles() const;
266 Returns the current file filter index.
268 For a @b EVT_FILECTRL_FILTERCHANGED event, this method returns the new
273 int GetFilterIndex() const;
276 Sets the files changed by this event.
278 void SetFiles(const wxArrayString
& files
);
282 Sets the directory of this event.
284 void SetDirectory( const wxString
&directory
);
287 Sets the filter index changed by this event.
291 void SetFilterIndex(int index
);