1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGenericDirCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
11 // Only allow directory viewing/selection, no files
12 wxDIRCTRL_DIR_ONLY
= 0x0010,
13 // When setting the default path, select the first file in the directory
14 wxDIRCTRL_SELECT_FIRST
= 0x0020,
15 // Use 3D borders on internal controls
16 wxDIRCTRL_3D_INTERNAL
= 0x0080,
18 wxDIRCTRL_EDIT_LABELS
= 0x0100,
19 // Allow multiple selection
20 wxDIRCTRL_MULTIPLE
= 0x0200
25 @class wxGenericDirCtrl
27 This control can be used to place a directory listing (with optional
28 files) on an arbitrary window.
30 The control contains a wxTreeCtrl window representing the directory
31 hierarchy, and optionally, a wxChoice window containing a list of filters.
34 @style{wxDIRCTRL_DIR_ONLY}
35 Only show directories, and not files.
36 @style{wxDIRCTRL_3D_INTERNAL}
37 Use 3D borders for internal controls.
38 @style{wxDIRCTRL_SELECT_FIRST}
39 When setting the default path, select the first file in the
41 @style{wxDIRCTRL_EDIT_LABELS}
42 Allow the folder and file labels to be editable.
43 @style{wxDIRCTRL_MULTIPLE}
44 Allows multiple files and folders to be selected.
49 @appearance{genericdirctrl.png}
51 class wxGenericDirCtrl
: public wxControl
73 Window style. Please see wxGenericDirCtrl for a list of possible
76 A filter string, using the same syntax as that for wxFileDialog.
77 This may be empty if filters are not being used. Example:
78 @c "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"
80 The zero-indexed default filter setting.
84 wxGenericDirCtrl(wxWindow
* parent
, const wxWindowID id
= wxID_ANY
,
85 const wxString
& dir
= wxDirDialogDefaultFolderStr
,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& size
= wxDefaultSize
,
88 long style
= wxDIRCTRL_3D_INTERNAL
,
89 const wxString
& filter
= wxEmptyString
,
90 int defaultFilter
= 0,
91 const wxString
& name
= wxTreeCtrlNameStr
);
96 virtual ~wxGenericDirCtrl();
99 Collapse the given @a path.
101 virtual bool CollapsePath(const wxString
& path
);
104 Collapses the entire tree.
106 virtual void CollapseTree();
109 Create function for two-step construction. See wxGenericDirCtrl() for
112 bool Create(wxWindow
* parent
, const wxWindowID id
= wxID_ANY
,
113 const wxString
& dir
= wxDirDialogDefaultFolderStr
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
116 long style
= wxDIRCTRL_3D_INTERNAL
,
117 const wxString
& filter
= wxEmptyString
, int defaultFilter
= 0,
118 const wxString
& name
= wxTreeCtrlNameStr
);
121 Tries to expand as much of the given @a path as possible, so that the
122 filename or directory is visible in the tree control.
124 virtual bool ExpandPath(const wxString
& path
);
127 Gets the default path.
129 virtual wxString
GetDefaultPath() const;
132 Gets selected filename path only (else empty string).
134 This function doesn't count a directory as a selection.
136 virtual wxString
GetFilePath() const;
139 Fills the array @a paths with the currently selected filepaths.
141 This function doesn't count a directory as a selection.
143 virtual void GetFilePaths(wxArrayString
& paths
) const;
146 Returns the filter string.
148 virtual wxString
GetFilter() const;
151 Returns the current filter index (zero-based).
153 virtual int GetFilterIndex() const;
156 Returns a pointer to the filter list control (if present).
158 virtual wxDirFilterListCtrl
* GetFilterListCtrl() const;
161 Gets the currently-selected directory or filename.
163 virtual wxString
GetPath() const;
166 Fills the array @a paths with the selected directories and filenames.
168 virtual void GetPaths(wxArrayString
& paths
) const;
171 Returns the root id for the tree control.
173 virtual wxTreeItemId
GetRootId();
176 Returns a pointer to the tree control.
178 virtual wxTreeCtrl
* GetTreeCtrl() const;
181 Initializes variables.
186 Collapse and expand the tree, thus re-creating it from scratch. May be
187 used to update the displayed directory content.
189 virtual void ReCreateTree();
192 Sets the default path.
194 virtual void SetDefaultPath(const wxString
& path
);
197 Sets the filter string.
199 virtual void SetFilter(const wxString
& filter
);
202 Sets the current filter index (zero-based).
204 virtual void SetFilterIndex(int n
);
207 Sets the current path.
209 virtual void SetPath(const wxString
& path
);
213 If @true, hidden folders and files will be displayed by the
214 control. If @false, they will not be displayed.
216 virtual void ShowHidden(bool show
);
219 Selects the given item.
221 In multiple selection controls, can be also used to deselect a
222 currently selected item if the value of @a select is false.
223 Existing selections are not changed. Only visible items can be
224 (de)selected, otherwise use ExpandPath().
226 virtual void SelectPath(const wxString
& path
, bool select
= true);
229 Selects only the specified paths, clearing any previous selection.
231 Only supported when wxDIRCTRL_MULTIPLE is set.
233 virtual void SelectPaths(const wxArrayString
& paths
);
236 Removes the selection from all currently selected items.
238 virtual void UnselectAll();
243 class wxDirFilterListCtrl
: public wxChoice
246 wxDirFilterListCtrl();
247 wxDirFilterListCtrl(wxGenericDirCtrl
* parent
, const wxWindowID id
= wxID_ANY
,
248 const wxPoint
& pos
= wxDefaultPosition
,
249 const wxSize
& size
= wxDefaultSize
,
251 bool Create(wxGenericDirCtrl
* parent
, const wxWindowID id
= wxID_ANY
,
252 const wxPoint
& pos
= wxDefaultPosition
,
253 const wxSize
& size
= wxDefaultSize
,
256 virtual ~wxDirFilterListCtrl() {}
261 void FillFilterList(const wxString
& filter
, int defaultFilter
);