1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxTreeCtrl and related classes
7 // Created: 10-June-1998
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
16 //---------------------------------------------------------------------------
19 #include <wx/treectrl.h>
20 #include "wx/wxPython/pytree.h"
23 MAKE_CONST_WXSTRING2(TreeCtrlNameStr, _T("wxTreeCtrl"));
25 //---------------------------------------------------------------------------
39 wxTR_HAS_VARIABLE_ROW_HEIGHT,
45 wxTR_FULL_ROW_HIGHLIGHT,
59 wxTreeItemIcon_Normal, // not selected, not expanded
60 wxTreeItemIcon_Selected, // selected, not expanded
61 wxTreeItemIcon_Expanded, // not selected, expanded
62 wxTreeItemIcon_SelectedExpanded, // selected, expanded
67 // constants for HitTest
71 wxTREE_HITTEST_NOWHERE,
72 wxTREE_HITTEST_ONITEMBUTTON,
73 wxTREE_HITTEST_ONITEMICON,
74 wxTREE_HITTEST_ONITEMINDENT,
75 wxTREE_HITTEST_ONITEMLABEL,
76 wxTREE_HITTEST_ONITEMRIGHT,
77 wxTREE_HITTEST_ONITEMSTATEICON,
78 wxTREE_HITTEST_TOLEFT,
79 wxTREE_HITTEST_TORIGHT,
80 wxTREE_HITTEST_ONITEMUPPERPART,
81 wxTREE_HITTEST_ONITEMLOWERPART,
85 //---------------------------------------------------------------------------
89 // wxTreeItemId identifies an element of the tree. In this implementation, it's
90 // just a trivial wrapper around Win32 HTREEITEM or a pointer to some private
91 // data structure in the generic version. It's opaque for the application and
92 // the only method which can be used by user code is IsOk().
98 // is this a valid tree item?
102 bool __eq__(const wxTreeItemId* other) { return other ? (*self == *other) : false; }
103 bool __ne__(const wxTreeItemId* other) { return other ? (*self != *other) : true; }
111 def __nonzero__(self): return self.IsOk() }
117 // wxTreeItemData is some (arbitrary) user data associated with some tree
118 // item. The Python version is just a simple wrapper around a Python object
119 // that knows how to handle references properly. Using this class directly in
120 // Python code should rarely be neccessary. Just use the GetItemPyData and
121 // SetItemPyData tree methods instead of the GetItemData and SetItemData
123 %rename(TreeItemData) wxPyTreeItemData;
124 class wxPyTreeItemData {
126 wxPyTreeItemData(PyObject* obj = NULL);
130 void SetData(PyObject* obj);
132 const wxTreeItemId& GetId();
133 void SetId(const wxTreeItemId& id);
135 %pythonAppend Destroy "args[0].thisown = 0"
136 %extend { void Destroy() { delete self; } }
141 #if 0 // it's not currently used anywhere...
143 // wxTreeItemAttr: a structure containing the visual attributes of an item
148 //wxTreeItemAttr() { }
149 wxTreeItemAttr(const wxColour& colText = wxNullColour,
150 const wxColour& colBack = wxNullColour,
151 const wxFont& font = wxNullFont);
155 void SetTextColour(const wxColour& colText);
156 void SetBackgroundColour(const wxColour& colBack);
157 void SetFont(const wxFont& font);
160 bool HasTextColour();
161 bool HasBackgroundColour();
164 wxColour GetTextColour();
165 wxColour GetBackgroundColour();
168 %pythonAppend Destroy "args[0].thisown = 0"
169 %extend { void Destroy() { delete self; } }
175 //---------------------------------------------------------------------------
178 /* Tree control event types */
179 %constant wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG;
180 %constant wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG;
181 %constant wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
182 %constant wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT;
183 %constant wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM;
184 %constant wxEventType wxEVT_COMMAND_TREE_GET_INFO;
185 %constant wxEventType wxEVT_COMMAND_TREE_SET_INFO;
186 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED;
187 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING;
188 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED;
189 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING;
190 %constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED;
191 %constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING;
192 %constant wxEventType wxEVT_COMMAND_TREE_KEY_DOWN;
193 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED;
194 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
195 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK;
196 %constant wxEventType wxEVT_COMMAND_TREE_END_DRAG;
197 %constant wxEventType wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK;
198 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP;
199 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_MENU;
202 EVT_TREE_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_DRAG , 1)
203 EVT_TREE_BEGIN_RDRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_RDRAG , 1)
204 EVT_TREE_BEGIN_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT , 1)
205 EVT_TREE_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_TREE_END_LABEL_EDIT , 1)
206 EVT_TREE_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_TREE_DELETE_ITEM , 1)
207 EVT_TREE_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_TREE_GET_INFO , 1)
208 EVT_TREE_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_TREE_SET_INFO , 1)
209 EVT_TREE_ITEM_EXPANDED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_EXPANDED , 1)
210 EVT_TREE_ITEM_EXPANDING = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_EXPANDING , 1)
211 EVT_TREE_ITEM_COLLAPSED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_COLLAPSED , 1)
212 EVT_TREE_ITEM_COLLAPSING = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_COLLAPSING , 1)
213 EVT_TREE_SEL_CHANGED = wx.PyEventBinder(wxEVT_COMMAND_TREE_SEL_CHANGED , 1)
214 EVT_TREE_SEL_CHANGING = wx.PyEventBinder(wxEVT_COMMAND_TREE_SEL_CHANGING , 1)
215 EVT_TREE_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_TREE_KEY_DOWN , 1)
216 EVT_TREE_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_ACTIVATED , 1)
217 EVT_TREE_ITEM_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK , 1)
218 EVT_TREE_ITEM_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, 1)
219 EVT_TREE_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_END_DRAG , 1)
220 EVT_TREE_STATE_IMAGE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK, 1)
221 EVT_TREE_ITEM_GETTOOLTIP = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 1)
222 EVT_TREE_ITEM_MENU = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_MENU, 1)
227 static wxTreeItemId wxNullTreeItemId;
229 wxTreeItemId wxNullTreeItemId;
232 // wxTreeEvent is a special class for all events associated with tree controls
234 // NB: note that not all accessors make sense for all events, see the event
235 // descriptions below
236 class wxTreeEvent : public wxNotifyEvent {
238 %nokwargs wxTreeEvent;
239 wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
240 wxTreeEvent(wxEventType commandType,
242 wxTreeItemId& item = wxNullTreeItemId);
244 // get the item on which the operation was performed or the newly
245 // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events
246 wxTreeItemId GetItem() const;
247 void SetItem(const wxTreeItemId& item);
249 // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously
251 wxTreeItemId GetOldItem() const;
252 void SetOldItem(const wxTreeItemId& item);
254 // the point where the mouse was when the drag operation started (for
255 // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
256 wxPoint GetPoint() const;
257 void SetPoint(const wxPoint& pt);
259 // keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only)
260 const wxKeyEvent& GetKeyEvent() const;
261 int GetKeyCode() const;
262 void SetKeyEvent(const wxKeyEvent& evt);
264 // label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
265 const wxString& GetLabel() const;
266 void SetLabel(const wxString& label);
268 // edit cancel flag (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
269 bool IsEditCancelled() const;
270 void SetEditCanceled(bool editCancelled);
272 // Set the tooltip for the item (for EVT_TREE_ITEM_GETTOOLTIP events)
273 void SetToolTip(const wxString& toolTip);
274 wxString GetToolTip();
277 //---------------------------------------------------------------------------
280 %{ // C++ version of Python aware wxTreeCtrl
281 class wxPyTreeCtrl : public wxTreeCtrl {
282 DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl)
284 wxPyTreeCtrl() : wxTreeCtrl() {}
285 wxPyTreeCtrl(wxWindow *parent, wxWindowID id,
289 const wxValidator& validator,
290 const wxString& name) :
291 wxTreeCtrl(parent, id, pos, size, style, validator, name) {}
293 bool Create(wxWindow *parent, wxWindowID id,
297 const wxValidator& validator,
298 const wxString& name) {
299 return wxTreeCtrl::Create(parent, id, pos, size, style, validator, name);
303 int OnCompareItems(const wxTreeItemId& item1,
304 const wxTreeItemId& item2) {
307 wxPyBlock_t blocked = wxPyBeginBlockThreads();
308 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
309 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), false);
310 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), false);
311 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
315 wxPyEndBlockThreads(blocked);
317 rval = wxTreeCtrl::OnCompareItems(item1, item2);
323 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl);
330 MustHaveApp(wxPyTreeCtrl);
332 %rename(TreeCtrl) wxPyTreeCtrl;
333 class wxPyTreeCtrl : public wxControl {
335 %pythonAppend wxPyTreeCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeCtrl)"
336 %pythonAppend wxPyTreeCtrl() ""
337 %typemap(out) wxPyTreeCtrl*; // turn off this typemap
339 wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1,
340 const wxPoint& pos = wxDefaultPosition,
341 const wxSize& size = wxDefaultSize,
342 long style = wxTR_DEFAULT_STYLE,
343 const wxValidator& validator = wxDefaultValidator,
344 const wxString& name = wxPyTreeCtrlNameStr);
345 %RenameCtor(PreTreeCtrl, wxPyTreeCtrl());
347 // Turn it back on again
348 %typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
350 bool Create(wxWindow *parent, wxWindowID id = -1,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxTR_DEFAULT_STYLE,
354 const wxValidator& validator = wxDefaultValidator,
355 const wxString& name = wxPyTreeCtrlNameStr);
357 void _setCallbackInfo(PyObject* self, PyObject* _class);
360 // get the total number of items in the control
361 unsigned int GetCount() const;
363 // indent is the number of pixels the children are indented relative to
364 // the parents position. SetIndent() also redraws the control
366 unsigned int GetIndent() const;
367 void SetIndent(unsigned int indent);
369 // spacing is the number of pixels between the start and the Text
370 // not implemented under wxMSW
371 unsigned int GetSpacing() const;
372 void SetSpacing(unsigned int spacing);
375 // image list: these functions allow to associate an image list with
376 // the control and retrieve it. Note that the control does _not_ delete
377 // the associated image list when it's deleted in order to allow image
378 // lists to be shared between different controls.
380 // The normal image list is for the icons which correspond to the
381 // normal tree item state (whether it is selected or not).
382 // Additionally, the application might choose to show a state icon
383 // which corresponds to an app-defined item state (for example,
384 // checked/unchecked) which are taken from the state image list.
385 wxImageList *GetImageList() const;
386 wxImageList *GetStateImageList() const;
388 void SetImageList(wxImageList *imageList);
389 void SetStateImageList(wxImageList *imageList);
391 %disownarg( wxImageList *imageList );
392 void AssignImageList(wxImageList *imageList);
393 void AssignStateImageList(wxImageList *imageList);
394 %cleardisown( wxImageList *imageList );
397 // retrieve items label
398 wxString GetItemText(const wxTreeItemId& item) const;
400 // get one of the images associated with the item (normal by default)
401 int GetItemImage(const wxTreeItemId& item,
402 wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
405 // get the wxPyTreeItemData associated with the tree item
406 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
407 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
409 data = new wxPyTreeItemData();
410 data->SetId(item); // set the id
411 self->SetItemData(item, data);
415 // Get the Python object associated with the tree item
416 PyObject* GetItemPyData(const wxTreeItemId& item) {
417 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
419 data = new wxPyTreeItemData();
420 data->SetId(item); // set the id
421 self->SetItemData(item, data);
423 return data->GetData();
426 %pythoncode { GetPyData = GetItemPyData }
429 // get the item's text colour
430 wxColour GetItemTextColour(const wxTreeItemId& item) const;
432 // get the item's background colour
433 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
435 // get the item's font
436 wxFont GetItemFont(const wxTreeItemId& item) const;
441 void SetItemText(const wxTreeItemId& item, const wxString& text);
443 // get one of the images associated with the item (normal by default)
444 void SetItemImage(const wxTreeItemId& item, int image,
445 wxTreeItemIcon which = wxTreeItemIcon_Normal);
448 // associate a wxPyTreeItemData with the tree item
449 %disownarg( wxPyTreeItemData* data );
450 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
451 data->SetId(item); // set the id
452 self->SetItemData(item, data);
454 %cleardisown( wxPyTreeItemData* data );
456 // associate a Python object with the tree item
457 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
458 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
460 data = new wxPyTreeItemData(obj);
461 data->SetId(item); // set the id
462 self->SetItemData(item, data);
467 %pythoncode { SetPyData = SetItemPyData }
470 // force appearance of [+] button near the item. This is useful to
471 // allow the user to expand the items which don't have any children now
472 // - but instead add them only when needed, thus minimizing memory
473 // usage and loading time.
474 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
476 // the item will be shown in bold
477 void SetItemBold(const wxTreeItemId& item, bool bold = true);
479 // the item will be shown with a drop highlight
480 void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true);
482 // set the items text colour
483 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
485 // set the items background colour
486 void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
488 // set the items font (should be of the same height for all items)
489 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
492 // is the item visible (it might be outside the view or not expanded)?
493 bool IsVisible(const wxTreeItemId& item) const;
495 // does the item has any children?
496 bool ItemHasChildren(const wxTreeItemId& item) const;
498 // is the item expanded (only makes sense if HasChildren())?
499 bool IsExpanded(const wxTreeItemId& item) const;
501 // is this item currently selected (the same as has focus)?
502 bool IsSelected(const wxTreeItemId& item) const;
504 // is item text in bold font?
505 bool IsBold(const wxTreeItemId& item) const;
508 // if 'recursively' is False, only immediate children count, otherwise
509 // the returned number is the number of all items in this branch
510 size_t GetChildrenCount(const wxTreeItemId& item,
511 bool recursively = true) /*const*/;
515 // get the root tree item
516 // wxTreeItemId.IsOk() will return False if there is no such item
517 wxTreeItemId GetRootItem() const;
519 // get the item currently selected
520 // wxTreeItemId.IsOk() will return False if there is no such item
521 wxTreeItemId GetSelection() const;
524 // get the items currently selected, return the number of such item
526 // NB: this operation is expensive and can take a long time for a
527 // control with a lot of items (~ O(number of items)).
528 PyObject* GetSelections() {
529 wxPyBlock_t blocked = wxPyBeginBlockThreads();
530 PyObject* rval = PyList_New(0);
531 wxArrayTreeItemIds array;
533 num = self->GetSelections(array);
534 for (x=0; x < num; x++) {
535 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
536 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
537 PyList_Append(rval, item);
540 wxPyEndBlockThreads(blocked);
545 // get the parent of this item
546 // wxTreeItemId.IsOk() will return False if there is no such item
547 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
550 // NOTE: These are a copy of the same methods in gizmos.i, be sure to
551 // update both at the same time. (Or find a good way to refactor!)
553 // Get the first child of this item. Returns a wxTreeItemId and an
554 // opaque "cookie" value that should be passed to GetNextChild in
555 // order to continue the search.
556 PyObject* GetFirstChild(const wxTreeItemId& item) {
558 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
559 wxPyBlock_t blocked = wxPyBeginBlockThreads();
560 PyObject* tup = PyTuple_New(2);
561 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
562 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
563 wxPyEndBlockThreads(blocked);
568 // Get the next child of this item. The cookie parameter is the 2nd
569 // value returned from GetFirstChild or the previous GetNextChild.
570 // Returns a wxTreeItemId and an opaque "cookie" value that should be
571 // passed to GetNextChild in order to continue the search.
572 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
573 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
574 wxPyBlock_t blocked = wxPyBeginBlockThreads();
575 PyObject* tup = PyTuple_New(2);
576 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
577 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
578 wxPyEndBlockThreads(blocked);
583 // get the last child of this item
584 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
586 // get the next sibling of this item
587 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
589 // get the previous sibling
590 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
592 // get first visible item
593 wxTreeItemId GetFirstVisibleItem() const;
595 // get the next visible item: item must be visible itself!
596 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
597 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
599 // get the previous visible item: item must be visible itself!
600 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
603 %disownarg( wxPyTreeItemData* data );
605 // add the root node to the tree
606 wxTreeItemId AddRoot(const wxString& text,
607 int image = -1, int selectedImage = -1,
608 wxPyTreeItemData *data = NULL);
610 // insert a new item in as the first child of the parent
611 wxTreeItemId PrependItem(const wxTreeItemId& parent,
612 const wxString& text,
613 int image = -1, int selectedImage = -1,
614 wxPyTreeItemData *data = NULL);
616 // insert a new item after a given one
617 wxTreeItemId InsertItem(const wxTreeItemId& parent,
618 const wxTreeItemId& idPrevious,
619 const wxString& text,
620 int image = -1, int selectedImage = -1,
621 wxPyTreeItemData *data = NULL);
623 // insert a new item before the one with the given index
624 %Rename(InsertItemBefore,
625 wxTreeItemId, InsertItem(const wxTreeItemId& parent,
627 const wxString& text,
628 int image = -1, int selectedImage = -1,
629 wxPyTreeItemData *data = NULL));
631 // insert a new item in as the last child of the parent
632 wxTreeItemId AppendItem(const wxTreeItemId& parent,
633 const wxString& text,
634 int image = -1, int selectedImage = -1,
635 wxPyTreeItemData *data = NULL);
638 %cleardisown( wxPyTreeItemData* data );
640 // delete this item and associated data if any
641 void Delete(const wxTreeItemId& item);
643 // delete all children (but don't delete the item itself)
644 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
645 void DeleteChildren(const wxTreeItemId& item);
647 // delete all items from the tree
648 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
649 void DeleteAllItems();
653 void Expand(const wxTreeItemId& item);
655 // expand the item and all its childs and thats childs
656 void ExpandAllChildren(const wxTreeItemId& item);
661 // collapse the item without removing its children
662 void Collapse(const wxTreeItemId& item);
664 // collapse the item and remove all children
665 void CollapseAndReset(const wxTreeItemId& item);
667 // toggles the current state
668 void Toggle(const wxTreeItemId& item);
671 // remove the selection from currently selected item (if any)
674 // remove the selection from the given one (multiselect mode only)
675 void UnselectItem(const wxTreeItemId& item);
677 // unselect all items (only makes sense for multiple selection control)
681 void SelectItem(const wxTreeItemId& item, bool select = true);
683 // toggle the item selection
684 void ToggleItemSelection(const wxTreeItemId& item);
687 // make sure this item is visible (expanding the parent item and/or
688 // scrolling to this item if necessary)
689 void EnsureVisible(const wxTreeItemId& item);
691 // scroll to this item (but don't expand its parent)
692 void ScrollTo(const wxTreeItemId& item);
696 // start editing the item label: this (temporarily) replaces the item
697 // with a one line edit control. The item will be selected if it hadn't
699 /**wxTextCtrl* */ void EditLabel(const wxTreeItemId& item);
701 // returns the same pointer as StartEdit() if the item is being edited,
702 // NULL otherwise (it's assumed that no more than one item may be
703 // edited simultaneously)
704 wxTextCtrl* GetEditControl() const;
707 // end editing and accept or discard the changes to item label
708 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
712 // Sort the children of this item using OnCompareItems, a member function
713 // that is called to compare 2 items and should return -1, 0 or +1 if the
714 // first item is less than, equal to or greater than the second one. The
715 // base class version performs alphabetic comparaison of item labels
717 void SortChildren(const wxTreeItemId& item);
722 wxTreeItemId, HitTest(const wxPoint& point, int& OUTPUT),
723 "HitTest(Point point) -> (item, where)",
724 "Determine which item (if any) belongs the given point. The coordinates
725 specified are relative to the client area of tree ctrl and the where return
726 value is set to a bitmask of wxTREE_HITTEST_xxx constants.
731 // get the bounding rectangle of the item (or of its label only)
732 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
734 if (self->GetBoundingRect(item, rect, textOnly)) {
735 wxPyBlock_t blocked = wxPyBeginBlockThreads();
736 wxRect* r = new wxRect(rect);
737 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), true);
738 wxPyEndBlockThreads(blocked);
747 // set/get the item state.image (state == -1 means cycle to the next one)
748 void SetState(const wxTreeItemId& node, int state);
749 int GetState(const wxTreeItemId& node);
752 static wxVisualAttributes
753 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
755 void SetQuickBestSize(bool q);
756 bool GetQuickBestSize() const;
761 //---------------------------------------------------------------------------
763 // Map renamed classes back to their common name for OOR
764 wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData");
765 wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl");
767 //---------------------------------------------------------------------------