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