]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/treectrl.tex
Doc updates (debug stuff); Cygwin corrections
[wxWidgets.git] / docs / latex / wx / treectrl.tex
CommitLineData
a660d684
KB
1\section{\class{wxTreeCtrl}}\label{wxtreectrl}
2
3A tree control presents information as a hierarchy, with items that may be expanded
4to show further items. Items in a tree control are referenced by long integer handles.
5
6To intercept events from a tree control, use the event table macros described in \helpref{wxTreeEvent}{wxtreeevent}.
7
8\wxheading{Derived from}
9
10\helpref{wxControl}{wxcontrol}\\
11\helpref{wxWindow}{wxwindow}\\
12\helpref{wxEvtHandler}{wxevthandler}\\
13\helpref{wxObject}{wxobject}
14
15\wxheading{Window styles}
16
17\twocolwidtha{5cm}
18\begin{twocollist}\itemsep=0pt
19\twocolitem{\windowstyle{wxTR\_HAS\_BUTTONS}}{Use this style to show + and - buttons to the
20left of parent items.}
21\twocolitem{\windowstyle{wxTR\_EDIT\_LABELS}}{Use this style if you wish the user to be
22able to edit labels in the tree control.}
23\end{twocollist}
24
25See also \helpref{window styles overview}{windowstyles}.
26
5de76427
JS
27\wxheading{Event handling}
28
29To process input from a tree control, use these event handler macros to direct input to member
30functions that take a \helpref{wxTreeEvent}{wxtreeevent} argument.
31
32\twocolwidtha{7cm}
33\begin{twocollist}\itemsep=0pt
34\twocolitem{{\bf EVT\_TREE\_BEGIN\_DRAG(id, func)}}{Begin dragging with the left mouse button.}
35\twocolitem{{\bf EVT\_TREE\_BEGIN\_RDRAG(id, func)}}{Begin dragging with the right mouse button.}
36\twocolitem{{\bf EVT\_TREE\_BEGIN\_LABEL\_EDIT(id, func)}}{Begin editing a label.}
37\twocolitem{{\bf EVT\_TREE\_END\_LABEL\_EDIT(id, func)}}{Finish editing a label.}
38\twocolitem{{\bf EVT\_TREE\_DELETE\_ITEM(id, func)}}{Delete an item.}
39\twocolitem{{\bf EVT\_TREE\_GET\_INFO(id, func)}}{Request information from the application.}
40\twocolitem{{\bf EVT\_TREE\_SET\_INFO(id, func)}}{Information is being supplied.}
41\twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDED(id, func)}}{Parent has been expanded.}
42\twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDING(id, func)}}{Parent is being expanded.}
43\twocolitem{{\bf EVT\_TREE\_SEL\_CHANGED(id, func)}}{Selection has changed.}
44\twocolitem{{\bf EVT\_TREE\_SEL\_CHANGING(id, func)}}{Selection is changing.}
45\twocolitem{{\bf EVT\_TREE\_KEY\_DOWN(id, func)}}{A key has been pressed.}
46\end{twocollist}%
47
a660d684
KB
48\wxheading{See also}
49
50\helpref{wxTreeCtrl overview}{wxtreectrloverview}, \helpref{wxListBox}{wxlistbox}, \helpref{wxListCtrl}{wxlistctrl},\rtfsp
51\helpref{wxImageList}{wximagelist}, \helpref{wxTreeEvent}{wxtreeevent}
52
53\latexignore{\rtfignore{\wxheading{Members}}}
54
55\membersection{wxTreeCtrl::wxTreeCtrl}\label{wxtreectrlconstr}
56
57\func{}{wxTreeCtrl}{\void}
58
59Default constructor.
60
eaaa6a06 61\func{}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 62\param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06 63\param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}}
a660d684
KB
64
65Constructor, creating and showing a tree control.
66
67\wxheading{Parameters}
68
69\docparam{parent}{Parent window. Must not be NULL.}
70
71\docparam{id}{Window identifier. A value of -1 indicates a default value.}
72
73\docparam{pos}{Window position.}
74
75\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
76appropriately.}
77
78\docparam{style}{Window style. See \helpref{wxTreeCtrl}{wxtreectrl}.}
79
80\docparam{validator}{Window validator.}
81
82\docparam{name}{Window name.}
83
84\wxheading{See also}
85
86\helpref{wxTreeCtrl::Create}{wxtreectrlcreate}, \helpref{wxValidator}{wxvalidator}
87
88\membersection{wxTreeCtrl::\destruct{wxTreeCtrl}}
89
90\func{void}{\destruct{wxTreeCtrl}}{\void}
91
92Destructor, destroying the list control.
93
94\membersection{wxTreeCtrl::Create}\label{wxtreectrlcreate}
95
eaaa6a06 96\func{bool}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
a660d684 97\param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
eaaa6a06 98\param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}}
a660d684
KB
99
100Creates the tree control. See \helpref{wxTreeCtrl::wxTreeCtrl}{wxtreectrlconstr} for further details.
101
102\membersection{wxTreeCtrl::DeleteAllItems}\label{wxtreectrldeleteallitems}
103
104\func{bool}{DeleteAllItems}{\void}
105
106Deletes all the items in the control.
107
108\membersection{wxTreeCtrl::DeleteItem}\label{wxtreectrldeleteitem}
109
eaaa6a06 110\func{bool}{DeleteItem}{\param{long }{item}}
a660d684
KB
111
112Deletes the specified item.
113
bbcdf8bc 114\membersection{wxTreeCtrl::EditLabel}\label{wxtreectrleditlabel}
a660d684 115
bbcdf8bc 116\func{wxTextCtrl*}{EditLabel}{\param{long }{item}, \param{wxClassInfo*}{ textControlClass = CLASSINFO(wxTextCtrl)}}
a660d684
KB
117
118Starts editing the label of the given item, returning the text control that the tree control uses for editing.
119
bbcdf8bc
JS
120Pass another {\it textControlClass} if a derived class is required. It usually will be, in order for
121the application to detect when editing has finished and to call \helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}.
122
123Do not delete the text control yourself.
124
125This function is currently supported under Windows only.
126
127\wxheading{See also}
128
129\helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}
130
131\membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel}
132
133\func{bool}{EndEditLabel}{\param{bool }{cancelEdit}}
134
135Ends label editing. If {\it cancelEdit} is TRUE, the edit will be cancelled.
136
137This function is currently supported under Windows only.
138
139\wxheading{See also}
140
141\helpref{wxTreeCtrl::EditLabel}{wxtreectrleditlabel}
142
a660d684
KB
143\membersection{wxTreeCtrl::EnsureVisible}\label{wxtreectrlensurevisible}
144
eaaa6a06 145\func{bool}{EnsureVisible}{\param{long }{item}}
a660d684
KB
146
147Scrolls and/or expands items to ensure that the given item is visible.
148
149\membersection{wxTreeCtrl::ExpandItem}\label{wxtreectrlexpanditem}
150
eaaa6a06 151\func{bool}{ExpandItem}{\param{long }{item}, \param{int }{action}}
a660d684
KB
152
153Expands the given item.
154
155{\it action} may be one of:
156
157\twocolwidtha{5cm}
158\begin{twocollist}\itemsep=0pt
159\twocolitem{\windowstyle{wxTREE\_EXPAND\_EXPAND}}{Expands the item.}
160\twocolitem{\windowstyle{wxTREE\_EXPAND\_COLLAPSE}}{Collapses the item.}
161\twocolitem{\windowstyle{wxTREE\_EXPAND\_COLLAPSE\_RESET}}{Collapses the item and removes the child items.}
162\twocolitem{\windowstyle{wxTREE\_EXPAND\_TOGGLE}}{Expands if the item is collapsed, collapses if the item is expanded.}
163\end{twocollist}
164
165\membersection{wxTreeCtrl::GetChild}\label{wxtreectrlgetchild}
166
eaaa6a06 167\constfunc{long}{GetChild}{\param{long }{item}}
a660d684
KB
168
169Call this function to retrieve the tree view item that is the first child of the item specified by {\it item}.
170
171\membersection{wxTreeCtrl::GetCount}\label{wxtreectrlgetcount}
172
173\constfunc{int}{GetCount}{\void}
174
175Returns the number of items in the control.
176
177\membersection{wxTreeCtrl::GetEditControl}\label{wxtreectrlgeteditcontrol}
178
179\constfunc{wxTextCtrl\&}{GetEditControl}{\void}
180
181Returns the edit control used to edit a label.
182
183\membersection{wxTreeCtrl::GetFirstVisibleItem}\label{wxtreectrlgetfirstvisibleitem}
184
185\constfunc{long}{GetFirstVisibleItem}{\void}
186
187Returns the first visible item.
188
189\membersection{wxTreeCtrl::GetImageList}\label{wxtreectrlgetimagelist}
190
eaaa6a06 191\constfunc{wxImageList*}{GetImageList}{\param{int }{which = wxIMAGE\_LIST\_NORMAL}}
a660d684
KB
192
193Returns the specified image list. {\it which} may be one of:
194
195\twocolwidtha{5cm}
196\begin{twocollist}\itemsep=0pt
197\twocolitem{\windowstyle{wxIMAGE\_LIST\_NORMAL}}{The normal (large icon) image list.}
198\twocolitem{\windowstyle{wxIMAGE\_LIST\_SMALL}}{The small icon image list.}
199\twocolitem{\windowstyle{wxIMAGE\_LIST\_STATE}}{The user-defined state image list (unimplemented).}
200\end{twocollist}
201
202\membersection{wxTreeCtrl::GetIndent}\label{wxtreectrlgetindent}
203
204\constfunc{int}{GetIndent}{\void}
205
206Returns the current tree control indentation.
207
208\membersection{wxTreeCtrl::GetItem}\label{wxtreectrlgetitem}
209
210\constfunc{bool}{GetItem}{\param{wxTreeItem\& }{info}}
211
212Gets information about the item. See \helpref{wxTreeCtrl::SetItem}{wxtreectrlsetitem} for more
213information.
214
215\membersection{wxTreeCtrl::GetItemData}\label{wxtreectrlgetitemdata}
216
eaaa6a06 217\constfunc{long}{GetItemData}{\param{long }{item}}
a660d684
KB
218
219Returns the client data associated with the item, if any.
220
221\membersection{wxTreeCtrl::GetItemRect}\label{wxtreectrlgetitemrect}
222
eaaa6a06 223\constfunc{bool}{GetItemRect}{\param{long }{item}, \param{wxRect\& }{rect}, \param{bool }{textOnly = FALSE}}
a660d684
KB
224
225Returns the position and size of the rectangle bounding the item.
226
227\membersection{wxTreeCtrl::GetItemState}\label{wxtreectrlgetitemstate}
228
eaaa6a06 229\constfunc{int}{GetItemState}{\param{long }{item}, \param{long }{stateMask}}
a660d684
KB
230
231Gets the item state. For a list of state flags, see \helpref{wxTreeCtrl::SetItem}{wxtreectrlsetitem}.
232
233\membersection{wxTreeCtrl::GetItemText}\label{wxtreectrlgetitemtext}
234
eaaa6a06 235\constfunc{wxString}{GetItemText}{\param{long }{item}}
a660d684
KB
236
237Returns the item label.
238
239\membersection{wxTreeCtrl::GetNextItem}\label{wxtreectrlgetnextitem}
240
eaaa6a06 241\constfunc{long}{GetNextItem}{\param{long }{item}, \param{int }{code}}
a660d684
KB
242
243Searches for an item using the given criterion, starting from {\it item}.
244
245Returns the item or 0 if unsuccessful.
246
247{\it code} can be one of:
248
249\twocolwidtha{5cm}
250\begin{twocollist}\itemsep=0pt
251\twocolitem{wxTREE\_NEXT\_CARET}{Retrieves the currently selected item.}
252\twocolitem{wxTREE\_NEXT\_CHILD}{Retrieves the first child item. The hItem parameter must be NULL.}
253\twocolitem{wxTREE\_NEXT\_DROPHILITE}{Retrieves the item that is the target of a drag-and-drop operation.}
254\twocolitem{wxTREE\_NEXT\_FIRSTVISIBLE}{Retrieves the first visible item.}
255\twocolitem{wxTREE\_NEXT\_NEXT}{Retrieves the next sibling item.}
256\twocolitem{wxTREE\_NEXT\_NEXTVISIBLE}{Retrieves the next visible item that follows the specified item.}
257\twocolitem{wxTREE\_NEXT\_PARENT}{Retrieves the parent of the specified item.}
258\twocolitem{wxTREE\_NEXT\_PREVIOUS}{Retrieves the previous sibling item.}
259\twocolitem{wxTREE\_NEXT\_PREVIOUSVISIBLE}{Retrieves the first visible item that precedes the specified item.}
260\twocolitem{wxTREE\_NEXT\_ROOT}{Retrieves the first child item of the root item of which the specified item is a part.}
261\end{twocollist}
262
263\membersection{wxTreeCtrl::GetNextVisibleItem}\label{wxtreectrlgetnextvisibleitem}
264
eaaa6a06 265\constfunc{long}{GetNextVisibleItem}{\param{long }{item}}
a660d684
KB
266
267Returns the next visible item.
268
269\membersection{wxTreeCtrl::GetParent}\label{wxtreectrlgetparent}
270
eaaa6a06 271\constfunc{long}{GetParent}{\param{long }{item}}
a660d684
KB
272
273Returns the item's parent.
274
275\membersection{wxTreeCtrl::GetRootItem}\label{wxtreectrlgetrootitem}
276
277\constfunc{long}{GetRootItem}{\void}
278
279Returns the root item for the tree control.
280
281\membersection{wxTreeCtrl::GetSelection}\label{wxtreectrlgetselection}
282
283\constfunc{long}{GetSelection}{\void}
284
285Returns the selection, or 0 if there is no selection.
286
287\membersection{wxTreeCtrl::HitTest}\label{wxtreectrlhittest}
288
289\func{long}{HitTest}{\param{const wxPoint\& }{point}, \param{int\& }{flags}}
290
291Calculates which (if any) item is under the given point, returning extra information
292in {\it flags}. {\it flags} is a bitlist of the following:
293
294\twocolwidtha{5cm}
295\begin{twocollist}\itemsep=0pt
296\twocolitem{wxTREE\_HITTEST\_ABOVE}{Above the client area.}
297\twocolitem{wxTREE\_HITTEST\_BELOW}{Below the client area.}
298\twocolitem{wxTREE\_HITTEST\_NOWHERE}{In the client area but below the last item.}
299\twocolitem{wxTREE\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.}
300\twocolitem{wxTREE\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.}
301\twocolitem{wxTREE\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.}
302\twocolitem{wxTREE\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.}
303\twocolitem{wxTREE\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.}
304\twocolitem{wxTREE\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.}
305\twocolitem{wxTREE\_HITTEST\_TOLEFT}{To the right of the client area.}
306\twocolitem{wxTREE\_HITTEST\_TORIGHT}{To the left of the client area.}
307\end{twocollist}
308
309\membersection{wxTreeCtrl::InsertItem}\label{wxtreectrlinsertitem}
310
eaaa6a06 311\func{long}{InsertItem}{\param{long }{parent}, \param{wxTreeItem\& }{info}, \param{long }{insertAfter = wxTREE\_INSERT\_LAST}}
a660d684
KB
312
313Inserts an item. For more information on {\it info}, see \helpref{wxTreeCtrl::SetItem}{wxtreectrlsetitem}.
314
eaaa6a06 315\func{long}{InsertItem}{\param{long }{parent}, \param{const wxString\& }{label}, \param{int }{image = -1}, \param{int }{selImage = -1}, \param{long }{insertAfter = wxTREE\_INSERT\_LAST}}
a660d684
KB
316
317Inserts an item.
318
319If {\it image} > -1 and {\it selImage} is -1, the same image is used for
320both selected and unselected items.
321
322\membersection{wxTreeCtrl::ItemHasChildren}\label{wxtreectrlitemhaschildren}
323
eaaa6a06 324\constfunc{bool}{ItemHasChildren}{\param{long }{item}}
a660d684
KB
325
326Returns TRUE if the item has children.
327
328\membersection{wxTreeCtrl::ScrollTo}\label{wxtreectrlscrollto}
329
eaaa6a06 330\func{bool}{ScrollTo}{\param{long }{item}}
a660d684
KB
331
332selects the specified item and scrolls the item into view,
333
334\membersection{wxTreeCtrl::SelectItem}\label{wxtreectrlselectitem}
335
eaaa6a06 336\func{bool}{SelectItem}{\param{long }{item}}
a660d684
KB
337
338Selects the given item.
339
340\membersection{wxTreeCtrl::SetIndent}\label{wxtreectrlsetindent}
341
342\func{void}{SetIndent}{\param{int }{indent}}
343
344Sets the indentation for the tree control.
345
346\membersection{wxTreeCtrl::SetImageList}\label{wxtreectrlsetimagelist}
347
eaaa6a06 348\func{void}{SetImageList}{\param{wxImageList*}{ imageList}, \param{int }{which = wxIMAGE\_LIST\_NORMAL}}
a660d684
KB
349
350Sets the image list. {\it which} should be one of wxIMAGE\_LIST\_NORMAL, wxIMAGE\_LIST\_SMALL and
351wxIMAGE\_LIST\_STATE.
352
353\membersection{wxTreeCtrl::SetItem}\label{wxtreectrlsetitem}
354
355\func{bool}{SetItem}{\param{wxTreeItem\& }{info}}
356
357Sets the properties of the item.
358
359The members of wxTreeItem are as follows:
360
361\twocolwidtha{5cm}
362\begin{twocollist}\itemsep=0pt
363\twocolitem{m\_mask}{A bitlist specifying the valid members. See below for mask flags.}
364\twocolitem{m\_itemId}{The item identifier.}
365\twocolitem{m\_state}{The item state. See below for state flags.}
366\twocolitem{m\_stateMask}{A bitlist specifying the valid contents of {\it m\_state}. These flags
367are taken from the same set of symbols as {\it m\_state}.}
368\twocolitem{m\_text}{The item label.}
369\twocolitem{m\_image}{The item image index (an index into the appropriate image list).}
370\twocolitem{m\_selectedImage}{The item selected index (an index into the appropriate image list).}
371\twocolitem{m\_children}{The number of child items that this item has.}
372\twocolitem{m\_data}{The application-defined data associated with this item.}
373\end{twocollist}
374
375Valid mask flags are:
376
377\twocolwidtha{5cm}
378\begin{twocollist}\itemsep=0pt
379\twocolitem{wxTREE\_MASK\_HANDLE}{The {\it m\_itemId} member is valid.}
380\twocolitem{wxTREE\_MASK\_STATE}{The {\it m\_state} member is valid.}
381\twocolitem{wxTREE\_MASK\_TEXT}{The {\it m\_text} member is valid.}
382\twocolitem{wxTREE\_MASK\_IMAGE}{The {\it m\_image} member is valid.}
383\twocolitem{wxTREE\_MASK\_SELECTED\_IMAGE}{The {\it m\_selectedImage} member is valid.}
384\twocolitem{wxTREE\_MASK\_CHILDREN}{The {\it m\_children} member is valid.}
385\twocolitem{wxTREE\_MASK\_DATA}{The {\it m\_data} member is valid.}
386\end{twocollist}
387
388Valid state and state mask flags are:
389
390\twocolwidtha{5cm}
391\begin{twocollist}\itemsep=0pt
392\twocolitem{wxTREE\_STATE\_BOLD}{The label is emboldened.}
393\twocolitem{wxTREE\_STATE\_DROPHILITED}{The item indicates it is a drop target.}
394\twocolitem{wxTREE\_STATE\_EXPANDED}{The item is expanded.}
395\twocolitem{wxTREE\_STATE\_EXPANDEDONCE}{The item's list of child items has been expanded at least once.}
396\twocolitem{wxTREE\_STATE\_FOCUSED}{The item has the focus, so it is surrounded by a standard focus rectangle.
397Only one item can have the focus.}
398\twocolitem{wxTREE\_STATE\_SELECTED}{The item is selected.}
399\twocolitem{wxTREE\_STATE\_CUT}{The item is selected as part of a cut and paste operation.}
400\end{twocollist}
401
402\membersection{wxTreeCtrl::SetItemImage}\label{wxtreectrlsetitemimage}
403
eaaa6a06 404\func{bool}{SetItemImage}{\param{long }{item}, \param{int }{image}, \param{int }{selImage}}
a660d684
KB
405
406Sets the item image and selected image. These are indices into the assciated image list.
407
408\membersection{wxTreeCtrl::SetItemState}\label{wxtreectrlsetitemstate}
409
eaaa6a06 410\func{bool}{SetItemState}{\param{long }{item}, \param{long }{state}, \param{long }{stateMask}}
a660d684
KB
411
412Sets the item state. See \helpref{wxTreeCtrl::SetItem}{wxtreectrlsetitem} for valid state and state mask flags.
413
414\membersection{wxTreeCtrl::SetItemText}\label{wxtreectrlsetitemtext}
415
eaaa6a06 416\func{void}{SetItemText}{\param{long }{item}, \param{const wxString\& }{text}}
a660d684
KB
417
418Sets the item label.
419
420\membersection{wxTreeCtrl::SetItemData}\label{wxtreectrlsetitemdata}
421
eaaa6a06 422\func{bool}{SetItemData}{\param{long }{item}, \param{long }{data}}
a660d684
KB
423
424Sets the item client data.
425
426\membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren}
427
eaaa6a06 428\func{bool}{SortChildren}{\param{long }{item}}
a660d684
KB
429
430Sorts the children of the given item in ascending alphabetical order.
431