]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/dirctrl.h
Call wxThread::Create() from Run() automatically.
[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,
aa9453d6
VZ
15 // Show the filter list
16 wxDIRCTRL_SHOW_FILTERS = 0x0040,
ae0a6d8b
RD
17 // Use 3D borders on internal controls
18 wxDIRCTRL_3D_INTERNAL = 0x0080,
19 // Editable labels
20 wxDIRCTRL_EDIT_LABELS = 0x0100,
21 // Allow multiple selection
22 wxDIRCTRL_MULTIPLE = 0x0200
23};
24
25
23324ae1
FM
26/**
27 @class wxGenericDirCtrl
7c913512 28
bc85d676
BP
29 This control can be used to place a directory listing (with optional
30 files) on an arbitrary window.
7c913512 31
23324ae1
FM
32 The control contains a wxTreeCtrl window representing the directory
33 hierarchy, and optionally, a wxChoice window containing a list of filters.
7c913512 34
bc85d676
BP
35 @beginStyleTable
36 @style{wxDIRCTRL_DIR_ONLY}
37 Only show directories, and not files.
38 @style{wxDIRCTRL_3D_INTERNAL}
39 Use 3D borders for internal controls.
40 @style{wxDIRCTRL_SELECT_FIRST}
41 When setting the default path, select the first file in the
42 directory.
aa9453d6
VZ
43 @style{wxDIRCTRL_SHOW_FILTERS}
44 Show the drop-down filter list.
bc85d676
BP
45 @style{wxDIRCTRL_EDIT_LABELS}
46 Allow the folder and file labels to be editable.
80f624ec
VZ
47 @style{wxDIRCTRL_MULTIPLE}
48 Allows multiple files and folders to be selected.
bc85d676
BP
49 @endStyleTable
50
6ab3e039 51 @library{wxcore}
23324ae1 52 @category{ctrl}
ce154616 53 @appearance{genericdirctrl}
84605707
VZ
54 @event{EVT_DIRCTRL_CHANGED(id, func)}
55 Selected directory has changed.
ce7fe42e 56 Processes a @c wxEVT_DIRCTRL_CHANGED event type.
84605707
VZ
57 Notice that this event is generated even for the changes done by the
58 program itself and not only those done by the user.
59 @since 2.9.5
23324ae1
FM
60*/
61class wxGenericDirCtrl : public wxControl
62{
63public:
bc85d676
BP
64 /**
65 Default constructor.
66 */
67 wxGenericDirCtrl();
a44f3b5a 68
23324ae1
FM
69 /**
70 Main constructor.
3c4f71cc 71
7c913512 72 @param parent
4cc4bfaf 73 Parent window.
7c913512 74 @param id
4cc4bfaf 75 Window identifier.
7c913512 76 @param dir
4cc4bfaf 77 Initial folder.
7c913512 78 @param pos
4cc4bfaf 79 Position.
7c913512 80 @param size
4cc4bfaf 81 Size.
7c913512 82 @param style
bc85d676
BP
83 Window style. Please see wxGenericDirCtrl for a list of possible
84 styles.
7c913512 85 @param filter
bc85d676
BP
86 A filter string, using the same syntax as that for wxFileDialog.
87 This may be empty if filters are not being used. Example:
88 @c "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"
7c913512 89 @param defaultFilter
4cc4bfaf 90 The zero-indexed default filter setting.
7c913512 91 @param name
4cc4bfaf 92 The window name.
23324ae1 93 */
a44f3b5a 94 wxGenericDirCtrl(wxWindow* parent, const wxWindowID id = wxID_ANY,
7c913512
FM
95 const wxString& dir = wxDirDialogDefaultFolderStr,
96 const wxPoint& pos = wxDefaultPosition,
97 const wxSize& size = wxDefaultSize,
ccf39540 98 long style = wxDIRCTRL_3D_INTERNAL,
7c913512
FM
99 const wxString& filter = wxEmptyString,
100 int defaultFilter = 0,
101 const wxString& name = wxTreeCtrlNameStr);
23324ae1
FM
102
103 /**
104 Destructor.
105 */
adaaa686 106 virtual ~wxGenericDirCtrl();
23324ae1
FM
107
108 /**
bc85d676 109 Collapse the given @a path.
23324ae1 110 */
adaaa686 111 virtual bool CollapsePath(const wxString& path);
23324ae1
FM
112
113 /**
114 Collapses the entire tree.
115 */
adaaa686 116 virtual void CollapseTree();
23324ae1
FM
117
118 /**
bc85d676
BP
119 Create function for two-step construction. See wxGenericDirCtrl() for
120 details.
23324ae1 121 */
b91c4601 122 bool Create(wxWindow* parent, const wxWindowID id = wxID_ANY,
23324ae1
FM
123 const wxString& dir = wxDirDialogDefaultFolderStr,
124 const wxPoint& pos = wxDefaultPosition,
125 const wxSize& size = wxDefaultSize,
b91c4601
FM
126 long style = wxDIRCTRL_3D_INTERNAL,
127 const wxString& filter = wxEmptyString, int defaultFilter = 0,
23324ae1
FM
128 const wxString& name = wxTreeCtrlNameStr);
129
130 /**
bc85d676
BP
131 Tries to expand as much of the given @a path as possible, so that the
132 filename or directory is visible in the tree control.
23324ae1 133 */
adaaa686 134 virtual bool ExpandPath(const wxString& path);
23324ae1
FM
135
136 /**
137 Gets the default path.
138 */
adaaa686 139 virtual wxString GetDefaultPath() const;
23324ae1
FM
140
141 /**
142 Gets selected filename path only (else empty string).
bc85d676 143
23324ae1
FM
144 This function doesn't count a directory as a selection.
145 */
adaaa686 146 virtual wxString GetFilePath() const;
23324ae1 147
80f624ec
VZ
148 /**
149 Fills the array @a paths with the currently selected filepaths.
150
151 This function doesn't count a directory as a selection.
152 */
153 virtual void GetFilePaths(wxArrayString& paths) const;
154
23324ae1
FM
155 /**
156 Returns the filter string.
157 */
adaaa686 158 virtual wxString GetFilter() const;
23324ae1
FM
159
160 /**
161 Returns the current filter index (zero-based).
162 */
adaaa686 163 virtual int GetFilterIndex() const;
23324ae1
FM
164
165 /**
166 Returns a pointer to the filter list control (if present).
167 */
adaaa686 168 virtual wxDirFilterListCtrl* GetFilterListCtrl() const;
23324ae1
FM
169
170 /**
171 Gets the currently-selected directory or filename.
172 */
adaaa686 173 virtual wxString GetPath() const;
23324ae1 174
e3f084fd
VZ
175 /**
176 Gets the path corresponding to the given tree control item.
177
178 @since 2.9.5
179 */
180 wxString GetPath(wxTreeItemId itemId) const;
181
80f624ec
VZ
182 /**
183 Fills the array @a paths with the selected directories and filenames.
184 */
185 virtual void GetPaths(wxArrayString& paths) const;
186
23324ae1
FM
187 /**
188 Returns the root id for the tree control.
189 */
adaaa686 190 virtual wxTreeItemId GetRootId();
23324ae1
FM
191
192 /**
193 Returns a pointer to the tree control.
194 */
adaaa686 195 virtual wxTreeCtrl* GetTreeCtrl() const;
23324ae1
FM
196
197 /**
198 Initializes variables.
199 */
adaaa686 200 virtual void Init();
23324ae1
FM
201
202 /**
bc85d676
BP
203 Collapse and expand the tree, thus re-creating it from scratch. May be
204 used to update the displayed directory content.
23324ae1 205 */
adaaa686 206 virtual void ReCreateTree();
23324ae1
FM
207
208 /**
209 Sets the default path.
210 */
adaaa686 211 virtual void SetDefaultPath(const wxString& path);
23324ae1
FM
212
213 /**
214 Sets the filter string.
215 */
adaaa686 216 virtual void SetFilter(const wxString& filter);
23324ae1
FM
217
218 /**
219 Sets the current filter index (zero-based).
220 */
adaaa686 221 virtual void SetFilterIndex(int n);
23324ae1
FM
222
223 /**
224 Sets the current path.
225 */
adaaa686 226 virtual void SetPath(const wxString& path);
23324ae1
FM
227
228 /**
7c913512 229 @param show
4cc4bfaf
FM
230 If @true, hidden folders and files will be displayed by the
231 control. If @false, they will not be displayed.
23324ae1 232 */
adaaa686 233 virtual void ShowHidden(bool show);
80f624ec
VZ
234
235 /**
236 Selects the given item.
237
238 In multiple selection controls, can be also used to deselect a
239 currently selected item if the value of @a select is false.
240 Existing selections are not changed. Only visible items can be
241 (de)selected, otherwise use ExpandPath().
242 */
243 virtual void SelectPath(const wxString& path, bool select = true);
244
245 /**
246 Selects only the specified paths, clearing any previous selection.
247
248 Only supported when wxDIRCTRL_MULTIPLE is set.
249 */
250 virtual void SelectPaths(const wxArrayString& paths);
251
252 /**
253 Removes the selection from all currently selected items.
254 */
255 virtual void UnselectAll();
23324ae1 256};
e54c96f1 257
ae0a6d8b
RD
258
259
260class wxDirFilterListCtrl: public wxChoice
261{
262public:
263 wxDirFilterListCtrl();
264 wxDirFilterListCtrl(wxGenericDirCtrl* parent, const wxWindowID id = wxID_ANY,
265 const wxPoint& pos = wxDefaultPosition,
266 const wxSize& size = wxDefaultSize,
267 long style = 0);
268 bool Create(wxGenericDirCtrl* parent, const wxWindowID id = wxID_ANY,
269 const wxPoint& pos = wxDefaultPosition,
270 const wxSize& size = wxDefaultSize,
271 long style = 0);
272
273 virtual ~wxDirFilterListCtrl() {}
274
275 void Init();
276
277 //// Operations
278 void FillFilterList(const wxString& filter, int defaultFilter);
279};
1dd2d2f8
RD
280
281wxEventType wxEVT_DIRCTRL_CHANGED;