]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: treectrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxTreeItemData |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
e54c96f1 | 9 | |
23324ae1 FM |
10 | /** |
11 | @class wxTreeCtrl | |
7c913512 | 12 | |
23324ae1 | 13 | A tree control presents information as a hierarchy, with items that may be |
7977b62a BP |
14 | expanded to show further items. Items in a tree control are referenced by |
15 | wxTreeItemId handles, which may be tested for validity by calling | |
16 | wxTreeItemId::IsOk(). | |
03966fcb | 17 | |
f0871806 RR |
18 | A similar control with a fully native implemtation for GTK+ and OS X |
19 | as well is wxDataViewTreeCtrl. | |
7c913512 | 20 | |
7977b62a BP |
21 | To intercept events from a tree control, use the event table macros |
22 | described in wxTreeEvent. | |
7c913512 | 23 | |
23324ae1 | 24 | @beginStyleTable |
8c6791e4 | 25 | @style{wxTR_EDIT_LABELS} |
7977b62a BP |
26 | Use this style if you wish the user to be able to edit labels in the |
27 | tree control. | |
8c6791e4 | 28 | @style{wxTR_NO_BUTTONS} |
7977b62a | 29 | For convenience to document that no buttons are to be drawn. |
8c6791e4 | 30 | @style{wxTR_HAS_BUTTONS} |
7977b62a | 31 | Use this style to show + and - buttons to the left of parent items. |
8c6791e4 | 32 | @style{wxTR_NO_LINES} |
7977b62a | 33 | Use this style to hide vertical level connectors. |
8c6791e4 | 34 | @style{wxTR_FULL_ROW_HIGHLIGHT} |
7977b62a BP |
35 | Use this style to have the background colour and the selection highlight |
36 | extend over the entire horizontal row of the tree control window. (This | |
37 | flag is ignored under Windows unless you specify @c wxTR_NO_LINES as | |
38 | well.) | |
8c6791e4 | 39 | @style{wxTR_LINES_AT_ROOT} |
7977b62a BP |
40 | Use this style to show lines between root nodes. Only applicable if @c |
41 | wxTR_HIDE_ROOT is set and @c wxTR_NO_LINES is not set. | |
8c6791e4 | 42 | @style{wxTR_HIDE_ROOT} |
7977b62a BP |
43 | Use this style to suppress the display of the root node, effectively |
44 | causing the first-level nodes to appear as a series of root nodes. | |
8c6791e4 | 45 | @style{wxTR_ROW_LINES} |
7977b62a | 46 | Use this style to draw a contrasting border between displayed rows. |
8c6791e4 | 47 | @style{wxTR_HAS_VARIABLE_ROW_HEIGHT} |
7977b62a BP |
48 | Use this style to cause row heights to be just big enough to fit the |
49 | content. If not set, all rows use the largest row height. The default is | |
50 | that this flag is unset. Generic only. | |
8c6791e4 | 51 | @style{wxTR_SINGLE} |
7977b62a BP |
52 | For convenience to document that only one item may be selected at a |
53 | time. Selecting another item causes the current selection, if any, to be | |
54 | deselected. This is the default. | |
8c6791e4 | 55 | @style{wxTR_MULTIPLE} |
7977b62a BP |
56 | Use this style to allow a range of items to be selected. If a second |
57 | range is selected, the current range, if any, is deselected. | |
8c6791e4 | 58 | @style{wxTR_DEFAULT_STYLE} |
7977b62a BP |
59 | The set of flags that are closest to the defaults for the native control |
60 | for a particular toolkit. | |
23324ae1 | 61 | @endStyleTable |
7c913512 | 62 | |
3051a44a | 63 | @beginEventEmissionTable{wxTreeEvent} |
98d45c55 RR |
64 | @event{EVT_TREE_BEGIN_DRAG(id, func)} |
65 | Begin dragging with the left mouse button. | |
6d62b2e2 FM |
66 | If you want to enable left-dragging you need to intercept this event |
67 | and explicitely call wxTreeEvent::Allow(), as it's vetoed by default. | |
232fdc63 | 68 | Processes a @c wxEVT_COMMAND_TREE_BEGIN_DRAG event type. |
98d45c55 RR |
69 | @event{EVT_TREE_BEGIN_RDRAG(id, func)} |
70 | Begin dragging with the right mouse button. | |
6d62b2e2 FM |
71 | If you want to enable right-dragging you need to intercept this event |
72 | and explicitely call wxTreeEvent::Allow(), as it's vetoed by default. | |
232fdc63 | 73 | Processes a @c wxEVT_COMMAND_TREE_BEGIN_RDRAG event type. |
98d45c55 RR |
74 | @event{EVT_TREE_END_DRAG(id, func)} |
75 | End dragging with the left or right mouse button. | |
232fdc63 | 76 | Processes a @c wxEVT_COMMAND_TREE_END_DRAG event type. |
98d45c55 RR |
77 | @event{EVT_TREE_BEGIN_LABEL_EDIT(id, func)} |
78 | Begin editing a label. This can be prevented by calling Veto(). | |
232fdc63 | 79 | Processes a @c wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT event type. |
98d45c55 RR |
80 | @event{EVT_TREE_END_LABEL_EDIT(id, func)} |
81 | Finish editing a label. This can be prevented by calling Veto(). | |
232fdc63 | 82 | Processes a @c wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT event type. |
98d45c55 RR |
83 | @event{EVT_TREE_DELETE_ITEM(id, func)} |
84 | An item was deleted. | |
232fdc63 | 85 | Processes a @c wxEVT_COMMAND_TREE_DELETE_ITEM event type. |
98d45c55 RR |
86 | @event{EVT_TREE_GET_INFO(id, func)} |
87 | Request information from the application. | |
232fdc63 | 88 | Processes a @c wxEVT_COMMAND_TREE_GET_INFO event type. |
98d45c55 RR |
89 | @event{EVT_TREE_SET_INFO(id, func)} |
90 | Information is being supplied. | |
232fdc63 | 91 | Processes a @c wxEVT_COMMAND_TREE_SET_INFO event type. |
98d45c55 | 92 | @event{EVT_TREE_ITEM_ACTIVATED(id, func)} |
6873eb5b FM |
93 | The item has been activated, i.e. chosen by double clicking it with |
94 | mouse or from keyboard. | |
232fdc63 | 95 | Processes a @c wxEVT_COMMAND_TREE_ITEM_ACTIVATED event type. |
98d45c55 RR |
96 | @event{EVT_TREE_ITEM_COLLAPSED(id, func)} |
97 | The item has been collapsed. | |
232fdc63 | 98 | Processes a @c wxEVT_COMMAND_TREE_ITEM_COLLAPSED event type. |
98d45c55 RR |
99 | @event{EVT_TREE_ITEM_COLLAPSING(id, func)} |
100 | The item is being collapsed. This can be prevented by calling Veto(). | |
232fdc63 | 101 | Processes a @c wxEVT_COMMAND_TREE_ITEM_COLLAPSING event type. |
98d45c55 RR |
102 | @event{EVT_TREE_ITEM_EXPANDED(id, func)} |
103 | The item has been expanded. | |
232fdc63 | 104 | Processes a @c wxEVT_COMMAND_TREE_ITEM_EXPANDED event type. |
98d45c55 RR |
105 | @event{EVT_TREE_ITEM_EXPANDING(id, func)} |
106 | The item is being expanded. This can be prevented by calling Veto(). | |
232fdc63 | 107 | Processes a @c wxEVT_COMMAND_TREE_ITEM_EXPANDING event type. |
98d45c55 RR |
108 | @event{EVT_TREE_ITEM_RIGHT_CLICK(id, func)} |
109 | The user has clicked the item with the right mouse button. | |
232fdc63 | 110 | Processes a @c wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK event type. |
98d45c55 | 111 | @event{EVT_TREE_ITEM_MIDDLE_CLICK(id, func)} |
232fdc63 VZ |
112 | The user has clicked the item with the middle mouse button. This is |
113 | only supported by the generic control. | |
114 | Processes a @c wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK event type. | |
98d45c55 RR |
115 | @event{EVT_TREE_SEL_CHANGED(id, func)} |
116 | Selection has changed. | |
232fdc63 | 117 | Processes a @c wxEVT_COMMAND_TREE_SEL_CHANGED event type. |
98d45c55 RR |
118 | @event{EVT_TREE_SEL_CHANGING(id, func)} |
119 | Selection is changing. This can be prevented by calling Veto(). | |
232fdc63 | 120 | Processes a @c wxEVT_COMMAND_TREE_SEL_CHANGING event type. |
98d45c55 RR |
121 | @event{EVT_TREE_KEY_DOWN(id, func)} |
122 | A key has been pressed. | |
232fdc63 | 123 | Processes a @c wxEVT_COMMAND_TREE_KEY_DOWN event type. |
98d45c55 | 124 | @event{EVT_TREE_ITEM_GETTOOLTIP(id, func)} |
6873eb5b FM |
125 | The opportunity to set the item tooltip is being given to the application |
126 | (call wxTreeEvent::SetToolTip). Windows only. | |
232fdc63 | 127 | Processes a @c wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP event type. |
98d45c55 | 128 | @event{EVT_TREE_ITEM_MENU(id, func)} |
6873eb5b FM |
129 | The context menu for the selected item has been requested, either by a |
130 | right click or by using the menu key. | |
232fdc63 | 131 | Processes a @c wxEVT_COMMAND_TREE_ITEM_MENU event type. |
98d45c55 RR |
132 | @event{EVT_TREE_STATE_IMAGE_CLICK(id, func)} |
133 | The state image has been clicked. Windows only. | |
232fdc63 | 134 | Processes a @c wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK event type. |
98d45c55 RR |
135 | @endEventTable |
136 | ||
137 | ||
7977b62a | 138 | See also @ref overview_windowstyles. |
03966fcb | 139 | |
7977b62a BP |
140 | @b Win32 @b notes: |
141 | ||
142 | wxTreeCtrl class uses the standard common treeview control under Win32 | |
143 | implemented in the system library comctl32.dll. Some versions of this | |
144 | library are known to have bugs with handling the tree control colours: the | |
145 | usual symptom is that the expanded items leave black (or otherwise | |
146 | incorrectly coloured) background behind them, especially for the controls | |
147 | using non-default background colour. The recommended solution is to upgrade | |
148 | the comctl32.dll to a newer version: see | |
149 | http://www.microsoft.com/downloads/details.aspx?familyid=cb2cf3a2-8025-4e8f-8511-9b476a8d35d2 | |
150 | ||
23324ae1 FM |
151 | @library{wxcore} |
152 | @category{ctrl} | |
7e59b885 | 153 | @appearance{treectrl.png} |
7c913512 | 154 | |
6873eb5b FM |
155 | @see wxDataViewTreeCtrl, wxTreeEvent, wxTreeItemData, @ref overview_treectrl, |
156 | wxListBox, wxListCtrl, wxImageList | |
23324ae1 FM |
157 | */ |
158 | class wxTreeCtrl : public wxControl | |
159 | { | |
160 | public: | |
7977b62a BP |
161 | /** |
162 | Default Constructor. | |
163 | */ | |
164 | wxTreeCtrl(); | |
165 | ||
23324ae1 FM |
166 | /** |
167 | Constructor, creating and showing a tree control. | |
3c4f71cc | 168 | |
7c913512 | 169 | @param parent |
4cc4bfaf | 170 | Parent window. Must not be @NULL. |
7c913512 | 171 | @param id |
7977b62a | 172 | Window identifier. The value @c wxID_ANY indicates a default value. |
7c913512 | 173 | @param pos |
4cc4bfaf | 174 | Window position. |
dc1b07fd | 175 | If ::wxDefaultPosition is specified then a default position is chosen. |
7c913512 | 176 | @param size |
dc1b07fd FM |
177 | Window size. |
178 | If ::wxDefaultSize is specified then the window is sized appropriately. | |
7c913512 | 179 | @param style |
4cc4bfaf | 180 | Window style. See wxTreeCtrl. |
7c913512 | 181 | @param validator |
4cc4bfaf | 182 | Window validator. |
7c913512 | 183 | @param name |
4cc4bfaf | 184 | Window name. |
3c4f71cc | 185 | |
4cc4bfaf | 186 | @see Create(), wxValidator |
23324ae1 | 187 | */ |
cfbe5614 | 188 | wxTreeCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, |
7c913512 FM |
189 | const wxPoint& pos = wxDefaultPosition, |
190 | const wxSize& size = wxDefaultSize, | |
cfbe5614 | 191 | long style = wxTR_DEFAULT_STYLE, |
7c913512 | 192 | const wxValidator& validator = wxDefaultValidator, |
cfbe5614 | 193 | const wxString& name = wxTreeCtrlNameStr); |
03966fcb | 194 | |
23324ae1 FM |
195 | |
196 | /** | |
197 | Destructor, destroying the tree control. | |
198 | */ | |
adaaa686 | 199 | virtual ~wxTreeCtrl(); |
23324ae1 FM |
200 | |
201 | /** | |
202 | Adds the root node to the tree, returning the new item. | |
7977b62a BP |
203 | |
204 | The @a image and @a selImage parameters are an index within the normal | |
205 | image list specifying the image to use for unselected and selected | |
206 | items, respectively. If @a image -1 and @a selImage is -1, the same | |
207 | image is used for both selected and unselected items. | |
23324ae1 | 208 | */ |
adaaa686 FM |
209 | virtual wxTreeItemId AddRoot(const wxString& text, int image = -1, |
210 | int selImage = -1, | |
211 | wxTreeItemData* data = NULL); | |
23324ae1 FM |
212 | |
213 | /** | |
7977b62a BP |
214 | Appends an item to the end of the branch identified by @a parent, return |
215 | a new item id. | |
03966fcb | 216 | |
7977b62a BP |
217 | The @a image and @a selImage parameters are an index within the normal |
218 | image list specifying the image to use for unselected and selected | |
219 | items, respectively. If @a image -1 and @a selImage is -1, the same | |
220 | image is used for both selected and unselected items. | |
23324ae1 FM |
221 | */ |
222 | wxTreeItemId AppendItem(const wxTreeItemId& parent, | |
223 | const wxString& text, | |
224 | int image = -1, | |
225 | int selImage = -1, | |
4cc4bfaf | 226 | wxTreeItemData* data = NULL); |
23324ae1 FM |
227 | |
228 | /** | |
7977b62a BP |
229 | Sets the buttons image list. The button images assigned with this method |
230 | will be automatically deleted by wxTreeCtrl as appropriate (i.e. it | |
231 | takes ownership of the list). | |
232 | ||
233 | Setting or assigning the button image list enables the display of image | |
234 | buttons. Once enabled, the only way to disable the display of button | |
235 | images is to set the button image list to @NULL. | |
236 | ||
23324ae1 | 237 | This function is only available in the generic version. |
7977b62a BP |
238 | |
239 | @see SetButtonsImageList(). | |
23324ae1 FM |
240 | */ |
241 | void AssignButtonsImageList(wxImageList* imageList); | |
242 | ||
243 | /** | |
7977b62a BP |
244 | Sets the normal image list. The image list assigned with this method |
245 | will be automatically deleted by wxTreeCtrl as appropriate (i.e. it | |
246 | takes ownership of the list). | |
247 | ||
248 | @see SetImageList(). | |
23324ae1 FM |
249 | */ |
250 | void AssignImageList(wxImageList* imageList); | |
251 | ||
252 | /** | |
7977b62a BP |
253 | Sets the state image list. Image list assigned with this method will be |
254 | automatically deleted by wxTreeCtrl as appropriate (i.e. it takes | |
255 | ownership of the list). | |
256 | ||
257 | @see SetStateImageList(). | |
23324ae1 FM |
258 | */ |
259 | void AssignStateImageList(wxImageList* imageList); | |
260 | ||
261 | /** | |
262 | Collapses the given item. | |
263 | */ | |
adaaa686 | 264 | virtual void Collapse(const wxTreeItemId& item); |
23324ae1 FM |
265 | |
266 | /** | |
267 | Collapses the root item. | |
3c4f71cc | 268 | |
4cc4bfaf | 269 | @see ExpandAll() |
23324ae1 FM |
270 | */ |
271 | void CollapseAll(); | |
272 | ||
273 | /** | |
274 | Collapses this item and all of its children, recursively. | |
3c4f71cc | 275 | |
4cc4bfaf | 276 | @see ExpandAllChildren() |
23324ae1 FM |
277 | */ |
278 | void CollapseAllChildren(const wxTreeItemId& item); | |
279 | ||
280 | /** | |
281 | Collapses the given item and removes all children. | |
282 | */ | |
adaaa686 | 283 | virtual void CollapseAndReset(const wxTreeItemId& item); |
23324ae1 FM |
284 | |
285 | /** | |
cfbe5614 FM |
286 | Creates the tree control. |
287 | See wxTreeCtrl::wxTreeCtrl() for further details. | |
23324ae1 | 288 | */ |
cfbe5614 | 289 | bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, |
7977b62a BP |
290 | const wxPoint& pos = wxDefaultPosition, |
291 | const wxSize& size = wxDefaultSize, | |
cfbe5614 | 292 | long style = wxTR_DEFAULT_STYLE, |
7977b62a | 293 | const wxValidator& validator = wxDefaultValidator, |
cfbe5614 | 294 | const wxString& name = wxTreeCtrlNameStr); |
23324ae1 FM |
295 | |
296 | /** | |
6873eb5b | 297 | Deletes the specified item. A @c EVT_TREE_DELETE_ITEM event will be |
23324ae1 | 298 | generated. |
7977b62a BP |
299 | |
300 | This function may cause a subsequent call to GetNextChild() to fail. | |
23324ae1 | 301 | */ |
adaaa686 | 302 | virtual void Delete(const wxTreeItemId& item); |
23324ae1 FM |
303 | |
304 | /** | |
305 | Deletes all items in the control. Note that this may not generate | |
6873eb5b | 306 | @c EVT_TREE_DELETE_ITEM events under some Windows versions although |
23324ae1 FM |
307 | normally such event is generated for each removed item. |
308 | */ | |
adaaa686 | 309 | virtual void DeleteAllItems(); |
23324ae1 FM |
310 | |
311 | /** | |
7977b62a BP |
312 | Deletes all children of the given item (but not the item itself). Note |
313 | that this will @b not generate any events unlike Delete() method. | |
314 | ||
315 | If you have called SetItemHasChildren(), you may need to call it again | |
316 | since DeleteChildren() does not automatically clear the setting. | |
23324ae1 | 317 | */ |
adaaa686 | 318 | virtual void DeleteChildren(const wxTreeItemId& item); |
23324ae1 FM |
319 | |
320 | /** | |
7977b62a | 321 | Starts editing the label of the given @a item. This function generates a |
6873eb5b | 322 | @c EVT_TREE_BEGIN_LABEL_EDIT event which can be vetoed so that no text |
7977b62a BP |
323 | control will appear for in-place editing. |
324 | ||
325 | If the user changed the label (i.e. s/he does not press ESC or leave the | |
6873eb5b | 326 | text control without changes, a @c EVT_TREE_END_LABEL_EDIT event will be |
7977b62a | 327 | sent which can be vetoed as well. |
3c4f71cc | 328 | |
4cc4bfaf | 329 | @see EndEditLabel(), wxTreeEvent |
23324ae1 | 330 | */ |
cfbe5614 | 331 | virtual wxTextCtrl *EditLabel(const wxTreeItemId& item, |
b19b28c8 | 332 | wxClassInfo* textCtrlClass = wxCLASSINFO(wxTextCtrl)); |
23324ae1 FM |
333 | |
334 | /** | |
7977b62a BP |
335 | Ends label editing. If @a cancelEdit is @true, the edit will be |
336 | cancelled. | |
337 | ||
338 | @note | |
339 | This function is currently supported under Windows only. | |
3c4f71cc | 340 | |
4cc4bfaf | 341 | @see EditLabel() |
23324ae1 | 342 | */ |
cfbe5614 | 343 | virtual void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false); |
23324ae1 FM |
344 | |
345 | /** | |
346 | Scrolls and/or expands items to ensure that the given item is visible. | |
347 | */ | |
adaaa686 | 348 | virtual void EnsureVisible(const wxTreeItemId& item); |
23324ae1 FM |
349 | |
350 | /** | |
351 | Expands the given item. | |
352 | */ | |
adaaa686 | 353 | virtual void Expand(const wxTreeItemId& item); |
23324ae1 FM |
354 | |
355 | /** | |
356 | Expands all items in the tree. | |
357 | */ | |
358 | void ExpandAll(); | |
359 | ||
360 | /** | |
361 | Expands the given item and all its children recursively. | |
362 | */ | |
363 | void ExpandAllChildren(const wxTreeItemId& item); | |
364 | ||
365 | /** | |
7977b62a BP |
366 | Retrieves the rectangle bounding the @a item. If @a textOnly is @true, |
367 | only the rectangle around the item's label will be returned, otherwise | |
368 | the item's image is also taken into account. | |
369 | ||
370 | The return value is @true if the rectangle was successfully retrieved or | |
371 | @c @false if it was not (in this case @a rect is not changed) -- for | |
372 | example, if the item is currently invisible. | |
373 | ||
374 | Notice that the rectangle coordinates are logical, not physical ones. | |
375 | So, for example, the x coordinate may be negative if the tree has a | |
376 | horizontal scrollbar and its position is not 0. | |
377 | ||
378 | @beginWxPythonOnly | |
379 | The wxPython version of this method requires only the @a item and @a | |
380 | textOnly parameters. The return value is either a wxRect object or @c | |
381 | None. | |
382 | @endWxPythonOnly | |
1058f652 MB |
383 | |
384 | @beginWxPerlOnly | |
385 | In wxPerl this method only takes the @a item and | |
386 | @a textOnly parameters and returns a @c Wx::Rect (or @c undef). | |
387 | @endWxPerlOnly | |
23324ae1 | 388 | */ |
fadc2df6 FM |
389 | virtual bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, |
390 | bool textOnly = false) const; | |
23324ae1 FM |
391 | |
392 | /** | |
7977b62a BP |
393 | Returns the buttons image list (from which application-defined button |
394 | images are taken). | |
395 | ||
23324ae1 FM |
396 | This function is only available in the generic version. |
397 | */ | |
328f5751 | 398 | wxImageList* GetButtonsImageList() const; |
23324ae1 FM |
399 | |
400 | /** | |
4cc4bfaf | 401 | Returns the number of items in the branch. If @a recursively is @true, |
7977b62a BP |
402 | returns the total number of descendants, otherwise only one level of |
403 | children is counted. | |
23324ae1 | 404 | */ |
cfbe5614 FM |
405 | virtual size_t GetChildrenCount(const wxTreeItemId& item, |
406 | bool recursively = true) const; | |
23324ae1 FM |
407 | |
408 | /** | |
409 | Returns the number of items in the control. | |
410 | */ | |
adaaa686 | 411 | virtual unsigned int GetCount() const; |
23324ae1 FM |
412 | |
413 | /** | |
7977b62a BP |
414 | Returns the edit control being currently used to edit a label. Returns |
415 | @NULL if no label is being edited. | |
416 | ||
417 | @note This is currently only implemented for wxMSW. | |
23324ae1 | 418 | */ |
adaaa686 | 419 | virtual wxTextCtrl* GetEditControl() const; |
23324ae1 FM |
420 | |
421 | /** | |
422 | Returns the first child; call GetNextChild() for the next child. | |
7977b62a | 423 | |
23324ae1 | 424 | For this enumeration function you must pass in a 'cookie' parameter |
7977b62a BP |
425 | which is opaque for the application but is necessary for the library to |
426 | make these functions reentrant (i.e. allow more than one enumeration on | |
427 | one and the same object simultaneously). The cookie passed to | |
428 | GetFirstChild() and GetNextChild() should be the same variable. | |
429 | ||
430 | Returns an invalid tree item (i.e. wxTreeItemId::IsOk() returns @false) | |
431 | if there are no further children. | |
432 | ||
433 | @beginWxPythonOnly | |
434 | In wxPython the returned wxTreeItemId and the new cookie value are both | |
435 | returned as a tuple containing the two values. | |
436 | @endWxPythonOnly | |
3c4f71cc | 437 | |
1058f652 MB |
438 | @beginWxPerlOnly |
439 | In wxPerl this method only takes the @a item parameter, and | |
440 | returns a 2-element list (item, cookie). | |
441 | @endWxPerlOnly | |
442 | ||
4cc4bfaf | 443 | @see GetNextChild(), GetNextSibling() |
23324ae1 | 444 | */ |
fadc2df6 FM |
445 | virtual wxTreeItemId GetFirstChild(const wxTreeItemId& item, |
446 | wxTreeItemIdValue& cookie) const; | |
23324ae1 FM |
447 | |
448 | /** | |
449 | Returns the first visible item. | |
450 | */ | |
adaaa686 | 451 | virtual wxTreeItemId GetFirstVisibleItem() const; |
23324ae1 | 452 | |
febebac1 VZ |
453 | /** |
454 | Returns the item last clicked or otherwise selected. | |
455 | Unlike GetSelection(), it can be used whether or not | |
456 | the control has the @c wxTR_MULTIPLE style. | |
457 | ||
458 | @since 2.9.1 | |
459 | */ | |
460 | virtual wxTreeItemId GetFocusedItem() const; | |
461 | ||
5708ae18 VZ |
462 | |
463 | /** | |
464 | Clears the currently focused item | |
465 | ||
466 | @since 2.9.1 | |
467 | */ | |
468 | virtual void ClearFocusedItem(); | |
469 | ||
470 | /** | |
471 | Sets the currently focused item. | |
472 | ||
473 | @param item | |
474 | The item to make the current one. It must be valid. | |
475 | @since 2.9.1 | |
476 | */ | |
477 | virtual void SetFocusedItem(const wxTreeItemId& item); | |
478 | ||
479 | ||
23324ae1 FM |
480 | /** |
481 | Returns the normal image list. | |
482 | */ | |
328f5751 | 483 | wxImageList* GetImageList() const; |
23324ae1 FM |
484 | |
485 | /** | |
486 | Returns the current tree control indentation. | |
487 | */ | |
cfbe5614 | 488 | virtual unsigned int GetIndent() const; |
23324ae1 FM |
489 | |
490 | /** | |
491 | Returns the background colour of the item. | |
492 | */ | |
adaaa686 | 493 | virtual wxColour GetItemBackgroundColour(const wxTreeItemId& item) const; |
23324ae1 | 494 | |
23324ae1 | 495 | /** |
7977b62a | 496 | Returns the tree item data associated with the item. |
23324ae1 | 497 | |
483724a1 | 498 | @see wxTreeItemData |
23324ae1 | 499 | |
483724a1 FM |
500 | @beginWxPythonOnly |
501 | wxPython provides the following shortcut method: | |
502 | @li GetPyData(item): Returns the Python Object associated with the | |
503 | wxTreeItemData for the given item Id. | |
504 | @endWxPythonOnly | |
1058f652 MB |
505 | |
506 | @beginWxPerlOnly | |
507 | wxPerl provides the following shortcut method: | |
508 | - GetPlData(item): returns the Perl data | |
509 | associated with the Wx::TreeItemData. It is just the same as | |
510 | tree->GetItemData(item)->GetData(). | |
511 | @endWxPerlOnly | |
483724a1 | 512 | */ |
adaaa686 | 513 | virtual wxTreeItemData* GetItemData(const wxTreeItemId& item) const; |
7977b62a BP |
514 | |
515 | /** | |
516 | Returns the font of the item label. | |
517 | */ | |
adaaa686 | 518 | virtual wxFont GetItemFont(const wxTreeItemId& item) const; |
23324ae1 FM |
519 | |
520 | /** | |
4cc4bfaf | 521 | Gets the specified item image. The value of @a which may be: |
7977b62a BP |
522 | - ::wxTreeItemIcon_Normal: to get the normal item image. |
523 | - ::wxTreeItemIcon_Selected: to get the selected item image (i.e. the | |
524 | image which is shown when the item is currently selected). | |
525 | - ::wxTreeItemIcon_Expanded: to get the expanded image (this only makes | |
526 | sense for items which have children - then this image is shown when | |
527 | the item is expanded and the normal image is shown when it is | |
528 | collapsed). | |
529 | - ::wxTreeItemIcon_SelectedExpanded: to get the selected expanded image | |
530 | (which is shown when an expanded item is currently selected). | |
23324ae1 | 531 | */ |
fadc2df6 FM |
532 | virtual int GetItemImage(const wxTreeItemId& item, |
533 | wxTreeItemIcon which = wxTreeItemIcon_Normal) const; | |
23324ae1 FM |
534 | |
535 | /** | |
536 | Returns the item's parent. | |
537 | */ | |
adaaa686 | 538 | virtual wxTreeItemId GetItemParent(const wxTreeItemId& item) const; |
23324ae1 | 539 | |
03966fcb RR |
540 | /** |
541 | Gets the specified item state. | |
542 | */ | |
543 | int GetItemState(const wxTreeItemId& item) const; | |
544 | ||
23324ae1 FM |
545 | /** |
546 | Returns the item label. | |
547 | */ | |
adaaa686 | 548 | virtual wxString GetItemText(const wxTreeItemId& item) const; |
23324ae1 FM |
549 | |
550 | /** | |
551 | Returns the colour of the item label. | |
552 | */ | |
adaaa686 | 553 | virtual wxColour GetItemTextColour(const wxTreeItemId& item) const; |
23324ae1 FM |
554 | |
555 | /** | |
7977b62a BP |
556 | Returns the last child of the item (or an invalid tree item if this item |
557 | has no children). | |
3c4f71cc | 558 | |
7977b62a | 559 | @see GetFirstChild(), GetNextSibling(), GetLastChild() |
23324ae1 | 560 | */ |
adaaa686 | 561 | virtual wxTreeItemId GetLastChild(const wxTreeItemId& item) const; |
23324ae1 FM |
562 | |
563 | /** | |
7977b62a BP |
564 | Returns the next child; call GetFirstChild() for the first child. For |
565 | this enumeration function you must pass in a 'cookie' parameter which is | |
566 | opaque for the application but is necessary for the library to make | |
567 | these functions reentrant (i.e. allow more than one enumeration on one | |
568 | and the same object simultaneously). The cookie passed to | |
569 | GetFirstChild() and GetNextChild() should be the same. | |
570 | ||
23324ae1 | 571 | Returns an invalid tree item if there are no further children. |
3c4f71cc | 572 | |
7977b62a BP |
573 | @beginWxPythonOnly |
574 | In wxPython the returned wxTreeItemId and the new cookie value are both | |
575 | returned as a tuple containing the two values. | |
576 | @endWxPythonOnly | |
577 | ||
1058f652 MB |
578 | @beginWxPerlOnly |
579 | In wxPerl this method returns a 2-element list | |
580 | (item, cookie) instead of modifying its parameters. | |
581 | @endWxPerlOnly | |
582 | ||
4cc4bfaf | 583 | @see GetFirstChild() |
23324ae1 | 584 | */ |
fadc2df6 FM |
585 | virtual wxTreeItemId GetNextChild(const wxTreeItemId& item, |
586 | wxTreeItemIdValue& cookie) const; | |
23324ae1 FM |
587 | |
588 | /** | |
7977b62a BP |
589 | Returns the next sibling of the specified item; call GetPrevSibling() |
590 | for the previous sibling. | |
591 | ||
23324ae1 | 592 | Returns an invalid tree item if there are no further siblings. |
3c4f71cc | 593 | |
4cc4bfaf | 594 | @see GetPrevSibling() |
23324ae1 | 595 | */ |
adaaa686 | 596 | virtual wxTreeItemId GetNextSibling(const wxTreeItemId& item) const; |
23324ae1 FM |
597 | |
598 | /** | |
7977b62a BP |
599 | Returns the next visible item or an invalid item if this item is the |
600 | last visible one. | |
601 | ||
602 | @note The @a item itself must be visible. | |
23324ae1 | 603 | */ |
adaaa686 | 604 | virtual wxTreeItemId GetNextVisible(const wxTreeItemId& item) const; |
23324ae1 FM |
605 | |
606 | /** | |
7977b62a BP |
607 | Returns the previous sibling of the specified item; call |
608 | GetNextSibling() for the next sibling. | |
609 | ||
23324ae1 | 610 | Returns an invalid tree item if there are no further children. |
3c4f71cc | 611 | |
4cc4bfaf | 612 | @see GetNextSibling() |
23324ae1 | 613 | */ |
adaaa686 | 614 | virtual wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const; |
23324ae1 FM |
615 | |
616 | /** | |
7977b62a BP |
617 | Returns the previous visible item or an invalid item if this item is the |
618 | first visible one. | |
619 | ||
620 | @note The @a item itself must be visible. | |
23324ae1 | 621 | */ |
adaaa686 | 622 | virtual wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const; |
23324ae1 FM |
623 | |
624 | /** | |
7977b62a BP |
625 | Returns @true if the control will use a quick calculation for the best |
626 | size, looking only at the first and last items. The default is @false. | |
3c4f71cc | 627 | |
4cc4bfaf | 628 | @see SetQuickBestSize() |
23324ae1 | 629 | */ |
328f5751 | 630 | bool GetQuickBestSize() const; |
23324ae1 FM |
631 | |
632 | /** | |
633 | Returns the root item for the tree control. | |
634 | */ | |
adaaa686 | 635 | virtual wxTreeItemId GetRootItem() const; |
23324ae1 FM |
636 | |
637 | /** | |
7977b62a BP |
638 | Returns the selection, or an invalid item if there is no selection. This |
639 | function only works with the controls without @c wxTR_MULTIPLE style, | |
febebac1 VZ |
640 | use GetSelections() for the controls which do have this style |
641 | or, if a single item is wanted, use GetFocusedItem(). | |
23324ae1 | 642 | */ |
adaaa686 | 643 | virtual wxTreeItemId GetSelection() const; |
23324ae1 FM |
644 | |
645 | /** | |
7977b62a BP |
646 | Fills the array of tree items passed in with the currently selected |
647 | items. This function can be called only if the control has the @c | |
648 | wxTR_MULTIPLE style. | |
649 | ||
23324ae1 | 650 | Returns the number of selected items. |
03966fcb | 651 | |
7977b62a BP |
652 | @beginWxPythonOnly |
653 | The wxPython version of this method accepts no parameters and returns a | |
654 | Python list of @ref wxTreeItemId "wxTreeItemId"s. | |
655 | @endWxPythonOnly | |
1058f652 MB |
656 | |
657 | @beginWxPerlOnly | |
658 | In wxPerl this method takes no parameters and returns a list of | |
659 | @c Wx::TreeItemId. | |
660 | @endWxPerlOnly | |
23324ae1 | 661 | */ |
cfbe5614 | 662 | virtual size_t GetSelections(wxArrayTreeItemIds& selection) const; |
23324ae1 FM |
663 | |
664 | /** | |
7977b62a BP |
665 | Returns the state image list (from which application-defined state |
666 | images are taken). | |
23324ae1 | 667 | */ |
328f5751 | 668 | wxImageList* GetStateImageList() const; |
23324ae1 FM |
669 | |
670 | /** | |
7977b62a BP |
671 | Calculates which (if any) item is under the given @a point, returning |
672 | the tree item id at this point plus extra information @a flags. @a flags | |
673 | is a bitlist of the following: | |
674 | ||
675 | - @c wxTREE_HITTEST_ABOVE: Above the client area. | |
676 | - @c wxTREE_HITTEST_BELOW: Below the client area. | |
677 | - @c wxTREE_HITTEST_NOWHERE: In the client area but below the last item. | |
678 | - @c wxTREE_HITTEST_ONITEMBUTTON: On the button associated with an item. | |
679 | - @c wxTREE_HITTEST_ONITEMICON: On the bitmap associated with an item. | |
6873eb5b FM |
680 | - @c wxTREE_HITTEST_ONITEMINDENT: In the indentation associated with an item. |
681 | - @c wxTREE_HITTEST_ONITEMLABEL: On the label (string) associated with an item. | |
7977b62a BP |
682 | - @c wxTREE_HITTEST_ONITEMRIGHT: In the area to the right of an item. |
683 | - @c wxTREE_HITTEST_ONITEMSTATEICON: On the state icon for a tree view | |
6873eb5b | 684 | item that is in a user-defined state. |
7977b62a BP |
685 | - @c wxTREE_HITTEST_TOLEFT: To the right of the client area. |
686 | - @c wxTREE_HITTEST_TORIGHT: To the left of the client area. | |
03966fcb | 687 | |
7977b62a BP |
688 | @beginWxPythonOnly |
689 | In wxPython both the wxTreeItemId and the flags are returned as a tuple. | |
690 | @endWxPythonOnly | |
1058f652 MB |
691 | |
692 | @beginWxPerlOnly | |
693 | In wxPerl this method only takes the @a point parameter | |
694 | and returns a 2-element list (item, flags). | |
695 | @endWxPerlOnly | |
23324ae1 | 696 | */ |
328f5751 | 697 | wxTreeItemId HitTest(const wxPoint& point, int& flags) const; |
23324ae1 | 698 | |
7977b62a | 699 | |
23324ae1 | 700 | /** |
7977b62a BP |
701 | Inserts an item after a given one (@a previous). |
702 | ||
703 | The @a image and @a selImage parameters are an index within the normal | |
704 | image list specifying the image to use for unselected and selected | |
705 | items, respectively. If @a image -1 and @a selImage is -1, the same | |
706 | image is used for both selected and unselected items. | |
23324ae1 FM |
707 | */ |
708 | wxTreeItemId InsertItem(const wxTreeItemId& parent, | |
709 | const wxTreeItemId& previous, | |
710 | const wxString& text, | |
711 | int image = -1, | |
712 | int selImage = -1, | |
4cc4bfaf | 713 | wxTreeItemData* data = NULL); |
7977b62a BP |
714 | |
715 | /** | |
716 | Inserts an item before one identified | |
717 | by its position (@a before). @a before must be less than the number of | |
718 | children. | |
719 | ||
720 | The @a image and @a selImage parameters are an index within the normal | |
721 | image list specifying the image to use for unselected and selected | |
722 | items, respectively. If @a image -1 and @a selImage is -1, the same | |
723 | image is used for both selected and unselected items. | |
724 | ||
725 | @beginWxPythonOnly | |
726 | In wxPython, this form of this method is called @c InsertItemBefore(). | |
727 | @endWxPythonOnly | |
728 | */ | |
7c913512 FM |
729 | wxTreeItemId InsertItem(const wxTreeItemId& parent, |
730 | size_t before, | |
731 | const wxString& text, | |
732 | int image = -1, | |
733 | int selImage = -1, | |
4cc4bfaf | 734 | wxTreeItemData* data = NULL); |
23324ae1 FM |
735 | |
736 | /** | |
737 | Returns @true if the given item is in bold state. | |
7977b62a BP |
738 | |
739 | @see SetItemBold() | |
23324ae1 | 740 | */ |
adaaa686 | 741 | virtual bool IsBold(const wxTreeItemId& item) const; |
23324ae1 FM |
742 | |
743 | /** | |
7977b62a BP |
744 | Returns @true if the control is empty (i.e. has no items, even no root |
745 | one). | |
23324ae1 | 746 | */ |
328f5751 | 747 | bool IsEmpty() const; |
23324ae1 FM |
748 | |
749 | /** | |
7977b62a BP |
750 | Returns @true if the item is expanded (only makes sense if it has |
751 | children). | |
23324ae1 | 752 | */ |
adaaa686 | 753 | virtual bool IsExpanded(const wxTreeItemId& item) const; |
23324ae1 FM |
754 | |
755 | /** | |
756 | Returns @true if the item is selected. | |
757 | */ | |
adaaa686 | 758 | virtual bool IsSelected(const wxTreeItemId& item) const; |
23324ae1 FM |
759 | |
760 | /** | |
761 | Returns @true if the item is visible on the screen. | |
762 | */ | |
adaaa686 | 763 | virtual bool IsVisible(const wxTreeItemId& item) const; |
23324ae1 FM |
764 | |
765 | /** | |
766 | Returns @true if the item has children. | |
767 | */ | |
adaaa686 | 768 | virtual bool ItemHasChildren(const wxTreeItemId& item) const; |
23324ae1 FM |
769 | |
770 | /** | |
7977b62a BP |
771 | Override this function in the derived class to change the sort order of |
772 | the items in the tree control. The function should return a negative, | |
773 | zero or positive value if the first item is less than, equal to or | |
774 | greater than the second one. | |
775 | ||
b19b28c8 FM |
776 | Please note that you @b must use wxRTTI macros wxDECLARE_DYNAMIC_CLASS() |
777 | and wxIMPLEMENT_DYNAMIC_CLASS() if you override this function because | |
7977b62a BP |
778 | otherwise the base class considers that it is not overridden and uses |
779 | the default comparison, i.e. sorts the items alphabetically, which | |
23324ae1 | 780 | allows it optimize away the calls to the virtual function completely. |
7977b62a BP |
781 | |
782 | @see SortChildren() | |
23324ae1 | 783 | */ |
fadc2df6 FM |
784 | virtual int OnCompareItems(const wxTreeItemId& item1, |
785 | const wxTreeItemId& item2); | |
23324ae1 FM |
786 | |
787 | /** | |
7977b62a BP |
788 | Appends an item as the first child of @a parent, return a new item id. |
789 | ||
790 | The @a image and @a selImage parameters are an index within the normal | |
791 | image list specifying the image to use for unselected and selected | |
792 | items, respectively. If @a image -1 and @a selImage is -1, the same | |
793 | image is used for both selected and unselected items. | |
23324ae1 FM |
794 | */ |
795 | wxTreeItemId PrependItem(const wxTreeItemId& parent, | |
796 | const wxString& text, | |
797 | int image = -1, | |
798 | int selImage = -1, | |
4cc4bfaf | 799 | wxTreeItemData* data = NULL); |
23324ae1 FM |
800 | |
801 | /** | |
802 | Scrolls the specified item into view. | |
803 | */ | |
adaaa686 | 804 | virtual void ScrollTo(const wxTreeItemId& item); |
23324ae1 FM |
805 | |
806 | /** | |
7977b62a BP |
807 | Selects the given item. In multiple selection controls, can be also used |
808 | to deselect a currently selected item if the value of @a select is | |
809 | @false. | |
23324ae1 | 810 | */ |
adaaa686 | 811 | virtual void SelectItem(const wxTreeItemId& item, bool select = true); |
23324ae1 FM |
812 | |
813 | /** | |
7977b62a BP |
814 | Sets the buttons image list (from which application-defined button |
815 | images are taken). | |
816 | ||
817 | The button images assigned with this method will @b not be deleted by | |
818 | @ref wxTreeCtrl "wxTreeCtrl"'s destructor, you must delete it yourself. | |
819 | Setting or assigning the button image list enables the display of image | |
820 | buttons. Once enabled, the only way to disable the display of button | |
821 | images is to set the button image list to @NULL. | |
822 | ||
823 | @note This function is only available in the generic version. | |
824 | ||
825 | @see AssignButtonsImageList(). | |
23324ae1 FM |
826 | */ |
827 | void SetButtonsImageList(wxImageList* imageList); | |
828 | ||
829 | /** | |
7977b62a BP |
830 | Sets the normal image list. The image list assigned with this method |
831 | will @b not be deleted by @ref wxTreeCtrl "wxTreeCtrl"'s destructor, you | |
832 | must delete it yourself. | |
833 | ||
834 | @see AssignImageList(). | |
23324ae1 | 835 | */ |
adaaa686 | 836 | virtual void SetImageList(wxImageList* imageList); |
23324ae1 FM |
837 | |
838 | /** | |
839 | Sets the indentation for the tree control. | |
840 | */ | |
cfbe5614 | 841 | virtual void SetIndent(unsigned int indent); |
23324ae1 FM |
842 | |
843 | /** | |
844 | Sets the colour of the item's background. | |
845 | */ | |
fadc2df6 FM |
846 | virtual void SetItemBackgroundColour(const wxTreeItemId& item, |
847 | const wxColour& col); | |
23324ae1 FM |
848 | |
849 | /** | |
7977b62a BP |
850 | Makes item appear in bold font if @a bold parameter is @true or resets |
851 | it to the normal state. | |
852 | ||
853 | @see IsBold() | |
23324ae1 | 854 | */ |
adaaa686 | 855 | virtual void SetItemBold(const wxTreeItemId& item, bool bold = true); |
23324ae1 | 856 | |
7977b62a BP |
857 | /** |
858 | Sets the item client data. | |
859 | ||
727539d8 VZ |
860 | Notice that the client data previously associated with the @a item (if |
861 | any) is @em not freed by this function and so calling this function | |
862 | multiple times for the same item will result in memory leaks unless you | |
863 | delete the old item data pointer yourself. | |
864 | ||
7977b62a BP |
865 | @beginWxPythonOnly |
866 | - @b SetPyData( @a item, @c obj): Associate the given Python Object with | |
867 | the wxTreeItemData for the given item Id. | |
868 | @endWxPythonOnly | |
869 | ||
1058f652 MB |
870 | @beginWxPerlOnly |
871 | wxPerl provides the following shortcut method: | |
872 | - SetPlData(item, data): sets the Perl data | |
873 | associated with the @c Wx::TreeItemData. It is just the same as | |
874 | tree->GetItemData(item)->SetData(data). | |
875 | @endWxPerlOnly | |
7977b62a | 876 | */ |
adaaa686 | 877 | virtual void SetItemData(const wxTreeItemId& item, wxTreeItemData* data); |
7977b62a BP |
878 | |
879 | ||
23324ae1 FM |
880 | /** |
881 | Gives the item the visual feedback for Drag'n'Drop actions, which is | |
882 | useful if something is dragged from the outside onto the tree control | |
883 | (as opposed to a DnD operation within the tree control, which already | |
884 | is implemented internally). | |
885 | */ | |
fadc2df6 FM |
886 | virtual void SetItemDropHighlight(const wxTreeItemId& item, |
887 | bool highlight = true); | |
23324ae1 FM |
888 | |
889 | /** | |
7977b62a BP |
890 | Sets the item's font. All items in the tree should have the same height |
891 | to avoid text clipping, so the fonts height should be the same for all | |
892 | of them, although font attributes may vary. | |
3c4f71cc | 893 | |
4cc4bfaf | 894 | @see SetItemBold() |
23324ae1 | 895 | */ |
adaaa686 | 896 | virtual void SetItemFont(const wxTreeItemId& item, const wxFont& font); |
23324ae1 FM |
897 | |
898 | /** | |
899 | Force appearance of the button next to the item. This is useful to | |
900 | allow the user to expand the items which don't have any children now, | |
901 | but instead adding them only when needed, thus minimizing memory | |
902 | usage and loading time. | |
903 | */ | |
fadc2df6 FM |
904 | virtual void SetItemHasChildren(const wxTreeItemId& item, |
905 | bool hasChildren = true); | |
23324ae1 FM |
906 | |
907 | /** | |
7977b62a BP |
908 | Sets the specified item's image. See GetItemImage() for the description |
909 | of the @a which parameter. | |
23324ae1 | 910 | */ |
fadc2df6 FM |
911 | virtual void SetItemImage(const wxTreeItemId& item, int image, |
912 | wxTreeItemIcon which = wxTreeItemIcon_Normal); | |
23324ae1 | 913 | |
03966fcb RR |
914 | /** |
915 | Sets the specified item state. The value of @a state may be: | |
809ca837 RR |
916 | - @c wxTREE_ITEMSTATE_NONE: to disable the item state (the state image will |
917 | be not displayed). | |
918 | - @c wxTREE_ITEMSTATE_NEXT: to set the next item state. | |
919 | - @c wxTREE_ITEMSTATE_PREV: to set the previous item state. | |
03966fcb RR |
920 | */ |
921 | void SetItemState(const wxTreeItemId& item, int state); | |
922 | ||
23324ae1 FM |
923 | /** |
924 | Sets the item label. | |
925 | */ | |
adaaa686 | 926 | virtual void SetItemText(const wxTreeItemId& item, const wxString& text); |
23324ae1 FM |
927 | |
928 | /** | |
929 | Sets the colour of the item's text. | |
930 | */ | |
fadc2df6 FM |
931 | virtual void SetItemTextColour(const wxTreeItemId& item, |
932 | const wxColour& col); | |
23324ae1 FM |
933 | |
934 | /** | |
7977b62a BP |
935 | If @true is passed, specifies that the control will use a quick |
936 | calculation for the best size, looking only at the first and last items. | |
937 | Otherwise, it will look at all items. The default is @false. | |
3c4f71cc | 938 | |
4cc4bfaf | 939 | @see GetQuickBestSize() |
23324ae1 FM |
940 | */ |
941 | void SetQuickBestSize(bool quickBestSize); | |
942 | ||
943 | /** | |
7977b62a BP |
944 | Sets the state image list (from which application-defined state images |
945 | are taken). Image list assigned with this method will @b not be deleted | |
946 | by @ref wxTreeCtrl "wxTreeCtrl"'s destructor, you must delete it | |
947 | yourself. | |
948 | ||
949 | @see AssignStateImageList(). | |
23324ae1 | 950 | */ |
adaaa686 | 951 | virtual void SetStateImageList(wxImageList* imageList); |
23324ae1 FM |
952 | |
953 | /** | |
7977b62a BP |
954 | Sets the mode flags associated with the display of the tree control. The |
955 | new mode takes effect immediately. | |
956 | ||
957 | @note Generic only; MSW ignores changes. | |
23324ae1 FM |
958 | */ |
959 | void SetWindowStyle(long styles); | |
960 | ||
961 | /** | |
7977b62a BP |
962 | Sorts the children of the given item using OnCompareItems(). |
963 | You should override that method to change the sort order (the default is | |
964 | ascending case-sensitive alphabetical order). | |
3c4f71cc | 965 | |
4cc4bfaf | 966 | @see wxTreeItemData, OnCompareItems() |
23324ae1 | 967 | */ |
adaaa686 | 968 | virtual void SortChildren(const wxTreeItemId& item); |
23324ae1 FM |
969 | |
970 | /** | |
971 | Toggles the given item between collapsed and expanded states. | |
972 | */ | |
adaaa686 | 973 | virtual void Toggle(const wxTreeItemId& item); |
23324ae1 FM |
974 | |
975 | /** | |
976 | Toggles the given item between selected and unselected states. For | |
977 | multiselection controls only. | |
978 | */ | |
979 | void ToggleItemSelection(const wxTreeItemId& item); | |
980 | ||
981 | /** | |
982 | Removes the selection from the currently selected item (if any). | |
983 | */ | |
adaaa686 | 984 | virtual void Unselect(); |
23324ae1 FM |
985 | |
986 | /** | |
7977b62a BP |
987 | This function either behaves the same as Unselect() if the control |
988 | doesn't have @c wxTR_MULTIPLE style, or removes the selection from all | |
989 | items if it does have this style. | |
23324ae1 | 990 | */ |
adaaa686 | 991 | virtual void UnselectAll(); |
23324ae1 FM |
992 | |
993 | /** | |
994 | Unselects the given item. This works in multiselection controls only. | |
995 | */ | |
996 | void UnselectItem(const wxTreeItemId& item); | |
5cb3a695 VZ |
997 | |
998 | /** | |
999 | Select all the immediate children of the given parent. | |
1000 | ||
1001 | This function can be used with multiselection controls only. | |
1002 | ||
1003 | @since 2.9.1 | |
1004 | */ | |
1005 | virtual void SelectChildren(const wxTreeItemId& parent); | |
23324ae1 FM |
1006 | }; |
1007 | ||
1008 | ||
e54c96f1 | 1009 | |
23324ae1 FM |
1010 | /** |
1011 | @class wxTreeEvent | |
7c913512 | 1012 | |
7977b62a BP |
1013 | A tree event holds information about events associated with wxTreeCtrl |
1014 | objects. | |
1015 | ||
1016 | To process input from a tree control, use these event handler macros to | |
1017 | direct input to member functions that take a wxTreeEvent argument. | |
1018 | ||
1019 | @beginEventTable{wxTreeEvent} | |
1020 | @event{EVT_TREE_BEGIN_DRAG(id, func)} | |
a1e92028 VZ |
1021 | Begin dragging with the left mouse button. If you want to enable |
1022 | left-dragging you need to intercept this event and explicitely call | |
1023 | wxTreeEvent::Allow(), as it's vetoed by default. Also notice that the | |
1024 | control must have an associated image list (see SetImageList()) to | |
1025 | drag its items under MSW. | |
7977b62a | 1026 | @event{EVT_TREE_BEGIN_RDRAG(id, func)} |
a1e92028 VZ |
1027 | Begin dragging with the right mouse button. If you want to enable |
1028 | right-dragging you need to intercept this event and explicitely call | |
1029 | wxTreeEvent::Allow(), as it's vetoed by default. | |
7977b62a BP |
1030 | @event{EVT_TREE_END_DRAG(id, func)} |
1031 | End dragging with the left or right mouse button. | |
1032 | @event{EVT_TREE_BEGIN_LABEL_EDIT(id, func)} | |
1033 | Begin editing a label. This can be prevented by calling Veto(). | |
1034 | @event{EVT_TREE_END_LABEL_EDIT(id, func)} | |
1035 | Finish editing a label. This can be prevented by calling Veto(). | |
1036 | @event{EVT_TREE_DELETE_ITEM(id, func)} | |
1037 | Delete an item. | |
1038 | @event{EVT_TREE_GET_INFO(id, func)} | |
1039 | Request information from the application. | |
1040 | @event{EVT_TREE_SET_INFO(id, func)} | |
1041 | Information is being supplied. | |
1042 | @event{EVT_TREE_ITEM_ACTIVATED(id, func)} | |
1043 | The item has been activated, i.e. chosen by double clicking it with | |
1044 | mouse or from keyboard. | |
1045 | @event{EVT_TREE_ITEM_COLLAPSED(id, func)} | |
1046 | The item has been collapsed. | |
1047 | @event{EVT_TREE_ITEM_COLLAPSING(id, func)} | |
1048 | The item is being collapsed. This can be prevented by calling Veto(). | |
1049 | @event{EVT_TREE_ITEM_EXPANDED(id, func)} | |
1050 | The item has been expanded. | |
1051 | @event{EVT_TREE_ITEM_EXPANDING(id, func)} | |
1052 | The item is being expanded. This can be prevented by calling Veto(). | |
1053 | @event{EVT_TREE_ITEM_RIGHT_CLICK(id, func)} | |
1054 | The user has clicked the item with the right mouse button. | |
1055 | @event{EVT_TREE_ITEM_MIDDLE_CLICK(id, func)} | |
1056 | The user has clicked the item with the middle mouse button. | |
1057 | @event{EVT_TREE_SEL_CHANGED(id, func)} | |
1058 | Selection has changed. | |
1059 | @event{EVT_TREE_SEL_CHANGING(id, func)} | |
1060 | Selection is changing. This can be prevented by calling Veto(). | |
1061 | @event{EVT_TREE_KEY_DOWN(id, func)} | |
1062 | A key has been pressed. | |
1063 | @event{EVT_TREE_ITEM_GETTOOLTIP(id, func)} | |
1064 | The opportunity to set the item tooltip is being given to the | |
1065 | application (call SetToolTip()). Windows only. | |
1066 | @event{EVT_TREE_ITEM_MENU(id, func)} | |
1067 | The context menu for the selected item has been requested, either by a | |
1068 | right click or by using the menu key. | |
1069 | @event{EVT_TREE_STATE_IMAGE_CLICK(id, func)} | |
809ca837 | 1070 | The state image has been clicked. |
7977b62a | 1071 | @endEventTable |
7c913512 | 1072 | |
23324ae1 FM |
1073 | @library{wxbase} |
1074 | @category{events} | |
7c913512 | 1075 | |
e54c96f1 | 1076 | @see wxTreeCtrl |
23324ae1 FM |
1077 | */ |
1078 | class wxTreeEvent : public wxNotifyEvent | |
1079 | { | |
1080 | public: | |
1081 | /** | |
23324ae1 FM |
1082 | Constructor, used by wxWidgets itself only. |
1083 | */ | |
cfbe5614 FM |
1084 | wxTreeEvent(wxEventType commandType, wxTreeCtrl* tree, |
1085 | const wxTreeItemId& item = wxTreeItemId()); | |
23324ae1 FM |
1086 | |
1087 | /** | |
1088 | Returns the item (valid for all events). | |
1089 | */ | |
328f5751 | 1090 | wxTreeItemId GetItem() const; |
23324ae1 FM |
1091 | |
1092 | /** | |
7977b62a BP |
1093 | Returns the key code if the event is a key event. Use GetKeyEvent() to |
1094 | get the values of the modifier keys for this event (i.e. Shift or Ctrl). | |
23324ae1 | 1095 | */ |
328f5751 | 1096 | int GetKeyCode() const; |
23324ae1 FM |
1097 | |
1098 | /** | |
6873eb5b | 1099 | Returns the key event for @c EVT_TREE_KEY_DOWN events. |
23324ae1 | 1100 | */ |
cfbe5614 | 1101 | const wxKeyEvent& GetKeyEvent() const; |
23324ae1 FM |
1102 | |
1103 | /** | |
1104 | Returns the label if the event is a begin or end edit label event. | |
1105 | */ | |
cfbe5614 | 1106 | const wxString& GetLabel() const; |
23324ae1 FM |
1107 | |
1108 | /** | |
6873eb5b FM |
1109 | Returns the old item index (valid for @c EVT_TREE_ITEM_CHANGING and |
1110 | @c EVT_TREE_ITEM_CHANGED events). | |
23324ae1 | 1111 | */ |
328f5751 | 1112 | wxTreeItemId GetOldItem() const; |
23324ae1 FM |
1113 | |
1114 | /** | |
1115 | Returns the position of the mouse pointer if the event is a drag or | |
1116 | menu-context event. | |
7977b62a BP |
1117 | |
1118 | In both cases the position is in client coordinates - i.e. relative to | |
1119 | the wxTreeCtrl window (so that you can pass it directly to e.g. | |
1120 | wxWindow::PopupMenu()). | |
23324ae1 | 1121 | */ |
328f5751 | 1122 | wxPoint GetPoint() const; |
23324ae1 FM |
1123 | |
1124 | /** | |
7977b62a | 1125 | Returns @true if the label edit was cancelled. This should be called |
6873eb5b | 1126 | from within an @c EVT_TREE_END_LABEL_EDIT handler. |
23324ae1 | 1127 | */ |
328f5751 | 1128 | bool IsEditCancelled() const; |
23324ae1 FM |
1129 | |
1130 | /** | |
6873eb5b | 1131 | Set the tooltip for the item (valid for @c EVT_TREE_ITEM_GETTOOLTIP |
7977b62a | 1132 | events). Windows only. |
23324ae1 FM |
1133 | */ |
1134 | void SetToolTip(const wxString& tooltip); | |
1135 | }; |