]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dirctrl.h
Remove wrong const from wxMenu::GetMenuItems() documentation.
[wxWidgets.git] / interface / wx / dirctrl.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dirctrl.h
e54c96f1 3// Purpose: interface of wxGenericDirCtrl
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
ae0a6d8b
RD
9enum
10{
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,
17 // Editable labels
18 wxDIRCTRL_EDIT_LABELS = 0x0100,
19 // Allow multiple selection
20 wxDIRCTRL_MULTIPLE = 0x0200
21};
22
23
23324ae1
FM
24/**
25 @class wxGenericDirCtrl
7c913512 26
bc85d676
BP
27 This control can be used to place a directory listing (with optional
28 files) on an arbitrary window.
7c913512 29
23324ae1
FM
30 The control contains a wxTreeCtrl window representing the directory
31 hierarchy, and optionally, a wxChoice window containing a list of filters.
7c913512 32
bc85d676
BP
33 @beginStyleTable
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
40 directory.
41 @style{wxDIRCTRL_EDIT_LABELS}
42 Allow the folder and file labels to be editable.
80f624ec
VZ
43 @style{wxDIRCTRL_MULTIPLE}
44 Allows multiple files and folders to be selected.
bc85d676
BP
45 @endStyleTable
46
6ab3e039 47 @library{wxcore}
23324ae1 48 @category{ctrl}
7e59b885 49 @appearance{genericdirctrl.png}
23324ae1
FM
50*/
51class wxGenericDirCtrl : public wxControl
52{
53public:
bc85d676
BP
54 /**
55 Default constructor.
56 */
57 wxGenericDirCtrl();
a44f3b5a 58
23324ae1
FM
59 /**
60 Main constructor.
3c4f71cc 61
7c913512 62 @param parent
4cc4bfaf 63 Parent window.
7c913512 64 @param id
4cc4bfaf 65 Window identifier.
7c913512 66 @param dir
4cc4bfaf 67 Initial folder.
7c913512 68 @param pos
4cc4bfaf 69 Position.
7c913512 70 @param size
4cc4bfaf 71 Size.
7c913512 72 @param style
bc85d676
BP
73 Window style. Please see wxGenericDirCtrl for a list of possible
74 styles.
7c913512 75 @param filter
bc85d676
BP
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"
7c913512 79 @param defaultFilter
4cc4bfaf 80 The zero-indexed default filter setting.
7c913512 81 @param name
4cc4bfaf 82 The window name.
23324ae1 83 */
a44f3b5a 84 wxGenericDirCtrl(wxWindow* parent, const wxWindowID id = wxID_ANY,
7c913512
FM
85 const wxString& dir = wxDirDialogDefaultFolderStr,
86 const wxPoint& pos = wxDefaultPosition,
87 const wxSize& size = wxDefaultSize,
ccf39540 88 long style = wxDIRCTRL_3D_INTERNAL,
7c913512
FM
89 const wxString& filter = wxEmptyString,
90 int defaultFilter = 0,
91 const wxString& name = wxTreeCtrlNameStr);
23324ae1
FM
92
93 /**
94 Destructor.
95 */
adaaa686 96 virtual ~wxGenericDirCtrl();
23324ae1
FM
97
98 /**
bc85d676 99 Collapse the given @a path.
23324ae1 100 */
adaaa686 101 virtual bool CollapsePath(const wxString& path);
23324ae1
FM
102
103 /**
104 Collapses the entire tree.
105 */
adaaa686 106 virtual void CollapseTree();
23324ae1
FM
107
108 /**
bc85d676
BP
109 Create function for two-step construction. See wxGenericDirCtrl() for
110 details.
23324ae1 111 */
b91c4601 112 bool Create(wxWindow* parent, const wxWindowID id = wxID_ANY,
23324ae1
FM
113 const wxString& dir = wxDirDialogDefaultFolderStr,
114 const wxPoint& pos = wxDefaultPosition,
115 const wxSize& size = wxDefaultSize,
b91c4601
FM
116 long style = wxDIRCTRL_3D_INTERNAL,
117 const wxString& filter = wxEmptyString, int defaultFilter = 0,
23324ae1
FM
118 const wxString& name = wxTreeCtrlNameStr);
119
120 /**
bc85d676
BP
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.
23324ae1 123 */
adaaa686 124 virtual bool ExpandPath(const wxString& path);
23324ae1
FM
125
126 /**
127 Gets the default path.
128 */
adaaa686 129 virtual wxString GetDefaultPath() const;
23324ae1
FM
130
131 /**
132 Gets selected filename path only (else empty string).
bc85d676 133
23324ae1
FM
134 This function doesn't count a directory as a selection.
135 */
adaaa686 136 virtual wxString GetFilePath() const;
23324ae1 137
80f624ec
VZ
138 /**
139 Fills the array @a paths with the currently selected filepaths.
140
141 This function doesn't count a directory as a selection.
142 */
143 virtual void GetFilePaths(wxArrayString& paths) const;
144
23324ae1
FM
145 /**
146 Returns the filter string.
147 */
adaaa686 148 virtual wxString GetFilter() const;
23324ae1
FM
149
150 /**
151 Returns the current filter index (zero-based).
152 */
adaaa686 153 virtual int GetFilterIndex() const;
23324ae1
FM
154
155 /**
156 Returns a pointer to the filter list control (if present).
157 */
adaaa686 158 virtual wxDirFilterListCtrl* GetFilterListCtrl() const;
23324ae1
FM
159
160 /**
161 Gets the currently-selected directory or filename.
162 */
adaaa686 163 virtual wxString GetPath() const;
23324ae1 164
80f624ec
VZ
165 /**
166 Fills the array @a paths with the selected directories and filenames.
167 */
168 virtual void GetPaths(wxArrayString& paths) const;
169
23324ae1
FM
170 /**
171 Returns the root id for the tree control.
172 */
adaaa686 173 virtual wxTreeItemId GetRootId();
23324ae1
FM
174
175 /**
176 Returns a pointer to the tree control.
177 */
adaaa686 178 virtual wxTreeCtrl* GetTreeCtrl() const;
23324ae1
FM
179
180 /**
181 Initializes variables.
182 */
adaaa686 183 virtual void Init();
23324ae1
FM
184
185 /**
bc85d676
BP
186 Collapse and expand the tree, thus re-creating it from scratch. May be
187 used to update the displayed directory content.
23324ae1 188 */
adaaa686 189 virtual void ReCreateTree();
23324ae1
FM
190
191 /**
192 Sets the default path.
193 */
adaaa686 194 virtual void SetDefaultPath(const wxString& path);
23324ae1
FM
195
196 /**
197 Sets the filter string.
198 */
adaaa686 199 virtual void SetFilter(const wxString& filter);
23324ae1
FM
200
201 /**
202 Sets the current filter index (zero-based).
203 */
adaaa686 204 virtual void SetFilterIndex(int n);
23324ae1
FM
205
206 /**
207 Sets the current path.
208 */
adaaa686 209 virtual void SetPath(const wxString& path);
23324ae1
FM
210
211 /**
7c913512 212 @param show
4cc4bfaf
FM
213 If @true, hidden folders and files will be displayed by the
214 control. If @false, they will not be displayed.
23324ae1 215 */
adaaa686 216 virtual void ShowHidden(bool show);
80f624ec
VZ
217
218 /**
219 Selects the given item.
220
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().
225 */
226 virtual void SelectPath(const wxString& path, bool select = true);
227
228 /**
229 Selects only the specified paths, clearing any previous selection.
230
231 Only supported when wxDIRCTRL_MULTIPLE is set.
232 */
233 virtual void SelectPaths(const wxArrayString& paths);
234
235 /**
236 Removes the selection from all currently selected items.
237 */
238 virtual void UnselectAll();
23324ae1 239};
e54c96f1 240
ae0a6d8b
RD
241
242
243class wxDirFilterListCtrl: public wxChoice
244{
245public:
246 wxDirFilterListCtrl();
247 wxDirFilterListCtrl(wxGenericDirCtrl* parent, const wxWindowID id = wxID_ANY,
248 const wxPoint& pos = wxDefaultPosition,
249 const wxSize& size = wxDefaultSize,
250 long style = 0);
251 bool Create(wxGenericDirCtrl* parent, const wxWindowID id = wxID_ANY,
252 const wxPoint& pos = wxDefaultPosition,
253 const wxSize& size = wxDefaultSize,
254 long style = 0);
255
256 virtual ~wxDirFilterListCtrl() {}
257
258 void Init();
259
260 //// Operations
261 void FillFilterList(const wxString& filter, int defaultFilter);
262};