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
\_EDIT\_LABELS}}{Use this style
24 if you wish the user to be able to edit labels in the tree control.
}
25 \twocolitem{\windowstyle{wxTR
\_NO\_BUTTONS}}{For convenience
26 to
document that no buttons are to be drawn.
}
27 \twocolitem{\windowstyle{wxTR
\_HAS\_BUTTONS}}{Use this style
28 to show + and - buttons to the left of parent items.
}
29 \twocolitem{\windowstyle{wxTR
\_TWIST\_BUTTONS}}{Use this style
30 to show Mac-style twister buttons to the left of parent items.
31 If both wxTR
\_HAS\_BUTTONS and wxTR
\_TWIST\_BUTTONS are given,
32 twister buttons are generated. Generic only.
}
33 \twocolitem{\windowstyle{wxTR
\_NO\_LINES}}{Use this style
34 to hide vertical level connectors.
}
35 \twocolitem{\windowstyle{wxTR
\_LINES\_AT\_ROOT}}{Use this style
36 to show lines between root nodes.
37 Only applicable if wxTR
\_HIDE\_ROOT is set and wxTR
\_NO\_LINES is not set.
}
38 \twocolitem{\windowstyle{wxTR
\_HIDE\_ROOT}}{Use this style
39 to suppress the display of the root node,
40 effectively causing the first-level nodes
41 to appear as a series of root nodes. Generic only.
}
42 \twocolitem{\windowstyle{wxTR
\_ROW\_LINES}}{Use this style
43 to draw a contrasting border between displayed rows.
}
44 \twocolitem{\windowstyle{wxTR
\_HAS\_VARIABLE\_ROW\_HEIGHT}}{Use this style
45 to cause row heights to be just big enough to fit the content.
46 If not set, all rows use the largest row height.
47 The default is that this flag is unset.
49 \twocolitem{\windowstyle{wxTR
\_SINGLE}}{For convenience
50 to
document that only one item may be selected at a time.
51 Selecting another item causes the current selection, if any,
52 to be deselected. This is the default.
}
53 \twocolitem{\windowstyle{wxTR
\_MULTIPLE}}{Use this style
54 to allow a range of items to be selected.
55 If a second range is selected, the current range, if any, is deselected.
}
56 \twocolitem{\windowstyle{wxTR
\_EXTENDED}}{Use this style
57 to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.)
}
58 \twocolitem{\windowstyle{wxTR
\_DEFAULT\_STYLE}}{The set of flags that are
59 closest to the defaults for the native control for a particular toolkit.
}
62 See also
\helpref{window styles overview
}{windowstyles
}.
64 \wxheading{Event handling
}
66 To process input from a tree control, use these event handler macros to direct input to member
67 functions that take a
\helpref{wxTreeEvent
}{wxtreeevent
} argument.
70 \begin{twocollist
}\itemsep=
0pt
71 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_DRAG(id, func)
}}{Begin dragging with the left mouse button.
}
72 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_RDRAG(id, func)
}}{Begin dragging with the right mouse button.
}
73 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_LABEL\_EDIT(id, func)
}}{Begin editing a label. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
74 \twocolitem{{\bf EVT
\_TREE\_END\_LABEL\_EDIT(id, func)
}}{Finish editing a label. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
75 \twocolitem{{\bf EVT
\_TREE\_DELETE\_ITEM(id, func)
}}{Delete an item.
}
76 \twocolitem{{\bf EVT
\_TREE\_GET\_INFO(id, func)
}}{Request information from the application.
}
77 \twocolitem{{\bf EVT
\_TREE\_SET\_INFO(id, func)
}}{Information is being supplied.
}
78 \twocolitem{{\bf EVT
\_TREE\_ITEM\_ACTIVATED(id, func)
}}{The item has been activated, i.e. chosen by double clicking it with mouse or from keyboard
}
79 \twocolitem{{\bf EVT
\_TREE\_ITEM\_COLLAPSED(id, func)
}}{The item has been collapsed.
}
80 \twocolitem{{\bf EVT
\_TREE\_ITEM\_COLLAPSING(id, func)
}}{The item is being collapsed. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
81 \twocolitem{{\bf EVT
\_TREE\_ITEM\_EXPANDED(id, func)
}}{The item has been expanded.
}
82 \twocolitem{{\bf EVT
\_TREE\_ITEM\_EXPANDING(id, func)
}}{The item is being expanded. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
83 \twocolitem{{\bf EVT
\_TREE\_SEL\_CHANGED(id, func)
}}{Selection has changed.
}
84 \twocolitem{{\bf EVT
\_TREE\_SEL\_CHANGING(id, func)
}}{Selection is changing. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
85 \twocolitem{{\bf EVT
\_TREE\_KEY\_DOWN(id, func)
}}{A key has been pressed.
}
90 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{wxTreeCtrl overview
}{wxtreectrloverview
},
\helpref{wxListBox
}{wxlistbox
},
\helpref{wxListCtrl
}{wxlistctrl
},
\rtfsp
91 \helpref{wxImageList
}{wximagelist
},
\helpref{wxTreeEvent
}{wxtreeevent
}
93 \wxheading{Win32 notes
}
95 wxTreeCtrl class uses the standard common treeview control under Win32
96 implemented in the system library
{\tt comctl32.dll
}. Some versions of this
97 library are known to have bugs with handling the tree control colours: the
98 usual symptom is that the expanded items leave black (or otherwise incorrectly
99 coloured) background behind them, especially for the controls using non
100 default background colour. The recommended solution is to upgrade the
{\tt comctl32.dll
}
101 to a newer version: see
102 \urlref{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
}{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
}.
104 \latexignore{\rtfignore{\wxheading{Members
}}}
106 \membersection{wxTreeCtrl::wxTreeCtrl
}\label{wxtreectrlconstr
}
108 \func{}{wxTreeCtrl
}{\void}
112 \func{}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
113 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
114 \param{long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
116 Constructor, creating and showing a tree control.
118 \wxheading{Parameters
}
120 \docparam{parent
}{Parent window. Must not be NULL.
}
122 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
124 \docparam{pos
}{Window position.
}
126 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
129 \docparam{style
}{Window style. See
\helpref{wxTreeCtrl
}{wxtreectrl
}.
}
131 \docparam{validator
}{Window validator.
}
133 \docparam{name
}{Window name.
}
137 \helpref{wxTreeCtrl::Create
}{wxtreectrlcreate
},
\helpref{wxValidator
}{wxvalidator
}
139 \membersection{wxTreeCtrl::
\destruct{wxTreeCtrl
}}
141 \func{void
}{\destruct{wxTreeCtrl
}}{\void}
143 Destructor, destroying the list control.
145 \membersection{wxTreeCtrl::AddRoot
}\label{wxtreectrladdroot
}
147 \func{wxTreeItemId
}{AddRoot
}{\param{const wxString\&
}{ text
},
148 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
150 Adds the root node to the tree, returning the new item.
152 The
{\it image
} and
{\it selImage
} parameters are an index within
153 the normal image list specifying the image to use for unselected and
154 selected items, respectively.
155 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
156 both selected and unselected items.
158 \membersection{wxTreeCtrl::AppendItem
}\label{wxtreectrlappenditem
}
160 \func{wxTreeItemId
}{AppendItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
161 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
163 Appends an item to the end of the branch identified by
{\it parent
}, return a new item id.
165 The
{\it image
} and
{\it selImage
} parameters are an index within
166 the normal image list specifying the image to use for unselected and
167 selected items, respectively.
168 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
169 both selected and unselected items.
171 \membersection{wxTreeCtrl::AssignButtonsImageList
}\label{wxtreectrlassignbuttonsimagelist
}
173 \func{void
}{AssignButtonsImageList
}{\param{wxImageList*
}{ imageList
}}
175 Sets the buttons image list. The button images assigned with this method will
176 be automatically deleted by wxTreeCtrl as appropriate
177 (i.e. it takes ownership of the list).
179 Setting or assigning the button image list enables the display of image buttons.
180 Once enabled, the only way to disable the display of button images is to set
181 the button image list to NULL.
183 This function is only available in the generic version.
185 See also
\helpref{SetButtonsImageList
}{wxtreectrlsetbuttonsimagelist
}.
187 \membersection{wxTreeCtrl::AssignImageList
}\label{wxtreectrlassignimagelist
}
189 \func{void
}{AssignImageList
}{\param{wxImageList*
}{ imageList
}}
191 Sets the normal image list. Image list assigned with this method will
192 be automatically deleted by wxTreeCtrl as appropriate
193 (i.e. it takes ownership of the list).
195 See also
\helpref{SetImageList
}{wxtreectrlsetimagelist
}.
197 \membersection{wxTreeCtrl::AssignStateImageList
}\label{wxtreectrlassignstateimagelist
}
199 \func{void
}{AssignStateImageList
}{\param{wxImageList*
}{ imageList
}}
201 Sets the state image list. Image list assigned with this method will
202 be automatically deleted by wxTreeCtrl as appropriate
203 (i.e. it takes ownership of the list).
205 See also
\helpref{SetStateImageList
}{wxtreectrlsetstateimagelist
}.
208 \membersection{wxTreeCtrl::Collapse
}\label{wxtreectrlcollapse
}
210 \func{void
}{Collapse
}{\param{const wxTreeItemId\&
}{ item
}}
212 Collapses the given item.
214 \membersection{wxTreeCtrl::CollapseAndReset
}\label{wxtreectrlcollapseandreset
}
216 \func{void
}{CollapseAndReset
}{\param{const wxTreeItemId\&
}{ item
}}
218 Collapses the given item and removes all children.
220 \membersection{wxTreeCtrl::Create
}\label{wxtreectrlcreate
}
222 \func{bool
}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
223 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
224 \param{long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
226 Creates the tree control. See
\helpref{wxTreeCtrl::wxTreeCtrl
}{wxtreectrlconstr
} for further details.
228 \membersection{wxTreeCtrl::Delete
}\label{wxtreectrldelete
}
230 \func{void
}{Delete
}{\param{const wxTreeItemId\&
}{ item
}}
232 Deletes the specified item.
234 \membersection{wxTreeCtrl::DeleteAllItems
}\label{wxtreectrldeleteallitems
}
236 \func{void
}{DeleteAllItems
}{\void}
238 Deletes all the items in the control.
240 \membersection{wxTreeCtrl::EditLabel
}\label{wxtreectrleditlabel
}
242 \func{void
}{EditLabel
}{\param{const wxTreeItemId\&
}{ item
}}
244 Starts editing the label of the given item. This function generates a
245 EVT
\_TREE\_BEGIN\_LABEL\_EDIT event which can be vetoed so that no
246 text control will appear for in-place editing.
248 If the user changed the label (i.e. s/he does not press ESC or leave
249 the text control without changes, a EVT
\_TREE\_END\_LABEL\_EDIT event
250 will be sent which can be vetoed as well.
254 \helpref{wxTreeCtrl::EndEditLabel
}{wxtreectrlendeditlabel
},
255 \helpref{wxTreeEvent
}{wxtreeevent
}
257 \membersection{wxTreeCtrl::EndEditLabel
}\label{wxtreectrlendeditlabel
}
259 \func{void
}{EndEditLabel
}{\param{bool
}{cancelEdit
}}
261 Ends label editing. If
{\it cancelEdit
} is TRUE, the edit will be cancelled.
263 This function is currently supported under Windows only.
267 \helpref{wxTreeCtrl::EditLabel
}{wxtreectrleditlabel
}
269 \membersection{wxTreeCtrl::EnsureVisible
}\label{wxtreectrlensurevisible
}
271 \func{void
}{EnsureVisible
}{\param{const wxTreeItemId\&
}{ item
}}
273 Scrolls and/or expands items to ensure that the given item is visible.
275 \membersection{wxTreeCtrl::Expand
}\label{wxtreectrlexpand
}
277 \func{void
}{Expand
}{\param{const wxTreeItemId\&
}{ item
}}
279 Expands the given item.
281 \membersection{wxTreeCtrl::GetBoundingRect
}\label{wxtreectrlgetitemrect
}
283 \constfunc{bool
}{GetBoundingRect
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxRect\&
}{rect
},
\param{bool
}{textOnly = FALSE
}}
285 Retrieves the rectangle bounding the
{\it item
}. If
{\it textOnly
} is TRUE,
286 only the rectangle around the item's label will be returned, otherwise the
287 item's image is also taken into account.
289 The return value is TRUE if the rectangle was successfully retrieved or FALSE
290 if it was not (in this case
{\it rect
} is not changed) - for example, if the
291 item is currently invisible.
293 \pythonnote{The wxPython version of this method requires only the
294 {\tt item
} and
{\tt textOnly
} parameters. The return value is either a
295 {\tt wxRect
} object or
{\tt None
}.
}
297 \perlnote{In wxPerl this method only takes the parameters
{\tt item
} and
298 {\tt textOnly
}, and returns a Wx::Rect ( or undef ).
}
300 \membersection{wxTreeCtrl::GetButtonsImageList
}\label{wxtreectrlgetbuttonsimagelist
}
302 \constfunc{wxImageList*
}{GetButtonsImageList
}{\void}
304 Returns the buttons image list (from which application-defined button images are taken).
306 This function is only available in the generic version.
308 \membersection{wxTreeCtrl::GetChildrenCount
}\label{wxtreectrlgetchildrencount
}
310 \constfunc{size
\_t}{GetChildrenCount
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{ recursively = TRUE
}}
312 Returns the number of items in the branch. If
{\it recursively
} is TRUE, returns the total number
313 of descendants, otherwise only one level of children is counted.
315 \membersection{wxTreeCtrl::GetCount
}\label{wxtreectrlgetcount
}
317 \constfunc{int
}{GetCount
}{\void}
319 Returns the number of items in the control.
321 \membersection{wxTreeCtrl::GetEditControl
}\label{wxtreectrlgeteditcontrol
}
323 \constfunc{wxTextCtrl\&
}{GetEditControl
}{\void}
325 Returns the edit control used to edit a label.
327 \membersection{wxTreeCtrl::GetFirstChild
}\label{wxtreectrlgetfirstchild
}
329 \constfunc{wxTreeItemId
}{GetFirstChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
331 Returns the first child; call
\helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
} for the next child.
333 For this enumeration function you must pass in a `cookie' parameter
334 which is opaque for the application but is necessary for the library
335 to make these functions reentrant (i.e. allow more than one
336 enumeration on one and the same object simultaneously). The cookie passed to
337 GetFirstChild and GetNextChild should be the same.
339 Returns an invalid tree item if there are no further children.
343 \helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
}
345 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
346 value are both returned as a tuple containing the two values.
}
348 \perlnote{In wxPerl this method only takes the
{\tt item
} parameter, and
349 returns a
2-element list ( item, cookie ).
}
351 \membersection{wxTreeCtrl::GetFirstVisibleItem
}\label{wxtreectrlgetfirstvisibleitem
}
353 \constfunc{wxTreeItemId
}{GetFirstVisibleItem
}{\void}
355 Returns the first visible item.
357 \membersection{wxTreeCtrl::GetImageList
}\label{wxtreectrlgetimagelist
}
359 \constfunc{wxImageList*
}{GetImageList
}{\void}
361 Returns the normal image list.
363 \membersection{wxTreeCtrl::GetIndent
}\label{wxtreectrlgetindent
}
365 \constfunc{int
}{GetIndent
}{\void}
367 Returns the current tree control indentation.
369 \membersection{wxTreeCtrl::GetItemData
}\label{wxtreectrlgetitemdata
}
371 \constfunc{wxTreeItemData*
}{GetItemData
}{\param{const wxTreeItemId\&
}{ item
}}
373 Returns the tree item data associated with the item.
377 \helpref{wxTreeItemData
}{wxtreeitemdata
}
379 \pythonnote{wxPython provides the following shortcut method:
381 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
382 \twocolitem{{\bf GetPyData(item)
}}{Returns the Python Object
383 associated with the wxTreeItemData for the given item Id.
}
387 \perlnote{wxPerl provides the following shortcut method:
389 \begin{twocollist
}\itemsep=
0pt
390 \twocolitem{{\bf GetPlData( item )
}}{Returns the Perl data
391 associated with the Wx::TreeItemData ( it is just the same as
392 tree->GetItemData( item )->GetData(); ).
}
396 \membersection{wxTreeCtrl::GetItemImage
}\label{wxtreectrlgetitemimage
}
398 \constfunc{int
}{GetItemImage
}{\param{const wxTreeItemId\&
}{item
},
399 \param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
401 Gets the specified item image. The value of
{\it which
} may be:
403 \begin{itemize
}\itemsep=
0pt
404 \item{wxTreeItemIcon
\_Normal} to get the normal item image
405 \item{wxTreeItemIcon
\_Selected} to get the selected item image (i.e. the image
406 which is shown when the item is currently selected)
407 \item{wxTreeItemIcon
\_Expanded} to get the expanded image (this only
408 makes sense for items which have children - then this image is shown when the
409 item is expanded and the normal image is shown when it is collapsed)
410 \item{wxTreeItemIcon
\_SelectedExpanded} to get the selected expanded image
411 (which is shown when an expanded item is currently selected)
414 \membersection{wxTreeCtrl::GetItemText
}\label{wxtreectrlgetitemtext
}
416 \constfunc{wxString
}{GetItemText
}{\param{const wxTreeItemId\&
}{ item
}}
418 Returns the item label.
420 \membersection{wxTreeCtrl::GetLastChild
}\label{wxtreectrlgetlastchild
}
422 \constfunc{wxTreeItemId
}{GetLastChild
}{\param{const wxTreeItemId\&
}{ item
}}
424 Returns the last child of the item (or an invalid tree item if this item has no children).
428 \helpref{GetFirstChild
}{wxtreectrlgetfirstchild
},
429 \helpref{GetLastChild
}{wxtreectrlgetlastchild
}
431 \membersection{wxTreeCtrl::GetNextChild
}\label{wxtreectrlgetnextchild
}
433 \constfunc{wxTreeItemId
}{GetNextChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
435 Returns the next child; call
\helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
} for the first child.
437 For this enumeration function you must pass in a `cookie' parameter
438 which is opaque for the application but is necessary for the library
439 to make these functions reentrant (i.e. allow more than one
440 enumeration on one and the same object simultaneously). The cookie passed to
441 GetFirstChild and GetNextChild should be the same.
443 Returns an invalid tree item if there are no further children.
447 \helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
}
449 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
450 value are both returned as a tuple containing the two values.
}
452 \perlnote{In wxPerl this method returns a
2-element list
453 ( item, cookie ), instead of modifying its parameters.
}
455 \membersection{wxTreeCtrl::GetNextSibling
}\label{wxtreectrlgetnextsibling
}
457 \constfunc{wxTreeItemId
}{GetNextSibling
}{\param{const wxTreeItemId\&
}{ item
}}
459 Returns the next sibling of the specified item; call
\helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
} for the previous sibling.
461 Returns an invalid tree item if there are no further siblings.
465 \helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
}
467 \membersection{wxTreeCtrl::GetNextVisible
}\label{wxtreectrlgetnextvisible
}
469 \constfunc{wxTreeItemId
}{GetNextVisible
}{\param{const wxTreeItemId\&
}{ item
}}
471 Returns the next visible item.
473 \membersection{wxTreeCtrl::GetParent
}\label{wxtreectrlgetparent
}
475 \constfunc{wxTreeItemId
}{GetParent
}{\param{const wxTreeItemId\&
}{ item
}}
477 Returns the item's parent.
479 \pythonnote{This method is named
{\tt GetItemParent
} to avoid a name
480 clash with wxWindow::GetParent.
}
482 \membersection{wxTreeCtrl::GetPrevSibling
}\label{wxtreectrlgetprevsibling
}
484 \constfunc{wxTreeItemId
}{GetPrevSibling
}{\param{const wxTreeItemId\&
}{ item
}}
486 Returns the previous sibling of the specified item; call
\helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
} for the next sibling.
488 Returns an invalid tree item if there are no further children.
492 \helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
}
494 \membersection{wxTreeCtrl::GetPrevVisible
}\label{wxtreectrlgetprevvisible
}
496 \constfunc{wxTreeItemId
}{GetPrevVisible
}{\param{const wxTreeItemId\&
}{ item
}}
498 Returns the previous visible item.
500 \membersection{wxTreeCtrl::GetRootItem
}\label{wxtreectrlgetrootitem
}
502 \constfunc{wxTreeItemId
}{GetRootItem
}{\void}
504 Returns the root item for the tree control.
506 \membersection{wxTreeCtrl::GetItemSelectedImage
}\label{wxtreectrlgetitemselectedimage
}
508 \constfunc{int
}{GetItemSelectedImage
}{\param{const wxTreeItemId\&
}{item
}}
510 Gets the selected item image (this function is obsolete, use
511 {\tt GetItemImage(item, wxTreeItemIcon
\_Selected}) instead).
513 \membersection{wxTreeCtrl::GetSelection
}\label{wxtreectrlgetselection
}
515 \constfunc{wxTreeItemId
}{GetSelection
}{\void}
517 Returns the selection, or an invalid item if there is no selection.
518 This function only works with the controls without wxTR
\_MULTIPLE style, use
519 \helpref{GetSelections
}{wxtreectrlgetselections
} for the controls which do have
522 \membersection{wxTreeCtrl::GetSelections
}\label{wxtreectrlgetselections
}
524 \constfunc{size
\_t}{GetSelections
}{\param{wxArrayTreeItemIds\&
}{selection
}}
526 Fills the array of tree items passed in with the currently selected items. This
527 function can be called only if the control has the wxTR
\_MULTIPLE style.
529 Returns the number of selected items.
531 \pythonnote{The wxPython version of this method accepts no parameters
532 and returns a Python list of
{\tt wxTreeItemId
}s.
}
534 \perlnote{In wxPerl this method takes no parameters and returns a list of
535 {\tt Wx::TreeItemId
}s.
}
537 \membersection{wxTreeCtrl::GetStateImageList
}\label{wxtreectrlgetstateimagelist
}
539 \constfunc{wxImageList*
}{GetStateImageList
}{\void}
541 Returns the state image list (from which application-defined state images are taken).
543 \membersection{wxTreeCtrl::HitTest
}\label{wxtreectrlhittest
}
545 \func{wxTreeItemId
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{int\&
}{flags
}}
547 Calculates which (if any) item is under the given point, returning the tree item
548 id at this point plus extra information
{\it flags
}.
{\it flags
} is a bitlist of the following:
551 \begin{twocollist
}\itemsep=
0pt
552 \twocolitem{wxTREE
\_HITTEST\_ABOVE}{Above the client area.
}
553 \twocolitem{wxTREE
\_HITTEST\_BELOW}{Below the client area.
}
554 \twocolitem{wxTREE
\_HITTEST\_NOWHERE}{In the client area but below the last item.
}
555 \twocolitem{wxTREE
\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.
}
556 \twocolitem{wxTREE
\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.
}
557 \twocolitem{wxTREE
\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.
}
558 \twocolitem{wxTREE
\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.
}
559 \twocolitem{wxTREE
\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.
}
560 \twocolitem{wxTREE
\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.
}
561 \twocolitem{wxTREE
\_HITTEST\_TOLEFT}{To the right of the client area.
}
562 \twocolitem{wxTREE
\_HITTEST\_TORIGHT}{To the left of the client area.
}
565 \pythonnote{in wxPython both the wxTreeItemId and the flags are
566 returned as a tuple.
}
568 \perlnote{In wxPerl this method only takes the
{\tt point
} parameter
569 and returns a
2-element list ( item, flags ).
}
571 \membersection{wxTreeCtrl::InsertItem
}\label{wxtreectrlinsertitem
}
573 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxTreeItemId\&
}{previous
},
\param{const wxString\&
}{ text
},
574 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
576 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{size
\_t}{ before
},
\param{const wxString\&
}{ text
},
577 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
579 Inserts an item after a given one (
{\it previous
}) or before one identified by its position (
{\it before
}).
581 The
{\it image
} and
{\it selImage
} parameters are an index within
582 the normal image list specifying the image to use for unselected and
583 selected items, respectively.
584 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
585 both selected and unselected items.
587 \pythonnote{The second form of this method is called
588 \tt{InsertItemBefore
} in wxPython.
}
590 \membersection{wxTreeCtrl::IsBold
}\label{wxtreectrlisbold
}
592 \constfunc{bool
}{IsBold
}{\param{const wxTreeItemId\&
}{item
}}
594 Returns TRUE if the given item is in bold state.
596 See also:
\helpref{SetItemBold
}{wxtreectrlsetitembold
}
598 \membersection{wxTreeCtrl::IsExpanded
}\label{wxtreectrlisexpanded
}
600 \constfunc{bool
}{IsExpanded
}{\param{const wxTreeItemId\&
}{ item
}}
602 Returns TRUE if the item is expanded (only makes sense if it has children).
604 \membersection{wxTreeCtrl::IsSelected
}\label{wxtreectrlisselected
}
606 \constfunc{bool
}{IsSelected
}{\param{const wxTreeItemId\&
}{ item
}}
608 Returns TRUE if the item is selected.
610 \membersection{wxTreeCtrl::IsVisible
}\label{wxtreectrlisvisible
}
612 \constfunc{bool
}{IsVisible
}{\param{const wxTreeItemId\&
}{ item
}}
614 Returns TRUE if the item is visible (it might be outside the view, or not expanded).
616 \membersection{wxTreeCtrl::ItemHasChildren
}\label{wxtreectrlitemhaschildren
}
618 \constfunc{bool
}{ItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
}}
620 Returns TRUE if the item has children.
622 \membersection{wxTreeCtrl::OnCompareItems
}\label{wxtreectrloncompareitems
}
624 \func{int
}{OnCompareItems
}{\param{const wxTreeItemId\&
}{item1
},
\param{const wxTreeItemId\&
}{item2
}}
626 Override this function in the derived class to change the sort order of the
627 items in the tree control. The function should return a negative, zero or
628 positive value if the first item is less than, equal to or greater than the
631 The base class version compares items alphabetically.
633 See also:
\helpref{SortChildren
}{wxtreectrlsortchildren
}
635 \membersection{wxTreeCtrl::PrependItem
}\label{wxtreectrlprependitem
}
637 \func{wxTreeItemId
}{PrependItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
638 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
640 Appends an item as the first child of
{\it parent
}, return a new item id.
642 The
{\it image
} and
{\it selImage
} parameters are an index within
643 the normal image list specifying the image to use for unselected and
644 selected items, respectively.
645 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
646 both selected and unselected items.
648 \membersection{wxTreeCtrl::ScrollTo
}\label{wxtreectrlscrollto
}
650 \func{void
}{ScrollTo
}{\param{const wxTreeItemId\&
}{ item
}}
652 Scrolls the specified item into view.
654 \membersection{wxTreeCtrl::SelectItem
}\label{wxtreectrlselectitem
}
656 \func{bool
}{SelectItem
}{\param{const wxTreeItemId\&
}{ item
}}
658 Selects the given item.
660 \membersection{wxTreeCtrl::SetButtonsImageList
}\label{wxtreectrlsetbuttonsimagelist
}
662 \func{void
}{SetButtonsImageList
}{\param{wxImageList*
}{ imageList
}}
664 Sets the buttons image list (from which application-defined button images are taken).
665 The button images assigned with this method will
666 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
668 Setting or assigning the button image list enables the display of image buttons.
669 Once enabled, the only way to disable the display of button images is to set
670 the button image list to NULL.
672 This function is only available in the generic version.
674 See also
\helpref{AssignButtonsImageList
}{wxtreectrlassignbuttonsimagelist
}.
676 \membersection{wxTreeCtrl::SetIndent
}\label{wxtreectrlsetindent
}
678 \func{void
}{SetIndent
}{\param{int
}{indent
}}
680 Sets the indentation for the tree control.
682 \membersection{wxTreeCtrl::SetImageList
}\label{wxtreectrlsetimagelist
}
684 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
}}
686 Sets the normal image list. Image list assigned with this method will
687 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
689 See also
\helpref{AssignImageList
}{wxtreectrlassignimagelist
}.
692 \membersection{wxTreeCtrl::SetItemBackgroundColour
}\label{wxtreectrlsetitembackgroundcolour
}
694 \func{void
}{SetItemBackgroundColour
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxColour\&
}{col
}}
696 Sets the colour of the item's background.
698 \membersection{wxTreeCtrl::SetItemBold
}\label{wxtreectrlsetitembold
}
700 \func{void
}{SetItemBold
}{\param{const wxTreeItemId\&
}{item
},
\param{bool
}{ bold = TRUE
}}
702 Makes item appear in bold font if
{\it bold
} parameter is TRUE or resets it to
705 See also:
\helpref{IsBold
}{wxtreectrlisbold
}
707 \membersection{wxTreeCtrl::SetItemData
}\label{wxtreectrlsetitemdata
}
709 \func{void
}{SetItemData
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxTreeItemData*
}{data
}}
711 Sets the item client data.
713 \pythonnote{wxPython provides the following shortcut method:
\par
714 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
715 \twocolitem{{\bf SetPyData(item, obj)
}}{Associate the given Python
716 Object with the wxTreeItemData for the given item Id.
}
720 \perlnote{wxPerl provides the following shortcut method:
722 \begin{twocollist
}\itemsep=
0pt
723 \twocolitem{{\bf SetPlData( item, data )
}}{Sets the Perl data
724 associated with the Wx::TreeItemData ( it is just the same as
725 tree->GetItemData( item )->SetData( data ); ).
}
729 \membersection{wxTreeCtrl::SetItemFont
}\label{wxtreectrlsetitemfont
}
731 \func{void
}{SetItemFont
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxFont\&
}{font
}}
733 Sets the item's font. All items in the tree should have the same height to avoid
734 text clipping, so the fonts height should be the same for all of them,
735 although font attributes may vary.
739 \helpref{SetItemBold
}{wxtreectrlsetitembold
}
741 \membersection{wxTreeCtrl::SetItemHasChildren
}\label{wxtreectrlsetitemhaschildren
}
743 \func{void
}{SetItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{hasChildren = TRUE
}}
745 Force appearance of the button next to the item. This is useful to
746 allow the user to expand the items which don't have any children now,
747 but instead adding them only when needed, thus minimizing memory
748 usage and loading time.
750 \membersection{wxTreeCtrl::SetItemImage
}\label{wxtreectrlsetitemimage
}
752 \func{void
}{SetItemImage
}{\param{const wxTreeItemId\&
}{ item
},
753 \param{int
}{image
},
\param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
755 Sets the specified item image. See
\helpref{GetItemImage
}{wxtreectrlgetitemimage
}
756 for the description of the
{\it which
} parameter.
758 \membersection{wxTreeCtrl::SetItemSelectedImage
}\label{wxtreectrlsetitemselectedimage
}
760 \func{void
}{SetItemSelectedImage
}{\param{const wxTreeItemId\&
}{ item
},
\param{int
}{selImage
}}
762 Sets the selected item image (this function is obsolete, use
{\tt SetItemImage(item, wxTreeItemIcon
\_Selected}) instead).
764 \membersection{wxTreeCtrl::SetItemText
}\label{wxtreectrlsetitemtext
}
766 \func{void
}{SetItemText
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxString\&
}{text
}}
770 \membersection{wxTreeCtrl::SetItemTextColour
}\label{wxtreectrlsetitemtextcolour
}
772 \func{void
}{SetItemTextColour
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxColour\&
}{col
}}
774 Sets the colour of the item's text.
776 \membersection{wxTreeCtrl::SetStateImageList
}\label{wxtreectrlsetstateimagelist
}
778 \func{void
}{SetStateImageList
}{\param{wxImageList*
}{ imageList
}}
780 Sets the state image list (from which application-defined state images are taken).
781 Image list assigned with this method will
782 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
784 See also
\helpref{AssignStateImageList
}{wxtreectrlassignstateimagelist
}.
786 \func{void
}{SetWindowStyle
}{\param{long
}{styles
}}
788 Sets the mode flags associated with the display of the tree control.
789 The new mode takes effect immediately.
790 (Generic only; MSW ignores changes.)
792 \membersection{wxTreeCtrl::SortChildren
}\label{wxtreectrlsortchildren
}
794 \func{void
}{SortChildren
}{\param{const wxTreeItemId\&
}{ item
}}
796 Sorts the children of the given item using
797 \helpref{OnCompareItems
}{wxtreectrloncompareitems
} method of wxTreeCtrl. You
798 should override that method to change the sort order (the default is ascending
803 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{OnCompareItems
}{wxtreectrloncompareitems
}
805 \membersection{wxTreeCtrl::Toggle
}\label{wxtreectrltoggle
}
807 \func{void
}{Toggle
}{\param{const wxTreeItemId\&
}{ item
}}
809 Toggles the given item between collapsed and expanded states.
811 \membersection{wxTreeCtrl::Unselect
}\label{wxtreectrlunselect
}
813 \func{void
}{Unselect
}{\void}
815 Removes the selection from the currently selected item (if any).
817 \membersection{wxTreeCtrl::UnselectAll
}\label{wxtreectrlunselectall
}
819 \func{void
}{UnselectAll
}{\void}
821 This function either behaves the same as
\helpref{Unselect
}{wxtreectrlunselect
}
822 if the control doesn't have wxTR
\_MULTIPLE style, or removes the selection from
823 all items if it does have this style.
825 \section{\class{wxTreeItemData
}}\label{wxtreeitemdata
}
827 wxTreeItemData is some (arbitrary) user class associated with some item. The
828 main advantage of having this class (compared to the old untyped interface) is
829 that wxTreeItemData's are destroyed automatically by the tree and, as this
830 class has virtual dtor, it means that the memory will be automatically
831 freed. We don't just use wxObject instead of wxTreeItemData because
832 the size of this class is critical: in any real application, each tree leaf
833 will have wxTreeItemData associated with it and number of leaves may be
836 Because the objects of this class are deleted by the tree, they should
837 always be allocated on the heap.
839 \wxheading{Derived from
}
843 \wxheading{Include files
}
849 \helpref{wxTreeCtrl
}{wxtreectrl
}
851 \latexignore{\rtfignore{\wxheading{Members
}}}
853 \membersection{wxTreeItemData::wxTreeItemData
}\label{wxtreeitemdataconstr
}
855 \func{}{wxTreeItemData
}{\void}
859 \pythonnote{The wxPython version of this constructor optionally
860 accepts any Python object as a parameter. This object is then
861 associated with the tree item using the wxTreeItemData as a
864 In addition, the following methods are added in wxPython for accessing
867 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
868 \twocolitem{{\bf GetData()
}}{Returns a reference to the Python Object
}
869 \twocolitem{{\bf SetData(obj)
}}{Associates a new Python Object with the
874 \perlnote{In wxPerl the constructor accepts as parameter an optional scalar,
875 and stores it as client data. You may retrieve this data by calling
876 {\bf GetData()
}, and set it by callling
{\bf SetData( data ).
}
879 \membersection{wxTreeItemData::
\destruct{wxTreeItemData
}}
881 \func{void
}{\destruct{wxTreeItemData
}}{\void}
885 \membersection{wxTreeItemData::GetId
}\label{wxtreeitemdatagetid
}
887 \func{const wxTreeItem\&
}{GetId
}{\void}
889 Returns the item associated with this node.
891 \membersection{wxTreeItemData::SetId
}\label{wxtreeitemdatasetid
}
893 \func{void
}{SetId
}{\param{const wxTreeItemId\&
}{ id
}}
895 Sets the item associated with this node.