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)
34 @beginEventTable{wxFileCtrlEvent}
35 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
36 The user activated a file(by double-clicking or pressing Enter)
37 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
38 The user changed the current selection(by selecting or deselecting a file)
39 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
40 The current folder of the file control has been changed
50 class wxFileCtrl
: public wxWindow
56 Constructs the window.
59 Parent window, must not be non-@NULL.
61 The identifier for the control.
62 @param defaultDirectory
63 The initial directory shown in the control. Must be
64 a valid path to a directory or the empty string.
65 In case it is the empty string, the current working directory is used.
66 @param defaultFilename
67 The default filename, or the empty string.
69 A wildcard specifying which files can be selected,
70 such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
72 The window style, see wxFC_* flags.
80 @return @true if the control was successfully created or @false if
84 wxFileCtrl(wxWindow
* parent
, wxWindowID id
,
85 const wxString
& defaultDirectory
= wxEmptyString
,
86 const wxString
& defaultFilename
= wxEmptyString
,
87 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
88 long style
= wxFC_DEFAULT_STYLE
,
89 const wxPoint
& pos
= wxDefaultPosition
,
90 const wxSize
& size
= wxDefaultSize
,
91 const wxString
& name
= "filectrl");
94 Create function for two-step construction. See wxFileCtrl() for details.
96 bool Create(wxWindow
* parent
, wxWindowID id
,
97 const wxString
& defaultDirectory
= wxEmptyString
,
98 const wxString
& defaultFilename
= wxEmptyString
,
99 const wxPoint
& wildCard
= wxFileSelectorDefaultWildcardStr
,
100 long style
= wxFC_DEFAULT_STYLE
,
101 const wxPoint
& pos
= wxDefaultPosition
,
102 const wxSize
& size
= wxDefaultSize
,
103 const wxString
& name
= "filectrl");
106 Returns the current directory of the file control (i.e. the directory shown by it).
108 virtual wxString
GetDirectory() const;
111 Returns the currently selected filename.
113 For the controls having the @c wxFC_MULTIPLE style, use GetFilenames() instead.
115 virtual wxString
GetFilename() const;
118 Fills the array @a filenames with the filenames only of selected items.
120 This function should only be used with the controls having the @c wxFC_MULTIPLE
121 style, use GetFilename() for the others.
123 @remarks filenames is emptied first.
125 virtual void GetFilenames(wxArrayString
& filenames
) const;
128 Returns the zero-based index of the currently selected filter.
130 virtual int GetFilterIndex() const;
133 Returns the full path (directory and filename) of the currently selected file.
134 For the controls having the @c wxFC_MULTIPLE style, use GetPaths() instead.
136 virtual wxString
GetPath() const;
139 Fills the array @a paths with the full paths of the files chosen.
141 This function should be used with the controls having the @c wxFC_MULTIPLE style,
142 use GetPath() otherwise.
144 @remarks paths is emptied first.
146 virtual void GetPaths(wxArrayString
& paths
) const;
149 Returns the current wildcard.
151 virtual wxString
GetWildcard() const;
154 Sets(changes) the current directory displayed in the control.
156 @return Returns @true on success, @false otherwise.
158 virtual bool SetDirectory(const wxString
& directory
);
161 Selects a certain file.
163 @return Returns @true on success, @false otherwise
165 virtual bool SetFilename(const wxString
& filename
);
168 Sets the current filter index, starting from zero.
170 virtual void SetFilterIndex(int filterIndex
);
173 Sets the wildcard, which can contain multiple file types, for example:
174 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
176 virtual void SetWildcard(const wxString
& wildCard
);
179 Sets whether hidden files and folders are shown or not.
181 void ShowHidden(const bool show
);
187 @class wxFileCtrlEvent
189 A file control event holds information about events associated with
192 @beginEventTable{wxFileCtrlEvent}
193 @event{EVT_FILECTRL_FILEACTIVATED(id, func)}
194 The user activated a file(by double-clicking or pressing Enter)
195 @event{EVT_FILECTRL_SELECTIONCHANGED(id, func)}
196 The user changed the current selection(by selecting or deselecting a file)
197 @event{EVT_FILECTRL_FOLDERCHANGED(id, func)}
198 The current folder of the file control has been changed
204 class wxFileCtrlEvent
: public wxCommandEvent
210 wxFileCtrlEvent(wxEventType type
, wxObject evtObject
, int id
);
213 Returns the current directory.
215 In case of a @b EVT_FILECTRL_FOLDERCHANGED, this method returns the new
218 wxString
GetDirectory() const;
221 Returns the file selected (assuming it is only one file).
223 wxString
GetFile() const;
226 Returns the files selected.
228 In case of a @b EVT_FILECTRL_SELECTIONCHANGED, this method returns the
229 files selected after the event.
231 wxArrayString
GetFiles() const;
234 Sets the files changed by this event.
236 void SetFiles(const wxArrayString files
);
240 Sets the directory of this event.
242 void SetDirectory( const wxString
&directory
);