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