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