]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/treectrl.tex
*** empty log message ***
[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 161If the user changed the label (i.e. s/he does not press ESC or leave
76e1c2de 162the text control without changes, a EVT\_TREE\_END\_LABEL\_EDIT event
fd128b0c 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
76e1c2de 206\pythonnote{The wxPython version of this method requires only the
c9110876
VS
207{\tt item} and {\tt textOnly} parameters. The return value is either a
208{\tt wxRect} object or {\tt None}.}
76e1c2de 209
4fabb575 210\membersection{wxTreeCtrl::GetChildrenCount}\label{wxtreectrlgetchildrencount}
a660d684 211
4fabb575 212\constfunc{size\_t}{GetChildrenCount}{\param{const wxTreeItemId\&}{ item}, \param{bool}{ recursively = TRUE}}
a660d684 213
4fabb575
JS
214Returns the number of items in the branch. If {\it recursively} is TRUE, returns the total number
215of descendants, otherwise only one level of children is counted.
a660d684
KB
216
217\membersection{wxTreeCtrl::GetCount}\label{wxtreectrlgetcount}
218
219\constfunc{int}{GetCount}{\void}
220
221Returns the number of items in the control.
222
223\membersection{wxTreeCtrl::GetEditControl}\label{wxtreectrlgeteditcontrol}
224
225\constfunc{wxTextCtrl\&}{GetEditControl}{\void}
226
227Returns the edit control used to edit a label.
228
4fabb575
JS
229\membersection{wxTreeCtrl::GetFirstChild}\label{wxtreectrlgetfirstchild}
230
231\constfunc{wxTreeItemId}{GetFirstChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}}
232
233Returns the first child; call \helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild} for the next child.
234
235For this enumeration function you must pass in a `cookie' parameter
236which is opaque for the application but is necessary for the library
237to make these functions reentrant (i.e. allow more than one
238enumeration on one and the same object simultaneously). The cookie passed to
239GetFirstChild and GetNextChild should be the same.
240
ed93168b 241Returns an invalid tree item if there are no further children.
4fabb575
JS
242
243\wxheading{See also}
244
245\helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild}
246
f899db6d
RD
247\pythonnote{In wxPython the returned wxTreeItemId and the new cookie
248value are both returned as a tuple containing the two values.}
249
a660d684
KB
250\membersection{wxTreeCtrl::GetFirstVisibleItem}\label{wxtreectrlgetfirstvisibleitem}
251
4fabb575 252\constfunc{wxTreeItemId}{GetFirstVisibleItem}{\void}
a660d684
KB
253
254Returns the first visible item.
255
256\membersection{wxTreeCtrl::GetImageList}\label{wxtreectrlgetimagelist}
257
e2b34251 258\constfunc{wxImageList*}{GetImageList}{\void}
a660d684 259
e2b34251 260Returns the normal image list.
a660d684
KB
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}
c9110876 280\twocolitem{{\bf GetPyData(item)}}{Returns the Python Object
f899db6d
RD
281associated with the wxTreeItemData for the given item Id.}
282\end{twocollist}}
283}
284
4fabb575 285\membersection{wxTreeCtrl::GetItemImage}\label{wxtreectrlgetitemimage}
a660d684 286
74b31181
VZ
287\constfunc{int}{GetItemImage}{\param{const wxTreeItemId\& }{item},
288\param{wxTreeItemIcon }{which = wxTreeItemIcon\_Normal}}
289
290Gets the specified item image. The value of {\it which} may be:
291\begin{itemize}\itemsep=0pt
292\item{wxTreeItemIcon\_Normal} to get the normal item image
293\item{wxTreeItemIcon\_Selected} to get the selected item image (i.e. the image
294which is shown when the item is currently selected)
295\item{wxTreeItemIcon\_Expanded} to get the expanded image (this only
296makes sense for items which have children - then this image is shown when the
297item is expanded and the normal image is shown when it is collapsed)
298\item{wxTreeItemIcon\_SelectedExpanded} to get the selected expanded image
299(which is shown when an expanded item is currently selected)
300\end{itemize}
a660d684 301
4fabb575 302\membersection{wxTreeCtrl::GetItemText}\label{wxtreectrlgetitemtext}
a660d684 303
4fabb575 304\constfunc{wxString}{GetItemText}{\param{const wxTreeItemId\&}{ item}}
a660d684 305
4fabb575 306Returns the item label.
a660d684 307
978f38c2
VZ
308\membersection{wxTreeCtrl::GetLastChild}\label{wxtreectrlgetlastchild}
309
310\constfunc{wxTreeItemId}{GetLastChild}{\param{const wxTreeItemId\&}{ item}}
311
ed93168b 312Returns the last child of the item (or an invalid tree item if this item has no children).
978f38c2
VZ
313
314\wxheading{See also}
315
f899db6d 316\helpref{GetFirstChild}{wxtreectrlgetfirstchild},
978f38c2
VZ
317\helpref{GetLastChild}{wxtreectrlgetlastchild}
318
4fabb575 319\membersection{wxTreeCtrl::GetNextChild}\label{wxtreectrlgetnextchild}
a660d684 320
4fabb575 321\constfunc{wxTreeItemId}{GetNextChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}}
a660d684 322
4fabb575 323Returns the next child; call \helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild} for the first child.
a660d684 324
4fabb575
JS
325For this enumeration function you must pass in a `cookie' parameter
326which is opaque for the application but is necessary for the library
327to make these functions reentrant (i.e. allow more than one
328enumeration on one and the same object simultaneously). The cookie passed to
329GetFirstChild and GetNextChild should be the same.
a660d684 330
ed93168b 331Returns an invalid tree item if there are no further children.
a660d684 332
4fabb575 333\wxheading{See also}
a660d684 334
4fabb575 335\helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild}
a660d684 336
f899db6d
RD
337\pythonnote{In wxPython the returned wxTreeItemId and the new cookie
338value are both returned as a tuple containing the two values.}
339
4fabb575 340\membersection{wxTreeCtrl::GetNextSibling}\label{wxtreectrlgetnextsibling}
a660d684 341
4fabb575 342\constfunc{wxTreeItemId}{GetNextSibling}{\param{const wxTreeItemId\&}{ item}}
a660d684 343
4fabb575 344Returns the next sibling of the specified item; call \helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling} for the previous sibling.
a660d684 345
ed93168b 346Returns an invalid tree item if there are no further siblings.
a660d684 347
4fabb575
JS
348\wxheading{See also}
349
350\helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling}
351
352\membersection{wxTreeCtrl::GetNextVisible}\label{wxtreectrlgetnextvisible}
353
354\constfunc{wxTreeItemId}{GetNextVisible}{\param{const wxTreeItemId\&}{ item}}
a660d684
KB
355
356Returns the next visible item.
357
358\membersection{wxTreeCtrl::GetParent}\label{wxtreectrlgetparent}
359
4fabb575 360\constfunc{wxTreeItemId}{GetParent}{\param{const wxTreeItemId\&}{ item}}
a660d684
KB
361
362Returns the item's parent.
363
c9110876 364\pythonnote{This method is named {\tt GetItemParent} to avoid a name
874a1686
RD
365clash with wxWindow::GetParent.}
366
4fabb575
JS
367\membersection{wxTreeCtrl::GetPrevSibling}\label{wxtreectrlgetprevsibling}
368
369\constfunc{wxTreeItemId}{GetPrevSibling}{\param{const wxTreeItemId\&}{ item}}
370
371Returns the previous sibling of the specified item; call \helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling} for the next sibling.
372
ed93168b 373Returns an invalid tree item if there are no further children.
4fabb575
JS
374
375\wxheading{See also}
376
377\helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling}
378
379\membersection{wxTreeCtrl::GetPrevVisible}\label{wxtreectrlgetprevvisible}
380
381\constfunc{wxTreeItemId}{GetPrevVisible}{\param{const wxTreeItemId\&}{ item}}
382
383Returns the previous visible item.
384
a660d684
KB
385\membersection{wxTreeCtrl::GetRootItem}\label{wxtreectrlgetrootitem}
386
4fabb575 387\constfunc{wxTreeItemId}{GetRootItem}{\void}
a660d684
KB
388
389Returns the root item for the tree control.
390
ed93168b 391\membersection{wxTreeCtrl::GetItemSelectedImage}\label{wxtreectrlgetitemselectedimage}
4fabb575 392
ed93168b 393\constfunc{int}{GetItemSelectedImage}{\param{const wxTreeItemId\& }{item}}
4fabb575 394
76e1c2de 395Gets the selected item image (this function is obsolete, use
74b31181 396{\tt GetItemImage(item, wxTreeItemIcon\_Selected} instead).
4fabb575 397
a660d684
KB
398\membersection{wxTreeCtrl::GetSelection}\label{wxtreectrlgetselection}
399
4fabb575 400\constfunc{wxTreeItemId}{GetSelection}{\void}
a660d684 401
ed93168b 402Returns the selection, or an invalid item if there is no selection.
76e1c2de 403This function only works with the controls without wxTR\_MULTIPLE style, use
9dfbf520
VZ
404\helpref{GetSelections}{wxtreectrlgetselections} for the controls which do have
405this style.
406
407\membersection{wxTreeCtrl::GetSelections}\label{wxtreectrlgetselections}
408
409\constfunc{size\_t}{GetSelections}{\param{wxArrayTreeItemIds\& }{selection}}
410
411Fills the array of tree items passed in with the currently selected items. This
412function can be called only if the control has the wxTR\_MULTIPLE style.
413
414Returns the number of selected items.
a660d684 415
76e1c2de 416\pythonnote{The wxPython version of this method accepts no parameters
c9110876 417and returns a Python list of {\tt wxTreeItemId}'s.}
76e1c2de 418
e2b34251
JS
419\membersection{wxTreeCtrl::GetStateImageList}\label{wxtreectrlgetstateimagelist}
420
421\constfunc{wxImageList*}{GetStateImageList}{\void}
422
423Returns the state image list (from which application-defined state images are taken).
424
a660d684
KB
425\membersection{wxTreeCtrl::HitTest}\label{wxtreectrlhittest}
426
427\func{long}{HitTest}{\param{const wxPoint\& }{point}, \param{int\& }{flags}}
428
429Calculates which (if any) item is under the given point, returning extra information
430in {\it flags}. {\it flags} is a bitlist of the following:
431
432\twocolwidtha{5cm}
433\begin{twocollist}\itemsep=0pt
434\twocolitem{wxTREE\_HITTEST\_ABOVE}{Above the client area.}
435\twocolitem{wxTREE\_HITTEST\_BELOW}{Below the client area.}
436\twocolitem{wxTREE\_HITTEST\_NOWHERE}{In the client area but below the last item.}
437\twocolitem{wxTREE\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.}
438\twocolitem{wxTREE\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.}
439\twocolitem{wxTREE\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.}
440\twocolitem{wxTREE\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.}
441\twocolitem{wxTREE\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.}
442\twocolitem{wxTREE\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.}
443\twocolitem{wxTREE\_HITTEST\_TOLEFT}{To the right of the client area.}
444\twocolitem{wxTREE\_HITTEST\_TORIGHT}{To the left of the client area.}
445\end{twocollist}
446
447\membersection{wxTreeCtrl::InsertItem}\label{wxtreectrlinsertitem}
448
4fabb575
JS
449\func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxTreeItemId\& }{previous}, \param{const wxString\&}{ text},
450 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
a660d684 451
f2593d0d
RR
452\func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{size\_t}{ before}, \param{const wxString\&}{ text},
453 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
454
455Inserts an item after a given one ({\it previous}) or before one identified by its position ({\it before}).
a660d684
KB
456
457If {\it image} > -1 and {\it selImage} is -1, the same image is used for
458both selected and unselected items.
459
ed93168b
VZ
460\membersection{wxTreeCtrl::IsBold}\label{wxtreectrlisbold}
461
462\constfunc{bool}{IsBold}{\param{const wxTreeItemId\& }{item}}
463
464Returns TRUE if the given item is in bold state.
465
466See also: \helpref{SetItemBold}{wxtreectrlsetitembold}
467
4fabb575
JS
468\membersection{wxTreeCtrl::IsExpanded}\label{wxtreectrlisexpanded}
469
470\constfunc{bool}{IsExpanded}{\param{const wxTreeItemId\&}{ item}}
471
472Returns TRUE if the item is expanded (only makes sense if it has children).
473
474\membersection{wxTreeCtrl::IsSelected}\label{wxtreectrlisselected}
475
476\constfunc{bool}{IsSelected}{\param{const wxTreeItemId\&}{ item}}
477
478Returns TRUE if the item is selected.
479
480\membersection{wxTreeCtrl::IsVisible}\label{wxtreectrlisvisible}
481
482\constfunc{bool}{IsVisible}{\param{const wxTreeItemId\&}{ item}}
483
484Returns TRUE if the item is visible (it might be outside the view, or not expanded).
485
a660d684
KB
486\membersection{wxTreeCtrl::ItemHasChildren}\label{wxtreectrlitemhaschildren}
487
4fabb575 488\constfunc{bool}{ItemHasChildren}{\param{const wxTreeItemId\&}{ item}}
a660d684
KB
489
490Returns TRUE if the item has children.
491
ed93168b
VZ
492\membersection{wxTreeCtrl::OnCompareItems}\label{wxtreectrloncompareitems}
493
494\func{int}{OnCompareItems}{\param{const wxTreeItemId\& }{item1}, \param{const wxTreeItemId\& }{item2}}
495
496Override this function in the derived class to change the sort order of the
497items in the tree control. The function should return a negative, zero or
498positive value if the first item is less than, equal to or greater than the
499second one.
500
501The base class version compares items alphabetically.
502
503See also: \helpref{SortChildren}{wxtreectrlsortchildren}
504
4fabb575
JS
505\membersection{wxTreeCtrl::PrependItem}\label{wxtreectrlprependitem}
506
507\func{wxTreeItemId}{PrependItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text},
508 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
509
510Appends an item as the first child of {\it parent}, return a new item id.
511
512If {\it image} > -1 and {\it selImage} is -1, the same image is used for
513both selected and unselected items.
514
a660d684
KB
515\membersection{wxTreeCtrl::ScrollTo}\label{wxtreectrlscrollto}
516
4fabb575 517\func{void}{ScrollTo}{\param{const wxTreeItemId\&}{ item}}
a660d684 518
4fabb575 519Scrolls the specified item into view.
a660d684
KB
520
521\membersection{wxTreeCtrl::SelectItem}\label{wxtreectrlselectitem}
522
4fabb575 523\func{bool}{SelectItem}{\param{const wxTreeItemId\&}{ item}}
a660d684
KB
524
525Selects the given item.
526
527\membersection{wxTreeCtrl::SetIndent}\label{wxtreectrlsetindent}
528
529\func{void}{SetIndent}{\param{int }{indent}}
530
531Sets the indentation for the tree control.
532
533\membersection{wxTreeCtrl::SetImageList}\label{wxtreectrlsetimagelist}
534
e2b34251 535\func{void}{SetImageList}{\param{wxImageList*}{ imageList}}
a660d684 536
e2b34251 537Sets the normal image list.
a660d684 538
9ec64fa7
VZ
539\membersection{wxTreeCtrl::SetItemBackgroundColour}\label{wxtreectrlsetitembackgroundcolour}
540
541\func{void}{SetItemBackgroundColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}}
542
543Sets the colour of the items background.
544
ed93168b
VZ
545\membersection{wxTreeCtrl::SetItemBold}\label{wxtreectrlsetitembold}
546
547\func{void}{SetItemBold}{\param{const wxTreeItemId\& }{item}, \param{bool}{ bold = TRUE}}
548
549Makes item appear in bold font if {\it bold} parameter is TRUE or resets it to
550the normal state.
551
552See also: \helpref{IsBold}{wxtreectrlisbold}
553
4fabb575 554\membersection{wxTreeCtrl::SetItemData}\label{wxtreectrlsetitemdata}
a660d684 555
4fabb575 556\func{void}{SetItemData}{\param{const wxTreeItemId\&}{ item}, \param{wxTreeItemData* }{data}}
a660d684 557
4fabb575 558Sets the item client data.
a660d684 559
f899db6d
RD
560\pythonnote{wxPython provides the following shortcut method:\par
561\indented{2cm}{\begin{twocollist}
c9110876 562\twocolitem{{\bf SetPyData(item, obj)}}{Associate the given Python
f899db6d
RD
563Object with the wxTreeItemData for the given item Id.}
564\end{twocollist}}
565}
566
9ec64fa7
VZ
567\membersection{wxTreeCtrl::SetItemFont}\label{wxtreectrlsetitemfont}
568
569\func{void}{SetItemFont}{\param{const wxTreeItemId\&}{ item}, \param{const wxFont\& }{font}}
570
571Sets the items font. All items in the tree should have the same height to avoid
572text clipping, so the fonts height should be the same for all of them,
573although font attributes may vary.
574
575\wxheading{See also}
576
577\helpref{SetItemBold}{wxtreectrlsetitembold}
578
4fabb575 579\membersection{wxTreeCtrl::SetItemHasChildren}\label{wxtreectrlsetitemhaschildren}
a660d684 580
4fabb575 581\func{void}{SetItemHasChildren}{\param{const wxTreeItemId\&}{ item}, \param{bool }{hasChildren = TRUE}}
a660d684 582
4fabb575
JS
583Force appearance of the button next to the item. This is useful to
584allow the user to expand the items which don't have any children now,
585but instead adding them only when needed, thus minimizing memory
586usage and loading time.
a660d684
KB
587
588\membersection{wxTreeCtrl::SetItemImage}\label{wxtreectrlsetitemimage}
589
74b31181
VZ
590\func{void}{SetItemImage}{\param{const wxTreeItemId\&}{ item},
591\param{int }{image},
592\param{wxTreeItemIcon }{which = wxTreeItemIcon\_Normal}}
a660d684 593
76e1c2de 594Sets the specified item image. See \helpref{GetItemImage}{wxtreectrlgetitemimage}
74b31181 595for the description of {\it which} parameter.
a660d684 596
4fabb575 597\membersection{wxTreeCtrl::SetItemSelectedImage}\label{wxtreectrlsetitemselectedimage}
a660d684 598
4fabb575 599\func{void}{SetItemSelectedImage}{\param{const wxTreeItemId\&}{ item}, \param{int }{selImage}}
a660d684 600
76e1c2de 601Sets the selected item image (this function is obsolete, use
74b31181 602{\tt SetItemImage(item, wxTreeItemIcon\_Selected} instead).
a660d684
KB
603
604\membersection{wxTreeCtrl::SetItemText}\label{wxtreectrlsetitemtext}
605
4fabb575 606\func{void}{SetItemText}{\param{const wxTreeItemId\&}{ item}, \param{const wxString\& }{text}}
a660d684
KB
607
608Sets the item label.
609
9ec64fa7
VZ
610\membersection{wxTreeCtrl::SetItemTextColour}\label{wxtreectrlsetitemtextcolour}
611
612\func{void}{SetItemTextColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}}
613
614Sets the colour of the items text.
615
e2b34251
JS
616\membersection{wxTreeCtrl::SetStateImageList}\label{wxtreectrlsetstateimagelist}
617
618\func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
619
620Sets the state image list (from which application-defined state images are taken).
621
4fabb575 622\membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren}
a660d684 623
ed93168b 624\func{void}{SortChildren}{\param{const wxTreeItemId\&}{ item}}
a660d684 625
f899db6d 626Sorts the children of the given item using
ed93168b
VZ
627\helpref{OnCompareItems}{wxtreectrloncompareitems} method of wxTreeCtrl. You
628should override that method to change the sort order (default is ascending
629alphabetical order).
4fabb575
JS
630
631\wxheading{See also}
632
ed93168b 633\helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{OnCompareItems}{wxtreectrloncompareitems}
4fabb575
JS
634
635\membersection{wxTreeCtrl::Toggle}\label{wxtreectrltoggle}
636
637\func{void}{Toggle}{\param{const wxTreeItemId\&}{ item}}
638
639Toggles the given item between collapsed and expanded states.
640
641\membersection{wxTreeCtrl::Unselect}\label{wxtreectrlunselect}
642
643\func{void}{Unselect}{\void}
644
645Removes the selection from the currently selected item (if any).
646
9dfbf520
VZ
647\membersection{wxTreeCtrl::UnselectAll}\label{wxtreectrlunselectall}
648
649\func{void}{UnselectAll}{\void}
650
76e1c2de 651This function either behaves the same as \helpref{Unselect}{wxtreectrlunselect}
9dfbf520
VZ
652if the control doesn't have wxTR\_MULTIPLE style, or removes the selection from
653all items if it does have this style.
654
4fabb575
JS
655\section{\class{wxTreeItemData}}\label{wxtreeitemdata}
656
657wxTreeItemData is some (arbitrary) user class associated with some item. The
658main advantage of having this class (compared to the old untyped interface) is
659that wxTreeItemData's are destroyed automatically by the tree and, as this
660class has virtual dtor, it means that the memory will be automatically
661freed. We don't just use wxObject instead of wxTreeItemData because
662the size of this class is critical: in any real application, each tree leaf
663will have wxTreeItemData associated with it and number of leaves may be
664quite big.
665
666Because the objects of this class are deleted by the tree, they should
667always be allocated on the heap.
668
669\wxheading{Derived from}
670
671wxTreeItemId
672
954b8ae6
JS
673\wxheading{Include files}
674
675<wx/treectrl.h>
676
4fabb575
JS
677\wxheading{See also}
678
679\helpref{wxTreeCtrl}{wxtreectrl}
680
681\latexignore{\rtfignore{\wxheading{Members}}}
682
683\membersection{wxTreeItemData::wxTreeItemData}\label{wxtreeitemdataconstr}
684
685\func{}{wxTreeItemData}{\void}
686
687Default constructor.
688
f899db6d
RD
689\pythonnote{The wxPython version of this constructor optionally
690accepts any Python object as a parameter. This object is then
691associated with the tree item using the wxTreeItemData as a
692container.
693
694In addition, the following methods are added in wxPython for accessing
695the object:\par
696\indented{2cm}{\begin{twocollist}
c9110876
VS
697\twocolitem{{\bf GetData()}}{Returns a reference to the Python Object}
698\twocolitem{{\bf SetData(obj)}}{Associates a new Python Object with the
f899db6d
RD
699wxTreeItemData}
700\end{twocollist}}
701}
702
703
4fabb575
JS
704\membersection{wxTreeItemData::\destruct{wxTreeItemData}}
705
706\func{void}{\destruct{wxTreeItemData}}{\void}
707
708Virtual destructor.
709
710\membersection{wxTreeItemData::GetId}\label{wxtreeitemdatagetid}
711
712\func{const wxTreeItem\&}{GetId}{\void}
713
714Returns the item associated with this node.
715
716\membersection{wxTreeItemData::SetId}\label{wxtreeitemdatasetid}
a660d684 717
4fabb575 718\func{void}{SetId}{\param{const wxTreeItemId\&}{ id}}
a660d684 719
4fabb575 720Sets the item associated with this node.
a660d684 721