1 \section{\class{wxTreeCtrl
}}\label{wxtreectrl
}
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.
6 To intercept events from a tree control, use the event table macros described in
\helpref{wxTreeEvent
}{wxtreeevent
}.
8 \wxheading{Derived from
}
10 \helpref{wxControl
}{wxcontrol
}\\
11 \helpref{wxWindow
}{wxwindow
}\\
12 \helpref{wxEvtHandler
}{wxevthandler
}\\
13 \helpref{wxObject
}{wxobject
}
15 \wxheading{Include files
}
19 \wxheading{Window styles
}
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
32 See also
\helpref{window styles overview
}{windowstyles
}.
34 \wxheading{Event handling
}
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.
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.
}
57 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{wxTreeCtrl overview
}{wxtreectrloverview
},
\helpref{wxListBox
}{wxlistbox
},
\helpref{wxListCtrl
}{wxlistctrl
},
\rtfsp
58 \helpref{wxImageList
}{wximagelist
},
\helpref{wxTreeEvent
}{wxtreeevent
}
60 \latexignore{\rtfignore{\wxheading{Members
}}}
62 \membersection{wxTreeCtrl::wxTreeCtrl
}\label{wxtreectrlconstr
}
64 \func{}{wxTreeCtrl
}{\void}
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"
}}
72 Constructor, creating and showing a tree control.
74 \wxheading{Parameters
}
76 \docparam{parent
}{Parent window. Must not be NULL.
}
78 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
80 \docparam{pos
}{Window position.
}
82 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
85 \docparam{style
}{Window style. See
\helpref{wxTreeCtrl
}{wxtreectrl
}.
}
87 \docparam{validator
}{Window validator.
}
89 \docparam{name
}{Window name.
}
93 \helpref{wxTreeCtrl::Create
}{wxtreectrlcreate
},
\helpref{wxValidator
}{wxvalidator
}
95 \membersection{wxTreeCtrl::
\destruct{wxTreeCtrl
}}
97 \func{void
}{\destruct{wxTreeCtrl
}}{\void}
99 Destructor, destroying the list control.
101 \membersection{wxTreeCtrl::AddRoot
}\label{wxtreectrladdroot
}
103 \func{wxTreeItemId
}{AddRoot
}{\param{const wxString\&
}{ text
},
104 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
106 Adds the root node to the tree, returning the new item.
108 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
109 both selected and unselected items.
111 \membersection{wxTreeCtrl::AppendItem
}\label{wxtreectrlappenditem
}
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
}}
116 Appends an item to the end of the branch identified by
{\it parent
}, return a new item id.
118 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
119 both selected and unselected items.
121 \membersection{wxTreeCtrl::Collapse
}\label{wxtreectrlcollapse
}
123 \func{void
}{Collapse
}{\param{const wxTreeItemId\&
}{ item
}}
125 Collapses the given item.
127 \membersection{wxTreeCtrl::CollapseAndReset
}\label{wxtreectrlcollapseandreset
}
129 \func{void
}{CollapseAndReset
}{\param{const wxTreeItemId\&
}{ item
}}
131 Collapses the given item and removes all children.
133 \membersection{wxTreeCtrl::Create
}\label{wxtreectrlcreate
}
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"
}}
139 Creates the tree control. See
\helpref{wxTreeCtrl::wxTreeCtrl
}{wxtreectrlconstr
} for further details.
141 \membersection{wxTreeCtrl::Delete
}\label{wxtreectrldelete
}
143 \func{void
}{Delete
}{\param{const wxTreeItemId\&
}{ item
}}
145 Deletes the specified item.
147 \membersection{wxTreeCtrl::DeleteAllItems
}\label{wxtreectrldeleteallitems
}
149 \func{void
}{DeleteAllItems
}{\void}
151 Deletes all the items in the control.
153 \membersection{wxTreeCtrl::EditLabel
}\label{wxtreectrleditlabel
}
155 \func{void
}{EditLabel
}{\param{const wxTreeItemId\&
}{ item
}}
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.
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.
167 \helpref{wxTreeCtrl::EndEditLabel
}{wxtreectrlendeditlabel
},
168 \helpref{wxTreeEvent
}{wxtreeevent
}
170 \membersection{wxTreeCtrl::EndEditLabel
}\label{wxtreectrlendeditlabel
}
172 \func{void
}{EndEditLabel
}{\param{bool
}{cancelEdit
}}
174 Ends label editing. If
{\it cancelEdit
} is TRUE, the edit will be cancelled.
176 This function is currently supported under Windows only.
180 \helpref{wxTreeCtrl::EditLabel
}{wxtreectrleditlabel
}
182 \membersection{wxTreeCtrl::EnsureVisible
}\label{wxtreectrlensurevisible
}
184 \func{void
}{EnsureVisible
}{\param{const wxTreeItemId\&
}{ item
}}
186 Scrolls and/or expands items to ensure that the given item is visible.
188 \membersection{wxTreeCtrl::Expand
}\label{wxtreectrlexpand
}
190 \func{void
}{Expand
}{\param{const wxTreeItemId\&
}{ item
}}
192 Expands the given item.
194 \membersection{wxTreeCtrl::GetBoundingRect
}\label{wxtreectrlgetitemrect
}
196 \constfunc{bool
}{GetBoundingRect
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxRect\&
}{rect
},
\param{bool
}{textOnly = FALSE
}}
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.
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.
206 \membersection{wxTreeCtrl::GetChildrenCount
}\label{wxtreectrlgetchildrencount
}
208 \constfunc{size
\_t}{GetChildrenCount
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{ recursively = TRUE
}}
210 Returns the number of items in the branch. If
{\it recursively
} is TRUE, returns the total number
211 of descendants, otherwise only one level of children is counted.
213 \membersection{wxTreeCtrl::GetCount
}\label{wxtreectrlgetcount
}
215 \constfunc{int
}{GetCount
}{\void}
217 Returns the number of items in the control.
219 \membersection{wxTreeCtrl::GetEditControl
}\label{wxtreectrlgeteditcontrol
}
221 \constfunc{wxTextCtrl\&
}{GetEditControl
}{\void}
223 Returns the edit control used to edit a label.
225 \membersection{wxTreeCtrl::GetFirstChild
}\label{wxtreectrlgetfirstchild
}
227 \constfunc{wxTreeItemId
}{GetFirstChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
229 Returns the first child; call
\helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
} for the next child.
231 For this enumeration function you must pass in a `cookie' parameter
232 which is opaque for the application but is necessary for the library
233 to make these functions reentrant (i.e. allow more than one
234 enumeration on one and the same object simultaneously). The cookie passed to
235 GetFirstChild and GetNextChild should be the same.
237 Returns an invalid tree item if there are no further children.
241 \helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
}
243 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
244 value are both returned as a tuple containing the two values.
}
246 \membersection{wxTreeCtrl::GetFirstVisibleItem
}\label{wxtreectrlgetfirstvisibleitem
}
248 \constfunc{wxTreeItemId
}{GetFirstVisibleItem
}{\void}
250 Returns the first visible item.
252 \membersection{wxTreeCtrl::GetImageList
}\label{wxtreectrlgetimagelist
}
254 \constfunc{wxImageList*
}{GetImageList
}{\param{int
}{which = wxIMAGE
\_LIST\_NORMAL}}
256 Returns the specified image list.
{\it which
} may be one of:
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).
}
265 \membersection{wxTreeCtrl::GetIndent
}\label{wxtreectrlgetindent
}
267 \constfunc{int
}{GetIndent
}{\void}
269 Returns the current tree control indentation.
271 \membersection{wxTreeCtrl::GetItemData
}\label{wxtreectrlgetitemdata
}
273 \constfunc{wxTreeItemData*
}{GetItemData
}{\param{const wxTreeItemId\&
}{ item
}}
275 Returns the tree item data associated with the item.
279 \helpref{wxTreeItemData
}{wxtreeitemdata
}
281 \pythonnote{wxPython provides the following shortcut method:
\par
282 \indented{2cm
}{\begin{twocollist
}
283 \twocolitem{\bf{GetPyData(item)
}}{Returns the Python Object
284 associated with the wxTreeItemData for the given item Id.
}
288 \membersection{wxTreeCtrl::GetItemImage
}\label{wxtreectrlgetitemimage
}
290 \constfunc{int
}{GetItemImage
}{\param{const wxTreeItemId\&
}{item
},
291 \param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
293 Gets the specified item image. The value of
{\it which
} may be:
294 \begin{itemize
}\itemsep=
0pt
295 \item{wxTreeItemIcon
\_Normal} to get the normal item image
296 \item{wxTreeItemIcon
\_Selected} to get the selected item image (i.e. the image
297 which is shown when the item is currently selected)
298 \item{wxTreeItemIcon
\_Expanded} to get the expanded image (this only
299 makes sense for items which have children - then this image is shown when the
300 item is expanded and the normal image is shown when it is collapsed)
301 \item{wxTreeItemIcon
\_SelectedExpanded} to get the selected expanded image
302 (which is shown when an expanded item is currently selected)
305 \membersection{wxTreeCtrl::GetItemText
}\label{wxtreectrlgetitemtext
}
307 \constfunc{wxString
}{GetItemText
}{\param{const wxTreeItemId\&
}{ item
}}
309 Returns the item label.
311 \membersection{wxTreeCtrl::GetLastChild
}\label{wxtreectrlgetlastchild
}
313 \constfunc{wxTreeItemId
}{GetLastChild
}{\param{const wxTreeItemId\&
}{ item
}}
315 Returns the last child of the item (or an invalid tree item if this item has no children).
319 \helpref{GetFirstChild
}{wxtreectrlgetfirstchild
},
320 \helpref{GetLastChild
}{wxtreectrlgetlastchild
}
322 \membersection{wxTreeCtrl::GetNextChild
}\label{wxtreectrlgetnextchild
}
324 \constfunc{wxTreeItemId
}{GetNextChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
326 Returns the next child; call
\helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
} for the first child.
328 For this enumeration function you must pass in a `cookie' parameter
329 which is opaque for the application but is necessary for the library
330 to make these functions reentrant (i.e. allow more than one
331 enumeration on one and the same object simultaneously). The cookie passed to
332 GetFirstChild and GetNextChild should be the same.
334 Returns an invalid tree item if there are no further children.
338 \helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
}
340 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
341 value are both returned as a tuple containing the two values.
}
343 \membersection{wxTreeCtrl::GetNextSibling
}\label{wxtreectrlgetnextsibling
}
345 \constfunc{wxTreeItemId
}{GetNextSibling
}{\param{const wxTreeItemId\&
}{ item
}}
347 Returns the next sibling of the specified item; call
\helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
} for the previous sibling.
349 Returns an invalid tree item if there are no further siblings.
353 \helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
}
355 \membersection{wxTreeCtrl::GetNextVisible
}\label{wxtreectrlgetnextvisible
}
357 \constfunc{wxTreeItemId
}{GetNextVisible
}{\param{const wxTreeItemId\&
}{ item
}}
359 Returns the next visible item.
361 \membersection{wxTreeCtrl::GetParent
}\label{wxtreectrlgetparent
}
363 \constfunc{wxTreeItemId
}{GetParent
}{\param{const wxTreeItemId\&
}{ item
}}
365 Returns the item's parent.
367 \membersection{wxTreeCtrl::GetPrevSibling
}\label{wxtreectrlgetprevsibling
}
369 \constfunc{wxTreeItemId
}{GetPrevSibling
}{\param{const wxTreeItemId\&
}{ item
}}
371 Returns the previous sibling of the specified item; call
\helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
} for the next sibling.
373 Returns an invalid tree item if there are no further children.
377 \helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
}
379 \membersection{wxTreeCtrl::GetPrevVisible
}\label{wxtreectrlgetprevvisible
}
381 \constfunc{wxTreeItemId
}{GetPrevVisible
}{\param{const wxTreeItemId\&
}{ item
}}
383 Returns the previous visible item.
385 \membersection{wxTreeCtrl::GetRootItem
}\label{wxtreectrlgetrootitem
}
387 \constfunc{wxTreeItemId
}{GetRootItem
}{\void}
389 Returns the root item for the tree control.
391 \membersection{wxTreeCtrl::GetItemSelectedImage
}\label{wxtreectrlgetitemselectedimage
}
393 \constfunc{int
}{GetItemSelectedImage
}{\param{const wxTreeItemId\&
}{item
}}
395 Gets the selected item image (this function is obsolete, use
396 {\tt GetItemImage(item, wxTreeItemIcon
\_Selected} instead).
398 \membersection{wxTreeCtrl::GetSelection
}\label{wxtreectrlgetselection
}
400 \constfunc{wxTreeItemId
}{GetSelection
}{\void}
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
407 \membersection{wxTreeCtrl::GetSelections
}\label{wxtreectrlgetselections
}
409 \constfunc{size
\_t}{GetSelections
}{\param{wxArrayTreeItemIds\&
}{selection
}}
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.
414 Returns the number of selected items.
416 \membersection{wxTreeCtrl::HitTest
}\label{wxtreectrlhittest
}
418 \func{long
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{int\&
}{flags
}}
420 Calculates which (if any) item is under the given point, returning extra information
421 in
{\it flags
}.
{\it flags
} is a bitlist of the following:
424 \begin{twocollist
}\itemsep=
0pt
425 \twocolitem{wxTREE
\_HITTEST\_ABOVE}{Above the client area.
}
426 \twocolitem{wxTREE
\_HITTEST\_BELOW}{Below the client area.
}
427 \twocolitem{wxTREE
\_HITTEST\_NOWHERE}{In the client area but below the last item.
}
428 \twocolitem{wxTREE
\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.
}
429 \twocolitem{wxTREE
\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.
}
430 \twocolitem{wxTREE
\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.
}
431 \twocolitem{wxTREE
\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.
}
432 \twocolitem{wxTREE
\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.
}
433 \twocolitem{wxTREE
\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.
}
434 \twocolitem{wxTREE
\_HITTEST\_TOLEFT}{To the right of the client area.
}
435 \twocolitem{wxTREE
\_HITTEST\_TORIGHT}{To the left of the client area.
}
438 \membersection{wxTreeCtrl::InsertItem
}\label{wxtreectrlinsertitem
}
440 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxTreeItemId\&
}{previous
},
\param{const wxString\&
}{ text
},
441 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
443 Inserts an item after a given one.
445 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
446 both selected and unselected items.
448 \membersection{wxTreeCtrl::IsBold
}\label{wxtreectrlisbold
}
450 \constfunc{bool
}{IsBold
}{\param{const wxTreeItemId\&
}{item
}}
452 Returns TRUE if the given item is in bold state.
454 See also:
\helpref{SetItemBold
}{wxtreectrlsetitembold
}
456 \membersection{wxTreeCtrl::IsExpanded
}\label{wxtreectrlisexpanded
}
458 \constfunc{bool
}{IsExpanded
}{\param{const wxTreeItemId\&
}{ item
}}
460 Returns TRUE if the item is expanded (only makes sense if it has children).
462 \membersection{wxTreeCtrl::IsSelected
}\label{wxtreectrlisselected
}
464 \constfunc{bool
}{IsSelected
}{\param{const wxTreeItemId\&
}{ item
}}
466 Returns TRUE if the item is selected.
468 \membersection{wxTreeCtrl::IsVisible
}\label{wxtreectrlisvisible
}
470 \constfunc{bool
}{IsVisible
}{\param{const wxTreeItemId\&
}{ item
}}
472 Returns TRUE if the item is visible (it might be outside the view, or not expanded).
474 \membersection{wxTreeCtrl::ItemHasChildren
}\label{wxtreectrlitemhaschildren
}
476 \constfunc{bool
}{ItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
}}
478 Returns TRUE if the item has children.
480 \membersection{wxTreeCtrl::OnCompareItems
}\label{wxtreectrloncompareitems
}
482 \func{int
}{OnCompareItems
}{\param{const wxTreeItemId\&
}{item1
},
\param{const wxTreeItemId\&
}{item2
}}
484 Override this function in the derived class to change the sort order of the
485 items in the tree control. The function should return a negative, zero or
486 positive value if the first item is less than, equal to or greater than the
489 The base class version compares items alphabetically.
491 See also:
\helpref{SortChildren
}{wxtreectrlsortchildren
}
493 \membersection{wxTreeCtrl::PrependItem
}\label{wxtreectrlprependitem
}
495 \func{wxTreeItemId
}{PrependItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
496 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
498 Appends an item as the first child of
{\it parent
}, return a new item id.
500 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
501 both selected and unselected items.
503 \membersection{wxTreeCtrl::ScrollTo
}\label{wxtreectrlscrollto
}
505 \func{void
}{ScrollTo
}{\param{const wxTreeItemId\&
}{ item
}}
507 Scrolls the specified item into view.
509 \membersection{wxTreeCtrl::SelectItem
}\label{wxtreectrlselectitem
}
511 \func{bool
}{SelectItem
}{\param{const wxTreeItemId\&
}{ item
}}
513 Selects the given item.
515 \membersection{wxTreeCtrl::SetIndent
}\label{wxtreectrlsetindent
}
517 \func{void
}{SetIndent
}{\param{int
}{indent
}}
519 Sets the indentation for the tree control.
521 \membersection{wxTreeCtrl::SetImageList
}\label{wxtreectrlsetimagelist
}
523 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
},
\param{int
}{which = wxIMAGE
\_LIST\_NORMAL}}
525 Sets the image list.
{\it which
} should be one of wxIMAGE
\_LIST\_NORMAL, wxIMAGE
\_LIST\_SMALL and
526 wxIMAGE
\_LIST\_STATE.
528 \membersection{wxTreeCtrl::SetItemBold
}\label{wxtreectrlsetitembold
}
530 \func{void
}{SetItemBold
}{\param{const wxTreeItemId\&
}{item
},
\param{bool
}{ bold = TRUE
}}
532 Makes item appear in bold font if
{\it bold
} parameter is TRUE or resets it to
535 See also:
\helpref{IsBold
}{wxtreectrlisbold
}
537 \membersection{wxTreeCtrl::SetItemData
}\label{wxtreectrlsetitemdata
}
539 \func{void
}{SetItemData
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxTreeItemData*
}{data
}}
541 Sets the item client data.
543 \pythonnote{wxPython provides the following shortcut method:
\par
544 \indented{2cm
}{\begin{twocollist
}
545 \twocolitem{\bf{SetPyData(item, obj)
}}{Associate the given Python
546 Object with the wxTreeItemData for the given item Id.
}
550 \membersection{wxTreeCtrl::SetItemHasChildren
}\label{wxtreectrlsetitemhaschildren
}
552 \func{void
}{SetItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{hasChildren = TRUE
}}
554 Force appearance of the button next to the item. This is useful to
555 allow the user to expand the items which don't have any children now,
556 but instead adding them only when needed, thus minimizing memory
557 usage and loading time.
559 \membersection{wxTreeCtrl::SetItemImage
}\label{wxtreectrlsetitemimage
}
561 \func{void
}{SetItemImage
}{\param{const wxTreeItemId\&
}{ item
},
563 \param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
565 Sets the specified item image. See
\helpref{GetItemImage
}{wxtreectrlgetitemimage
}
566 for the description of
{\it which
} parameter.
568 \membersection{wxTreeCtrl::SetItemSelectedImage
}\label{wxtreectrlsetitemselectedimage
}
570 \func{void
}{SetItemSelectedImage
}{\param{const wxTreeItemId\&
}{ item
},
\param{int
}{selImage
}}
572 Sets the selected item image (this function is obsolete, use
573 {\tt SetItemImage(item, wxTreeItemIcon
\_Selected} instead).
575 \membersection{wxTreeCtrl::SetItemText
}\label{wxtreectrlsetitemtext
}
577 \func{void
}{SetItemText
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxString\&
}{text
}}
581 \membersection{wxTreeCtrl::SortChildren
}\label{wxtreectrlsortchildren
}
583 \func{void
}{SortChildren
}{\param{const wxTreeItemId\&
}{ item
}}
585 Sorts the children of the given item using
586 \helpref{OnCompareItems
}{wxtreectrloncompareitems
} method of wxTreeCtrl. You
587 should override that method to change the sort order (default is ascending
592 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{OnCompareItems
}{wxtreectrloncompareitems
}
594 \membersection{wxTreeCtrl::Toggle
}\label{wxtreectrltoggle
}
596 \func{void
}{Toggle
}{\param{const wxTreeItemId\&
}{ item
}}
598 Toggles the given item between collapsed and expanded states.
600 \membersection{wxTreeCtrl::Unselect
}\label{wxtreectrlunselect
}
602 \func{void
}{Unselect
}{\void}
604 Removes the selection from the currently selected item (if any).
606 \membersection{wxTreeCtrl::UnselectAll
}\label{wxtreectrlunselectall
}
608 \func{void
}{UnselectAll
}{\void}
610 This function either behaves the same as
\helpref{Unselect
}{wxtreectrlunselect
}
611 if the control doesn't have wxTR
\_MULTIPLE style, or removes the selection from
612 all items if it does have this style.
614 \section{\class{wxTreeItemData
}}\label{wxtreeitemdata
}
616 wxTreeItemData is some (arbitrary) user class associated with some item. The
617 main advantage of having this class (compared to the old untyped interface) is
618 that wxTreeItemData's are destroyed automatically by the tree and, as this
619 class has virtual dtor, it means that the memory will be automatically
620 freed. We don't just use wxObject instead of wxTreeItemData because
621 the size of this class is critical: in any real application, each tree leaf
622 will have wxTreeItemData associated with it and number of leaves may be
625 Because the objects of this class are deleted by the tree, they should
626 always be allocated on the heap.
628 \wxheading{Derived from
}
632 \wxheading{Include files
}
638 \helpref{wxTreeCtrl
}{wxtreectrl
}
640 \latexignore{\rtfignore{\wxheading{Members
}}}
642 \membersection{wxTreeItemData::wxTreeItemData
}\label{wxtreeitemdataconstr
}
644 \func{}{wxTreeItemData
}{\void}
648 \pythonnote{The wxPython version of this constructor optionally
649 accepts any Python object as a parameter. This object is then
650 associated with the tree item using the wxTreeItemData as a
653 In addition, the following methods are added in wxPython for accessing
655 \indented{2cm
}{\begin{twocollist
}
656 \twocolitem{\bf{GetData()
}}{Returns a reference to the Python Object
}
657 \twocolitem{\bf{SetData(obj)
}}{Associates a new Python Object with the
663 \membersection{wxTreeItemData::
\destruct{wxTreeItemData
}}
665 \func{void
}{\destruct{wxTreeItemData
}}{\void}
669 \membersection{wxTreeItemData::GetId
}\label{wxtreeitemdatagetid
}
671 \func{const wxTreeItem\&
}{GetId
}{\void}
673 Returns the item associated with this node.
675 \membersection{wxTreeItemData::SetId
}\label{wxtreeitemdatasetid
}
677 \func{void
}{SetId
}{\param{const wxTreeItemId\&
}{ id
}}
679 Sets the item associated with this node.