]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/treectrl.tex
added wxFileName::MakeRelativeTo() and the tests/docs for it
[wxWidgets.git] / docs / latex / wx / treectrl.tex
... / ...
CommitLineData
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 wxTreeItemId 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{Include files}
16
17<wx/treectrl.h>
18
19\wxheading{Window styles}
20
21\twocolwidtha{5cm}
22\begin{twocollist}\itemsep=0pt
23\twocolitem{\windowstyle{wxTR\_EDIT\_LABELS}}{Use this style
24if you wish the user to be able to edit labels in the tree control.}
25\twocolitem{\windowstyle{wxTR\_NO\_BUTTONS}}{For convenience
26to document that no buttons are to be drawn.}
27\twocolitem{\windowstyle{wxTR\_HAS\_BUTTONS}}{Use this style
28to show + and - buttons to the left of parent items.}
29\twocolitem{\windowstyle{wxTR\_TWIST\_BUTTONS}}{Use this style
30to show Mac-style twister buttons to the left of parent items.
31If both wxTR\_HAS\_BUTTONS and wxTR\_TWIST\_BUTTONS are given,
32twister buttons are generated. Generic only.}
33\twocolitem{\windowstyle{wxTR\_NO\_LINES}}{Use this style
34to hide vertical level connectors.}
35\twocolitem{\windowstyle{wxTR\_LINES\_AT\_ROOT}}{Use this style
36to show lines between root nodes.
37Only applicable if wxTR\_HIDE\_ROOT is set and wxTR\_NO\_LINES is not set.}
38\twocolitem{\windowstyle{wxTR\_HIDE\_ROOT}}{Use this style
39to suppress the display of the root node,
40effectively causing the first-level nodes
41to appear as a series of root nodes. Generic only.}
42\twocolitem{\windowstyle{wxTR\_ROW\_LINES}}{Use this style
43to draw a contrasting border between displayed rows.}
44\twocolitem{\windowstyle{wxTR\_HAS\_VARIABLE\_ROW\_HEIGHT}}{Use this style
45to cause row heights to be just big enough to fit the content.
46If not set, all rows use the largest row height.
47The default is that this flag is unset.
48Generic only.}
49\twocolitem{\windowstyle{wxTR\_SINGLE}}{For convenience
50to document that only one item may be selected at a time.
51Selecting another item causes the current selection, if any,
52to be deselected. This is the default.}
53\twocolitem{\windowstyle{wxTR\_MULTIPLE}}{Use this style
54to allow a range of items to be selected.
55If a second range is selected, the current range, if any, is deselected.}
56\twocolitem{\windowstyle{wxTR\_EXTENDED}}{Use this style
57to allow disjoint items to be selected. (Only partially implemented; may not work in all cases.)}
58\twocolitem{\windowstyle{wxTR\_DEFAULT\_STYLE}}{The set of flags that are
59closest to the defaults for the native control for a particular toolkit.}
60\end{twocollist}
61
62See also \helpref{window styles overview}{windowstyles}.
63
64\wxheading{Event handling}
65
66To process input from a tree control, use these event handler macros to direct input to member
67functions that take a \helpref{wxTreeEvent}{wxtreeevent} argument.
68
69\twocolwidtha{7cm}
70\begin{twocollist}\itemsep=0pt
71\twocolitem{{\bf EVT\_TREE\_BEGIN\_DRAG(id, func)}}{Begin dragging with the left mouse button.}
72\twocolitem{{\bf EVT\_TREE\_BEGIN\_RDRAG(id, func)}}{Begin dragging with the right mouse button.}
73\twocolitem{{\bf EVT\_TREE\_BEGIN\_LABEL\_EDIT(id, func)}}{Begin editing a label. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.}
74\twocolitem{{\bf EVT\_TREE\_END\_LABEL\_EDIT(id, func)}}{Finish editing a label. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.}
75\twocolitem{{\bf EVT\_TREE\_DELETE\_ITEM(id, func)}}{Delete an item.}
76\twocolitem{{\bf EVT\_TREE\_GET\_INFO(id, func)}}{Request information from the application.}
77\twocolitem{{\bf EVT\_TREE\_SET\_INFO(id, func)}}{Information is being supplied.}
78\twocolitem{{\bf EVT\_TREE\_ITEM\_ACTIVATED(id, func)}}{The item has been activated, i.e. chosen by double clicking it with mouse or from keyboard}
79\twocolitem{{\bf EVT\_TREE\_ITEM\_COLLAPSED(id, func)}}{The item has been collapsed.}
80\twocolitem{{\bf EVT\_TREE\_ITEM\_COLLAPSING(id, func)}}{The item is being collapsed. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.}
81\twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDED(id, func)}}{The item has been expanded.}
82\twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDING(id, func)}}{The item is being expanded. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.}
83\twocolitem{{\bf EVT\_TREE\_SEL\_CHANGED(id, func)}}{Selection has changed.}
84\twocolitem{{\bf EVT\_TREE\_SEL\_CHANGING(id, func)}}{Selection is changing. This can be prevented by calling \helpref{Veto()}{wxnotifyeventveto}.}
85\twocolitem{{\bf EVT\_TREE\_KEY\_DOWN(id, func)}}{A key has been pressed.}
86\end{twocollist}%
87
88\wxheading{See also}
89
90\helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{wxTreeCtrl overview}{wxtreectrloverview}, \helpref{wxListBox}{wxlistbox}, \helpref{wxListCtrl}{wxlistctrl},\rtfsp
91\helpref{wxImageList}{wximagelist}, \helpref{wxTreeEvent}{wxtreeevent}
92
93\wxheading{Win32 notes}
94
95wxTreeCtrl class uses the standard common treeview control under Win32
96implemented in the system library {\tt comctl32.dll}. Some versions of this
97library are known to have bugs with handling the tree control colours: the
98usual symptom is that the expanded items leave black (or otherwise incorrectly
99coloured) background behind them, especially for the controls using non
100default background colour. The recommended solution is to upgrade the {\tt comctl32.dll}
101to a newer version: see
102\urlref{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp}{http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp}.
103
104\latexignore{\rtfignore{\wxheading{Members}}}
105
106\membersection{wxTreeCtrl::wxTreeCtrl}\label{wxtreectrlconstr}
107
108\func{}{wxTreeCtrl}{\void}
109
110Default constructor.
111
112\func{}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
113\param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
114\param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}}
115
116Constructor, creating and showing a tree control.
117
118\wxheading{Parameters}
119
120\docparam{parent}{Parent window. Must not be NULL.}
121
122\docparam{id}{Window identifier. A value of -1 indicates a default value.}
123
124\docparam{pos}{Window position.}
125
126\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized
127appropriately.}
128
129\docparam{style}{Window style. See \helpref{wxTreeCtrl}{wxtreectrl}.}
130
131\docparam{validator}{Window validator.}
132
133\docparam{name}{Window name.}
134
135\wxheading{See also}
136
137\helpref{wxTreeCtrl::Create}{wxtreectrlcreate}, \helpref{wxValidator}{wxvalidator}
138
139\membersection{wxTreeCtrl::\destruct{wxTreeCtrl}}
140
141\func{void}{\destruct{wxTreeCtrl}}{\void}
142
143Destructor, destroying the list control.
144
145\membersection{wxTreeCtrl::AddRoot}\label{wxtreectrladdroot}
146
147\func{wxTreeItemId}{AddRoot}{\param{const wxString\&}{ text},
148 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
149
150Adds the root node to the tree, returning the new item.
151
152The {\it image} and {\it selImage} parameters are an index within
153the normal image list specifying the image to use for unselected and
154selected items, respectively.
155If {\it image} > -1 and {\it selImage} is -1, the same image is used for
156both selected and unselected items.
157
158\membersection{wxTreeCtrl::AppendItem}\label{wxtreectrlappenditem}
159
160\func{wxTreeItemId}{AppendItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text},
161 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
162
163Appends an item to the end of the branch identified by {\it parent}, return a new item id.
164
165The {\it image} and {\it selImage} parameters are an index within
166the normal image list specifying the image to use for unselected and
167selected items, respectively.
168If {\it image} > -1 and {\it selImage} is -1, the same image is used for
169both selected and unselected items.
170
171\membersection{wxTreeCtrl::AssignButtonsImageList}\label{wxtreectrlassignbuttonsimagelist}
172
173\func{void}{AssignButtonsImageList}{\param{wxImageList*}{ imageList}}
174
175Sets the buttons image list. The button images assigned with this method will
176be automatically deleted by wxTreeCtrl as appropriate
177(i.e. it takes ownership of the list).
178
179Setting or assigning the button image list enables the display of image buttons.
180Once enabled, the only way to disable the display of button images is to set
181the button image list to NULL.
182
183This function is only available in the generic version.
184
185See also \helpref{SetButtonsImageList}{wxtreectrlsetbuttonsimagelist}.
186
187\membersection{wxTreeCtrl::AssignImageList}\label{wxtreectrlassignimagelist}
188
189\func{void}{AssignImageList}{\param{wxImageList*}{ imageList}}
190
191Sets the normal image list. Image list assigned with this method will
192be automatically deleted by wxTreeCtrl as appropriate
193(i.e. it takes ownership of the list).
194
195See also \helpref{SetImageList}{wxtreectrlsetimagelist}.
196
197\membersection{wxTreeCtrl::AssignStateImageList}\label{wxtreectrlassignstateimagelist}
198
199\func{void}{AssignStateImageList}{\param{wxImageList*}{ imageList}}
200
201Sets the state image list. Image list assigned with this method will
202be automatically deleted by wxTreeCtrl as appropriate
203(i.e. it takes ownership of the list).
204
205See also \helpref{SetStateImageList}{wxtreectrlsetstateimagelist}.
206
207
208\membersection{wxTreeCtrl::Collapse}\label{wxtreectrlcollapse}
209
210\func{void}{Collapse}{\param{const wxTreeItemId\&}{ item}}
211
212Collapses the given item.
213
214\membersection{wxTreeCtrl::CollapseAndReset}\label{wxtreectrlcollapseandreset}
215
216\func{void}{CollapseAndReset}{\param{const wxTreeItemId\&}{ item}}
217
218Collapses the given item and removes all children.
219
220\membersection{wxTreeCtrl::Create}\label{wxtreectrlcreate}
221
222\func{bool}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp
223\param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp
224\param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}}
225
226Creates the tree control. See \helpref{wxTreeCtrl::wxTreeCtrl}{wxtreectrlconstr} for further details.
227
228\membersection{wxTreeCtrl::Delete}\label{wxtreectrldelete}
229
230\func{void}{Delete}{\param{const wxTreeItemId\&}{ item}}
231
232Deletes the specified item.
233
234\membersection{wxTreeCtrl::DeleteAllItems}\label{wxtreectrldeleteallitems}
235
236\func{void}{DeleteAllItems}{\void}
237
238Deletes all the items in the control.
239
240\membersection{wxTreeCtrl::EditLabel}\label{wxtreectrleditlabel}
241
242\func{void}{EditLabel}{\param{const wxTreeItemId\&}{ item}}
243
244Starts editing the label of the given item. This function generates a
245EVT\_TREE\_BEGIN\_LABEL\_EDIT event which can be vetoed so that no
246text control will appear for in-place editing.
247
248If the user changed the label (i.e. s/he does not press ESC or leave
249the text control without changes, a EVT\_TREE\_END\_LABEL\_EDIT event
250will be sent which can be vetoed as well.
251
252\wxheading{See also}
253
254\helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel},
255\helpref{wxTreeEvent}{wxtreeevent}
256
257\membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel}
258
259\func{void}{EndEditLabel}{\param{bool }{cancelEdit}}
260
261Ends label editing. If {\it cancelEdit} is TRUE, the edit will be cancelled.
262
263This function is currently supported under Windows only.
264
265\wxheading{See also}
266
267\helpref{wxTreeCtrl::EditLabel}{wxtreectrleditlabel}
268
269\membersection{wxTreeCtrl::EnsureVisible}\label{wxtreectrlensurevisible}
270
271\func{void}{EnsureVisible}{\param{const wxTreeItemId\&}{ item}}
272
273Scrolls and/or expands items to ensure that the given item is visible.
274
275\membersection{wxTreeCtrl::Expand}\label{wxtreectrlexpand}
276
277\func{void}{Expand}{\param{const wxTreeItemId\&}{ item}}
278
279Expands the given item.
280
281\membersection{wxTreeCtrl::GetBoundingRect}\label{wxtreectrlgetitemrect}
282
283\constfunc{bool}{GetBoundingRect}{\param{const wxTreeItemId\&}{ item}, \param{wxRect\& }{rect}, \param{bool }{textOnly = FALSE}}
284
285Retrieves the rectangle bounding the {\it item}. If {\it textOnly} is TRUE,
286only the rectangle around the item's label will be returned, otherwise the
287item's image is also taken into account.
288
289The return value is TRUE if the rectangle was successfully retrieved or FALSE
290if it was not (in this case {\it rect} is not changed) - for example, if the
291item is currently invisible.
292
293\pythonnote{The wxPython version of this method requires only the
294{\tt item} and {\tt textOnly} parameters. The return value is either a
295{\tt wxRect} object or {\tt None}.}
296
297\perlnote{In wxPerl this method only takes the parameters {\tt item} and
298 {\tt textOnly}, and returns a Wx::Rect ( or undef ).}
299
300\membersection{wxTreeCtrl::GetButtonsImageList}\label{wxtreectrlgetbuttonsimagelist}
301
302\constfunc{wxImageList*}{GetButtonsImageList}{\void}
303
304Returns the buttons image list (from which application-defined button images are taken).
305
306This function is only available in the generic version.
307
308\membersection{wxTreeCtrl::GetChildrenCount}\label{wxtreectrlgetchildrencount}
309
310\constfunc{size\_t}{GetChildrenCount}{\param{const wxTreeItemId\&}{ item}, \param{bool}{ recursively = TRUE}}
311
312Returns the number of items in the branch. If {\it recursively} is TRUE, returns the total number
313of descendants, otherwise only one level of children is counted.
314
315\membersection{wxTreeCtrl::GetCount}\label{wxtreectrlgetcount}
316
317\constfunc{int}{GetCount}{\void}
318
319Returns the number of items in the control.
320
321\membersection{wxTreeCtrl::GetEditControl}\label{wxtreectrlgeteditcontrol}
322
323\constfunc{wxTextCtrl\&}{GetEditControl}{\void}
324
325Returns the edit control used to edit a label.
326
327\membersection{wxTreeCtrl::GetFirstChild}\label{wxtreectrlgetfirstchild}
328
329\constfunc{wxTreeItemId}{GetFirstChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}}
330
331Returns the first child; call \helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild} for the next child.
332
333For this enumeration function you must pass in a `cookie' parameter
334which is opaque for the application but is necessary for the library
335to make these functions reentrant (i.e. allow more than one
336enumeration on one and the same object simultaneously). The cookie passed to
337GetFirstChild and GetNextChild should be the same.
338
339Returns an invalid tree item if there are no further children.
340
341\wxheading{See also}
342
343\helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild}
344
345\pythonnote{In wxPython the returned wxTreeItemId and the new cookie
346value are both returned as a tuple containing the two values.}
347
348\perlnote{In wxPerl this method only takes the {\tt item} parameter, and
349 returns a 2-element list ( item, cookie ).}
350
351\membersection{wxTreeCtrl::GetFirstVisibleItem}\label{wxtreectrlgetfirstvisibleitem}
352
353\constfunc{wxTreeItemId}{GetFirstVisibleItem}{\void}
354
355Returns the first visible item.
356
357\membersection{wxTreeCtrl::GetImageList}\label{wxtreectrlgetimagelist}
358
359\constfunc{wxImageList*}{GetImageList}{\void}
360
361Returns the normal image list.
362
363\membersection{wxTreeCtrl::GetIndent}\label{wxtreectrlgetindent}
364
365\constfunc{int}{GetIndent}{\void}
366
367Returns the current tree control indentation.
368
369\membersection{wxTreeCtrl::GetItemData}\label{wxtreectrlgetitemdata}
370
371\constfunc{wxTreeItemData*}{GetItemData}{\param{const wxTreeItemId\&}{ item}}
372
373Returns the tree item data associated with the item.
374
375\wxheading{See also}
376
377\helpref{wxTreeItemData}{wxtreeitemdata}
378
379\pythonnote{wxPython provides the following shortcut method:
380
381\indented{2cm}{\begin{twocollist}\itemsep=0pt
382\twocolitem{{\bf GetPyData(item)}}{Returns the Python Object
383associated with the wxTreeItemData for the given item Id.}
384\end{twocollist}}
385}
386
387\perlnote{wxPerl provides the following shortcut method:
388\indented{2cm}{
389\begin{twocollist}\itemsep=0pt
390\twocolitem{{\bf GetPlData( item )}}{Returns the Perl data
391associated with the Wx::TreeItemData ( it is just the same as
392tree->GetItemData( item )->GetData(); ).}
393\end{twocollist}}
394}
395
396\membersection{wxTreeCtrl::GetItemImage}\label{wxtreectrlgetitemimage}
397
398\constfunc{int}{GetItemImage}{\param{const wxTreeItemId\& }{item},
399 \param{wxTreeItemIcon }{which = wxTreeItemIcon\_Normal}}
400
401Gets the specified item image. The value of {\it which} may be:
402
403\begin{itemize}\itemsep=0pt
404\item{wxTreeItemIcon\_Normal} to get the normal item image
405\item{wxTreeItemIcon\_Selected} to get the selected item image (i.e. the image
406which is shown when the item is currently selected)
407\item{wxTreeItemIcon\_Expanded} to get the expanded image (this only
408makes sense for items which have children - then this image is shown when the
409item is expanded and the normal image is shown when it is collapsed)
410\item{wxTreeItemIcon\_SelectedExpanded} to get the selected expanded image
411(which is shown when an expanded item is currently selected)
412\end{itemize}
413
414\membersection{wxTreeCtrl::GetItemText}\label{wxtreectrlgetitemtext}
415
416\constfunc{wxString}{GetItemText}{\param{const wxTreeItemId\&}{ item}}
417
418Returns the item label.
419
420\membersection{wxTreeCtrl::GetLastChild}\label{wxtreectrlgetlastchild}
421
422\constfunc{wxTreeItemId}{GetLastChild}{\param{const wxTreeItemId\&}{ item}}
423
424Returns the last child of the item (or an invalid tree item if this item has no children).
425
426\wxheading{See also}
427
428\helpref{GetFirstChild}{wxtreectrlgetfirstchild},
429\helpref{GetLastChild}{wxtreectrlgetlastchild}
430
431\membersection{wxTreeCtrl::GetNextChild}\label{wxtreectrlgetnextchild}
432
433\constfunc{wxTreeItemId}{GetNextChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}}
434
435Returns the next child; call \helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild} for the first child.
436
437For this enumeration function you must pass in a `cookie' parameter
438which is opaque for the application but is necessary for the library
439to make these functions reentrant (i.e. allow more than one
440enumeration on one and the same object simultaneously). The cookie passed to
441GetFirstChild and GetNextChild should be the same.
442
443Returns an invalid tree item if there are no further children.
444
445\wxheading{See also}
446
447\helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild}
448
449\pythonnote{In wxPython the returned wxTreeItemId and the new cookie
450value are both returned as a tuple containing the two values.}
451
452\perlnote{In wxPerl this method returns a 2-element list
453 ( item, cookie ), instead of modifying its parameters.}
454
455\membersection{wxTreeCtrl::GetNextSibling}\label{wxtreectrlgetnextsibling}
456
457\constfunc{wxTreeItemId}{GetNextSibling}{\param{const wxTreeItemId\&}{ item}}
458
459Returns the next sibling of the specified item; call \helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling} for the previous sibling.
460
461Returns an invalid tree item if there are no further siblings.
462
463\wxheading{See also}
464
465\helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling}
466
467\membersection{wxTreeCtrl::GetNextVisible}\label{wxtreectrlgetnextvisible}
468
469\constfunc{wxTreeItemId}{GetNextVisible}{\param{const wxTreeItemId\&}{ item}}
470
471Returns the next visible item.
472
473\membersection{wxTreeCtrl::GetParent}\label{wxtreectrlgetparent}
474
475\constfunc{wxTreeItemId}{GetParent}{\param{const wxTreeItemId\&}{ item}}
476
477Returns the item's parent.
478
479\pythonnote{This method is named {\tt GetItemParent} to avoid a name
480clash with wxWindow::GetParent.}
481
482\membersection{wxTreeCtrl::GetPrevSibling}\label{wxtreectrlgetprevsibling}
483
484\constfunc{wxTreeItemId}{GetPrevSibling}{\param{const wxTreeItemId\&}{ item}}
485
486Returns the previous sibling of the specified item; call \helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling} for the next sibling.
487
488Returns an invalid tree item if there are no further children.
489
490\wxheading{See also}
491
492\helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling}
493
494\membersection{wxTreeCtrl::GetPrevVisible}\label{wxtreectrlgetprevvisible}
495
496\constfunc{wxTreeItemId}{GetPrevVisible}{\param{const wxTreeItemId\&}{ item}}
497
498Returns the previous visible item.
499
500\membersection{wxTreeCtrl::GetRootItem}\label{wxtreectrlgetrootitem}
501
502\constfunc{wxTreeItemId}{GetRootItem}{\void}
503
504Returns the root item for the tree control.
505
506\membersection{wxTreeCtrl::GetItemSelectedImage}\label{wxtreectrlgetitemselectedimage}
507
508\constfunc{int}{GetItemSelectedImage}{\param{const wxTreeItemId\& }{item}}
509
510Gets the selected item image (this function is obsolete, use
511{\tt GetItemImage(item, wxTreeItemIcon\_Selected}) instead).
512
513\membersection{wxTreeCtrl::GetSelection}\label{wxtreectrlgetselection}
514
515\constfunc{wxTreeItemId}{GetSelection}{\void}
516
517Returns the selection, or an invalid item if there is no selection.
518This function only works with the controls without wxTR\_MULTIPLE style, use
519\helpref{GetSelections}{wxtreectrlgetselections} for the controls which do have
520this style.
521
522\membersection{wxTreeCtrl::GetSelections}\label{wxtreectrlgetselections}
523
524\constfunc{size\_t}{GetSelections}{\param{wxArrayTreeItemIds\& }{selection}}
525
526Fills the array of tree items passed in with the currently selected items. This
527function can be called only if the control has the wxTR\_MULTIPLE style.
528
529Returns the number of selected items.
530
531\pythonnote{The wxPython version of this method accepts no parameters
532and returns a Python list of {\tt wxTreeItemId}s.}
533
534\perlnote{In wxPerl this method takes no parameters and returns a list of
535 {\tt Wx::TreeItemId}s.}
536
537\membersection{wxTreeCtrl::GetStateImageList}\label{wxtreectrlgetstateimagelist}
538
539\constfunc{wxImageList*}{GetStateImageList}{\void}
540
541Returns the state image list (from which application-defined state images are taken).
542
543\membersection{wxTreeCtrl::HitTest}\label{wxtreectrlhittest}
544
545\func{wxTreeItemId}{HitTest}{\param{const wxPoint\& }{point}, \param{int\& }{flags}}
546
547Calculates which (if any) item is under the given point, returning the tree item
548id at this point plus extra information {\it flags}. {\it flags} is a bitlist of the following:
549
550\twocolwidtha{5cm}
551\begin{twocollist}\itemsep=0pt
552\twocolitem{wxTREE\_HITTEST\_ABOVE}{Above the client area.}
553\twocolitem{wxTREE\_HITTEST\_BELOW}{Below the client area.}
554\twocolitem{wxTREE\_HITTEST\_NOWHERE}{In the client area but below the last item.}
555\twocolitem{wxTREE\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.}
556\twocolitem{wxTREE\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.}
557\twocolitem{wxTREE\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.}
558\twocolitem{wxTREE\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.}
559\twocolitem{wxTREE\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.}
560\twocolitem{wxTREE\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.}
561\twocolitem{wxTREE\_HITTEST\_TOLEFT}{To the right of the client area.}
562\twocolitem{wxTREE\_HITTEST\_TORIGHT}{To the left of the client area.}
563\end{twocollist}
564
565\pythonnote{in wxPython both the wxTreeItemId and the flags are
566returned as a tuple.}
567
568\perlnote{In wxPerl this method only takes the {\tt point} parameter
569 and returns a 2-element list ( item, flags ).}
570
571\membersection{wxTreeCtrl::InsertItem}\label{wxtreectrlinsertitem}
572
573\func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxTreeItemId\& }{previous}, \param{const wxString\&}{ text},
574 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
575
576\func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{size\_t}{ before}, \param{const wxString\&}{ text},
577 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
578
579Inserts an item after a given one ({\it previous}) or before one identified by its position ({\it before}).
580
581The {\it image} and {\it selImage} parameters are an index within
582the normal image list specifying the image to use for unselected and
583selected items, respectively.
584If {\it image} > -1 and {\it selImage} is -1, the same image is used for
585both selected and unselected items.
586
587\pythonnote{The second form of this method is called
588\tt{InsertItemBefore} in wxPython.}
589
590\membersection{wxTreeCtrl::IsBold}\label{wxtreectrlisbold}
591
592\constfunc{bool}{IsBold}{\param{const wxTreeItemId\& }{item}}
593
594Returns TRUE if the given item is in bold state.
595
596See also: \helpref{SetItemBold}{wxtreectrlsetitembold}
597
598\membersection{wxTreeCtrl::IsExpanded}\label{wxtreectrlisexpanded}
599
600\constfunc{bool}{IsExpanded}{\param{const wxTreeItemId\&}{ item}}
601
602Returns TRUE if the item is expanded (only makes sense if it has children).
603
604\membersection{wxTreeCtrl::IsSelected}\label{wxtreectrlisselected}
605
606\constfunc{bool}{IsSelected}{\param{const wxTreeItemId\&}{ item}}
607
608Returns TRUE if the item is selected.
609
610\membersection{wxTreeCtrl::IsVisible}\label{wxtreectrlisvisible}
611
612\constfunc{bool}{IsVisible}{\param{const wxTreeItemId\&}{ item}}
613
614Returns TRUE if the item is visible (it might be outside the view, or not expanded).
615
616\membersection{wxTreeCtrl::ItemHasChildren}\label{wxtreectrlitemhaschildren}
617
618\constfunc{bool}{ItemHasChildren}{\param{const wxTreeItemId\&}{ item}}
619
620Returns TRUE if the item has children.
621
622\membersection{wxTreeCtrl::OnCompareItems}\label{wxtreectrloncompareitems}
623
624\func{int}{OnCompareItems}{\param{const wxTreeItemId\& }{item1}, \param{const wxTreeItemId\& }{item2}}
625
626Override this function in the derived class to change the sort order of the
627items in the tree control. The function should return a negative, zero or
628positive value if the first item is less than, equal to or greater than the
629second one.
630
631The base class version compares items alphabetically.
632
633See also: \helpref{SortChildren}{wxtreectrlsortchildren}
634
635\membersection{wxTreeCtrl::PrependItem}\label{wxtreectrlprependitem}
636
637\func{wxTreeItemId}{PrependItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text},
638 \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}}
639
640Appends an item as the first child of {\it parent}, return a new item id.
641
642The {\it image} and {\it selImage} parameters are an index within
643the normal image list specifying the image to use for unselected and
644selected items, respectively.
645If {\it image} > -1 and {\it selImage} is -1, the same image is used for
646both selected and unselected items.
647
648\membersection{wxTreeCtrl::ScrollTo}\label{wxtreectrlscrollto}
649
650\func{void}{ScrollTo}{\param{const wxTreeItemId\&}{ item}}
651
652Scrolls the specified item into view.
653
654\membersection{wxTreeCtrl::SelectItem}\label{wxtreectrlselectitem}
655
656\func{bool}{SelectItem}{\param{const wxTreeItemId\&}{ item}}
657
658Selects the given item.
659
660\membersection{wxTreeCtrl::SetButtonsImageList}\label{wxtreectrlsetbuttonsimagelist}
661
662\func{void}{SetButtonsImageList}{\param{wxImageList*}{ imageList}}
663
664Sets the buttons image list (from which application-defined button images are taken).
665The button images assigned with this method will
666{\bf not} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
667
668Setting or assigning the button image list enables the display of image buttons.
669Once enabled, the only way to disable the display of button images is to set
670the button image list to NULL.
671
672This function is only available in the generic version.
673
674See also \helpref{AssignButtonsImageList}{wxtreectrlassignbuttonsimagelist}.
675
676\membersection{wxTreeCtrl::SetIndent}\label{wxtreectrlsetindent}
677
678\func{void}{SetIndent}{\param{int }{indent}}
679
680Sets the indentation for the tree control.
681
682\membersection{wxTreeCtrl::SetImageList}\label{wxtreectrlsetimagelist}
683
684\func{void}{SetImageList}{\param{wxImageList*}{ imageList}}
685
686Sets the normal image list. Image list assigned with this method will
687{\bf not} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
688
689See also \helpref{AssignImageList}{wxtreectrlassignimagelist}.
690
691
692\membersection{wxTreeCtrl::SetItemBackgroundColour}\label{wxtreectrlsetitembackgroundcolour}
693
694\func{void}{SetItemBackgroundColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}}
695
696Sets the colour of the item's background.
697
698\membersection{wxTreeCtrl::SetItemBold}\label{wxtreectrlsetitembold}
699
700\func{void}{SetItemBold}{\param{const wxTreeItemId\& }{item}, \param{bool}{ bold = TRUE}}
701
702Makes item appear in bold font if {\it bold} parameter is TRUE or resets it to
703the normal state.
704
705See also: \helpref{IsBold}{wxtreectrlisbold}
706
707\membersection{wxTreeCtrl::SetItemData}\label{wxtreectrlsetitemdata}
708
709\func{void}{SetItemData}{\param{const wxTreeItemId\&}{ item}, \param{wxTreeItemData* }{data}}
710
711Sets the item client data.
712
713\pythonnote{wxPython provides the following shortcut method:\par
714\indented{2cm}{\begin{twocollist}\itemsep=0pt
715\twocolitem{{\bf SetPyData(item, obj)}}{Associate the given Python
716Object with the wxTreeItemData for the given item Id.}
717\end{twocollist}}
718}
719
720\perlnote{wxPerl provides the following shortcut method:
721\indented{2cm}{
722\begin{twocollist}\itemsep=0pt
723\twocolitem{{\bf SetPlData( item, data )}}{Sets the Perl data
724associated with the Wx::TreeItemData ( it is just the same as
725tree->GetItemData( item )->SetData( data ); ).}
726\end{twocollist}}
727}
728
729\membersection{wxTreeCtrl::SetItemFont}\label{wxtreectrlsetitemfont}
730
731\func{void}{SetItemFont}{\param{const wxTreeItemId\&}{ item}, \param{const wxFont\& }{font}}
732
733Sets the item's font. All items in the tree should have the same height to avoid
734text clipping, so the fonts height should be the same for all of them,
735although font attributes may vary.
736
737\wxheading{See also}
738
739\helpref{SetItemBold}{wxtreectrlsetitembold}
740
741\membersection{wxTreeCtrl::SetItemHasChildren}\label{wxtreectrlsetitemhaschildren}
742
743\func{void}{SetItemHasChildren}{\param{const wxTreeItemId\&}{ item}, \param{bool }{hasChildren = TRUE}}
744
745Force appearance of the button next to the item. This is useful to
746allow the user to expand the items which don't have any children now,
747but instead adding them only when needed, thus minimizing memory
748usage and loading time.
749
750\membersection{wxTreeCtrl::SetItemImage}\label{wxtreectrlsetitemimage}
751
752\func{void}{SetItemImage}{\param{const wxTreeItemId\&}{ item},
753 \param{int }{image}, \param{wxTreeItemIcon }{which = wxTreeItemIcon\_Normal}}
754
755Sets the specified item image. See \helpref{GetItemImage}{wxtreectrlgetitemimage}
756for the description of the {\it which} parameter.
757
758\membersection{wxTreeCtrl::SetItemSelectedImage}\label{wxtreectrlsetitemselectedimage}
759
760\func{void}{SetItemSelectedImage}{\param{const wxTreeItemId\&}{ item}, \param{int }{selImage}}
761
762Sets the selected item image (this function is obsolete, use {\tt SetItemImage(item, wxTreeItemIcon\_Selected}) instead).
763
764\membersection{wxTreeCtrl::SetItemText}\label{wxtreectrlsetitemtext}
765
766\func{void}{SetItemText}{\param{const wxTreeItemId\&}{ item}, \param{const wxString\& }{text}}
767
768Sets the item label.
769
770\membersection{wxTreeCtrl::SetItemTextColour}\label{wxtreectrlsetitemtextcolour}
771
772\func{void}{SetItemTextColour}{\param{const wxTreeItemId\&}{ item}, \param{const wxColour\& }{col}}
773
774Sets the colour of the item's text.
775
776\membersection{wxTreeCtrl::SetStateImageList}\label{wxtreectrlsetstateimagelist}
777
778\func{void}{SetStateImageList}{\param{wxImageList*}{ imageList}}
779
780Sets the state image list (from which application-defined state images are taken).
781Image list assigned with this method will
782{\bf not} be deleted by wxTreeCtrl's destructor, you must delete it yourself.
783
784See also \helpref{AssignStateImageList}{wxtreectrlassignstateimagelist}.
785
786\func{void}{SetWindowStyle}{\param{long}{styles}}
787
788Sets the mode flags associated with the display of the tree control.
789The new mode takes effect immediately.
790(Generic only; MSW ignores changes.)
791
792\membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren}
793
794\func{void}{SortChildren}{\param{const wxTreeItemId\&}{ item}}
795
796Sorts the children of the given item using
797\helpref{OnCompareItems}{wxtreectrloncompareitems} method of wxTreeCtrl. You
798should override that method to change the sort order (the default is ascending
799alphabetical order).
800
801\wxheading{See also}
802
803\helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{OnCompareItems}{wxtreectrloncompareitems}
804
805\membersection{wxTreeCtrl::Toggle}\label{wxtreectrltoggle}
806
807\func{void}{Toggle}{\param{const wxTreeItemId\&}{ item}}
808
809Toggles the given item between collapsed and expanded states.
810
811\membersection{wxTreeCtrl::Unselect}\label{wxtreectrlunselect}
812
813\func{void}{Unselect}{\void}
814
815Removes the selection from the currently selected item (if any).
816
817\membersection{wxTreeCtrl::UnselectAll}\label{wxtreectrlunselectall}
818
819\func{void}{UnselectAll}{\void}
820
821This function either behaves the same as \helpref{Unselect}{wxtreectrlunselect}
822if the control doesn't have wxTR\_MULTIPLE style, or removes the selection from
823all items if it does have this style.
824
825\section{\class{wxTreeItemData}}\label{wxtreeitemdata}
826
827wxTreeItemData is some (arbitrary) user class associated with some item. The
828main advantage of having this class (compared to the old untyped interface) is
829that wxTreeItemData's are destroyed automatically by the tree and, as this
830class has virtual dtor, it means that the memory will be automatically
831freed. We don't just use wxObject instead of wxTreeItemData because
832the size of this class is critical: in any real application, each tree leaf
833will have wxTreeItemData associated with it and number of leaves may be
834quite big.
835
836Because the objects of this class are deleted by the tree, they should
837always be allocated on the heap.
838
839\wxheading{Derived from}
840
841wxTreeItemId
842
843\wxheading{Include files}
844
845<wx/treectrl.h>
846
847\wxheading{See also}
848
849\helpref{wxTreeCtrl}{wxtreectrl}
850
851\latexignore{\rtfignore{\wxheading{Members}}}
852
853\membersection{wxTreeItemData::wxTreeItemData}\label{wxtreeitemdataconstr}
854
855\func{}{wxTreeItemData}{\void}
856
857Default constructor.
858
859\pythonnote{The wxPython version of this constructor optionally
860accepts any Python object as a parameter. This object is then
861associated with the tree item using the wxTreeItemData as a
862container.
863
864In addition, the following methods are added in wxPython for accessing
865the object:
866
867\indented{2cm}{\begin{twocollist}\itemsep=0pt
868\twocolitem{{\bf GetData()}}{Returns a reference to the Python Object}
869\twocolitem{{\bf SetData(obj)}}{Associates a new Python Object with the
870wxTreeItemData}
871\end{twocollist}}
872}
873
874\perlnote{In wxPerl the constructor accepts as parameter an optional scalar,
875 and stores it as client data. You may retrieve this data by calling
876 {\bf GetData()}, and set it by callling {\bf SetData( data ).}
877}
878
879\membersection{wxTreeItemData::\destruct{wxTreeItemData}}
880
881\func{void}{\destruct{wxTreeItemData}}{\void}
882
883Virtual destructor.
884
885\membersection{wxTreeItemData::GetId}\label{wxtreeitemdatagetid}
886
887\func{const wxTreeItem\&}{GetId}{\void}
888
889Returns the item associated with this node.
890
891\membersection{wxTreeItemData::SetId}\label{wxtreeitemdatasetid}
892
893\func{void}{SetId}{\param{const wxTreeItemId\&}{ id}}
894
895Sets the item associated with this node.
896