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 long integer 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{Window styles
}
18 \begin{twocollist
}\itemsep=
0pt
19 \twocolitem{\windowstyle{wxTR
\_HAS\_BUTTONS}}{Use this style to show + and - buttons to the
20 left of parent items.
}
21 \twocolitem{\windowstyle{wxTR
\_EDIT\_LABELS}}{Use this style if you wish the user to be
22 able to edit labels in the tree control.
}
25 See also
\helpref{window styles overview
}{windowstyles
}.
29 \helpref{wxTreeCtrl overview
}{wxtreectrloverview
},
\helpref{wxListBox
}{wxlistbox
},
\helpref{wxListCtrl
}{wxlistctrl
},
\rtfsp
30 \helpref{wxImageList
}{wximagelist
},
\helpref{wxTreeEvent
}{wxtreeevent
}
32 \latexignore{\rtfignore{\wxheading{Members
}}}
34 \membersection{wxTreeCtrl::wxTreeCtrl
}\label{wxtreectrlconstr
}
36 \func{}{wxTreeCtrl
}{\void}
40 \func{}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{const wxWindowID
}{ id
},
\rtfsp
41 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
42 \param{const long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
44 Constructor, creating and showing a tree control.
46 \wxheading{Parameters
}
48 \docparam{parent
}{Parent window. Must not be NULL.
}
50 \docparam{id
}{Window identifier. A value of -
1 indicates a default value.
}
52 \docparam{pos
}{Window position.
}
54 \docparam{size
}{Window size. If the default size (-
1, -
1) is specified then the window is sized
57 \docparam{style
}{Window style. See
\helpref{wxTreeCtrl
}{wxtreectrl
}.
}
59 \docparam{validator
}{Window validator.
}
61 \docparam{name
}{Window name.
}
65 \helpref{wxTreeCtrl::Create
}{wxtreectrlcreate
},
\helpref{wxValidator
}{wxvalidator
}
67 \membersection{wxTreeCtrl::
\destruct{wxTreeCtrl
}}
69 \func{void
}{\destruct{wxTreeCtrl
}}{\void}
71 Destructor, destroying the list control.
73 \membersection{wxTreeCtrl::Create
}\label{wxtreectrlcreate
}
75 \func{bool
}{wxTreeCtrl
}{\param{wxWindow*
}{ parent
},
\param{const wxWindowID
}{ id
},
\rtfsp
76 \param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\param{const wxSize\&
}{ size = wxDefaultSize
},
\rtfsp
77 \param{const long
}{ style = wxTR
\_HAS\_BUTTONS},
\param{const wxValidator\&
}{validator = wxDefaultValidator
},
\param{const wxString\&
}{name = ``listCtrl"
}}
79 Creates the tree control. See
\helpref{wxTreeCtrl::wxTreeCtrl
}{wxtreectrlconstr
} for further details.
81 \membersection{wxTreeCtrl::DeleteAllItems
}\label{wxtreectrldeleteallitems
}
83 \func{bool
}{DeleteAllItems
}{\void}
85 Deletes all the items in the control.
87 \membersection{wxTreeCtrl::DeleteItem
}\label{wxtreectrldeleteitem
}
89 \func{bool
}{DeleteItem
}{\param{const long
}{item
}}
91 Deletes the specified item.
93 \membersection{wxTreeCtrl::Edit
}\label{wxtreectrledit
}
95 \func{wxTextCtrl\&
}{Edit
}{\param{const long
}{item
}}
97 Starts editing the label of the given item, returning the text control that the tree control uses for editing.
99 \membersection{wxTreeCtrl::EnsureVisible
}\label{wxtreectrlensurevisible
}
101 \func{bool
}{EnsureVisible
}{\param{const long
}{item
}}
103 Scrolls and/or expands items to ensure that the given item is visible.
105 \membersection{wxTreeCtrl::ExpandItem
}\label{wxtreectrlexpanditem
}
107 \func{bool
}{ExpandItem
}{\param{const long
}{item
},
\param{const int
}{action
}}
109 Expands the given item.
111 {\it action
} may be one of:
114 \begin{twocollist
}\itemsep=
0pt
115 \twocolitem{\windowstyle{wxTREE
\_EXPAND\_EXPAND}}{Expands the item.
}
116 \twocolitem{\windowstyle{wxTREE
\_EXPAND\_COLLAPSE}}{Collapses the item.
}
117 \twocolitem{\windowstyle{wxTREE
\_EXPAND\_COLLAPSE\_RESET}}{Collapses the item and removes the child items.
}
118 \twocolitem{\windowstyle{wxTREE
\_EXPAND\_TOGGLE}}{Expands if the item is collapsed, collapses if the item is expanded.
}
121 \membersection{wxTreeCtrl::GetChild
}\label{wxtreectrlgetchild
}
123 \constfunc{long
}{GetChild
}{\param{const long
}{item
}}
125 Call this function to retrieve the tree view item that is the first child of the item specified by
{\it item
}.
127 \membersection{wxTreeCtrl::GetCount
}\label{wxtreectrlgetcount
}
129 \constfunc{int
}{GetCount
}{\void}
131 Returns the number of items in the control.
133 \membersection{wxTreeCtrl::GetEditControl
}\label{wxtreectrlgeteditcontrol
}
135 \constfunc{wxTextCtrl\&
}{GetEditControl
}{\void}
137 Returns the edit control used to edit a label.
139 \membersection{wxTreeCtrl::GetFirstVisibleItem
}\label{wxtreectrlgetfirstvisibleitem
}
141 \constfunc{long
}{GetFirstVisibleItem
}{\void}
143 Returns the first visible item.
145 \membersection{wxTreeCtrl::GetImageList
}\label{wxtreectrlgetimagelist
}
147 \constfunc{wxImageList*
}{GetImageList
}{\param{const int
}{which = wxIMAGE
\_LIST\_NORMAL}}
149 Returns the specified image list.
{\it which
} may be one of:
152 \begin{twocollist
}\itemsep=
0pt
153 \twocolitem{\windowstyle{wxIMAGE
\_LIST\_NORMAL}}{The normal (large icon) image list.
}
154 \twocolitem{\windowstyle{wxIMAGE
\_LIST\_SMALL}}{The small icon image list.
}
155 \twocolitem{\windowstyle{wxIMAGE
\_LIST\_STATE}}{The user-defined state image list (unimplemented).
}
158 \membersection{wxTreeCtrl::GetIndent
}\label{wxtreectrlgetindent
}
160 \constfunc{int
}{GetIndent
}{\void}
162 Returns the current tree control indentation.
164 \membersection{wxTreeCtrl::GetItem
}\label{wxtreectrlgetitem
}
166 \constfunc{bool
}{GetItem
}{\param{wxTreeItem\&
}{info
}}
168 Gets information about the item. See
\helpref{wxTreeCtrl::SetItem
}{wxtreectrlsetitem
} for more
171 \membersection{wxTreeCtrl::GetItemData
}\label{wxtreectrlgetitemdata
}
173 \constfunc{long
}{GetItemData
}{\param{const long
}{item
}}
175 Returns the client data associated with the item, if any.
177 \membersection{wxTreeCtrl::GetItemRect
}\label{wxtreectrlgetitemrect
}
179 \constfunc{bool
}{GetItemRect
}{\param{const long
}{item
},
\param{wxRect\&
}{rect
},
\param{bool
}{textOnly = FALSE
}}
181 Returns the position and size of the rectangle bounding the item.
183 \membersection{wxTreeCtrl::GetItemState
}\label{wxtreectrlgetitemstate
}
185 \constfunc{int
}{GetItemState
}{\param{const long
}{item
},
\param{const long
}{stateMask
}}
187 Gets the item state. For a list of state flags, see
\helpref{wxTreeCtrl::SetItem
}{wxtreectrlsetitem
}.
189 \membersection{wxTreeCtrl::GetItemText
}\label{wxtreectrlgetitemtext
}
191 \constfunc{wxString
}{GetItemText
}{\param{const long
}{item
}}
193 Returns the item label.
195 \membersection{wxTreeCtrl::GetNextItem
}\label{wxtreectrlgetnextitem
}
197 \constfunc{long
}{GetNextItem
}{\param{const long
}{item
},
\param{int
}{code
}}
199 Searches for an item using the given criterion, starting from
{\it item
}.
201 Returns the item or
0 if unsuccessful.
203 {\it code
} can be one of:
206 \begin{twocollist
}\itemsep=
0pt
207 \twocolitem{wxTREE
\_NEXT\_CARET}{Retrieves the currently selected item.
}
208 \twocolitem{wxTREE
\_NEXT\_CHILD}{Retrieves the first child item. The hItem parameter must be NULL.
}
209 \twocolitem{wxTREE
\_NEXT\_DROPHILITE}{Retrieves the item that is the target of a drag-and-drop operation.
}
210 \twocolitem{wxTREE
\_NEXT\_FIRSTVISIBLE}{Retrieves the first visible item.
}
211 \twocolitem{wxTREE
\_NEXT\_NEXT}{Retrieves the next sibling item.
}
212 \twocolitem{wxTREE
\_NEXT\_NEXTVISIBLE}{Retrieves the next visible item that follows the specified item.
}
213 \twocolitem{wxTREE
\_NEXT\_PARENT}{Retrieves the parent of the specified item.
}
214 \twocolitem{wxTREE
\_NEXT\_PREVIOUS}{Retrieves the previous sibling item.
}
215 \twocolitem{wxTREE
\_NEXT\_PREVIOUSVISIBLE}{Retrieves the first visible item that precedes the specified item.
}
216 \twocolitem{wxTREE
\_NEXT\_ROOT}{Retrieves the first child item of the root item of which the specified item is a part.
}
219 \membersection{wxTreeCtrl::GetNextVisibleItem
}\label{wxtreectrlgetnextvisibleitem
}
221 \constfunc{long
}{GetNextVisibleItem
}{\param{const long
}{item
}}
223 Returns the next visible item.
225 \membersection{wxTreeCtrl::GetParent
}\label{wxtreectrlgetparent
}
227 \constfunc{long
}{GetParent
}{\param{const long
}{item
}}
229 Returns the item's parent.
231 \membersection{wxTreeCtrl::GetRootItem
}\label{wxtreectrlgetrootitem
}
233 \constfunc{long
}{GetRootItem
}{\void}
235 Returns the root item for the tree control.
237 \membersection{wxTreeCtrl::GetSelection
}\label{wxtreectrlgetselection
}
239 \constfunc{long
}{GetSelection
}{\void}
241 Returns the selection, or
0 if there is no selection.
243 \membersection{wxTreeCtrl::HitTest
}\label{wxtreectrlhittest
}
245 \func{long
}{HitTest
}{\param{const wxPoint\&
}{point
},
\param{int\&
}{flags
}}
247 Calculates which (if any) item is under the given point, returning extra information
248 in
{\it flags
}.
{\it flags
} is a bitlist of the following:
251 \begin{twocollist
}\itemsep=
0pt
252 \twocolitem{wxTREE
\_HITTEST\_ABOVE}{Above the client area.
}
253 \twocolitem{wxTREE
\_HITTEST\_BELOW}{Below the client area.
}
254 \twocolitem{wxTREE
\_HITTEST\_NOWHERE}{In the client area but below the last item.
}
255 \twocolitem{wxTREE
\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.
}
256 \twocolitem{wxTREE
\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.
}
257 \twocolitem{wxTREE
\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.
}
258 \twocolitem{wxTREE
\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.
}
259 \twocolitem{wxTREE
\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.
}
260 \twocolitem{wxTREE
\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.
}
261 \twocolitem{wxTREE
\_HITTEST\_TOLEFT}{To the right of the client area.
}
262 \twocolitem{wxTREE
\_HITTEST\_TORIGHT}{To the left of the client area.
}
265 \membersection{wxTreeCtrl::InsertItem
}\label{wxtreectrlinsertitem
}
267 \func{long
}{InsertItem
}{\param{const long
}{parent
},
\param{wxTreeItem\&
}{info
},
\param{const long
}{insertAfter = wxTREE
\_INSERT\_LAST}}
269 Inserts an item. For more information on
{\it info
}, see
\helpref{wxTreeCtrl::SetItem
}{wxtreectrlsetitem
}.
271 \func{long
}{InsertItem
}{\param{const long
}{parent
},
\param{const wxString\&
}{label
},
\param{const int
}{image = -
1},
\param{const int
}{selImage = -
1},
\param{const long
}{insertAfter = wxTREE
\_INSERT\_LAST}}
275 If
{\it image
} > -
1 and
{\it selImage
} is -
1, the same image is used for
276 both selected and unselected items.
278 \membersection{wxTreeCtrl::ItemHasChildren
}\label{wxtreectrlitemhaschildren
}
280 \constfunc{bool
}{ItemHasChildren
}{\param{const long
}{item
}}
282 Returns TRUE if the item has children.
284 \membersection{wxTreeCtrl::ScrollTo
}\label{wxtreectrlscrollto
}
286 \func{bool
}{ScrollTo
}{\param{const long
}{item
}}
288 selects the specified item and scrolls the item into view,
290 \membersection{wxTreeCtrl::SelectItem
}\label{wxtreectrlselectitem
}
292 \func{bool
}{SelectItem
}{\param{const long
}{item
}}
294 Selects the given item.
296 \membersection{wxTreeCtrl::SetIndent
}\label{wxtreectrlsetindent
}
298 \func{void
}{SetIndent
}{\param{int
}{indent
}}
300 Sets the indentation for the tree control.
302 \membersection{wxTreeCtrl::SetImageList
}\label{wxtreectrlsetimagelist
}
304 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
},
\param{const int
}{which = wxIMAGE
\_LIST\_NORMAL}}
306 Sets the image list.
{\it which
} should be one of wxIMAGE
\_LIST\_NORMAL, wxIMAGE
\_LIST\_SMALL and
307 wxIMAGE
\_LIST\_STATE.
309 \membersection{wxTreeCtrl::SetItem
}\label{wxtreectrlsetitem
}
311 \func{bool
}{SetItem
}{\param{wxTreeItem\&
}{info
}}
313 Sets the properties of the item.
315 The members of wxTreeItem are as follows:
318 \begin{twocollist
}\itemsep=
0pt
319 \twocolitem{m
\_mask}{A bitlist specifying the valid members. See below for mask flags.
}
320 \twocolitem{m
\_itemId}{The item identifier.
}
321 \twocolitem{m
\_state}{The item state. See below for state flags.
}
322 \twocolitem{m
\_stateMask}{A bitlist specifying the valid contents of
{\it m
\_state}. These flags
323 are taken from the same set of symbols as
{\it m
\_state}.
}
324 \twocolitem{m
\_text}{The item label.
}
325 \twocolitem{m
\_image}{The item image index (an index into the appropriate image list).
}
326 \twocolitem{m
\_selectedImage}{The item selected index (an index into the appropriate image list).
}
327 \twocolitem{m
\_children}{The number of child items that this item has.
}
328 \twocolitem{m
\_data}{The application-defined data associated with this item.
}
331 Valid mask flags are:
334 \begin{twocollist
}\itemsep=
0pt
335 \twocolitem{wxTREE
\_MASK\_HANDLE}{The
{\it m
\_itemId} member is valid.
}
336 \twocolitem{wxTREE
\_MASK\_STATE}{The
{\it m
\_state} member is valid.
}
337 \twocolitem{wxTREE
\_MASK\_TEXT}{The
{\it m
\_text} member is valid.
}
338 \twocolitem{wxTREE
\_MASK\_IMAGE}{The
{\it m
\_image} member is valid.
}
339 \twocolitem{wxTREE
\_MASK\_SELECTED\_IMAGE}{The
{\it m
\_selectedImage} member is valid.
}
340 \twocolitem{wxTREE
\_MASK\_CHILDREN}{The
{\it m
\_children} member is valid.
}
341 \twocolitem{wxTREE
\_MASK\_DATA}{The
{\it m
\_data} member is valid.
}
344 Valid state and state mask flags are:
347 \begin{twocollist
}\itemsep=
0pt
348 \twocolitem{wxTREE
\_STATE\_BOLD}{The label is emboldened.
}
349 \twocolitem{wxTREE
\_STATE\_DROPHILITED}{The item indicates it is a drop target.
}
350 \twocolitem{wxTREE
\_STATE\_EXPANDED}{The item is expanded.
}
351 \twocolitem{wxTREE
\_STATE\_EXPANDEDONCE}{The item's list of child items has been expanded at least once.
}
352 \twocolitem{wxTREE
\_STATE\_FOCUSED}{The item has the focus, so it is surrounded by a standard focus rectangle.
353 Only one item can have the focus.
}
354 \twocolitem{wxTREE
\_STATE\_SELECTED}{The item is selected.
}
355 \twocolitem{wxTREE
\_STATE\_CUT}{The item is selected as part of a cut and paste operation.
}
358 \membersection{wxTreeCtrl::SetItemImage
}\label{wxtreectrlsetitemimage
}
360 \func{bool
}{SetItemImage
}{\param{const long
}{item
},
\param{const int
}{image
},
\param{const int
}{selImage
}}
362 Sets the item image and selected image. These are indices into the assciated image list.
364 \membersection{wxTreeCtrl::SetItemState
}\label{wxtreectrlsetitemstate
}
366 \func{bool
}{SetItemState
}{\param{const long
}{item
},
\param{const long
}{state
},
\param{const long
}{stateMask
}}
368 Sets the item state. See
\helpref{wxTreeCtrl::SetItem
}{wxtreectrlsetitem
} for valid state and state mask flags.
370 \membersection{wxTreeCtrl::SetItemText
}\label{wxtreectrlsetitemtext
}
372 \func{void
}{SetItemText
}{\param{const long
}{item
},
\param{const wxString\&
}{text
}}
376 \membersection{wxTreeCtrl::SetItemData
}\label{wxtreectrlsetitemdata
}
378 \func{bool
}{SetItemData
}{\param{const long
}{item
},
\param{long
}{data
}}
380 Sets the item client data.
382 \membersection{wxTreeCtrl::SortChildren
}\label{wxtreectrlsortchildren
}
384 \func{bool
}{SortChildren
}{\param{const long
}{item
}}
386 Sorts the children of the given item in ascending alphabetical order.