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