]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxTreeCtrl}}\label{wxtreectrl} |
2 | ||
3 | A tree control presents information as a hierarchy, with items that may be expanded | |
4fabb575 | 4 | to show further items. Items in a tree control are referenced by wxTreeItemId handles. |
a660d684 KB |
5 | |
6 | To intercept events from a tree control, use the event table macros described in \helpref{wxTreeEvent}{wxtreeevent}. | |
7 | ||
8 | \wxheading{Derived from} | |
9 | ||
10 | \helpref{wxControl}{wxcontrol}\\ | |
11 | \helpref{wxWindow}{wxwindow}\\ | |
12 | \helpref{wxEvtHandler}{wxevthandler}\\ | |
13 | \helpref{wxObject}{wxobject} | |
14 | ||
954b8ae6 JS |
15 | \wxheading{Include files} |
16 | ||
17 | <wx/treectrl.h> | |
18 | ||
a660d684 KB |
19 | \wxheading{Window styles} |
20 | ||
21 | \twocolwidtha{5cm} | |
22 | \begin{twocollist}\itemsep=0pt | |
23 | \twocolitem{\windowstyle{wxTR\_HAS\_BUTTONS}}{Use this style to show + and - buttons to the | |
e4628635 | 24 | left of parent items. Win32 only. } |
a660d684 KB |
25 | \twocolitem{\windowstyle{wxTR\_EDIT\_LABELS}}{Use this style if you wish the user to be |
26 | able to edit labels in the tree control.} | |
9dfbf520 VZ |
27 | \twocolitem{\windowstyle{wxTR\_MULTIPLE}}{Use this style to allow the user to |
28 | select more than one item in the control - by default, only one item may be | |
29 | selected.} | |
a660d684 KB |
30 | \end{twocollist} |
31 | ||
32 | See also \helpref{window styles overview}{windowstyles}. | |
33 | ||
5de76427 JS |
34 | \wxheading{Event handling} |
35 | ||
36 | To process input from a tree control, use these event handler macros to direct input to member | |
37 | functions that take a \helpref{wxTreeEvent}{wxtreeevent} argument. | |
38 | ||
39 | \twocolwidtha{7cm} | |
40 | \begin{twocollist}\itemsep=0pt | |
41 | \twocolitem{{\bf EVT\_TREE\_BEGIN\_DRAG(id, func)}}{Begin dragging with the left mouse button.} | |
42 | \twocolitem{{\bf EVT\_TREE\_BEGIN\_RDRAG(id, func)}}{Begin dragging with the right mouse button.} | |
fd128b0c RR |
43 | \twocolitem{{\bf EVT\_TREE\_BEGIN\_LABEL\_EDIT(id, func)}}{Begin editing a label. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.} |
44 | \twocolitem{{\bf EVT\_TREE\_END\_LABEL\_EDIT(id, func)}}{Finish editing a label. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.} | |
5de76427 JS |
45 | \twocolitem{{\bf EVT\_TREE\_DELETE\_ITEM(id, func)}}{Delete an item.} |
46 | \twocolitem{{\bf EVT\_TREE\_GET\_INFO(id, func)}}{Request information from the application.} | |
47 | \twocolitem{{\bf EVT\_TREE\_SET\_INFO(id, func)}}{Information is being supplied.} | |
9711961c | 48 | \twocolitem{{\bf EVT\_TREE\_ITEM\_ACTIVATED(id, func)}}{The item has been activated, i.e. chosen by double clicking it with mouse or from keyboard} |
61b1a1af VZ |
49 | \twocolitem{{\bf EVT\_TREE\_ITEM\_COLLAPSED(id, func)}}{Parent has been collapsed.} |
50 | \twocolitem{{\bf EVT\_TREE\_ITEM\_COLLAPSING(id, func)}}{Parent is being collapsed. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.} | |
5de76427 | 51 | \twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDED(id, func)}}{Parent has been expanded.} |
fd128b0c | 52 | \twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDING(id, func)}}{Parent is being expanded. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.} |
5de76427 | 53 | \twocolitem{{\bf EVT\_TREE\_SEL\_CHANGED(id, func)}}{Selection has changed.} |
fd128b0c | 54 | \twocolitem{{\bf EVT\_TREE\_SEL\_CHANGING(id, func)}}{Selection is changing. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.} |
5de76427 JS |
55 | \twocolitem{{\bf EVT\_TREE\_KEY\_DOWN(id, func)}}{A key has been pressed.} |
56 | \end{twocollist}% | |
57 | ||
a660d684 KB |
58 | \wxheading{See also} |
59 | ||
4fabb575 | 60 | \helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{wxTreeCtrl overview}{wxtreectrloverview}, \helpref{wxListBox}{wxlistbox}, \helpref{wxListCtrl}{wxlistctrl},\rtfsp |
a660d684 KB |
61 | \helpref{wxImageList}{wximagelist}, \helpref{wxTreeEvent}{wxtreeevent} |
62 | ||
63 | \latexignore{\rtfignore{\wxheading{Members}}} | |
64 | ||
65 | \membersection{wxTreeCtrl::wxTreeCtrl}\label{wxtreectrlconstr} | |
66 | ||
67 | \func{}{wxTreeCtrl}{\void} | |
68 | ||
69 | Default constructor. | |
70 | ||
eaaa6a06 | 71 | \func{}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 72 | \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 | 73 | \param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}} |
a660d684 KB |
74 | |
75 | Constructor, creating and showing a tree control. | |
76 | ||
77 | \wxheading{Parameters} | |
78 | ||
79 | \docparam{parent}{Parent window. Must not be NULL.} | |
80 | ||
81 | \docparam{id}{Window identifier. A value of -1 indicates a default value.} | |
82 | ||
83 | \docparam{pos}{Window position.} | |
84 | ||
85 | \docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized | |
86 | appropriately.} | |
87 | ||
88 | \docparam{style}{Window style. See \helpref{wxTreeCtrl}{wxtreectrl}.} | |
89 | ||
90 | \docparam{validator}{Window validator.} | |
91 | ||
92 | \docparam{name}{Window name.} | |
93 | ||
94 | \wxheading{See also} | |
95 | ||
96 | \helpref{wxTreeCtrl::Create}{wxtreectrlcreate}, \helpref{wxValidator}{wxvalidator} | |
97 | ||
98 | \membersection{wxTreeCtrl::\destruct{wxTreeCtrl}} | |
99 | ||
100 | \func{void}{\destruct{wxTreeCtrl}}{\void} | |
101 | ||
102 | Destructor, destroying the list control. | |
103 | ||
4fabb575 JS |
104 | \membersection{wxTreeCtrl::AddRoot}\label{wxtreectrladdroot} |
105 | ||
106 | \func{wxTreeItemId}{AddRoot}{\param{const wxString\&}{ text}, | |
107 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
108 | ||
109 | Adds the root node to the tree, returning the new item. | |
110 | ||
111 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
112 | both selected and unselected items. | |
113 | ||
114 | \membersection{wxTreeCtrl::AppendItem}\label{wxtreectrlappenditem} | |
115 | ||
116 | \func{wxTreeItemId}{AppendItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text}, | |
117 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
118 | ||
119 | Appends an item to the end of the branch identified by {\it parent}, return a new item id. | |
120 | ||
121 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
122 | both selected and unselected items. | |
123 | ||
124 | \membersection{wxTreeCtrl::Collapse}\label{wxtreectrlcollapse} | |
125 | ||
126 | \func{void}{Collapse}{\param{const wxTreeItemId\&}{ item}} | |
127 | ||
128 | Collapses the given item. | |
129 | ||
130 | \membersection{wxTreeCtrl::CollapseAndReset}\label{wxtreectrlcollapseandreset} | |
131 | ||
132 | \func{void}{CollapseAndReset}{\param{const wxTreeItemId\&}{ item}} | |
133 | ||
134 | Collapses the given item and removes all children. | |
135 | ||
a660d684 KB |
136 | \membersection{wxTreeCtrl::Create}\label{wxtreectrlcreate} |
137 | ||
eaaa6a06 | 138 | \func{bool}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 139 | \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 | 140 | \param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}} |
a660d684 KB |
141 | |
142 | Creates the tree control. See \helpref{wxTreeCtrl::wxTreeCtrl}{wxtreectrlconstr} for further details. | |
143 | ||
4fabb575 | 144 | \membersection{wxTreeCtrl::Delete}\label{wxtreectrldelete} |
a660d684 | 145 | |
4fabb575 | 146 | \func{void}{Delete}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 147 | |
4fabb575 | 148 | Deletes the specified item. |
a660d684 | 149 | |
4fabb575 | 150 | \membersection{wxTreeCtrl::DeleteAllItems}\label{wxtreectrldeleteallitems} |
a660d684 | 151 | |
4fabb575 | 152 | \func{void}{DeleteAllItems}{\void} |
a660d684 | 153 | |
4fabb575 | 154 | Deletes all the items in the control. |
a660d684 | 155 | |
bbcdf8bc | 156 | \membersection{wxTreeCtrl::EditLabel}\label{wxtreectrleditlabel} |
a660d684 | 157 | |
fd128b0c | 158 | \func{void}{EditLabel}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 159 | |
fd128b0c RR |
160 | Starts editing the label of the given item. This function generates a |
161 | EVT\_TREE\_BEGIN\_LABEL\_EDIT event which can be vetoed so that no | |
162 | text control will appear for in-place editing. | |
a660d684 | 163 | |
fd128b0c | 164 | If the user changed the label (i.e. s/he does not press ESC or leave |
76e1c2de | 165 | the text control without changes, a EVT\_TREE\_END\_LABEL\_EDIT event |
fd128b0c | 166 | will be sent which can be vetoed as well. |
bbcdf8bc JS |
167 | |
168 | \wxheading{See also} | |
169 | ||
86f975a8 VZ |
170 | \helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}, |
171 | \helpref{wxTreeEvent}{wxtreeevent} | |
bbcdf8bc JS |
172 | |
173 | \membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel} | |
174 | ||
4fabb575 | 175 | \func{void}{EndEditLabel}{\param{bool }{cancelEdit}} |
bbcdf8bc JS |
176 | |
177 | Ends label editing. If {\it cancelEdit} is TRUE, the edit will be cancelled. | |
178 | ||
179 | This function is currently supported under Windows only. | |
180 | ||
181 | \wxheading{See also} | |
182 | ||
183 | \helpref{wxTreeCtrl::EditLabel}{wxtreectrleditlabel} | |
184 | ||
a660d684 KB |
185 | \membersection{wxTreeCtrl::EnsureVisible}\label{wxtreectrlensurevisible} |
186 | ||
4fabb575 | 187 | \func{void}{EnsureVisible}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
188 | |
189 | Scrolls and/or expands items to ensure that the given item is visible. | |
190 | ||
4fabb575 | 191 | \membersection{wxTreeCtrl::Expand}\label{wxtreectrlexpand} |
a660d684 | 192 | |
4fabb575 | 193 | \func{void}{Expand}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
194 | |
195 | Expands the given item. | |
196 | ||
4fabb575 | 197 | \membersection{wxTreeCtrl::GetBoundingRect}\label{wxtreectrlgetitemrect} |
a660d684 | 198 | |
296ec7d3 | 199 | \constfunc{bool}{GetBoundingRect}{\param{const wxTreeItemId\&}{ item}, \param{wxRect\& }{rect}, \param{bool }{textOnly = FALSE}} |
4fabb575 | 200 | |
296ec7d3 VZ |
201 | Retrieves the rectangle bounding the {\it item}. If {\it textOnly} is TRUE, |
202 | only the rectangle around the items label will be returned, otherwise the | |
203 | items image is also taken into account. | |
204 | ||
205 | The return value is TRUE if the rectangle was successfully retrieved or FALSE | |
206 | if it was not (in this case {\it rect} is not changed) - for example, if the | |
207 | item is currently invisible. | |
a660d684 | 208 | |
76e1c2de | 209 | \pythonnote{The wxPython version of this method requires only the |
c9110876 VS |
210 | {\tt item} and {\tt textOnly} parameters. The return value is either a |
211 | {\tt wxRect} object or {\tt None}.} | |
76e1c2de | 212 | |
4fabb575 | 213 | \membersection{wxTreeCtrl::GetChildrenCount}\label{wxtreectrlgetchildrencount} |
a660d684 | 214 | |
4fabb575 | 215 | \constfunc{size\_t}{GetChildrenCount}{\param{const wxTreeItemId\&}{ item}, \param{bool}{ recursively = TRUE}} |
a660d684 | 216 | |
4fabb575 JS |
217 | Returns the number of items in the branch. If {\it recursively} is TRUE, returns the total number |
218 | of descendants, otherwise only one level of children is counted. | |
a660d684 KB |
219 | |
220 | \membersection{wxTreeCtrl::GetCount}\label{wxtreectrlgetcount} | |
221 | ||
222 | \constfunc{int}{GetCount}{\void} | |
223 | ||
224 | Returns the number of items in the control. | |
225 | ||
226 | \membersection{wxTreeCtrl::GetEditControl}\label{wxtreectrlgeteditcontrol} | |
227 | ||
228 | \constfunc{wxTextCtrl\&}{GetEditControl}{\void} | |
229 | ||
230 | Returns the edit control used to edit a label. | |
231 | ||
4fabb575 JS |
232 | \membersection{wxTreeCtrl::GetFirstChild}\label{wxtreectrlgetfirstchild} |
233 | ||
234 | \constfunc{wxTreeItemId}{GetFirstChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}} | |
235 | ||
236 | Returns the first child; call \helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild} for the next child. | |
237 | ||
238 | For this enumeration function you must pass in a `cookie' parameter | |
239 | which is opaque for the application but is necessary for the library | |
240 | to make these functions reentrant (i.e. allow more than one | |
241 | enumeration on one and the same object simultaneously). The cookie passed to | |
242 | GetFirstChild and GetNextChild should be the same. | |
243 | ||
ed93168b | 244 | Returns an invalid tree item if there are no further children. |
4fabb575 JS |
245 | |
246 | \wxheading{See also} | |
247 | ||
248 | \helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild} | |
249 | ||
f899db6d RD |
250 | \pythonnote{In wxPython the returned wxTreeItemId and the new cookie |
251 | value are both returned as a tuple containing the two values.} | |
252 | ||
a660d684 KB |
253 | \membersection{wxTreeCtrl::GetFirstVisibleItem}\label{wxtreectrlgetfirstvisibleitem} |
254 | ||
4fabb575 | 255 | \constfunc{wxTreeItemId}{GetFirstVisibleItem}{\void} |
a660d684 KB |
256 | |
257 | Returns the first visible item. | |
258 | ||
259 | \membersection{wxTreeCtrl::GetImageList}\label{wxtreectrlgetimagelist} | |
260 | ||
e2b34251 | 261 | \constfunc{wxImageList*}{GetImageList}{\void} |
a660d684 | 262 | |
e2b34251 | 263 | Returns the normal image list. |
a660d684 KB |
264 | |
265 | \membersection{wxTreeCtrl::GetIndent}\label{wxtreectrlgetindent} | |
266 | ||
267 | \constfunc{int}{GetIndent}{\void} | |
268 | ||
269 | Returns the current tree control indentation. | |
270 | ||
4fabb575 | 271 | \membersection{wxTreeCtrl::GetItemData}\label{wxtreectrlgetitemdata} |
a660d684 | 272 | |
4fabb575 | 273 | \constfunc{wxTreeItemData*}{GetItemData}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 274 | |
4fabb575 | 275 | Returns the tree item data associated with the item. |
a660d684 | 276 | |
4fabb575 | 277 | \wxheading{See also} |
a660d684 | 278 | |
4fabb575 | 279 | \helpref{wxTreeItemData}{wxtreeitemdata} |
a660d684 | 280 | |
f899db6d RD |
281 | \pythonnote{wxPython provides the following shortcut method:\par |
282 | \indented{2cm}{\begin{twocollist} | |
c9110876 | 283 | \twocolitem{{\bf GetPyData(item)}}{Returns the Python Object |
f899db6d RD |
284 | associated with the wxTreeItemData for the given item Id.} |
285 | \end{twocollist}} | |
286 | } | |
287 | ||
4fabb575 | 288 | \membersection{wxTreeCtrl::GetItemImage}\label{wxtreectrlgetitemimage} |
a660d684 | 289 | |
74b31181 VZ |
290 | \constfunc{int}{GetItemImage}{\param{const wxTreeItemId\& }{item}, |
291 | \param{wxTreeItemIcon }{which = wxTreeItemIcon\_Normal}} | |
292 | ||
293 | Gets the specified item image. The value of {\it which} may be: | |
294 | \begin{itemize}\itemsep=0pt | |
295 | \item{wxTreeItemIcon\_Normal} to get the normal item image | |
296 | \item{wxTreeItemIcon\_Selected} to get the selected item image (i.e. the image | |
297 | which is shown when the item is currently selected) | |
298 | \item{wxTreeItemIcon\_Expanded} to get the expanded image (this only | |
299 | makes sense for items which have children - then this image is shown when the | |
300 | item is expanded and the normal image is shown when it is collapsed) | |
301 | \item{wxTreeItemIcon\_SelectedExpanded} to get the selected expanded image | |
302 | (which is shown when an expanded item is currently selected) | |
303 | \end{itemize} | |
a660d684 | 304 | |
4fabb575 | 305 | \membersection{wxTreeCtrl::GetItemText}\label{wxtreectrlgetitemtext} |
a660d684 | 306 | |
4fabb575 | 307 | \constfunc{wxString}{GetItemText}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 308 | |
4fabb575 | 309 | Returns the item label. |
a660d684 | 310 | |
978f38c2 VZ |
311 | \membersection{wxTreeCtrl::GetLastChild}\label{wxtreectrlgetlastchild} |
312 | ||
313 | \constfunc{wxTreeItemId}{GetLastChild}{\param{const wxTreeItemId\&}{ item}} | |
314 | ||
ed93168b | 315 | Returns the last child of the item (or an invalid tree item if this item has no children). |
978f38c2 VZ |
316 | |
317 | \wxheading{See also} | |
318 | ||
f899db6d | 319 | \helpref{GetFirstChild}{wxtreectrlgetfirstchild}, |
978f38c2 VZ |
320 | \helpref{GetLastChild}{wxtreectrlgetlastchild} |
321 | ||
4fabb575 | 322 | \membersection{wxTreeCtrl::GetNextChild}\label{wxtreectrlgetnextchild} |
a660d684 | 323 | |
4fabb575 | 324 | \constfunc{wxTreeItemId}{GetNextChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}} |
a660d684 | 325 | |
4fabb575 | 326 | Returns the next child; call \helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild} for the first child. |
a660d684 | 327 | |
4fabb575 JS |
328 | For this enumeration function you must pass in a `cookie' parameter |
329 | which is opaque for the application but is necessary for the library | |
330 | to make these functions reentrant (i.e. allow more than one | |
331 | enumeration on one and the same object simultaneously). The cookie passed to | |
332 | GetFirstChild and GetNextChild should be the same. | |
a660d684 | 333 | |
ed93168b | 334 | Returns an invalid tree item if there are no further children. |
a660d684 | 335 | |
4fabb575 | 336 | \wxheading{See also} |
a660d684 | 337 | |
4fabb575 | 338 | \helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild} |
a660d684 | 339 | |
f899db6d RD |
340 | \pythonnote{In wxPython the returned wxTreeItemId and the new cookie |
341 | value are both returned as a tuple containing the two values.} | |
342 | ||
4fabb575 | 343 | \membersection{wxTreeCtrl::GetNextSibling}\label{wxtreectrlgetnextsibling} |
a660d684 | 344 | |
4fabb575 | 345 | \constfunc{wxTreeItemId}{GetNextSibling}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 346 | |
4fabb575 | 347 | Returns the next sibling of the specified item; call \helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling} for the previous sibling. |
a660d684 | 348 | |
ed93168b | 349 | Returns an invalid tree item if there are no further siblings. |
a660d684 | 350 | |
4fabb575 JS |
351 | \wxheading{See also} |
352 | ||
353 | \helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling} | |
354 | ||
355 | \membersection{wxTreeCtrl::GetNextVisible}\label{wxtreectrlgetnextvisible} | |
356 | ||
357 | \constfunc{wxTreeItemId}{GetNextVisible}{\param{const wxTreeItemId\&}{ item}} | |
a660d684 KB |
358 | |
359 | Returns the next visible item. | |
360 | ||
361 | \membersection{wxTreeCtrl::GetParent}\label{wxtreectrlgetparent} | |
362 | ||
4fabb575 | 363 | \constfunc{wxTreeItemId}{GetParent}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
364 | |
365 | Returns the item's parent. | |
366 | ||
c9110876 | 367 | \pythonnote{This method is named {\tt GetItemParent} to avoid a name |
874a1686 RD |
368 | clash with wxWindow::GetParent.} |
369 | ||
4fabb575 JS |
370 | \membersection{wxTreeCtrl::GetPrevSibling}\label{wxtreectrlgetprevsibling} |
371 | ||
372 | \constfunc{wxTreeItemId}{GetPrevSibling}{\param{const wxTreeItemId\&}{ item}} | |
373 | ||
374 | Returns the previous sibling of the specified item; call \helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling} for the next sibling. | |
375 | ||
ed93168b | 376 | Returns an invalid tree item if there are no further children. |
4fabb575 JS |
377 | |
378 | \wxheading{See also} | |
379 | ||
380 | \helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling} | |
381 | ||
382 | \membersection{wxTreeCtrl::GetPrevVisible}\label{wxtreectrlgetprevvisible} | |
383 | ||
384 | \constfunc{wxTreeItemId}{GetPrevVisible}{\param{const wxTreeItemId\&}{ item}} | |
385 | ||
386 | Returns the previous visible item. | |
387 | ||
a660d684 KB |
388 | \membersection{wxTreeCtrl::GetRootItem}\label{wxtreectrlgetrootitem} |
389 | ||
4fabb575 | 390 | \constfunc{wxTreeItemId}{GetRootItem}{\void} |
a660d684 KB |
391 | |
392 | Returns the root item for the tree control. | |
393 | ||
ed93168b | 394 | \membersection{wxTreeCtrl::GetItemSelectedImage}\label{wxtreectrlgetitemselectedimage} |
4fabb575 | 395 | |
ed93168b | 396 | \constfunc{int}{GetItemSelectedImage}{\param{const wxTreeItemId\& }{item}} |
4fabb575 | 397 | |
76e1c2de | 398 | Gets the selected item image (this function is obsolete, use |
74b31181 | 399 | {\tt GetItemImage(item, wxTreeItemIcon\_Selected} instead). |
4fabb575 | 400 | |
a660d684 KB |
401 | \membersection{wxTreeCtrl::GetSelection}\label{wxtreectrlgetselection} |
402 | ||
4fabb575 | 403 | \constfunc{wxTreeItemId}{GetSelection}{\void} |
a660d684 | 404 | |
ed93168b | 405 | Returns the selection, or an invalid item if there is no selection. |
76e1c2de | 406 | This function only works with the controls without wxTR\_MULTIPLE style, use |
9dfbf520 VZ |
407 | \helpref{GetSelections}{wxtreectrlgetselections} for the controls which do have |
408 | this style. | |
409 | ||
410 | \membersection{wxTreeCtrl::GetSelections}\label{wxtreectrlgetselections} | |
411 | ||
412 | \constfunc{size\_t}{GetSelections}{\param{wxArrayTreeItemIds\& }{selection}} | |
413 | ||
414 | Fills the array of tree items passed in with the currently selected items. This | |
415 | function can be called only if the control has the wxTR\_MULTIPLE style. | |
416 | ||
417 | Returns the number of selected items. | |
a660d684 | 418 | |
76e1c2de | 419 | \pythonnote{The wxPython version of this method accepts no parameters |
c9110876 | 420 | and returns a Python list of {\tt wxTreeItemId}'s.} |
76e1c2de | 421 | |
e2b34251 JS |
422 | \membersection{wxTreeCtrl::GetStateImageList}\label{wxtreectrlgetstateimagelist} |
423 | ||
424 | \constfunc{wxImageList*}{GetStateImageList}{\void} | |
425 | ||
426 | Returns the state image list (from which application-defined state images are taken). | |
427 | ||
a660d684 KB |
428 | \membersection{wxTreeCtrl::HitTest}\label{wxtreectrlhittest} |
429 | ||
430 | \func{long}{HitTest}{\param{const wxPoint\& }{point}, \param{int\& }{flags}} | |
431 | ||
432 | Calculates which (if any) item is under the given point, returning extra information | |
433 | in {\it flags}. {\it flags} is a bitlist of the following: | |
434 | ||
435 | \twocolwidtha{5cm} | |
436 | \begin{twocollist}\itemsep=0pt | |
437 | \twocolitem{wxTREE\_HITTEST\_ABOVE}{Above the client area.} | |
438 | \twocolitem{wxTREE\_HITTEST\_BELOW}{Below the client area.} | |
439 | \twocolitem{wxTREE\_HITTEST\_NOWHERE}{In the client area but below the last item.} | |
440 | \twocolitem{wxTREE\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.} | |
441 | \twocolitem{wxTREE\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.} | |
442 | \twocolitem{wxTREE\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.} | |
443 | \twocolitem{wxTREE\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.} | |
444 | \twocolitem{wxTREE\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.} | |
445 | \twocolitem{wxTREE\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.} | |
446 | \twocolitem{wxTREE\_HITTEST\_TOLEFT}{To the right of the client area.} | |
447 | \twocolitem{wxTREE\_HITTEST\_TORIGHT}{To the left of the client area.} | |
448 | \end{twocollist} | |
449 | ||
450 | \membersection{wxTreeCtrl::InsertItem}\label{wxtreectrlinsertitem} | |
451 | ||
4fabb575 JS |
452 | \func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxTreeItemId\& }{previous}, \param{const wxString\&}{ text}, |
453 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
a660d684 | 454 | |
f2593d0d RR |
455 | \func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{size\_t}{ before}, \param{const wxString\&}{ text}, |
456 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
457 | ||
458 | Inserts an item after a given one ({\it previous}) or before one identified by its position ({\it before}). | |
a660d684 KB |
459 | |
460 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
461 | both selected and unselected items. | |
462 | ||
ed93168b VZ |
463 | \membersection{wxTreeCtrl::IsBold}\label{wxtreectrlisbold} |
464 | ||
465 | \constfunc{bool}{IsBold}{\param{const wxTreeItemId\& }{item}} | |
466 | ||
467 | Returns TRUE if the given item is in bold state. | |
468 | ||
469 | See also: \helpref{SetItemBold}{wxtreectrlsetitembold} | |
470 | ||
4fabb575 JS |
471 | \membersection{wxTreeCtrl::IsExpanded}\label{wxtreectrlisexpanded} |
472 | ||
473 | \constfunc{bool}{IsExpanded}{\param{const wxTreeItemId\&}{ item}} | |
474 | ||
475 | Returns TRUE if the item is expanded (only makes sense if it has children). | |
476 | ||
477 | \membersection{wxTreeCtrl::IsSelected}\label{wxtreectrlisselected} | |
478 | ||
479 | \constfunc{bool}{IsSelected}{\param{const wxTreeItemId\&}{ item}} | |
480 | ||
481 | Returns TRUE if the item is selected. | |
482 | ||
483 | \membersection{wxTreeCtrl::IsVisible}\label{wxtreectrlisvisible} | |
484 | ||
485 | \constfunc{bool}{IsVisible}{\param{const wxTreeItemId\&}{ item}} | |
486 | ||
487 | Returns TRUE if the item is visible (it might be outside the view, or not expanded). | |
488 | ||
a660d684 KB |
489 | \membersection{wxTreeCtrl::ItemHasChildren}\label{wxtreectrlitemhaschildren} |
490 | ||
4fabb575 | 491 | \constfunc{bool}{ItemHasChildren}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
492 | |
493 | Returns TRUE if the item has children. | |
494 | ||
ed93168b VZ |
495 | \membersection{wxTreeCtrl::OnCompareItems}\label{wxtreectrloncompareitems} |
496 | ||
497 | \func{int}{OnCompareItems}{\param{const wxTreeItemId\& }{item1}, \param{const wxTreeItemId\& }{item2}} | |
498 | ||
499 | Override this function in the derived class to change the sort order of the | |
500 | items in the tree control. The function should return a negative, zero or | |
501 | positive value if the first item is less than, equal to or greater than the | |
502 | second one. | |
503 | ||
504 | The base class version compares items alphabetically. | |
505 | ||
506 | See also: \helpref{SortChildren}{wxtreectrlsortchildren} | |
507 | ||
4fabb575 JS |
508 | \membersection{wxTreeCtrl::PrependItem}\label{wxtreectrlprependitem} |
509 | ||
510 | \func{wxTreeItemId}{PrependItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text}, | |
511 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
512 | ||
513 | Appends an item as the first child of {\it parent}, return a new item id. | |
514 | ||
515 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
516 | both selected and unselected items. | |
517 | ||
a660d684 KB |
518 | \membersection{wxTreeCtrl::ScrollTo}\label{wxtreectrlscrollto} |
519 | ||
4fabb575 | 520 | \func{void}{ScrollTo}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 521 | |
4fabb575 | 522 | Scrolls the specified item into view. |
a660d684 KB |
523 | |
524 | \membersection{wxTreeCtrl::SelectItem}\label{wxtreectrlselectitem} | |
525 | ||
4fabb575 | 526 | \func{bool}{SelectItem}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
527 | |
528 | Selects the given item. | |
529 | ||
530 | \membersection{wxTreeCtrl::SetIndent}\label{wxtreectrlsetindent} | |
531 | ||
532 | \func{void}{SetIndent}{\param{int }{indent}} | |
533 | ||
534 | Sets the indentation for the tree control. | |
535 | ||
536 | \membersection{wxTreeCtrl::SetImageList}\label{wxtreectrlsetimagelist} | |
537 | ||
e2b34251 | 538 | \func{void}{SetImageList}{\param{wxImageList*}{ imageList}} |
a660d684 | 539 | |
e2b34251 | 540 | Sets the normal image list. |
a660d684 | 541 | |
9ec64fa7 VZ |
542 | \membersection{wxTreeCtrl::SetItemBackgroundColour}\label{wxtreectrlsetitembackgroundcolour} |
543 | ||
544 | \func{void}{SetItemBackgroundColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}} | |
545 | ||
546 | Sets the colour of the items background. | |
547 | ||
ed93168b VZ |
548 | \membersection{wxTreeCtrl::SetItemBold}\label{wxtreectrlsetitembold} |
549 | ||
550 | \func{void}{SetItemBold}{\param{const wxTreeItemId\& }{item}, \param{bool}{ bold = TRUE}} | |
551 | ||
552 | Makes item appear in bold font if {\it bold} parameter is TRUE or resets it to | |
553 | the normal state. | |
554 | ||
555 | See also: \helpref{IsBold}{wxtreectrlisbold} | |
556 | ||
4fabb575 | 557 | \membersection{wxTreeCtrl::SetItemData}\label{wxtreectrlsetitemdata} |
a660d684 | 558 | |
4fabb575 | 559 | \func{void}{SetItemData}{\param{const wxTreeItemId\&}{ item}, \param{wxTreeItemData* }{data}} |
a660d684 | 560 | |
4fabb575 | 561 | Sets the item client data. |
a660d684 | 562 | |
f899db6d RD |
563 | \pythonnote{wxPython provides the following shortcut method:\par |
564 | \indented{2cm}{\begin{twocollist} | |
c9110876 | 565 | \twocolitem{{\bf SetPyData(item, obj)}}{Associate the given Python |
f899db6d RD |
566 | Object with the wxTreeItemData for the given item Id.} |
567 | \end{twocollist}} | |
568 | } | |
569 | ||
9ec64fa7 VZ |
570 | \membersection{wxTreeCtrl::SetItemFont}\label{wxtreectrlsetitemfont} |
571 | ||
572 | \func{void}{SetItemFont}{\param{const wxTreeItemId\&}{ item}, \param{const wxFont\& }{font}} | |
573 | ||
574 | Sets the items font. All items in the tree should have the same height to avoid | |
575 | text clipping, so the fonts height should be the same for all of them, | |
576 | although font attributes may vary. | |
577 | ||
578 | \wxheading{See also} | |
579 | ||
580 | \helpref{SetItemBold}{wxtreectrlsetitembold} | |
581 | ||
4fabb575 | 582 | \membersection{wxTreeCtrl::SetItemHasChildren}\label{wxtreectrlsetitemhaschildren} |
a660d684 | 583 | |
4fabb575 | 584 | \func{void}{SetItemHasChildren}{\param{const wxTreeItemId\&}{ item}, \param{bool }{hasChildren = TRUE}} |
a660d684 | 585 | |
4fabb575 JS |
586 | Force appearance of the button next to the item. This is useful to |
587 | allow the user to expand the items which don't have any children now, | |
588 | but instead adding them only when needed, thus minimizing memory | |
589 | usage and loading time. | |
a660d684 KB |
590 | |
591 | \membersection{wxTreeCtrl::SetItemImage}\label{wxtreectrlsetitemimage} | |
592 | ||
74b31181 VZ |
593 | \func{void}{SetItemImage}{\param{const wxTreeItemId\&}{ item}, |
594 | \param{int }{image}, | |
595 | \param{wxTreeItemIcon }{which = wxTreeItemIcon\_Normal}} | |
a660d684 | 596 | |
76e1c2de | 597 | Sets the specified item image. See \helpref{GetItemImage}{wxtreectrlgetitemimage} |
74b31181 | 598 | for the description of {\it which} parameter. |
a660d684 | 599 | |
4fabb575 | 600 | \membersection{wxTreeCtrl::SetItemSelectedImage}\label{wxtreectrlsetitemselectedimage} |
a660d684 | 601 | |
4fabb575 | 602 | \func{void}{SetItemSelectedImage}{\param{const wxTreeItemId\&}{ item}, \param{int }{selImage}} |
a660d684 | 603 | |
76e1c2de | 604 | Sets the selected item image (this function is obsolete, use |
74b31181 | 605 | {\tt SetItemImage(item, wxTreeItemIcon\_Selected} instead). |
a660d684 KB |
606 | |
607 | \membersection{wxTreeCtrl::SetItemText}\label{wxtreectrlsetitemtext} | |
608 | ||
4fabb575 | 609 | \func{void}{SetItemText}{\param{const wxTreeItemId\&}{ item}, \param{const wxString\& }{text}} |
a660d684 KB |
610 | |
611 | Sets the item label. | |
612 | ||
9ec64fa7 VZ |
613 | \membersection{wxTreeCtrl::SetItemTextColour}\label{wxtreectrlsetitemtextcolour} |
614 | ||
615 | \func{void}{SetItemTextColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}} | |
616 | ||
617 | Sets the colour of the items text. | |
618 | ||
e2b34251 JS |
619 | \membersection{wxTreeCtrl::SetStateImageList}\label{wxtreectrlsetstateimagelist} |
620 | ||
621 | \func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}} | |
622 | ||
623 | Sets the state image list (from which application-defined state images are taken). | |
624 | ||
4fabb575 | 625 | \membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren} |
a660d684 | 626 | |
ed93168b | 627 | \func{void}{SortChildren}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 628 | |
f899db6d | 629 | Sorts the children of the given item using |
ed93168b VZ |
630 | \helpref{OnCompareItems}{wxtreectrloncompareitems} method of wxTreeCtrl. You |
631 | should override that method to change the sort order (default is ascending | |
632 | alphabetical order). | |
4fabb575 JS |
633 | |
634 | \wxheading{See also} | |
635 | ||
ed93168b | 636 | \helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{OnCompareItems}{wxtreectrloncompareitems} |
4fabb575 JS |
637 | |
638 | \membersection{wxTreeCtrl::Toggle}\label{wxtreectrltoggle} | |
639 | ||
640 | \func{void}{Toggle}{\param{const wxTreeItemId\&}{ item}} | |
641 | ||
642 | Toggles the given item between collapsed and expanded states. | |
643 | ||
644 | \membersection{wxTreeCtrl::Unselect}\label{wxtreectrlunselect} | |
645 | ||
646 | \func{void}{Unselect}{\void} | |
647 | ||
648 | Removes the selection from the currently selected item (if any). | |
649 | ||
9dfbf520 VZ |
650 | \membersection{wxTreeCtrl::UnselectAll}\label{wxtreectrlunselectall} |
651 | ||
652 | \func{void}{UnselectAll}{\void} | |
653 | ||
76e1c2de | 654 | This function either behaves the same as \helpref{Unselect}{wxtreectrlunselect} |
9dfbf520 VZ |
655 | if the control doesn't have wxTR\_MULTIPLE style, or removes the selection from |
656 | all items if it does have this style. | |
657 | ||
4fabb575 JS |
658 | \section{\class{wxTreeItemData}}\label{wxtreeitemdata} |
659 | ||
660 | wxTreeItemData is some (arbitrary) user class associated with some item. The | |
661 | main advantage of having this class (compared to the old untyped interface) is | |
662 | that wxTreeItemData's are destroyed automatically by the tree and, as this | |
663 | class has virtual dtor, it means that the memory will be automatically | |
664 | freed. We don't just use wxObject instead of wxTreeItemData because | |
665 | the size of this class is critical: in any real application, each tree leaf | |
666 | will have wxTreeItemData associated with it and number of leaves may be | |
667 | quite big. | |
668 | ||
669 | Because the objects of this class are deleted by the tree, they should | |
670 | always be allocated on the heap. | |
671 | ||
672 | \wxheading{Derived from} | |
673 | ||
674 | wxTreeItemId | |
675 | ||
954b8ae6 JS |
676 | \wxheading{Include files} |
677 | ||
678 | <wx/treectrl.h> | |
679 | ||
4fabb575 JS |
680 | \wxheading{See also} |
681 | ||
682 | \helpref{wxTreeCtrl}{wxtreectrl} | |
683 | ||
684 | \latexignore{\rtfignore{\wxheading{Members}}} | |
685 | ||
686 | \membersection{wxTreeItemData::wxTreeItemData}\label{wxtreeitemdataconstr} | |
687 | ||
688 | \func{}{wxTreeItemData}{\void} | |
689 | ||
690 | Default constructor. | |
691 | ||
f899db6d RD |
692 | \pythonnote{The wxPython version of this constructor optionally |
693 | accepts any Python object as a parameter. This object is then | |
694 | associated with the tree item using the wxTreeItemData as a | |
695 | container. | |
696 | ||
697 | In addition, the following methods are added in wxPython for accessing | |
698 | the object:\par | |
699 | \indented{2cm}{\begin{twocollist} | |
c9110876 VS |
700 | \twocolitem{{\bf GetData()}}{Returns a reference to the Python Object} |
701 | \twocolitem{{\bf SetData(obj)}}{Associates a new Python Object with the | |
f899db6d RD |
702 | wxTreeItemData} |
703 | \end{twocollist}} | |
704 | } | |
705 | ||
706 | ||
4fabb575 JS |
707 | \membersection{wxTreeItemData::\destruct{wxTreeItemData}} |
708 | ||
709 | \func{void}{\destruct{wxTreeItemData}}{\void} | |
710 | ||
711 | Virtual destructor. | |
712 | ||
713 | \membersection{wxTreeItemData::GetId}\label{wxtreeitemdatagetid} | |
714 | ||
715 | \func{const wxTreeItem\&}{GetId}{\void} | |
716 | ||
717 | Returns the item associated with this node. | |
718 | ||
719 | \membersection{wxTreeItemData::SetId}\label{wxtreeitemdatasetid} | |
a660d684 | 720 | |
4fabb575 | 721 | \func{void}{SetId}{\param{const wxTreeItemId\&}{ id}} |
a660d684 | 722 | |
4fabb575 | 723 | Sets the item associated with this node. |
a660d684 | 724 |