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