1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxGenericDirCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxGenericDirCtrl
12 This control can be used to place a directory listing (with optional
13 files) on an arbitrary window.
15 The control contains a wxTreeCtrl window representing the directory
16 hierarchy, and optionally, a wxChoice window containing a list of filters.
19 @style{wxDIRCTRL_DIR_ONLY}
20 Only show directories, and not files.
21 @style{wxDIRCTRL_3D_INTERNAL}
22 Use 3D borders for internal controls.
23 @style{wxDIRCTRL_SELECT_FIRST}
24 When setting the default path, select the first file in the
26 @style{wxDIRCTRL_EDIT_LABELS}
27 Allow the folder and file labels to be editable.
28 @style{wxDIRCTRL_MULTIPLE}
29 Allows multiple files and folders to be selected.
34 @appearance{genericdirctrl.png}
36 class wxGenericDirCtrl
: public wxControl
58 Window style. Please see wxGenericDirCtrl for a list of possible
61 A filter string, using the same syntax as that for wxFileDialog.
62 This may be empty if filters are not being used. Example:
63 @c "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"
65 The zero-indexed default filter setting.
69 wxGenericDirCtrl(wxWindow
* parent
, const wxWindowID id
= wxID_ANY
,
70 const wxString
& dir
= wxDirDialogDefaultFolderStr
,
71 const wxPoint
& pos
= wxDefaultPosition
,
72 const wxSize
& size
= wxDefaultSize
,
73 long style
= wxDIRCTRL_3D_INTERNAL
,
74 const wxString
& filter
= wxEmptyString
,
75 int defaultFilter
= 0,
76 const wxString
& name
= wxTreeCtrlNameStr
);
81 virtual ~wxGenericDirCtrl();
84 Collapse the given @a path.
86 virtual bool CollapsePath(const wxString
& path
);
89 Collapses the entire tree.
91 virtual void CollapseTree();
94 Create function for two-step construction. See wxGenericDirCtrl() for
97 bool Create(wxWindow
* parent
, const wxWindowID id
= wxID_ANY
,
98 const wxString
& dir
= wxDirDialogDefaultFolderStr
,
99 const wxPoint
& pos
= wxDefaultPosition
,
100 const wxSize
& size
= wxDefaultSize
,
101 long style
= wxDIRCTRL_3D_INTERNAL
,
102 const wxString
& filter
= wxEmptyString
, int defaultFilter
= 0,
103 const wxString
& name
= wxTreeCtrlNameStr
);
106 Tries to expand as much of the given @a path as possible, so that the
107 filename or directory is visible in the tree control.
109 virtual bool ExpandPath(const wxString
& path
);
112 Gets the default path.
114 virtual wxString
GetDefaultPath() const;
117 Gets selected filename path only (else empty string).
119 This function doesn't count a directory as a selection.
121 virtual wxString
GetFilePath() const;
124 Fills the array @a paths with the currently selected filepaths.
126 This function doesn't count a directory as a selection.
128 virtual void GetFilePaths(wxArrayString
& paths
) const;
131 Returns the filter string.
133 virtual wxString
GetFilter() const;
136 Returns the current filter index (zero-based).
138 virtual int GetFilterIndex() const;
141 Returns a pointer to the filter list control (if present).
143 virtual wxDirFilterListCtrl
* GetFilterListCtrl() const;
146 Gets the currently-selected directory or filename.
148 virtual wxString
GetPath() const;
151 Fills the array @a paths with the selected directories and filenames.
153 virtual void GetPaths(wxArrayString
& paths
) const;
156 Returns the root id for the tree control.
158 virtual wxTreeItemId
GetRootId();
161 Returns a pointer to the tree control.
163 virtual wxTreeCtrl
* GetTreeCtrl() const;
166 Initializes variables.
171 Collapse and expand the tree, thus re-creating it from scratch. May be
172 used to update the displayed directory content.
174 virtual void ReCreateTree();
177 Sets the default path.
179 virtual void SetDefaultPath(const wxString
& path
);
182 Sets the filter string.
184 virtual void SetFilter(const wxString
& filter
);
187 Sets the current filter index (zero-based).
189 virtual void SetFilterIndex(int n
);
192 Sets the current path.
194 virtual void SetPath(const wxString
& path
);
198 If @true, hidden folders and files will be displayed by the
199 control. If @false, they will not be displayed.
201 virtual void ShowHidden(bool show
);
204 Selects the given item.
206 In multiple selection controls, can be also used to deselect a
207 currently selected item if the value of @a select is false.
208 Existing selections are not changed. Only visible items can be
209 (de)selected, otherwise use ExpandPath().
211 virtual void SelectPath(const wxString
& path
, bool select
= true);
214 Selects only the specified paths, clearing any previous selection.
216 Only supported when wxDIRCTRL_MULTIPLE is set.
218 virtual void SelectPaths(const wxArrayString
& paths
);
221 Removes the selection from all currently selected items.
223 virtual void UnselectAll();