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
\_FULL\_ROW\_HIGHLIGHT}}{Use this style to have the background
36 colour and the selection highlight extend over the entire horizontal
37 row of the tree control window. (This flag is ignored under Windows unless you
38 specify wxTR
\_NO\_LINES as well.)
}
39 \twocolitem{\windowstyle{wxTR
\_LINES\_AT\_ROOT}}{Use this style
40 to show lines between root nodes.
41 Only applicable if wxTR
\_HIDE\_ROOT is set and wxTR
\_NO\_LINES is not set.
}
42 \twocolitem{\windowstyle{wxTR
\_HIDE\_ROOT}}{Use this style
43 to suppress the display of the root node,
44 effectively causing the first-level nodes
45 to appear as a series of root nodes. Generic only.
}
46 \twocolitem{\windowstyle{wxTR
\_ROW\_LINES}}{Use this style
47 to draw a contrasting border between displayed rows.
}
48 \twocolitem{\windowstyle{wxTR
\_HAS\_VARIABLE\_ROW\_HEIGHT}}{Use this style
49 to cause row heights to be just big enough to fit the content.
50 If not set, all rows use the largest row height.
51 The default is that this flag is unset.
53 \twocolitem{\windowstyle{wxTR
\_SINGLE}}{For convenience
54 to
document that only one item may be selected at a time.
55 Selecting another item causes the current selection, if any,
56 to be deselected. This is the default.
}
57 \twocolitem{\windowstyle{wxTR
\_MULTIPLE}}{Use this style
58 to allow a range of items to be selected.
59 If a second range is selected, the current range, if any, is deselected.
}
60 \twocolitem{\windowstyle{wxTR
\_EXTENDED}}{Use this style
61 to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.)
}
62 \twocolitem{\windowstyle{wxTR
\_DEFAULT\_STYLE}}{The set of flags that are
63 closest to the defaults for the native control for a particular toolkit.
}
66 See also
\helpref{window styles overview
}{windowstyles
}.
68 \wxheading{Event handling
}
70 To process input from a tree control, use these event handler macros to direct input to member
71 functions that take a
\helpref{wxTreeEvent
}{wxtreeevent
} argument.
74 \begin{twocollist
}\itemsep=
0pt
75 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_DRAG(id, func)
}}{Begin dragging with the left mouse button.
}
76 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_RDRAG(id, func)
}}{Begin dragging with the right mouse button.
}
77 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_LABEL\_EDIT(id, func)
}}{Begin editing a label. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
78 \twocolitem{{\bf EVT
\_TREE\_END\_LABEL\_EDIT(id, func)
}}{Finish editing a label. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
79 \twocolitem{{\bf EVT
\_TREE\_DELETE\_ITEM(id, func)
}}{Delete an item.
}
80 \twocolitem{{\bf EVT
\_TREE\_GET\_INFO(id, func)
}}{Request information from the application.
}
81 \twocolitem{{\bf EVT
\_TREE\_SET\_INFO(id, func)
}}{Information is being supplied.
}
82 \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
}
83 \twocolitem{{\bf EVT
\_TREE\_ITEM\_COLLAPSED(id, func)
}}{The item has been collapsed.
}
84 \twocolitem{{\bf EVT
\_TREE\_ITEM\_COLLAPSING(id, func)
}}{The item is being collapsed. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
85 \twocolitem{{\bf EVT
\_TREE\_ITEM\_EXPANDED(id, func)
}}{The item has been expanded.
}
86 \twocolitem{{\bf EVT
\_TREE\_ITEM\_EXPANDING(id, func)
}}{The item is being expanded. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
87 \twocolitem{{\bf EVT
\_TREE\_SEL\_CHANGED(id, func)
}}{Selection has changed.
}
88 \twocolitem{{\bf EVT
\_TREE\_SEL\_CHANGING(id, func)
}}{Selection is changing. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
89 \twocolitem{{\bf EVT
\_TREE\_KEY\_DOWN(id, func)
}}{A key has been pressed.
}
94 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{wxTreeCtrl overview
}{wxtreectrloverview
},
\helpref{wxListBox
}{wxlistbox
},
\helpref{wxListCtrl
}{wxlistctrl
},
\rtfsp
95 \helpref{wxImageList
}{wximagelist
},
\helpref{wxTreeEvent
}{wxtreeevent
}
97 \wxheading{Win32 notes
}
99 wxTreeCtrl class uses the standard common treeview control under Win32
100 implemented in the system library
{\tt comctl32.dll
}. Some versions of this
101 library are known to have bugs with handling the tree control colours: the
102 usual symptom is that the expanded items leave black (or otherwise incorrectly
103 coloured) background behind them, especially for the controls using non
104 default background colour. The recommended solution is to upgrade the
{\tt comctl32.dll
}
105 to a newer version: see
106 \urlref{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
}{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
}.
108 \latexignore{\rtfignore{\wxheading{Members
}}}
110 \membersection{wxTreeCtrl::wxTreeCtrl
}\label{wxtreectrlconstr
}
112 \func{}{wxTreeCtrl
}{\void}
116 \func{}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
117 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
118 \param{long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
120 Constructor, creating and showing a tree control.
122 \wxheading{Parameters
}
124 \docparam{parent
}{Parent window. Must not be NULL.
}
126 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
128 \docparam{pos
}{Window position.
}
130 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
133 \docparam{style
}{Window style. See
\helpref{wxTreeCtrl
}{wxtreectrl
}.
}
135 \docparam{validator
}{Window validator.
}
137 \docparam{name
}{Window name.
}
141 \helpref{wxTreeCtrl::Create
}{wxtreectrlcreate
},
\helpref{wxValidator
}{wxvalidator
}
143 \membersection{wxTreeCtrl::
\destruct{wxTreeCtrl
}}
145 \func{void
}{\destruct{wxTreeCtrl
}}{\void}
147 Destructor, destroying the list control.
149 \membersection{wxTreeCtrl::AddRoot
}\label{wxtreectrladdroot
}
151 \func{wxTreeItemId
}{AddRoot
}{\param{const wxString\&
}{ text
},
152 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
154 Adds the root node to the tree, returning the new item.
156 The
{\it image
} and
{\it selImage
} parameters are an index within
157 the normal image list specifying the image to use for unselected and
158 selected items, respectively.
159 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
160 both selected and unselected items.
162 \membersection{wxTreeCtrl::AppendItem
}\label{wxtreectrlappenditem
}
164 \func{wxTreeItemId
}{AppendItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
165 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
167 Appends an item to the end of the branch identified by
{\it parent
}, return a new item id.
169 The
{\it image
} and
{\it selImage
} parameters are an index within
170 the normal image list specifying the image to use for unselected and
171 selected items, respectively.
172 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
173 both selected and unselected items.
175 \membersection{wxTreeCtrl::AssignButtonsImageList
}\label{wxtreectrlassignbuttonsimagelist
}
177 \func{void
}{AssignButtonsImageList
}{\param{wxImageList*
}{ imageList
}}
179 Sets the buttons image list. The button images assigned with this method will
180 be automatically deleted by wxTreeCtrl as appropriate
181 (i.e. it takes ownership of the list).
183 Setting or assigning the button image list enables the display of image buttons.
184 Once enabled, the only way to disable the display of button images is to set
185 the button image list to NULL.
187 This function is only available in the generic version.
189 See also
\helpref{SetButtonsImageList
}{wxtreectrlsetbuttonsimagelist
}.
191 \membersection{wxTreeCtrl::AssignImageList
}\label{wxtreectrlassignimagelist
}
193 \func{void
}{AssignImageList
}{\param{wxImageList*
}{ imageList
}}
195 Sets the normal image list. Image list assigned with this method will
196 be automatically deleted by wxTreeCtrl as appropriate
197 (i.e. it takes ownership of the list).
199 See also
\helpref{SetImageList
}{wxtreectrlsetimagelist
}.
201 \membersection{wxTreeCtrl::AssignStateImageList
}\label{wxtreectrlassignstateimagelist
}
203 \func{void
}{AssignStateImageList
}{\param{wxImageList*
}{ imageList
}}
205 Sets the state image list. Image list assigned with this method will
206 be automatically deleted by wxTreeCtrl as appropriate
207 (i.e. it takes ownership of the list).
209 See also
\helpref{SetStateImageList
}{wxtreectrlsetstateimagelist
}.
212 \membersection{wxTreeCtrl::Collapse
}\label{wxtreectrlcollapse
}
214 \func{void
}{Collapse
}{\param{const wxTreeItemId\&
}{ item
}}
216 Collapses the given item.
218 \membersection{wxTreeCtrl::CollapseAndReset
}\label{wxtreectrlcollapseandreset
}
220 \func{void
}{CollapseAndReset
}{\param{const wxTreeItemId\&
}{ item
}}
222 Collapses the given item and removes all children.
224 \membersection{wxTreeCtrl::Create
}\label{wxtreectrlcreate
}
226 \func{bool
}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
227 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
228 \param{long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
230 Creates the tree control. See
\helpref{wxTreeCtrl::wxTreeCtrl
}{wxtreectrlconstr
} for further details.
232 \membersection{wxTreeCtrl::Delete
}\label{wxtreectrldelete
}
234 \func{void
}{Delete
}{\param{const wxTreeItemId\&
}{ item
}}
236 Deletes the specified item.
238 \membersection{wxTreeCtrl::DeleteAllItems
}\label{wxtreectrldeleteallitems
}
240 \func{void
}{DeleteAllItems
}{\void}
242 Deletes all the items in the control.
244 \membersection{wxTreeCtrl::EditLabel
}\label{wxtreectrleditlabel
}
246 \func{void
}{EditLabel
}{\param{const wxTreeItemId\&
}{ item
}}
248 Starts editing the label of the given item. This function generates a
249 EVT
\_TREE\_BEGIN\_LABEL\_EDIT event which can be vetoed so that no
250 text control will appear for in-place editing.
252 If the user changed the label (i.e. s/he does not press ESC or leave
253 the text control without changes, a EVT
\_TREE\_END\_LABEL\_EDIT event
254 will be sent which can be vetoed as well.
258 \helpref{wxTreeCtrl::EndEditLabel
}{wxtreectrlendeditlabel
},
259 \helpref{wxTreeEvent
}{wxtreeevent
}
261 \membersection{wxTreeCtrl::EndEditLabel
}\label{wxtreectrlendeditlabel
}
263 \func{void
}{EndEditLabel
}{\param{bool
}{cancelEdit
}}
265 Ends label editing. If
{\it cancelEdit
} is TRUE, the edit will be cancelled.
267 This function is currently supported under Windows only.
271 \helpref{wxTreeCtrl::EditLabel
}{wxtreectrleditlabel
}
273 \membersection{wxTreeCtrl::EnsureVisible
}\label{wxtreectrlensurevisible
}
275 \func{void
}{EnsureVisible
}{\param{const wxTreeItemId\&
}{ item
}}
277 Scrolls and/or expands items to ensure that the given item is visible.
279 \membersection{wxTreeCtrl::Expand
}\label{wxtreectrlexpand
}
281 \func{void
}{Expand
}{\param{const wxTreeItemId\&
}{ item
}}
283 Expands the given item.
285 \membersection{wxTreeCtrl::GetBoundingRect
}\label{wxtreectrlgetitemrect
}
287 \constfunc{bool
}{GetBoundingRect
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxRect\&
}{rect
},
\param{bool
}{textOnly = FALSE
}}
289 Retrieves the rectangle bounding the
{\it item
}. If
{\it textOnly
} is TRUE,
290 only the rectangle around the item's label will be returned, otherwise the
291 item's image is also taken into account.
293 The return value is TRUE if the rectangle was successfully retrieved or FALSE
294 if it was not (in this case
{\it rect
} is not changed) - for example, if the
295 item is currently invisible.
297 \pythonnote{The wxPython version of this method requires only the
298 {\tt item
} and
{\tt textOnly
} parameters. The return value is either a
299 {\tt wxRect
} object or
{\tt None
}.
}
301 \perlnote{In wxPerl this method only takes the parameters
{\tt item
} and
302 {\tt textOnly
}, and returns a Wx::Rect ( or undef ).
}
304 \membersection{wxTreeCtrl::GetButtonsImageList
}\label{wxtreectrlgetbuttonsimagelist
}
306 \constfunc{wxImageList*
}{GetButtonsImageList
}{\void}
308 Returns the buttons image list (from which application-defined button images are taken).
310 This function is only available in the generic version.
312 \membersection{wxTreeCtrl::GetChildrenCount
}\label{wxtreectrlgetchildrencount
}
314 \constfunc{size
\_t}{GetChildrenCount
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{ recursively = TRUE
}}
316 Returns the number of items in the branch. If
{\it recursively
} is TRUE, returns the total number
317 of descendants, otherwise only one level of children is counted.
319 \membersection{wxTreeCtrl::GetCount
}\label{wxtreectrlgetcount
}
321 \constfunc{int
}{GetCount
}{\void}
323 Returns the number of items in the control.
325 \membersection{wxTreeCtrl::GetEditControl
}\label{wxtreectrlgeteditcontrol
}
327 \constfunc{wxTextCtrl\&
}{GetEditControl
}{\void}
329 Returns the edit control used to edit a label.
331 \membersection{wxTreeCtrl::GetFirstChild
}\label{wxtreectrlgetfirstchild
}
333 \constfunc{wxTreeItemId
}{GetFirstChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
335 Returns the first child; call
\helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
} for the next child.
337 For this enumeration function you must pass in a `cookie' parameter
338 which is opaque for the application but is necessary for the library
339 to make these functions reentrant (i.e. allow more than one
340 enumeration on one and the same object simultaneously). The cookie passed to
341 GetFirstChild and GetNextChild should be the same.
343 Returns an invalid tree item if there are no further children.
347 \helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
}
349 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
350 value are both returned as a tuple containing the two values.
}
352 \perlnote{In wxPerl this method only takes the
{\tt item
} parameter, and
353 returns a
2-element list ( item, cookie ).
}
355 \membersection{wxTreeCtrl::GetFirstVisibleItem
}\label{wxtreectrlgetfirstvisibleitem
}
357 \constfunc{wxTreeItemId
}{GetFirstVisibleItem
}{\void}
359 Returns the first visible item.
361 \membersection{wxTreeCtrl::GetImageList
}\label{wxtreectrlgetimagelist
}
363 \constfunc{wxImageList*
}{GetImageList
}{\void}
365 Returns the normal image list.
367 \membersection{wxTreeCtrl::GetIndent
}\label{wxtreectrlgetindent
}
369 \constfunc{int
}{GetIndent
}{\void}
371 Returns the current tree control indentation.
373 \membersection{wxTreeCtrl::GetItemData
}\label{wxtreectrlgetitemdata
}
375 \constfunc{wxTreeItemData*
}{GetItemData
}{\param{const wxTreeItemId\&
}{ item
}}
377 Returns the tree item data associated with the item.
381 \helpref{wxTreeItemData
}{wxtreeitemdata
}
383 \pythonnote{wxPython provides the following shortcut method:
385 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
386 \twocolitem{{\bf GetPyData(item)
}}{Returns the Python Object
387 associated with the wxTreeItemData for the given item Id.
}
391 \perlnote{wxPerl provides the following shortcut method:
393 \begin{twocollist
}\itemsep=
0pt
394 \twocolitem{{\bf GetPlData( item )
}}{Returns the Perl data
395 associated with the Wx::TreeItemData ( it is just the same as
396 tree->GetItemData( item )->GetData(); ).
}
400 \membersection{wxTreeCtrl::GetItemImage
}\label{wxtreectrlgetitemimage
}
402 \constfunc{int
}{GetItemImage
}{\param{const wxTreeItemId\&
}{item
},
403 \param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
405 Gets the specified item image. The value of
{\it which
} may be:
407 \begin{itemize
}\itemsep=
0pt
408 \item{wxTreeItemIcon
\_Normal} to get the normal item image
409 \item{wxTreeItemIcon
\_Selected} to get the selected item image (i.e. the image
410 which is shown when the item is currently selected)
411 \item{wxTreeItemIcon
\_Expanded} to get the expanded image (this only
412 makes sense for items which have children - then this image is shown when the
413 item is expanded and the normal image is shown when it is collapsed)
414 \item{wxTreeItemIcon
\_SelectedExpanded} to get the selected expanded image
415 (which is shown when an expanded item is currently selected)
418 \membersection{wxTreeCtrl::GetItemText
}\label{wxtreectrlgetitemtext
}
420 \constfunc{wxString
}{GetItemText
}{\param{const wxTreeItemId\&
}{ item
}}
422 Returns the item label.
424 \membersection{wxTreeCtrl::GetLastChild
}\label{wxtreectrlgetlastchild
}
426 \constfunc{wxTreeItemId
}{GetLastChild
}{\param{const wxTreeItemId\&
}{ item
}}
428 Returns the last child of the item (or an invalid tree item if this item has no children).
432 \helpref{GetFirstChild
}{wxtreectrlgetfirstchild
},
433 \helpref{GetLastChild
}{wxtreectrlgetlastchild
}
435 \membersection{wxTreeCtrl::GetNextChild
}\label{wxtreectrlgetnextchild
}
437 \constfunc{wxTreeItemId
}{GetNextChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
439 Returns the next child; call
\helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
} for the first child.
441 For this enumeration function you must pass in a `cookie' parameter
442 which is opaque for the application but is necessary for the library
443 to make these functions reentrant (i.e. allow more than one
444 enumeration on one and the same object simultaneously). The cookie passed to
445 GetFirstChild and GetNextChild should be the same.
447 Returns an invalid tree item if there are no further children.
451 \helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
}
453 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
454 value are both returned as a tuple containing the two values.
}
456 \perlnote{In wxPerl this method returns a
2-element list
457 ( item, cookie ), instead of modifying its parameters.
}
459 \membersection{wxTreeCtrl::GetNextSibling
}\label{wxtreectrlgetnextsibling
}
461 \constfunc{wxTreeItemId
}{GetNextSibling
}{\param{const wxTreeItemId\&
}{ item
}}
463 Returns the next sibling of the specified item; call
\helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
} for the previous sibling.
465 Returns an invalid tree item if there are no further siblings.
469 \helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
}
471 \membersection{wxTreeCtrl::GetNextVisible
}\label{wxtreectrlgetnextvisible
}
473 \constfunc{wxTreeItemId
}{GetNextVisible
}{\param{const wxTreeItemId\&
}{ item
}}
475 Returns the next visible item.
477 \membersection{wxTreeCtrl::GetParent
}\label{wxtreectrlgetparent
}
479 \constfunc{wxTreeItemId
}{GetParent
}{\param{const wxTreeItemId\&
}{ item
}}
481 Returns the item's parent.
483 \pythonnote{This method is named
{\tt GetItemParent
} to avoid a name
484 clash with wxWindow::GetParent.
}
486 \membersection{wxTreeCtrl::GetPrevSibling
}\label{wxtreectrlgetprevsibling
}
488 \constfunc{wxTreeItemId
}{GetPrevSibling
}{\param{const wxTreeItemId\&
}{ item
}}
490 Returns the previous sibling of the specified item; call
\helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
} for the next sibling.
492 Returns an invalid tree item if there are no further children.
496 \helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
}
498 \membersection{wxTreeCtrl::GetPrevVisible
}\label{wxtreectrlgetprevvisible
}
500 \constfunc{wxTreeItemId
}{GetPrevVisible
}{\param{const wxTreeItemId\&
}{ item
}}
502 Returns the previous visible item.
504 \membersection{wxTreeCtrl::GetRootItem
}\label{wxtreectrlgetrootitem
}
506 \constfunc{wxTreeItemId
}{GetRootItem
}{\void}
508 Returns the root item for the tree control.
510 \membersection{wxTreeCtrl::GetItemSelectedImage
}\label{wxtreectrlgetitemselectedimage
}
512 \constfunc{int
}{GetItemSelectedImage
}{\param{const wxTreeItemId\&
}{item
}}
514 Gets the selected item image (this function is obsolete, use
515 {\tt GetItemImage(item, wxTreeItemIcon
\_Selected}) instead).
517 \membersection{wxTreeCtrl::GetSelection
}\label{wxtreectrlgetselection
}
519 \constfunc{wxTreeItemId
}{GetSelection
}{\void}
521 Returns the selection, or an invalid item if there is no selection.
522 This function only works with the controls without wxTR
\_MULTIPLE style, use
523 \helpref{GetSelections
}{wxtreectrlgetselections
} for the controls which do have
526 \membersection{wxTreeCtrl::GetSelections
}\label{wxtreectrlgetselections
}
528 \constfunc{size
\_t}{GetSelections
}{\param{wxArrayTreeItemIds\&
}{selection
}}
530 Fills the array of tree items passed in with the currently selected items. This
531 function can be called only if the control has the wxTR
\_MULTIPLE style.
533 Returns the number of selected items.
535 \pythonnote{The wxPython version of this method accepts no parameters
536 and returns a Python list of
{\tt wxTreeItemId
}s.
}
538 \perlnote{In wxPerl this method takes no parameters and returns a list of
539 {\tt Wx::TreeItemId
}s.
}
541 \membersection{wxTreeCtrl::GetStateImageList
}\label{wxtreectrlgetstateimagelist
}
543 \constfunc{wxImageList*
}{GetStateImageList
}{\void}
545 Returns the state image list (from which application-defined state images are taken).
547 \membersection{wxTreeCtrl::HitTest
}\label{wxtreectrlhittest
}
549 \func{wxTreeItemId
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{int\&
}{flags
}}
551 Calculates which (if any) item is under the given point, returning the tree item
552 id at this point plus extra information
{\it flags
}.
{\it flags
} is a bitlist of the following:
555 \begin{twocollist
}\itemsep=
0pt
556 \twocolitem{wxTREE
\_HITTEST\_ABOVE}{Above the client area.
}
557 \twocolitem{wxTREE
\_HITTEST\_BELOW}{Below the client area.
}
558 \twocolitem{wxTREE
\_HITTEST\_NOWHERE}{In the client area but below the last item.
}
559 \twocolitem{wxTREE
\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.
}
560 \twocolitem{wxTREE
\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.
}
561 \twocolitem{wxTREE
\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.
}
562 \twocolitem{wxTREE
\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.
}
563 \twocolitem{wxTREE
\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.
}
564 \twocolitem{wxTREE
\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.
}
565 \twocolitem{wxTREE
\_HITTEST\_TOLEFT}{To the right of the client area.
}
566 \twocolitem{wxTREE
\_HITTEST\_TORIGHT}{To the left of the client area.
}
569 \pythonnote{in wxPython both the wxTreeItemId and the flags are
570 returned as a tuple.
}
572 \perlnote{In wxPerl this method only takes the
{\tt point
} parameter
573 and returns a
2-element list ( item, flags ).
}
575 \membersection{wxTreeCtrl::InsertItem
}\label{wxtreectrlinsertitem
}
577 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxTreeItemId\&
}{previous
},
\param{const wxString\&
}{ text
},
578 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
580 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{size
\_t}{ before
},
\param{const wxString\&
}{ text
},
581 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
583 Inserts an item after a given one (
{\it previous
}) or before one identified by its position (
{\it before
}).
585 The
{\it image
} and
{\it selImage
} parameters are an index within
586 the normal image list specifying the image to use for unselected and
587 selected items, respectively.
588 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
589 both selected and unselected items.
591 \pythonnote{The second form of this method is called
592 \tt{InsertItemBefore
} in wxPython.
}
594 \membersection{wxTreeCtrl::IsBold
}\label{wxtreectrlisbold
}
596 \constfunc{bool
}{IsBold
}{\param{const wxTreeItemId\&
}{item
}}
598 Returns TRUE if the given item is in bold state.
600 See also:
\helpref{SetItemBold
}{wxtreectrlsetitembold
}
602 \membersection{wxTreeCtrl::IsExpanded
}\label{wxtreectrlisexpanded
}
604 \constfunc{bool
}{IsExpanded
}{\param{const wxTreeItemId\&
}{ item
}}
606 Returns TRUE if the item is expanded (only makes sense if it has children).
608 \membersection{wxTreeCtrl::IsSelected
}\label{wxtreectrlisselected
}
610 \constfunc{bool
}{IsSelected
}{\param{const wxTreeItemId\&
}{ item
}}
612 Returns TRUE if the item is selected.
614 \membersection{wxTreeCtrl::IsVisible
}\label{wxtreectrlisvisible
}
616 \constfunc{bool
}{IsVisible
}{\param{const wxTreeItemId\&
}{ item
}}
618 Returns TRUE if the item is visible (it might be outside the view, or not expanded).
620 \membersection{wxTreeCtrl::ItemHasChildren
}\label{wxtreectrlitemhaschildren
}
622 \constfunc{bool
}{ItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
}}
624 Returns TRUE if the item has children.
626 \membersection{wxTreeCtrl::OnCompareItems
}\label{wxtreectrloncompareitems
}
628 \func{int
}{OnCompareItems
}{\param{const wxTreeItemId\&
}{item1
},
\param{const wxTreeItemId\&
}{item2
}}
630 Override this function in the derived class to change the sort order of the
631 items in the tree control. The function should return a negative, zero or
632 positive value if the first item is less than, equal to or greater than the
635 The base class version compares items alphabetically.
637 See also:
\helpref{SortChildren
}{wxtreectrlsortchildren
}
639 \membersection{wxTreeCtrl::PrependItem
}\label{wxtreectrlprependitem
}
641 \func{wxTreeItemId
}{PrependItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
642 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
644 Appends an item as the first child of
{\it parent
}, return a new item id.
646 The
{\it image
} and
{\it selImage
} parameters are an index within
647 the normal image list specifying the image to use for unselected and
648 selected items, respectively.
649 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
650 both selected and unselected items.
652 \membersection{wxTreeCtrl::ScrollTo
}\label{wxtreectrlscrollto
}
654 \func{void
}{ScrollTo
}{\param{const wxTreeItemId\&
}{ item
}}
656 Scrolls the specified item into view.
658 \membersection{wxTreeCtrl::SelectItem
}\label{wxtreectrlselectitem
}
660 \func{bool
}{SelectItem
}{\param{const wxTreeItemId\&
}{ item
}}
662 Selects the given item.
664 \membersection{wxTreeCtrl::SetButtonsImageList
}\label{wxtreectrlsetbuttonsimagelist
}
666 \func{void
}{SetButtonsImageList
}{\param{wxImageList*
}{ imageList
}}
668 Sets the buttons image list (from which application-defined button images are taken).
669 The button images assigned with this method will
670 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
672 Setting or assigning the button image list enables the display of image buttons.
673 Once enabled, the only way to disable the display of button images is to set
674 the button image list to NULL.
676 This function is only available in the generic version.
678 See also
\helpref{AssignButtonsImageList
}{wxtreectrlassignbuttonsimagelist
}.
680 \membersection{wxTreeCtrl::SetIndent
}\label{wxtreectrlsetindent
}
682 \func{void
}{SetIndent
}{\param{int
}{indent
}}
684 Sets the indentation for the tree control.
686 \membersection{wxTreeCtrl::SetImageList
}\label{wxtreectrlsetimagelist
}
688 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
}}
690 Sets the normal image list. Image list assigned with this method will
691 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
693 See also
\helpref{AssignImageList
}{wxtreectrlassignimagelist
}.
696 \membersection{wxTreeCtrl::SetItemBackgroundColour
}\label{wxtreectrlsetitembackgroundcolour
}
698 \func{void
}{SetItemBackgroundColour
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxColour\&
}{col
}}
700 Sets the colour of the item's background.
702 \membersection{wxTreeCtrl::SetItemBold
}\label{wxtreectrlsetitembold
}
704 \func{void
}{SetItemBold
}{\param{const wxTreeItemId\&
}{item
},
\param{bool
}{ bold = TRUE
}}
706 Makes item appear in bold font if
{\it bold
} parameter is TRUE or resets it to
709 See also:
\helpref{IsBold
}{wxtreectrlisbold
}
711 \membersection{wxTreeCtrl::SetItemData
}\label{wxtreectrlsetitemdata
}
713 \func{void
}{SetItemData
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxTreeItemData*
}{data
}}
715 Sets the item client data.
717 \pythonnote{wxPython provides the following shortcut method:
\par
718 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
719 \twocolitem{{\bf SetPyData(item, obj)
}}{Associate the given Python
720 Object with the wxTreeItemData for the given item Id.
}
724 \perlnote{wxPerl provides the following shortcut method:
726 \begin{twocollist
}\itemsep=
0pt
727 \twocolitem{{\bf SetPlData( item, data )
}}{Sets the Perl data
728 associated with the Wx::TreeItemData ( it is just the same as
729 tree->GetItemData( item )->SetData( data ); ).
}
733 \membersection{wxTreeCtrl::SetItemFont
}\label{wxtreectrlsetitemfont
}
735 \func{void
}{SetItemFont
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxFont\&
}{font
}}
737 Sets the item's font. All items in the tree should have the same height to avoid
738 text clipping, so the fonts height should be the same for all of them,
739 although font attributes may vary.
743 \helpref{SetItemBold
}{wxtreectrlsetitembold
}
745 \membersection{wxTreeCtrl::SetItemHasChildren
}\label{wxtreectrlsetitemhaschildren
}
747 \func{void
}{SetItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{hasChildren = TRUE
}}
749 Force appearance of the button next to the item. This is useful to
750 allow the user to expand the items which don't have any children now,
751 but instead adding them only when needed, thus minimizing memory
752 usage and loading time.
754 \membersection{wxTreeCtrl::SetItemImage
}\label{wxtreectrlsetitemimage
}
756 \func{void
}{SetItemImage
}{\param{const wxTreeItemId\&
}{ item
},
757 \param{int
}{image
},
\param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
759 Sets the specified item image. See
\helpref{GetItemImage
}{wxtreectrlgetitemimage
}
760 for the description of the
{\it which
} parameter.
762 \membersection{wxTreeCtrl::SetItemSelectedImage
}\label{wxtreectrlsetitemselectedimage
}
764 \func{void
}{SetItemSelectedImage
}{\param{const wxTreeItemId\&
}{ item
},
\param{int
}{selImage
}}
766 Sets the selected item image (this function is obsolete, use
{\tt SetItemImage(item, wxTreeItemIcon
\_Selected}) instead).
768 \membersection{wxTreeCtrl::SetItemText
}\label{wxtreectrlsetitemtext
}
770 \func{void
}{SetItemText
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxString\&
}{text
}}
774 \membersection{wxTreeCtrl::SetItemTextColour
}\label{wxtreectrlsetitemtextcolour
}
776 \func{void
}{SetItemTextColour
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxColour\&
}{col
}}
778 Sets the colour of the item's text.
780 \membersection{wxTreeCtrl::SetStateImageList
}\label{wxtreectrlsetstateimagelist
}
782 \func{void
}{SetStateImageList
}{\param{wxImageList*
}{ imageList
}}
784 Sets the state image list (from which application-defined state images are taken).
785 Image list assigned with this method will
786 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
788 See also
\helpref{AssignStateImageList
}{wxtreectrlassignstateimagelist
}.
790 \func{void
}{SetWindowStyle
}{\param{long
}{styles
}}
792 Sets the mode flags associated with the display of the tree control.
793 The new mode takes effect immediately.
794 (Generic only; MSW ignores changes.)
796 \membersection{wxTreeCtrl::SortChildren
}\label{wxtreectrlsortchildren
}
798 \func{void
}{SortChildren
}{\param{const wxTreeItemId\&
}{ item
}}
800 Sorts the children of the given item using
801 \helpref{OnCompareItems
}{wxtreectrloncompareitems
} method of wxTreeCtrl. You
802 should override that method to change the sort order (the default is ascending
807 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{OnCompareItems
}{wxtreectrloncompareitems
}
809 \membersection{wxTreeCtrl::Toggle
}\label{wxtreectrltoggle
}
811 \func{void
}{Toggle
}{\param{const wxTreeItemId\&
}{ item
}}
813 Toggles the given item between collapsed and expanded states.
815 \membersection{wxTreeCtrl::Unselect
}\label{wxtreectrlunselect
}
817 \func{void
}{Unselect
}{\void}
819 Removes the selection from the currently selected item (if any).
821 \membersection{wxTreeCtrl::UnselectAll
}\label{wxtreectrlunselectall
}
823 \func{void
}{UnselectAll
}{\void}
825 This function either behaves the same as
\helpref{Unselect
}{wxtreectrlunselect
}
826 if the control doesn't have wxTR
\_MULTIPLE style, or removes the selection from
827 all items if it does have this style.
829 \section{\class{wxTreeItemData
}}\label{wxtreeitemdata
}
831 wxTreeItemData is some (arbitrary) user class associated with some item. The
832 main advantage of having this class (compared to the old untyped interface) is
833 that wxTreeItemData's are destroyed automatically by the tree and, as this
834 class has virtual dtor, it means that the memory will be automatically
835 freed. We don't just use wxObject instead of wxTreeItemData because
836 the size of this class is critical: in any real application, each tree leaf
837 will have wxTreeItemData associated with it and number of leaves may be
840 Because the objects of this class are deleted by the tree, they should
841 always be allocated on the heap.
843 \wxheading{Derived from
}
847 \wxheading{Include files
}
853 \helpref{wxTreeCtrl
}{wxtreectrl
}
855 \latexignore{\rtfignore{\wxheading{Members
}}}
857 \membersection{wxTreeItemData::wxTreeItemData
}\label{wxtreeitemdataconstr
}
859 \func{}{wxTreeItemData
}{\void}
863 \pythonnote{The wxPython version of this constructor optionally
864 accepts any Python object as a parameter. This object is then
865 associated with the tree item using the wxTreeItemData as a
868 In addition, the following methods are added in wxPython for accessing
871 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
872 \twocolitem{{\bf GetData()
}}{Returns a reference to the Python Object
}
873 \twocolitem{{\bf SetData(obj)
}}{Associates a new Python Object with the
878 \perlnote{In wxPerl the constructor accepts as parameter an optional scalar,
879 and stores it as client data. You may retrieve this data by calling
880 {\bf GetData()
}, and set it by callling
{\bf SetData( data ).
}
883 \membersection{wxTreeItemData::
\destruct{wxTreeItemData
}}
885 \func{void
}{\destruct{wxTreeItemData
}}{\void}
889 \membersection{wxTreeItemData::GetId
}\label{wxtreeitemdatagetid
}
891 \func{const wxTreeItem\&
}{GetId
}{\void}
893 Returns the item associated with this node.
895 \membersection{wxTreeItemData::SetId
}\label{wxtreeitemdatasetid
}
897 \func{void
}{SetId
}{\param{const wxTreeItemId\&
}{ id
}}
899 Sets the item associated with this node.