]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dirctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxGenericDirCtrl |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxGenericDirCtrl | |
7c913512 | 11 | |
bc85d676 BP |
12 | This control can be used to place a directory listing (with optional |
13 | files) on an arbitrary window. | |
7c913512 | 14 | |
23324ae1 FM |
15 | The control contains a wxTreeCtrl window representing the directory |
16 | hierarchy, and optionally, a wxChoice window containing a list of filters. | |
7c913512 | 17 | |
bc85d676 BP |
18 | @beginStyleTable |
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 | |
25 | directory. | |
26 | @style{wxDIRCTRL_EDIT_LABELS} | |
27 | Allow the folder and file labels to be editable. | |
28 | @endStyleTable | |
29 | ||
23324ae1 FM |
30 | @library{wxbase} |
31 | @category{ctrl} | |
7e59b885 | 32 | @appearance{genericdirctrl.png} |
23324ae1 FM |
33 | */ |
34 | class wxGenericDirCtrl : public wxControl | |
35 | { | |
36 | public: | |
bc85d676 BP |
37 | /** |
38 | Default constructor. | |
39 | */ | |
40 | wxGenericDirCtrl(); | |
a44f3b5a | 41 | |
23324ae1 FM |
42 | /** |
43 | Main constructor. | |
3c4f71cc | 44 | |
7c913512 | 45 | @param parent |
4cc4bfaf | 46 | Parent window. |
7c913512 | 47 | @param id |
4cc4bfaf | 48 | Window identifier. |
7c913512 | 49 | @param dir |
4cc4bfaf | 50 | Initial folder. |
7c913512 | 51 | @param pos |
4cc4bfaf | 52 | Position. |
7c913512 | 53 | @param size |
4cc4bfaf | 54 | Size. |
7c913512 | 55 | @param style |
bc85d676 BP |
56 | Window style. Please see wxGenericDirCtrl for a list of possible |
57 | styles. | |
7c913512 | 58 | @param filter |
bc85d676 BP |
59 | A filter string, using the same syntax as that for wxFileDialog. |
60 | This may be empty if filters are not being used. Example: | |
61 | @c "All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg" | |
7c913512 | 62 | @param defaultFilter |
4cc4bfaf | 63 | The zero-indexed default filter setting. |
7c913512 | 64 | @param name |
4cc4bfaf | 65 | The window name. |
23324ae1 | 66 | */ |
a44f3b5a | 67 | wxGenericDirCtrl(wxWindow* parent, const wxWindowID id = wxID_ANY, |
7c913512 FM |
68 | const wxString& dir = wxDirDialogDefaultFolderStr, |
69 | const wxPoint& pos = wxDefaultPosition, | |
70 | const wxSize& size = wxDefaultSize, | |
ccf39540 | 71 | long style = wxDIRCTRL_3D_INTERNAL, |
7c913512 FM |
72 | const wxString& filter = wxEmptyString, |
73 | int defaultFilter = 0, | |
74 | const wxString& name = wxTreeCtrlNameStr); | |
23324ae1 FM |
75 | |
76 | /** | |
77 | Destructor. | |
78 | */ | |
adaaa686 | 79 | virtual ~wxGenericDirCtrl(); |
23324ae1 FM |
80 | |
81 | /** | |
bc85d676 | 82 | Collapse the given @a path. |
23324ae1 | 83 | */ |
adaaa686 | 84 | virtual bool CollapsePath(const wxString& path); |
23324ae1 FM |
85 | |
86 | /** | |
87 | Collapses the entire tree. | |
88 | */ | |
adaaa686 | 89 | virtual void CollapseTree(); |
23324ae1 FM |
90 | |
91 | /** | |
bc85d676 BP |
92 | Create function for two-step construction. See wxGenericDirCtrl() for |
93 | details. | |
23324ae1 | 94 | */ |
b91c4601 | 95 | bool Create(wxWindow* parent, const wxWindowID id = wxID_ANY, |
23324ae1 FM |
96 | const wxString& dir = wxDirDialogDefaultFolderStr, |
97 | const wxPoint& pos = wxDefaultPosition, | |
98 | const wxSize& size = wxDefaultSize, | |
b91c4601 FM |
99 | long style = wxDIRCTRL_3D_INTERNAL, |
100 | const wxString& filter = wxEmptyString, int defaultFilter = 0, | |
23324ae1 FM |
101 | const wxString& name = wxTreeCtrlNameStr); |
102 | ||
103 | /** | |
bc85d676 BP |
104 | Tries to expand as much of the given @a path as possible, so that the |
105 | filename or directory is visible in the tree control. | |
23324ae1 | 106 | */ |
adaaa686 | 107 | virtual bool ExpandPath(const wxString& path); |
23324ae1 FM |
108 | |
109 | /** | |
110 | Gets the default path. | |
111 | */ | |
adaaa686 | 112 | virtual wxString GetDefaultPath() const; |
23324ae1 FM |
113 | |
114 | /** | |
115 | Gets selected filename path only (else empty string). | |
bc85d676 | 116 | |
23324ae1 FM |
117 | This function doesn't count a directory as a selection. |
118 | */ | |
adaaa686 | 119 | virtual wxString GetFilePath() const; |
23324ae1 FM |
120 | |
121 | /** | |
122 | Returns the filter string. | |
123 | */ | |
adaaa686 | 124 | virtual wxString GetFilter() const; |
23324ae1 FM |
125 | |
126 | /** | |
127 | Returns the current filter index (zero-based). | |
128 | */ | |
adaaa686 | 129 | virtual int GetFilterIndex() const; |
23324ae1 FM |
130 | |
131 | /** | |
132 | Returns a pointer to the filter list control (if present). | |
133 | */ | |
adaaa686 | 134 | virtual wxDirFilterListCtrl* GetFilterListCtrl() const; |
23324ae1 FM |
135 | |
136 | /** | |
137 | Gets the currently-selected directory or filename. | |
138 | */ | |
adaaa686 | 139 | virtual wxString GetPath() const; |
23324ae1 FM |
140 | |
141 | /** | |
142 | Returns the root id for the tree control. | |
143 | */ | |
adaaa686 | 144 | virtual wxTreeItemId GetRootId(); |
23324ae1 FM |
145 | |
146 | /** | |
147 | Returns a pointer to the tree control. | |
148 | */ | |
adaaa686 | 149 | virtual wxTreeCtrl* GetTreeCtrl() const; |
23324ae1 FM |
150 | |
151 | /** | |
152 | Initializes variables. | |
153 | */ | |
adaaa686 | 154 | virtual void Init(); |
23324ae1 FM |
155 | |
156 | /** | |
bc85d676 BP |
157 | Collapse and expand the tree, thus re-creating it from scratch. May be |
158 | used to update the displayed directory content. | |
23324ae1 | 159 | */ |
adaaa686 | 160 | virtual void ReCreateTree(); |
23324ae1 FM |
161 | |
162 | /** | |
163 | Sets the default path. | |
164 | */ | |
adaaa686 | 165 | virtual void SetDefaultPath(const wxString& path); |
23324ae1 FM |
166 | |
167 | /** | |
168 | Sets the filter string. | |
169 | */ | |
adaaa686 | 170 | virtual void SetFilter(const wxString& filter); |
23324ae1 FM |
171 | |
172 | /** | |
173 | Sets the current filter index (zero-based). | |
174 | */ | |
adaaa686 | 175 | virtual void SetFilterIndex(int n); |
23324ae1 FM |
176 | |
177 | /** | |
178 | Sets the current path. | |
179 | */ | |
adaaa686 | 180 | virtual void SetPath(const wxString& path); |
23324ae1 FM |
181 | |
182 | /** | |
7c913512 | 183 | @param show |
4cc4bfaf FM |
184 | If @true, hidden folders and files will be displayed by the |
185 | control. If @false, they will not be displayed. | |
23324ae1 | 186 | */ |
adaaa686 | 187 | virtual void ShowHidden(bool show); |
23324ae1 | 188 | }; |
e54c96f1 | 189 |