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
\_NO\_LINES}}{Use this style to hide vertical lines.
27 \twocolitem{\windowstyle{wxTR
\_LINES\_AT\_ROOT}}{Use this style to show lines at the
28 tree root. Win32 only.
}
29 \twocolitem{\windowstyle{wxTR
\_EDIT\_LABELS}}{Use this style if you wish the user to be
30 able to edit labels in the tree control.
}
31 \twocolitem{\windowstyle{wxTR
\_MULTIPLE}}{Use this style to allow the user to
32 select more than one item in the control - by default, only one item may be
36 See also
\helpref{window styles overview
}{windowstyles
}.
38 \wxheading{Event handling
}
40 To process input from a tree control, use these event handler macros to direct input to member
41 functions that take a
\helpref{wxTreeEvent
}{wxtreeevent
} argument.
44 \begin{twocollist
}\itemsep=
0pt
45 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_DRAG(id, func)
}}{Begin dragging with the left mouse button.
}
46 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_RDRAG(id, func)
}}{Begin dragging with the right mouse button.
}
47 \twocolitem{{\bf EVT
\_TREE\_BEGIN\_LABEL\_EDIT(id, func)
}}{Begin editing a label. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
48 \twocolitem{{\bf EVT
\_TREE\_END\_LABEL\_EDIT(id, func)
}}{Finish editing a label. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
49 \twocolitem{{\bf EVT
\_TREE\_DELETE\_ITEM(id, func)
}}{Delete an item.
}
50 \twocolitem{{\bf EVT
\_TREE\_GET\_INFO(id, func)
}}{Request information from the application.
}
51 \twocolitem{{\bf EVT
\_TREE\_SET\_INFO(id, func)
}}{Information is being supplied.
}
52 \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
}
53 \twocolitem{{\bf EVT
\_TREE\_ITEM\_COLLAPSED(id, func)
}}{The item has been collapsed.
}
54 \twocolitem{{\bf EVT
\_TREE\_ITEM\_COLLAPSING(id, func)
}}{The item is being collapsed. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
55 \twocolitem{{\bf EVT
\_TREE\_ITEM\_EXPANDED(id, func)
}}{The item has been expanded.
}
56 \twocolitem{{\bf EVT
\_TREE\_ITEM\_EXPANDING(id, func)
}}{The item is being expanded. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
57 \twocolitem{{\bf EVT
\_TREE\_SEL\_CHANGED(id, func)
}}{Selection has changed.
}
58 \twocolitem{{\bf EVT
\_TREE\_SEL\_CHANGING(id, func)
}}{Selection is changing. This can be prevented by calling
\helpref{Veto()
}{wxnotifyeventveto
}.
}
59 \twocolitem{{\bf EVT
\_TREE\_KEY\_DOWN(id, func)
}}{A key has been pressed.
}
64 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{wxTreeCtrl overview
}{wxtreectrloverview
},
\helpref{wxListBox
}{wxlistbox
},
\helpref{wxListCtrl
}{wxlistctrl
},
\rtfsp
65 \helpref{wxImageList
}{wximagelist
},
\helpref{wxTreeEvent
}{wxtreeevent
}
67 \wxheading{Win32 notes
}
69 wxTreeCtrl class uses the standard common treeview control under Win32
70 implemented in the system library
{\tt comctl32.dll
}. Some versions of this
71 library are known to have bugs with handling the tree control colours: the
72 usual symptom is that the expanded items leave black (or otherwise incorrectly
73 coloured) background behind them, especially for the controls using non
74 default background colour. The recommended solution is to upgrade the
{\tt comctl32.dll
}
75 to a newer version: see
76 \urlref{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
}{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp
}.
78 \latexignore{\rtfignore{\wxheading{Members
}}}
80 \membersection{wxTreeCtrl::wxTreeCtrl
}\label{wxtreectrlconstr
}
82 \func{}{wxTreeCtrl
}{\void}
86 \func{}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
87 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
88 \param{long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
90 Constructor, creating and showing a tree control.
92 \wxheading{Parameters
}
94 \docparam{parent
}{Parent window. Must not be NULL.
}
96 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
98 \docparam{pos
}{Window position.
}
100 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
103 \docparam{style
}{Window style. See
\helpref{wxTreeCtrl
}{wxtreectrl
}.
}
105 \docparam{validator
}{Window validator.
}
107 \docparam{name
}{Window name.
}
111 \helpref{wxTreeCtrl::Create
}{wxtreectrlcreate
},
\helpref{wxValidator
}{wxvalidator
}
113 \membersection{wxTreeCtrl::
\destruct{wxTreeCtrl
}}
115 \func{void
}{\destruct{wxTreeCtrl
}}{\void}
117 Destructor, destroying the list control.
119 \membersection{wxTreeCtrl::AddRoot
}\label{wxtreectrladdroot
}
121 \func{wxTreeItemId
}{AddRoot
}{\param{const wxString\&
}{ text
},
122 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
124 Adds the root node to the tree, returning the new item.
126 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
127 both selected and unselected items.
129 \membersection{wxTreeCtrl::AppendItem
}\label{wxtreectrlappenditem
}
131 \func{wxTreeItemId
}{AppendItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
132 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
134 Appends an item to the end of the branch identified by
{\it parent
}, return a new item id.
136 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
137 both selected and unselected items.
139 \membersection{wxTreeCtrl::AssignImageList
}\label{wxtreectrlassignimagelist
}
141 \func{void
}{AssignImageList
}{\param{wxImageList*
}{ imageList
}}
143 Sets the normal image list. Image list assigned with this method will
144 be deleted by wxTreeCtrl's destructor (i.e. it takes ownership of it).
146 See also
\helpref{SetImageList
}{wxtreectrlsetimagelist
}.
148 \membersection{wxTreeCtrl::AssignStateImageList
}\label{wxtreectrlassignstateimagelist
}
150 \func{void
}{AssignStateImageList
}{\param{wxImageList*
}{ imageList
}}
152 Sets the state image list. Image list assigned with this method will
153 be deleted by wxTreeCtrl's destructor (i.e. it takes ownership of it).
155 See also
\helpref{SetStateImageList
}{wxtreectrlsetstateimagelist
}.
158 \membersection{wxTreeCtrl::Collapse
}\label{wxtreectrlcollapse
}
160 \func{void
}{Collapse
}{\param{const wxTreeItemId\&
}{ item
}}
162 Collapses the given item.
164 \membersection{wxTreeCtrl::CollapseAndReset
}\label{wxtreectrlcollapseandreset
}
166 \func{void
}{CollapseAndReset
}{\param{const wxTreeItemId\&
}{ item
}}
168 Collapses the given item and removes all children.
170 \membersection{wxTreeCtrl::Create
}\label{wxtreectrlcreate
}
172 \func{bool
}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{ id
},
\rtfsp
173 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
174 \param{long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
176 Creates the tree control. See
\helpref{wxTreeCtrl::wxTreeCtrl
}{wxtreectrlconstr
} for further details.
178 \membersection{wxTreeCtrl::Delete
}\label{wxtreectrldelete
}
180 \func{void
}{Delete
}{\param{const wxTreeItemId\&
}{ item
}}
182 Deletes the specified item.
184 \membersection{wxTreeCtrl::DeleteAllItems
}\label{wxtreectrldeleteallitems
}
186 \func{void
}{DeleteAllItems
}{\void}
188 Deletes all the items in the control.
190 \membersection{wxTreeCtrl::EditLabel
}\label{wxtreectrleditlabel
}
192 \func{void
}{EditLabel
}{\param{const wxTreeItemId\&
}{ item
}}
194 Starts editing the label of the given item. This function generates a
195 EVT
\_TREE\_BEGIN\_LABEL\_EDIT event which can be vetoed so that no
196 text control will appear for in-place editing.
198 If the user changed the label (i.e. s/he does not press ESC or leave
199 the text control without changes, a EVT
\_TREE\_END\_LABEL\_EDIT event
200 will be sent which can be vetoed as well.
204 \helpref{wxTreeCtrl::EndEditLabel
}{wxtreectrlendeditlabel
},
205 \helpref{wxTreeEvent
}{wxtreeevent
}
207 \membersection{wxTreeCtrl::EndEditLabel
}\label{wxtreectrlendeditlabel
}
209 \func{void
}{EndEditLabel
}{\param{bool
}{cancelEdit
}}
211 Ends label editing. If
{\it cancelEdit
} is TRUE, the edit will be cancelled.
213 This function is currently supported under Windows only.
217 \helpref{wxTreeCtrl::EditLabel
}{wxtreectrleditlabel
}
219 \membersection{wxTreeCtrl::EnsureVisible
}\label{wxtreectrlensurevisible
}
221 \func{void
}{EnsureVisible
}{\param{const wxTreeItemId\&
}{ item
}}
223 Scrolls and/or expands items to ensure that the given item is visible.
225 \membersection{wxTreeCtrl::Expand
}\label{wxtreectrlexpand
}
227 \func{void
}{Expand
}{\param{const wxTreeItemId\&
}{ item
}}
229 Expands the given item.
231 \membersection{wxTreeCtrl::GetBoundingRect
}\label{wxtreectrlgetitemrect
}
233 \constfunc{bool
}{GetBoundingRect
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxRect\&
}{rect
},
\param{bool
}{textOnly = FALSE
}}
235 Retrieves the rectangle bounding the
{\it item
}. If
{\it textOnly
} is TRUE,
236 only the rectangle around the items label will be returned, otherwise the
237 items image is also taken into account.
239 The return value is TRUE if the rectangle was successfully retrieved or FALSE
240 if it was not (in this case
{\it rect
} is not changed) - for example, if the
241 item is currently invisible.
243 \pythonnote{The wxPython version of this method requires only the
244 {\tt item
} and
{\tt textOnly
} parameters. The return value is either a
245 {\tt wxRect
} object or
{\tt None
}.
}
247 \perlnote{In wxPerl this method only takes the parameters
{\tt item
} and
248 {\tt textOnly
}, and returns a Wx::Rect ( or undef ).
}
250 \membersection{wxTreeCtrl::GetChildrenCount
}\label{wxtreectrlgetchildrencount
}
252 \constfunc{size
\_t}{GetChildrenCount
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{ recursively = TRUE
}}
254 Returns the number of items in the branch. If
{\it recursively
} is TRUE, returns the total number
255 of descendants, otherwise only one level of children is counted.
257 \membersection{wxTreeCtrl::GetCount
}\label{wxtreectrlgetcount
}
259 \constfunc{int
}{GetCount
}{\void}
261 Returns the number of items in the control.
263 \membersection{wxTreeCtrl::GetEditControl
}\label{wxtreectrlgeteditcontrol
}
265 \constfunc{wxTextCtrl\&
}{GetEditControl
}{\void}
267 Returns the edit control used to edit a label.
269 \membersection{wxTreeCtrl::GetFirstChild
}\label{wxtreectrlgetfirstchild
}
271 \constfunc{wxTreeItemId
}{GetFirstChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
273 Returns the first child; call
\helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
} for the next child.
275 For this enumeration function you must pass in a `cookie' parameter
276 which is opaque for the application but is necessary for the library
277 to make these functions reentrant (i.e. allow more than one
278 enumeration on one and the same object simultaneously). The cookie passed to
279 GetFirstChild and GetNextChild should be the same.
281 Returns an invalid tree item if there are no further children.
285 \helpref{wxTreeCtrl::GetNextChild
}{wxtreectrlgetnextchild
}
287 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
288 value are both returned as a tuple containing the two values.
}
290 \perlnote{In wxPerl this method only takes the
{\tt item
} parameter, and
291 returns a
2-element list ( item, cookie ).
}
293 \membersection{wxTreeCtrl::GetFirstVisibleItem
}\label{wxtreectrlgetfirstvisibleitem
}
295 \constfunc{wxTreeItemId
}{GetFirstVisibleItem
}{\void}
297 Returns the first visible item.
299 \membersection{wxTreeCtrl::GetImageList
}\label{wxtreectrlgetimagelist
}
301 \constfunc{wxImageList*
}{GetImageList
}{\void}
303 Returns the normal image list.
305 \membersection{wxTreeCtrl::GetIndent
}\label{wxtreectrlgetindent
}
307 \constfunc{int
}{GetIndent
}{\void}
309 Returns the current tree control indentation.
311 \membersection{wxTreeCtrl::GetItemData
}\label{wxtreectrlgetitemdata
}
313 \constfunc{wxTreeItemData*
}{GetItemData
}{\param{const wxTreeItemId\&
}{ item
}}
315 Returns the tree item data associated with the item.
319 \helpref{wxTreeItemData
}{wxtreeitemdata
}
321 \pythonnote{wxPython provides the following shortcut method:
323 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
324 \twocolitem{{\bf GetPyData(item)
}}{Returns the Python Object
325 associated with the wxTreeItemData for the given item Id.
}
329 \perlnote{wxPerl provides the following shortcut method:
331 \begin{twocollist
}\itemsep=
0pt
332 \twocolitem{{\bf GetPlData( item )
}}{Returns the Perl data
333 associated with the Wx::TreeItemData ( it is just the same as
334 tree->GetItemData( item )->GetData(); ).
}
338 \membersection{wxTreeCtrl::GetItemImage
}\label{wxtreectrlgetitemimage
}
340 \constfunc{int
}{GetItemImage
}{\param{const wxTreeItemId\&
}{item
},
341 \param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
343 Gets the specified item image. The value of
{\it which
} may be:
345 \begin{itemize
}\itemsep=
0pt
346 \item{wxTreeItemIcon
\_Normal} to get the normal item image
347 \item{wxTreeItemIcon
\_Selected} to get the selected item image (i.e. the image
348 which is shown when the item is currently selected)
349 \item{wxTreeItemIcon
\_Expanded} to get the expanded image (this only
350 makes sense for items which have children - then this image is shown when the
351 item is expanded and the normal image is shown when it is collapsed)
352 \item{wxTreeItemIcon
\_SelectedExpanded} to get the selected expanded image
353 (which is shown when an expanded item is currently selected)
356 \membersection{wxTreeCtrl::GetItemText
}\label{wxtreectrlgetitemtext
}
358 \constfunc{wxString
}{GetItemText
}{\param{const wxTreeItemId\&
}{ item
}}
360 Returns the item label.
362 \membersection{wxTreeCtrl::GetLastChild
}\label{wxtreectrlgetlastchild
}
364 \constfunc{wxTreeItemId
}{GetLastChild
}{\param{const wxTreeItemId\&
}{ item
}}
366 Returns the last child of the item (or an invalid tree item if this item has no children).
370 \helpref{GetFirstChild
}{wxtreectrlgetfirstchild
},
371 \helpref{GetLastChild
}{wxtreectrlgetlastchild
}
373 \membersection{wxTreeCtrl::GetNextChild
}\label{wxtreectrlgetnextchild
}
375 \constfunc{wxTreeItemId
}{GetNextChild
}{\param{const wxTreeItemId\&
}{ item
},
\param{long\&
}{cookie
}}
377 Returns the next child; call
\helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
} for the first child.
379 For this enumeration function you must pass in a `cookie' parameter
380 which is opaque for the application but is necessary for the library
381 to make these functions reentrant (i.e. allow more than one
382 enumeration on one and the same object simultaneously). The cookie passed to
383 GetFirstChild and GetNextChild should be the same.
385 Returns an invalid tree item if there are no further children.
389 \helpref{wxTreeCtrl::GetFirstChild
}{wxtreectrlgetfirstchild
}
391 \pythonnote{In wxPython the returned wxTreeItemId and the new cookie
392 value are both returned as a tuple containing the two values.
}
394 \perlnote{In wxPerl this method returns a
2-element list
395 ( item, cookie ), instead of modifying its parameters.
}
397 \membersection{wxTreeCtrl::GetNextSibling
}\label{wxtreectrlgetnextsibling
}
399 \constfunc{wxTreeItemId
}{GetNextSibling
}{\param{const wxTreeItemId\&
}{ item
}}
401 Returns the next sibling of the specified item; call
\helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
} for the previous sibling.
403 Returns an invalid tree item if there are no further siblings.
407 \helpref{wxTreeCtrl::GetPrevSibling
}{wxtreectrlgetprevsibling
}
409 \membersection{wxTreeCtrl::GetNextVisible
}\label{wxtreectrlgetnextvisible
}
411 \constfunc{wxTreeItemId
}{GetNextVisible
}{\param{const wxTreeItemId\&
}{ item
}}
413 Returns the next visible item.
415 \membersection{wxTreeCtrl::GetParent
}\label{wxtreectrlgetparent
}
417 \constfunc{wxTreeItemId
}{GetParent
}{\param{const wxTreeItemId\&
}{ item
}}
419 Returns the item's parent.
421 \pythonnote{This method is named
{\tt GetItemParent
} to avoid a name
422 clash with wxWindow::GetParent.
}
424 \membersection{wxTreeCtrl::GetPrevSibling
}\label{wxtreectrlgetprevsibling
}
426 \constfunc{wxTreeItemId
}{GetPrevSibling
}{\param{const wxTreeItemId\&
}{ item
}}
428 Returns the previous sibling of the specified item; call
\helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
} for the next sibling.
430 Returns an invalid tree item if there are no further children.
434 \helpref{wxTreeCtrl::GetNextSibling
}{wxtreectrlgetnextsibling
}
436 \membersection{wxTreeCtrl::GetPrevVisible
}\label{wxtreectrlgetprevvisible
}
438 \constfunc{wxTreeItemId
}{GetPrevVisible
}{\param{const wxTreeItemId\&
}{ item
}}
440 Returns the previous visible item.
442 \membersection{wxTreeCtrl::GetRootItem
}\label{wxtreectrlgetrootitem
}
444 \constfunc{wxTreeItemId
}{GetRootItem
}{\void}
446 Returns the root item for the tree control.
448 \membersection{wxTreeCtrl::GetItemSelectedImage
}\label{wxtreectrlgetitemselectedimage
}
450 \constfunc{int
}{GetItemSelectedImage
}{\param{const wxTreeItemId\&
}{item
}}
452 Gets the selected item image (this function is obsolete, use
453 {\tt GetItemImage(item, wxTreeItemIcon
\_Selected}) instead).
455 \membersection{wxTreeCtrl::GetSelection
}\label{wxtreectrlgetselection
}
457 \constfunc{wxTreeItemId
}{GetSelection
}{\void}
459 Returns the selection, or an invalid item if there is no selection.
460 This function only works with the controls without wxTR
\_MULTIPLE style, use
461 \helpref{GetSelections
}{wxtreectrlgetselections
} for the controls which do have
464 \membersection{wxTreeCtrl::GetSelections
}\label{wxtreectrlgetselections
}
466 \constfunc{size
\_t}{GetSelections
}{\param{wxArrayTreeItemIds\&
}{selection
}}
468 Fills the array of tree items passed in with the currently selected items. This
469 function can be called only if the control has the wxTR
\_MULTIPLE style.
471 Returns the number of selected items.
473 \pythonnote{The wxPython version of this method accepts no parameters
474 and returns a Python list of
{\tt wxTreeItemId
}s.
}
476 \perlnote{In wxPerl this method takes no parameters and returns a list of
477 {\tt Wx::TreeItemId
}s.
}
479 \membersection{wxTreeCtrl::GetStateImageList
}\label{wxtreectrlgetstateimagelist
}
481 \constfunc{wxImageList*
}{GetStateImageList
}{\void}
483 Returns the state image list (from which application-defined state images are taken).
485 \membersection{wxTreeCtrl::HitTest
}\label{wxtreectrlhittest
}
487 \func{wxTreeItemId
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{int\&
}{flags
}}
489 Calculates which (if any) item is under the given point, returning the tree item
490 id at this point plus extra information
{\it flags
}.
{\it flags
} is a bitlist of the following:
493 \begin{twocollist
}\itemsep=
0pt
494 \twocolitem{wxTREE
\_HITTEST\_ABOVE}{Above the client area.
}
495 \twocolitem{wxTREE
\_HITTEST\_BELOW}{Below the client area.
}
496 \twocolitem{wxTREE
\_HITTEST\_NOWHERE}{In the client area but below the last item.
}
497 \twocolitem{wxTREE
\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.
}
498 \twocolitem{wxTREE
\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.
}
499 \twocolitem{wxTREE
\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.
}
500 \twocolitem{wxTREE
\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.
}
501 \twocolitem{wxTREE
\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.
}
502 \twocolitem{wxTREE
\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.
}
503 \twocolitem{wxTREE
\_HITTEST\_TOLEFT}{To the right of the client area.
}
504 \twocolitem{wxTREE
\_HITTEST\_TORIGHT}{To the left of the client area.
}
507 \pythonnote{in wxPython both the wxTreeItemId and the flags are
508 returned as a tuple.
}
510 \perlnote{In wxPerl this method only takes the
{\tt point
} parameter
511 and returns a
2-element list ( item, flags ).
}
513 \membersection{wxTreeCtrl::InsertItem
}\label{wxtreectrlinsertitem
}
515 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxTreeItemId\&
}{previous
},
\param{const wxString\&
}{ text
},
516 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
518 \func{wxTreeItemId
}{InsertItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{size
\_t}{ before
},
\param{const wxString\&
}{ text
},
519 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
521 Inserts an item after a given one (
{\it previous
}) or before one identified by its position (
{\it before
}).
523 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
524 both selected and unselected items.
526 \pythonnote{The second form of this method is called
527 \tt{InsertItemBefore
} in wxPython.
}
529 \membersection{wxTreeCtrl::IsBold
}\label{wxtreectrlisbold
}
531 \constfunc{bool
}{IsBold
}{\param{const wxTreeItemId\&
}{item
}}
533 Returns TRUE if the given item is in bold state.
535 See also:
\helpref{SetItemBold
}{wxtreectrlsetitembold
}
537 \membersection{wxTreeCtrl::IsExpanded
}\label{wxtreectrlisexpanded
}
539 \constfunc{bool
}{IsExpanded
}{\param{const wxTreeItemId\&
}{ item
}}
541 Returns TRUE if the item is expanded (only makes sense if it has children).
543 \membersection{wxTreeCtrl::IsSelected
}\label{wxtreectrlisselected
}
545 \constfunc{bool
}{IsSelected
}{\param{const wxTreeItemId\&
}{ item
}}
547 Returns TRUE if the item is selected.
549 \membersection{wxTreeCtrl::IsVisible
}\label{wxtreectrlisvisible
}
551 \constfunc{bool
}{IsVisible
}{\param{const wxTreeItemId\&
}{ item
}}
553 Returns TRUE if the item is visible (it might be outside the view, or not expanded).
555 \membersection{wxTreeCtrl::ItemHasChildren
}\label{wxtreectrlitemhaschildren
}
557 \constfunc{bool
}{ItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
}}
559 Returns TRUE if the item has children.
561 \membersection{wxTreeCtrl::OnCompareItems
}\label{wxtreectrloncompareitems
}
563 \func{int
}{OnCompareItems
}{\param{const wxTreeItemId\&
}{item1
},
\param{const wxTreeItemId\&
}{item2
}}
565 Override this function in the derived class to change the sort order of the
566 items in the tree control. The function should return a negative, zero or
567 positive value if the first item is less than, equal to or greater than the
570 The base class version compares items alphabetically.
572 See also:
\helpref{SortChildren
}{wxtreectrlsortchildren
}
574 \membersection{wxTreeCtrl::PrependItem
}\label{wxtreectrlprependitem
}
576 \func{wxTreeItemId
}{PrependItem
}{\param{const wxTreeItemId\&
}{parent
},
\param{const wxString\&
}{ text
},
577 \param{int
}{ image = -
1},
\param{int
}{ selImage = -
1},
\param{wxTreeItemData*
}{ data = NULL
}}
579 Appends an item as the first child of
{\it parent
}, return a new item id.
581 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
582 both selected and unselected items.
584 \membersection{wxTreeCtrl::ScrollTo
}\label{wxtreectrlscrollto
}
586 \func{void
}{ScrollTo
}{\param{const wxTreeItemId\&
}{ item
}}
588 Scrolls the specified item into view.
590 \membersection{wxTreeCtrl::SelectItem
}\label{wxtreectrlselectitem
}
592 \func{bool
}{SelectItem
}{\param{const wxTreeItemId\&
}{ item
}}
594 Selects the given item.
596 \membersection{wxTreeCtrl::SetIndent
}\label{wxtreectrlsetindent
}
598 \func{void
}{SetIndent
}{\param{int
}{indent
}}
600 Sets the indentation for the tree control.
602 \membersection{wxTreeCtrl::SetImageList
}\label{wxtreectrlsetimagelist
}
604 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
}}
606 Sets the normal image list. Image list assigned with this method will
607 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
609 See also
\helpref{AssignImageList
}{wxtreectrlassignimagelist
}.
612 \membersection{wxTreeCtrl::SetItemBackgroundColour
}\label{wxtreectrlsetitembackgroundcolour
}
614 \func{void
}{SetItemBackgroundColour
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxColour\&
}{col
}}
616 Sets the colour of the items background.
618 \membersection{wxTreeCtrl::SetItemBold
}\label{wxtreectrlsetitembold
}
620 \func{void
}{SetItemBold
}{\param{const wxTreeItemId\&
}{item
},
\param{bool
}{ bold = TRUE
}}
622 Makes item appear in bold font if
{\it bold
} parameter is TRUE or resets it to
625 See also:
\helpref{IsBold
}{wxtreectrlisbold
}
627 \membersection{wxTreeCtrl::SetItemData
}\label{wxtreectrlsetitemdata
}
629 \func{void
}{SetItemData
}{\param{const wxTreeItemId\&
}{ item
},
\param{wxTreeItemData*
}{data
}}
631 Sets the item client data.
633 \pythonnote{wxPython provides the following shortcut method:
\par
634 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
635 \twocolitem{{\bf SetPyData(item, obj)
}}{Associate the given Python
636 Object with the wxTreeItemData for the given item Id.
}
640 \perlnote{wxPerl provides the following shortcut method:
642 \begin{twocollist
}\itemsep=
0pt
643 \twocolitem{{\bf SetPlData( item, data )
}}{Sets the Perl data
644 associated with the Wx::TreeItemData ( it is just the same as
645 tree->GetItemData( item )->SetData( data ); ).
}
649 \membersection{wxTreeCtrl::SetItemFont
}\label{wxtreectrlsetitemfont
}
651 \func{void
}{SetItemFont
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxFont\&
}{font
}}
653 Sets the items font. All items in the tree should have the same height to avoid
654 text clipping, so the fonts height should be the same for all of them,
655 although font attributes may vary.
659 \helpref{SetItemBold
}{wxtreectrlsetitembold
}
661 \membersection{wxTreeCtrl::SetItemHasChildren
}\label{wxtreectrlsetitemhaschildren
}
663 \func{void
}{SetItemHasChildren
}{\param{const wxTreeItemId\&
}{ item
},
\param{bool
}{hasChildren = TRUE
}}
665 Force appearance of the button next to the item. This is useful to
666 allow the user to expand the items which don't have any children now,
667 but instead adding them only when needed, thus minimizing memory
668 usage and loading time.
670 \membersection{wxTreeCtrl::SetItemImage
}\label{wxtreectrlsetitemimage
}
672 \func{void
}{SetItemImage
}{\param{const wxTreeItemId\&
}{ item
},
673 \param{int
}{image
},
\param{wxTreeItemIcon
}{which = wxTreeItemIcon
\_Normal}}
675 Sets the specified item image. See
\helpref{GetItemImage
}{wxtreectrlgetitemimage
}
676 for the description of the
{\it which
} parameter.
678 \membersection{wxTreeCtrl::SetItemSelectedImage
}\label{wxtreectrlsetitemselectedimage
}
680 \func{void
}{SetItemSelectedImage
}{\param{const wxTreeItemId\&
}{ item
},
\param{int
}{selImage
}}
682 Sets the selected item image (this function is obsolete, use
{\tt SetItemImage(item, wxTreeItemIcon
\_Selected}) instead).
684 \membersection{wxTreeCtrl::SetItemText
}\label{wxtreectrlsetitemtext
}
686 \func{void
}{SetItemText
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxString\&
}{text
}}
690 \membersection{wxTreeCtrl::SetItemTextColour
}\label{wxtreectrlsetitemtextcolour
}
692 \func{void
}{SetItemTextColour
}{\param{const wxTreeItemId\&
}{ item
},
\param{const wxColour\&
}{col
}}
694 Sets the colour of the items text.
696 \membersection{wxTreeCtrl::SetStateImageList
}\label{wxtreectrlsetstateimagelist
}
698 \func{void
}{SetStateImageList
}{\param{wxImageList*
}{ imageList
}}
700 Sets the state image list (from which application-defined state images are taken).
701 Image list assigned with this method will
702 {\bf not
} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
704 See also
\helpref{AssignStateImageList
}{wxtreectrlassignstateimagelist
}.
706 \membersection{wxTreeCtrl::SortChildren
}\label{wxtreectrlsortchildren
}
708 \func{void
}{SortChildren
}{\param{const wxTreeItemId\&
}{ item
}}
710 Sorts the children of the given item using
711 \helpref{OnCompareItems
}{wxtreectrloncompareitems
} method of wxTreeCtrl. You
712 should override that method to change the sort order (the default is ascending
717 \helpref{wxTreeItemData
}{wxtreeitemdata
},
\helpref{OnCompareItems
}{wxtreectrloncompareitems
}
719 \membersection{wxTreeCtrl::Toggle
}\label{wxtreectrltoggle
}
721 \func{void
}{Toggle
}{\param{const wxTreeItemId\&
}{ item
}}
723 Toggles the given item between collapsed and expanded states.
725 \membersection{wxTreeCtrl::Unselect
}\label{wxtreectrlunselect
}
727 \func{void
}{Unselect
}{\void}
729 Removes the selection from the currently selected item (if any).
731 \membersection{wxTreeCtrl::UnselectAll
}\label{wxtreectrlunselectall
}
733 \func{void
}{UnselectAll
}{\void}
735 This function either behaves the same as
\helpref{Unselect
}{wxtreectrlunselect
}
736 if the control doesn't have wxTR
\_MULTIPLE style, or removes the selection from
737 all items if it does have this style.
739 \section{\class{wxTreeItemData
}}\label{wxtreeitemdata
}
741 wxTreeItemData is some (arbitrary) user class associated with some item. The
742 main advantage of having this class (compared to the old untyped interface) is
743 that wxTreeItemData's are destroyed automatically by the tree and, as this
744 class has virtual dtor, it means that the memory will be automatically
745 freed. We don't just use wxObject instead of wxTreeItemData because
746 the size of this class is critical: in any real application, each tree leaf
747 will have wxTreeItemData associated with it and number of leaves may be
750 Because the objects of this class are deleted by the tree, they should
751 always be allocated on the heap.
753 \wxheading{Derived from
}
757 \wxheading{Include files
}
763 \helpref{wxTreeCtrl
}{wxtreectrl
}
765 \latexignore{\rtfignore{\wxheading{Members
}}}
767 \membersection{wxTreeItemData::wxTreeItemData
}\label{wxtreeitemdataconstr
}
769 \func{}{wxTreeItemData
}{\void}
773 \pythonnote{The wxPython version of this constructor optionally
774 accepts any Python object as a parameter. This object is then
775 associated with the tree item using the wxTreeItemData as a
778 In addition, the following methods are added in wxPython for accessing
781 \indented{2cm
}{\begin{twocollist
}\itemsep=
0pt
782 \twocolitem{{\bf GetData()
}}{Returns a reference to the Python Object
}
783 \twocolitem{{\bf SetData(obj)
}}{Associates a new Python Object with the
788 \perlnote{In wxPerl the constructor accepts as parameter an optional scalar,
789 and stores it as client data. You may retrieve this data by calling
790 {\bf GetData()
}, and set it by callling
{\bf SetData( data ).
}
793 \membersection{wxTreeItemData::
\destruct{wxTreeItemData
}}
795 \func{void
}{\destruct{wxTreeItemData
}}{\void}
799 \membersection{wxTreeItemData::GetId
}\label{wxtreeitemdatagetid
}
801 \func{const wxTreeItem\&
}{GetId
}{\void}
803 Returns the item associated with this node.
805 \membersection{wxTreeItemData::SetId
}\label{wxtreeitemdatasetid
}
807 \func{void
}{SetId
}{\param{const wxTreeItemId\&
}{ id
}}
809 Sets the item associated with this node.