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