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