]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxTreeCtrl}}\label{wxtreectrl} |
2 | ||
3 | A tree control presents information as a hierarchy, with items that may be expanded | |
4fabb575 | 4 | to show further items. Items in a tree control are referenced by wxTreeItemId handles. |
a660d684 KB |
5 | |
6 | To 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 | ||
954b8ae6 JS |
15 | \wxheading{Include files} |
16 | ||
17 | <wx/treectrl.h> | |
18 | ||
a660d684 KB |
19 | \wxheading{Window styles} |
20 | ||
21 | \twocolwidtha{5cm} | |
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.} | |
25 | \twocolitem{\windowstyle{wxTR\_EDIT\_LABELS}}{Use this style if you wish the user to be | |
26 | able to edit labels in the tree control.} | |
27 | \end{twocollist} | |
28 | ||
29 | See also \helpref{window styles overview}{windowstyles}. | |
30 | ||
5de76427 JS |
31 | \wxheading{Event handling} |
32 | ||
33 | To process input from a tree control, use these event handler macros to direct input to member | |
34 | functions that take a \helpref{wxTreeEvent}{wxtreeevent} argument. | |
35 | ||
36 | \twocolwidtha{7cm} | |
37 | \begin{twocollist}\itemsep=0pt | |
38 | \twocolitem{{\bf EVT\_TREE\_BEGIN\_DRAG(id, func)}}{Begin dragging with the left mouse button.} | |
39 | \twocolitem{{\bf EVT\_TREE\_BEGIN\_RDRAG(id, func)}}{Begin dragging with the right mouse button.} | |
40 | \twocolitem{{\bf EVT\_TREE\_BEGIN\_LABEL\_EDIT(id, func)}}{Begin editing a label.} | |
41 | \twocolitem{{\bf EVT\_TREE\_END\_LABEL\_EDIT(id, func)}}{Finish editing a label.} | |
42 | \twocolitem{{\bf EVT\_TREE\_DELETE\_ITEM(id, func)}}{Delete an item.} | |
43 | \twocolitem{{\bf EVT\_TREE\_GET\_INFO(id, func)}}{Request information from the application.} | |
44 | \twocolitem{{\bf EVT\_TREE\_SET\_INFO(id, func)}}{Information is being supplied.} | |
45 | \twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDED(id, func)}}{Parent has been expanded.} | |
46 | \twocolitem{{\bf EVT\_TREE\_ITEM\_EXPANDING(id, func)}}{Parent is being expanded.} | |
47 | \twocolitem{{\bf EVT\_TREE\_SEL\_CHANGED(id, func)}}{Selection has changed.} | |
48 | \twocolitem{{\bf EVT\_TREE\_SEL\_CHANGING(id, func)}}{Selection is changing.} | |
49 | \twocolitem{{\bf EVT\_TREE\_KEY\_DOWN(id, func)}}{A key has been pressed.} | |
50 | \end{twocollist}% | |
51 | ||
a660d684 KB |
52 | \wxheading{See also} |
53 | ||
4fabb575 | 54 | \helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{wxTreeCtrl overview}{wxtreectrloverview}, \helpref{wxListBox}{wxlistbox}, \helpref{wxListCtrl}{wxlistctrl},\rtfsp |
a660d684 KB |
55 | \helpref{wxImageList}{wximagelist}, \helpref{wxTreeEvent}{wxtreeevent} |
56 | ||
57 | \latexignore{\rtfignore{\wxheading{Members}}} | |
58 | ||
59 | \membersection{wxTreeCtrl::wxTreeCtrl}\label{wxtreectrlconstr} | |
60 | ||
61 | \func{}{wxTreeCtrl}{\void} | |
62 | ||
63 | Default constructor. | |
64 | ||
eaaa6a06 | 65 | \func{}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 66 | \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 | 67 | \param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}} |
a660d684 KB |
68 | |
69 | Constructor, creating and showing a tree control. | |
70 | ||
71 | \wxheading{Parameters} | |
72 | ||
73 | \docparam{parent}{Parent window. Must not be NULL.} | |
74 | ||
75 | \docparam{id}{Window identifier. A value of -1 indicates a default value.} | |
76 | ||
77 | \docparam{pos}{Window position.} | |
78 | ||
79 | \docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized | |
80 | appropriately.} | |
81 | ||
82 | \docparam{style}{Window style. See \helpref{wxTreeCtrl}{wxtreectrl}.} | |
83 | ||
84 | \docparam{validator}{Window validator.} | |
85 | ||
86 | \docparam{name}{Window name.} | |
87 | ||
88 | \wxheading{See also} | |
89 | ||
90 | \helpref{wxTreeCtrl::Create}{wxtreectrlcreate}, \helpref{wxValidator}{wxvalidator} | |
91 | ||
92 | \membersection{wxTreeCtrl::\destruct{wxTreeCtrl}} | |
93 | ||
94 | \func{void}{\destruct{wxTreeCtrl}}{\void} | |
95 | ||
96 | Destructor, destroying the list control. | |
97 | ||
4fabb575 JS |
98 | \membersection{wxTreeCtrl::AddRoot}\label{wxtreectrladdroot} |
99 | ||
100 | \func{wxTreeItemId}{AddRoot}{\param{const wxString\&}{ text}, | |
101 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
102 | ||
103 | Adds the root node to the tree, returning the new item. | |
104 | ||
105 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
106 | both selected and unselected items. | |
107 | ||
108 | \membersection{wxTreeCtrl::AppendItem}\label{wxtreectrlappenditem} | |
109 | ||
110 | \func{wxTreeItemId}{AppendItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text}, | |
111 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
112 | ||
113 | Appends an item to the end of the branch identified by {\it parent}, return a new item id. | |
114 | ||
115 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
116 | both selected and unselected items. | |
117 | ||
118 | \membersection{wxTreeCtrl::Collapse}\label{wxtreectrlcollapse} | |
119 | ||
120 | \func{void}{Collapse}{\param{const wxTreeItemId\&}{ item}} | |
121 | ||
122 | Collapses the given item. | |
123 | ||
124 | \membersection{wxTreeCtrl::CollapseAndReset}\label{wxtreectrlcollapseandreset} | |
125 | ||
126 | \func{void}{CollapseAndReset}{\param{const wxTreeItemId\&}{ item}} | |
127 | ||
128 | Collapses the given item and removes all children. | |
129 | ||
a660d684 KB |
130 | \membersection{wxTreeCtrl::Create}\label{wxtreectrlcreate} |
131 | ||
eaaa6a06 | 132 | \func{bool}{wxTreeCtrl}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id},\rtfsp |
a660d684 | 133 | \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\rtfsp |
eaaa6a06 | 134 | \param{long}{ style = wxTR\_HAS\_BUTTONS}, \param{const wxValidator\& }{validator = wxDefaultValidator}, \param{const wxString\& }{name = ``listCtrl"}} |
a660d684 KB |
135 | |
136 | Creates the tree control. See \helpref{wxTreeCtrl::wxTreeCtrl}{wxtreectrlconstr} for further details. | |
137 | ||
4fabb575 | 138 | \membersection{wxTreeCtrl::Delete}\label{wxtreectrldelete} |
a660d684 | 139 | |
4fabb575 | 140 | \func{void}{Delete}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 141 | |
4fabb575 | 142 | Deletes the specified item. |
a660d684 | 143 | |
4fabb575 | 144 | \membersection{wxTreeCtrl::DeleteAllItems}\label{wxtreectrldeleteallitems} |
a660d684 | 145 | |
4fabb575 | 146 | \func{void}{DeleteAllItems}{\void} |
a660d684 | 147 | |
4fabb575 | 148 | Deletes all the items in the control. |
a660d684 | 149 | |
bbcdf8bc | 150 | \membersection{wxTreeCtrl::EditLabel}\label{wxtreectrleditlabel} |
a660d684 | 151 | |
86f975a8 | 152 | \func{wxTextCtrl*}{EditLabel}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 153 | |
86f975a8 VZ |
154 | Starts editing the label of the given item, returning the text control that |
155 | the tree control uses for editing. This function generates a | |
156 | EVT\_BEGIN\_LABEL\_EDIT event and if the event handler returns FALSE, label | |
157 | editing will not start and NULL will be returned - be ready to handle this | |
158 | case. | |
a660d684 | 159 | |
86f975a8 VZ |
160 | The text control returned should not be deleted by the application and is not |
161 | valid any longer after the EVT\_END\_LABEL\_EDIT event is received. | |
bbcdf8bc JS |
162 | |
163 | \wxheading{See also} | |
164 | ||
86f975a8 VZ |
165 | \helpref{wxTreeCtrl::EndEditLabel}{wxtreectrlendeditlabel}, |
166 | \helpref{wxTreeEvent}{wxtreeevent} | |
bbcdf8bc JS |
167 | |
168 | \membersection{wxTreeCtrl::EndEditLabel}\label{wxtreectrlendeditlabel} | |
169 | ||
4fabb575 | 170 | \func{void}{EndEditLabel}{\param{bool }{cancelEdit}} |
bbcdf8bc JS |
171 | |
172 | Ends label editing. If {\it cancelEdit} is TRUE, the edit will be cancelled. | |
173 | ||
174 | This function is currently supported under Windows only. | |
175 | ||
176 | \wxheading{See also} | |
177 | ||
178 | \helpref{wxTreeCtrl::EditLabel}{wxtreectrleditlabel} | |
179 | ||
a660d684 KB |
180 | \membersection{wxTreeCtrl::EnsureVisible}\label{wxtreectrlensurevisible} |
181 | ||
4fabb575 | 182 | \func{void}{EnsureVisible}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
183 | |
184 | Scrolls and/or expands items to ensure that the given item is visible. | |
185 | ||
4fabb575 | 186 | \membersection{wxTreeCtrl::Expand}\label{wxtreectrlexpand} |
a660d684 | 187 | |
4fabb575 | 188 | \func{void}{Expand}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
189 | |
190 | Expands the given item. | |
191 | ||
4fabb575 | 192 | \membersection{wxTreeCtrl::GetBoundingRect}\label{wxtreectrlgetitemrect} |
a660d684 | 193 | |
296ec7d3 | 194 | \constfunc{bool}{GetBoundingRect}{\param{const wxTreeItemId\&}{ item}, \param{wxRect\& }{rect}, \param{bool }{textOnly = FALSE}} |
4fabb575 | 195 | |
296ec7d3 VZ |
196 | Retrieves the rectangle bounding the {\it item}. If {\it textOnly} is TRUE, |
197 | only the rectangle around the items label will be returned, otherwise the | |
198 | items image is also taken into account. | |
199 | ||
200 | The return value is TRUE if the rectangle was successfully retrieved or FALSE | |
201 | if it was not (in this case {\it rect} is not changed) - for example, if the | |
202 | item is currently invisible. | |
a660d684 | 203 | |
4fabb575 | 204 | \membersection{wxTreeCtrl::GetChildrenCount}\label{wxtreectrlgetchildrencount} |
a660d684 | 205 | |
4fabb575 | 206 | \constfunc{size\_t}{GetChildrenCount}{\param{const wxTreeItemId\&}{ item}, \param{bool}{ recursively = TRUE}} |
a660d684 | 207 | |
4fabb575 JS |
208 | Returns the number of items in the branch. If {\it recursively} is TRUE, returns the total number |
209 | of descendants, otherwise only one level of children is counted. | |
a660d684 KB |
210 | |
211 | \membersection{wxTreeCtrl::GetCount}\label{wxtreectrlgetcount} | |
212 | ||
213 | \constfunc{int}{GetCount}{\void} | |
214 | ||
215 | Returns the number of items in the control. | |
216 | ||
217 | \membersection{wxTreeCtrl::GetEditControl}\label{wxtreectrlgeteditcontrol} | |
218 | ||
219 | \constfunc{wxTextCtrl\&}{GetEditControl}{\void} | |
220 | ||
221 | Returns the edit control used to edit a label. | |
222 | ||
4fabb575 JS |
223 | \membersection{wxTreeCtrl::GetFirstChild}\label{wxtreectrlgetfirstchild} |
224 | ||
225 | \constfunc{wxTreeItemId}{GetFirstChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}} | |
226 | ||
227 | Returns the first child; call \helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild} for the next child. | |
228 | ||
229 | For this enumeration function you must pass in a `cookie' parameter | |
230 | which is opaque for the application but is necessary for the library | |
231 | to make these functions reentrant (i.e. allow more than one | |
232 | enumeration on one and the same object simultaneously). The cookie passed to | |
233 | GetFirstChild and GetNextChild should be the same. | |
234 | ||
ed93168b | 235 | Returns an invalid tree item if there are no further children. |
4fabb575 JS |
236 | |
237 | \wxheading{See also} | |
238 | ||
239 | \helpref{wxTreeCtrl::GetNextChild}{wxtreectrlgetnextchild} | |
240 | ||
f899db6d RD |
241 | \pythonnote{In wxPython the returned wxTreeItemId and the new cookie |
242 | value are both returned as a tuple containing the two values.} | |
243 | ||
a660d684 KB |
244 | \membersection{wxTreeCtrl::GetFirstVisibleItem}\label{wxtreectrlgetfirstvisibleitem} |
245 | ||
4fabb575 | 246 | \constfunc{wxTreeItemId}{GetFirstVisibleItem}{\void} |
a660d684 KB |
247 | |
248 | Returns the first visible item. | |
249 | ||
250 | \membersection{wxTreeCtrl::GetImageList}\label{wxtreectrlgetimagelist} | |
251 | ||
eaaa6a06 | 252 | \constfunc{wxImageList*}{GetImageList}{\param{int }{which = wxIMAGE\_LIST\_NORMAL}} |
a660d684 KB |
253 | |
254 | Returns the specified image list. {\it which} may be one of: | |
255 | ||
256 | \twocolwidtha{5cm} | |
257 | \begin{twocollist}\itemsep=0pt | |
258 | \twocolitem{\windowstyle{wxIMAGE\_LIST\_NORMAL}}{The normal (large icon) image list.} | |
259 | \twocolitem{\windowstyle{wxIMAGE\_LIST\_SMALL}}{The small icon image list.} | |
260 | \twocolitem{\windowstyle{wxIMAGE\_LIST\_STATE}}{The user-defined state image list (unimplemented).} | |
261 | \end{twocollist} | |
262 | ||
263 | \membersection{wxTreeCtrl::GetIndent}\label{wxtreectrlgetindent} | |
264 | ||
265 | \constfunc{int}{GetIndent}{\void} | |
266 | ||
267 | Returns the current tree control indentation. | |
268 | ||
4fabb575 | 269 | \membersection{wxTreeCtrl::GetItemData}\label{wxtreectrlgetitemdata} |
a660d684 | 270 | |
4fabb575 | 271 | \constfunc{wxTreeItemData*}{GetItemData}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 272 | |
4fabb575 | 273 | Returns the tree item data associated with the item. |
a660d684 | 274 | |
4fabb575 | 275 | \wxheading{See also} |
a660d684 | 276 | |
4fabb575 | 277 | \helpref{wxTreeItemData}{wxtreeitemdata} |
a660d684 | 278 | |
f899db6d RD |
279 | \pythonnote{wxPython provides the following shortcut method:\par |
280 | \indented{2cm}{\begin{twocollist} | |
281 | \twocolitem{\bf{GetPyData(item)}}{Returns the Python Object | |
282 | associated with the wxTreeItemData for the given item Id.} | |
283 | \end{twocollist}} | |
284 | } | |
285 | ||
4fabb575 | 286 | \membersection{wxTreeCtrl::GetItemImage}\label{wxtreectrlgetitemimage} |
a660d684 | 287 | |
4fabb575 | 288 | \constfunc{int}{GetItemImage}{\param{const wxTreeItemId\& }{item}} |
a660d684 | 289 | |
4fabb575 | 290 | Gets the normal item image. |
a660d684 | 291 | |
4fabb575 | 292 | \membersection{wxTreeCtrl::GetItemText}\label{wxtreectrlgetitemtext} |
a660d684 | 293 | |
4fabb575 | 294 | \constfunc{wxString}{GetItemText}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 295 | |
4fabb575 | 296 | Returns the item label. |
a660d684 | 297 | |
978f38c2 VZ |
298 | \membersection{wxTreeCtrl::GetLastChild}\label{wxtreectrlgetlastchild} |
299 | ||
300 | \constfunc{wxTreeItemId}{GetLastChild}{\param{const wxTreeItemId\&}{ item}} | |
301 | ||
ed93168b | 302 | Returns the last child of the item (or an invalid tree item if this item has no children). |
978f38c2 VZ |
303 | |
304 | \wxheading{See also} | |
305 | ||
f899db6d | 306 | \helpref{GetFirstChild}{wxtreectrlgetfirstchild}, |
978f38c2 VZ |
307 | \helpref{GetLastChild}{wxtreectrlgetlastchild} |
308 | ||
4fabb575 | 309 | \membersection{wxTreeCtrl::GetNextChild}\label{wxtreectrlgetnextchild} |
a660d684 | 310 | |
4fabb575 | 311 | \constfunc{wxTreeItemId}{GetNextChild}{\param{const wxTreeItemId\&}{ item}, \param{long\& }{cookie}} |
a660d684 | 312 | |
4fabb575 | 313 | Returns the next child; call \helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild} for the first child. |
a660d684 | 314 | |
4fabb575 JS |
315 | For this enumeration function you must pass in a `cookie' parameter |
316 | which is opaque for the application but is necessary for the library | |
317 | to make these functions reentrant (i.e. allow more than one | |
318 | enumeration on one and the same object simultaneously). The cookie passed to | |
319 | GetFirstChild and GetNextChild should be the same. | |
a660d684 | 320 | |
ed93168b | 321 | Returns an invalid tree item if there are no further children. |
a660d684 | 322 | |
4fabb575 | 323 | \wxheading{See also} |
a660d684 | 324 | |
4fabb575 | 325 | \helpref{wxTreeCtrl::GetFirstChild}{wxtreectrlgetfirstchild} |
a660d684 | 326 | |
f899db6d RD |
327 | \pythonnote{In wxPython the returned wxTreeItemId and the new cookie |
328 | value are both returned as a tuple containing the two values.} | |
329 | ||
4fabb575 | 330 | \membersection{wxTreeCtrl::GetNextSibling}\label{wxtreectrlgetnextsibling} |
a660d684 | 331 | |
4fabb575 | 332 | \constfunc{wxTreeItemId}{GetNextSibling}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 333 | |
4fabb575 | 334 | Returns the next sibling of the specified item; call \helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling} for the previous sibling. |
a660d684 | 335 | |
ed93168b | 336 | Returns an invalid tree item if there are no further siblings. |
a660d684 | 337 | |
4fabb575 JS |
338 | \wxheading{See also} |
339 | ||
340 | \helpref{wxTreeCtrl::GetPrevSibling}{wxtreectrlgetprevsibling} | |
341 | ||
342 | \membersection{wxTreeCtrl::GetNextVisible}\label{wxtreectrlgetnextvisible} | |
343 | ||
344 | \constfunc{wxTreeItemId}{GetNextVisible}{\param{const wxTreeItemId\&}{ item}} | |
a660d684 KB |
345 | |
346 | Returns the next visible item. | |
347 | ||
348 | \membersection{wxTreeCtrl::GetParent}\label{wxtreectrlgetparent} | |
349 | ||
4fabb575 | 350 | \constfunc{wxTreeItemId}{GetParent}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
351 | |
352 | Returns the item's parent. | |
353 | ||
4fabb575 JS |
354 | \membersection{wxTreeCtrl::GetPrevSibling}\label{wxtreectrlgetprevsibling} |
355 | ||
356 | \constfunc{wxTreeItemId}{GetPrevSibling}{\param{const wxTreeItemId\&}{ item}} | |
357 | ||
358 | Returns the previous sibling of the specified item; call \helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling} for the next sibling. | |
359 | ||
ed93168b | 360 | Returns an invalid tree item if there are no further children. |
4fabb575 JS |
361 | |
362 | \wxheading{See also} | |
363 | ||
364 | \helpref{wxTreeCtrl::GetNextSibling}{wxtreectrlgetnextsibling} | |
365 | ||
366 | \membersection{wxTreeCtrl::GetPrevVisible}\label{wxtreectrlgetprevvisible} | |
367 | ||
368 | \constfunc{wxTreeItemId}{GetPrevVisible}{\param{const wxTreeItemId\&}{ item}} | |
369 | ||
370 | Returns the previous visible item. | |
371 | ||
a660d684 KB |
372 | \membersection{wxTreeCtrl::GetRootItem}\label{wxtreectrlgetrootitem} |
373 | ||
4fabb575 | 374 | \constfunc{wxTreeItemId}{GetRootItem}{\void} |
a660d684 KB |
375 | |
376 | Returns the root item for the tree control. | |
377 | ||
ed93168b | 378 | \membersection{wxTreeCtrl::GetItemSelectedImage}\label{wxtreectrlgetitemselectedimage} |
4fabb575 | 379 | |
ed93168b | 380 | \constfunc{int}{GetItemSelectedImage}{\param{const wxTreeItemId\& }{item}} |
4fabb575 JS |
381 | |
382 | Gets the selected item image. | |
383 | ||
a660d684 KB |
384 | \membersection{wxTreeCtrl::GetSelection}\label{wxtreectrlgetselection} |
385 | ||
4fabb575 | 386 | \constfunc{wxTreeItemId}{GetSelection}{\void} |
a660d684 | 387 | |
ed93168b | 388 | Returns the selection, or an invalid item if there is no selection. |
a660d684 KB |
389 | |
390 | \membersection{wxTreeCtrl::HitTest}\label{wxtreectrlhittest} | |
391 | ||
392 | \func{long}{HitTest}{\param{const wxPoint\& }{point}, \param{int\& }{flags}} | |
393 | ||
394 | Calculates which (if any) item is under the given point, returning extra information | |
395 | in {\it flags}. {\it flags} is a bitlist of the following: | |
396 | ||
397 | \twocolwidtha{5cm} | |
398 | \begin{twocollist}\itemsep=0pt | |
399 | \twocolitem{wxTREE\_HITTEST\_ABOVE}{Above the client area.} | |
400 | \twocolitem{wxTREE\_HITTEST\_BELOW}{Below the client area.} | |
401 | \twocolitem{wxTREE\_HITTEST\_NOWHERE}{In the client area but below the last item.} | |
402 | \twocolitem{wxTREE\_HITTEST\_ONITEMBUTTON}{On the button associated with an item.} | |
403 | \twocolitem{wxTREE\_HITTEST\_ONITEMICON}{On the bitmap associated with an item.} | |
404 | \twocolitem{wxTREE\_HITTEST\_ONITEMINDENT}{In the indentation associated with an item.} | |
405 | \twocolitem{wxTREE\_HITTEST\_ONITEMLABEL}{On the label (string) associated with an item.} | |
406 | \twocolitem{wxTREE\_HITTEST\_ONITEMRIGHT}{In the area to the right of an item.} | |
407 | \twocolitem{wxTREE\_HITTEST\_ONITEMSTATEICON}{On the state icon for a tree view item that is in a user-defined state.} | |
408 | \twocolitem{wxTREE\_HITTEST\_TOLEFT}{To the right of the client area.} | |
409 | \twocolitem{wxTREE\_HITTEST\_TORIGHT}{To the left of the client area.} | |
410 | \end{twocollist} | |
411 | ||
412 | \membersection{wxTreeCtrl::InsertItem}\label{wxtreectrlinsertitem} | |
413 | ||
4fabb575 JS |
414 | \func{wxTreeItemId}{InsertItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxTreeItemId\& }{previous}, \param{const wxString\&}{ text}, |
415 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
a660d684 | 416 | |
4fabb575 | 417 | Inserts an item after a given one. |
a660d684 KB |
418 | |
419 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
420 | both selected and unselected items. | |
421 | ||
ed93168b VZ |
422 | \membersection{wxTreeCtrl::IsBold}\label{wxtreectrlisbold} |
423 | ||
424 | \constfunc{bool}{IsBold}{\param{const wxTreeItemId\& }{item}} | |
425 | ||
426 | Returns TRUE if the given item is in bold state. | |
427 | ||
428 | See also: \helpref{SetItemBold}{wxtreectrlsetitembold} | |
429 | ||
4fabb575 JS |
430 | \membersection{wxTreeCtrl::IsExpanded}\label{wxtreectrlisexpanded} |
431 | ||
432 | \constfunc{bool}{IsExpanded}{\param{const wxTreeItemId\&}{ item}} | |
433 | ||
434 | Returns TRUE if the item is expanded (only makes sense if it has children). | |
435 | ||
436 | \membersection{wxTreeCtrl::IsSelected}\label{wxtreectrlisselected} | |
437 | ||
438 | \constfunc{bool}{IsSelected}{\param{const wxTreeItemId\&}{ item}} | |
439 | ||
440 | Returns TRUE if the item is selected. | |
441 | ||
442 | \membersection{wxTreeCtrl::IsVisible}\label{wxtreectrlisvisible} | |
443 | ||
444 | \constfunc{bool}{IsVisible}{\param{const wxTreeItemId\&}{ item}} | |
445 | ||
446 | Returns TRUE if the item is visible (it might be outside the view, or not expanded). | |
447 | ||
a660d684 KB |
448 | \membersection{wxTreeCtrl::ItemHasChildren}\label{wxtreectrlitemhaschildren} |
449 | ||
4fabb575 | 450 | \constfunc{bool}{ItemHasChildren}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
451 | |
452 | Returns TRUE if the item has children. | |
453 | ||
ed93168b VZ |
454 | \membersection{wxTreeCtrl::OnCompareItems}\label{wxtreectrloncompareitems} |
455 | ||
456 | \func{int}{OnCompareItems}{\param{const wxTreeItemId\& }{item1}, \param{const wxTreeItemId\& }{item2}} | |
457 | ||
458 | Override this function in the derived class to change the sort order of the | |
459 | items in the tree control. The function should return a negative, zero or | |
460 | positive value if the first item is less than, equal to or greater than the | |
461 | second one. | |
462 | ||
463 | The base class version compares items alphabetically. | |
464 | ||
465 | See also: \helpref{SortChildren}{wxtreectrlsortchildren} | |
466 | ||
4fabb575 JS |
467 | \membersection{wxTreeCtrl::PrependItem}\label{wxtreectrlprependitem} |
468 | ||
469 | \func{wxTreeItemId}{PrependItem}{\param{const wxTreeItemId\& }{parent}, \param{const wxString\&}{ text}, | |
470 | \param{int}{ image = -1}, \param{int}{ selImage = -1}, \param{wxTreeItemData*}{ data = NULL}} | |
471 | ||
472 | Appends an item as the first child of {\it parent}, return a new item id. | |
473 | ||
474 | If {\it image} > -1 and {\it selImage} is -1, the same image is used for | |
475 | both selected and unselected items. | |
476 | ||
a660d684 KB |
477 | \membersection{wxTreeCtrl::ScrollTo}\label{wxtreectrlscrollto} |
478 | ||
4fabb575 | 479 | \func{void}{ScrollTo}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 480 | |
4fabb575 | 481 | Scrolls the specified item into view. |
a660d684 KB |
482 | |
483 | \membersection{wxTreeCtrl::SelectItem}\label{wxtreectrlselectitem} | |
484 | ||
4fabb575 | 485 | \func{bool}{SelectItem}{\param{const wxTreeItemId\&}{ item}} |
a660d684 KB |
486 | |
487 | Selects the given item. | |
488 | ||
489 | \membersection{wxTreeCtrl::SetIndent}\label{wxtreectrlsetindent} | |
490 | ||
491 | \func{void}{SetIndent}{\param{int }{indent}} | |
492 | ||
493 | Sets the indentation for the tree control. | |
494 | ||
495 | \membersection{wxTreeCtrl::SetImageList}\label{wxtreectrlsetimagelist} | |
496 | ||
eaaa6a06 | 497 | \func{void}{SetImageList}{\param{wxImageList*}{ imageList}, \param{int }{which = wxIMAGE\_LIST\_NORMAL}} |
a660d684 KB |
498 | |
499 | Sets the image list. {\it which} should be one of wxIMAGE\_LIST\_NORMAL, wxIMAGE\_LIST\_SMALL and | |
500 | wxIMAGE\_LIST\_STATE. | |
501 | ||
ed93168b VZ |
502 | \membersection{wxTreeCtrl::SetItemBold}\label{wxtreectrlsetitembold} |
503 | ||
504 | \func{void}{SetItemBold}{\param{const wxTreeItemId\& }{item}, \param{bool}{ bold = TRUE}} | |
505 | ||
506 | Makes item appear in bold font if {\it bold} parameter is TRUE or resets it to | |
507 | the normal state. | |
508 | ||
509 | See also: \helpref{IsBold}{wxtreectrlisbold} | |
510 | ||
4fabb575 | 511 | \membersection{wxTreeCtrl::SetItemData}\label{wxtreectrlsetitemdata} |
a660d684 | 512 | |
4fabb575 | 513 | \func{void}{SetItemData}{\param{const wxTreeItemId\&}{ item}, \param{wxTreeItemData* }{data}} |
a660d684 | 514 | |
4fabb575 | 515 | Sets the item client data. |
a660d684 | 516 | |
f899db6d RD |
517 | \pythonnote{wxPython provides the following shortcut method:\par |
518 | \indented{2cm}{\begin{twocollist} | |
519 | \twocolitem{\bf{SetPyData(item, obj)}}{Associate the given Python | |
520 | Object with the wxTreeItemData for the given item Id.} | |
521 | \end{twocollist}} | |
522 | } | |
523 | ||
4fabb575 | 524 | \membersection{wxTreeCtrl::SetItemHasChildren}\label{wxtreectrlsetitemhaschildren} |
a660d684 | 525 | |
4fabb575 | 526 | \func{void}{SetItemHasChildren}{\param{const wxTreeItemId\&}{ item}, \param{bool }{hasChildren = TRUE}} |
a660d684 | 527 | |
4fabb575 JS |
528 | Force appearance of the button next to the item. This is useful to |
529 | allow the user to expand the items which don't have any children now, | |
530 | but instead adding them only when needed, thus minimizing memory | |
531 | usage and loading time. | |
a660d684 KB |
532 | |
533 | \membersection{wxTreeCtrl::SetItemImage}\label{wxtreectrlsetitemimage} | |
534 | ||
4fabb575 | 535 | \func{void}{SetItemImage}{\param{const wxTreeItemId\&}{ item}, \param{int }{image}} |
a660d684 | 536 | |
4fabb575 | 537 | Sets the normal item image. This is an index into the assciated image list. |
a660d684 | 538 | |
4fabb575 | 539 | \membersection{wxTreeCtrl::SetItemSelectedImage}\label{wxtreectrlsetitemselectedimage} |
a660d684 | 540 | |
4fabb575 | 541 | \func{void}{SetItemSelectedImage}{\param{const wxTreeItemId\&}{ item}, \param{int }{selImage}} |
a660d684 | 542 | |
4fabb575 | 543 | Sets the item selected image. This is an index into the assciated image list. |
a660d684 KB |
544 | |
545 | \membersection{wxTreeCtrl::SetItemText}\label{wxtreectrlsetitemtext} | |
546 | ||
4fabb575 | 547 | \func{void}{SetItemText}{\param{const wxTreeItemId\&}{ item}, \param{const wxString\& }{text}} |
a660d684 KB |
548 | |
549 | Sets the item label. | |
550 | ||
4fabb575 | 551 | \membersection{wxTreeCtrl::SortChildren}\label{wxtreectrlsortchildren} |
a660d684 | 552 | |
ed93168b | 553 | \func{void}{SortChildren}{\param{const wxTreeItemId\&}{ item}} |
a660d684 | 554 | |
f899db6d | 555 | Sorts the children of the given item using |
ed93168b VZ |
556 | \helpref{OnCompareItems}{wxtreectrloncompareitems} method of wxTreeCtrl. You |
557 | should override that method to change the sort order (default is ascending | |
558 | alphabetical order). | |
4fabb575 JS |
559 | |
560 | \wxheading{See also} | |
561 | ||
ed93168b | 562 | \helpref{wxTreeItemData}{wxtreeitemdata}, \helpref{OnCompareItems}{wxtreectrloncompareitems} |
4fabb575 JS |
563 | |
564 | \membersection{wxTreeCtrl::Toggle}\label{wxtreectrltoggle} | |
565 | ||
566 | \func{void}{Toggle}{\param{const wxTreeItemId\&}{ item}} | |
567 | ||
568 | Toggles the given item between collapsed and expanded states. | |
569 | ||
570 | \membersection{wxTreeCtrl::Unselect}\label{wxtreectrlunselect} | |
571 | ||
572 | \func{void}{Unselect}{\void} | |
573 | ||
574 | Removes the selection from the currently selected item (if any). | |
575 | ||
576 | \section{\class{wxTreeItemData}}\label{wxtreeitemdata} | |
577 | ||
578 | wxTreeItemData is some (arbitrary) user class associated with some item. The | |
579 | main advantage of having this class (compared to the old untyped interface) is | |
580 | that wxTreeItemData's are destroyed automatically by the tree and, as this | |
581 | class has virtual dtor, it means that the memory will be automatically | |
582 | freed. We don't just use wxObject instead of wxTreeItemData because | |
583 | the size of this class is critical: in any real application, each tree leaf | |
584 | will have wxTreeItemData associated with it and number of leaves may be | |
585 | quite big. | |
586 | ||
587 | Because the objects of this class are deleted by the tree, they should | |
588 | always be allocated on the heap. | |
589 | ||
590 | \wxheading{Derived from} | |
591 | ||
592 | wxTreeItemId | |
593 | ||
954b8ae6 JS |
594 | \wxheading{Include files} |
595 | ||
596 | <wx/treectrl.h> | |
597 | ||
4fabb575 JS |
598 | \wxheading{See also} |
599 | ||
600 | \helpref{wxTreeCtrl}{wxtreectrl} | |
601 | ||
602 | \latexignore{\rtfignore{\wxheading{Members}}} | |
603 | ||
604 | \membersection{wxTreeItemData::wxTreeItemData}\label{wxtreeitemdataconstr} | |
605 | ||
606 | \func{}{wxTreeItemData}{\void} | |
607 | ||
608 | Default constructor. | |
609 | ||
f899db6d RD |
610 | \pythonnote{The wxPython version of this constructor optionally |
611 | accepts any Python object as a parameter. This object is then | |
612 | associated with the tree item using the wxTreeItemData as a | |
613 | container. | |
614 | ||
615 | In addition, the following methods are added in wxPython for accessing | |
616 | the object:\par | |
617 | \indented{2cm}{\begin{twocollist} | |
618 | \twocolitem{\bf{GetData()}}{Returns a reference to the Python Object} | |
619 | \twocolitem{\bf{SetData(obj)}}{Associates a new Python Object with the | |
620 | wxTreeItemData} | |
621 | \end{twocollist}} | |
622 | } | |
623 | ||
624 | ||
4fabb575 JS |
625 | \membersection{wxTreeItemData::\destruct{wxTreeItemData}} |
626 | ||
627 | \func{void}{\destruct{wxTreeItemData}}{\void} | |
628 | ||
629 | Virtual destructor. | |
630 | ||
631 | \membersection{wxTreeItemData::GetId}\label{wxtreeitemdatagetid} | |
632 | ||
633 | \func{const wxTreeItem\&}{GetId}{\void} | |
634 | ||
635 | Returns the item associated with this node. | |
636 | ||
637 | \membersection{wxTreeItemData::SetId}\label{wxtreeitemdatasetid} | |
a660d684 | 638 | |
4fabb575 | 639 | \func{void}{SetId}{\param{const wxTreeItemId\&}{ id}} |
a660d684 | 640 | |
4fabb575 | 641 | Sets the item associated with this node. |
a660d684 | 642 |