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 // wxTreeEvent is a special class for all events associated with tree controls
229 // NB: note that not all accessors make sense for all events, see the event
230 // descriptions below
231 class wxTreeEvent : public wxNotifyEvent {
233 wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
235 // get the item on which the operation was performed or the newly
236 // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events
237 wxTreeItemId GetItem() const;
238 void SetItem(const wxTreeItemId& item);
240 // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously
242 wxTreeItemId GetOldItem() const;
243 void SetOldItem(const wxTreeItemId& item);
245 // the point where the mouse was when the drag operation started (for
246 // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
247 wxPoint GetPoint() const;
248 void SetPoint(const wxPoint& pt);
250 // keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only)
251 const wxKeyEvent& GetKeyEvent() const;
252 int GetKeyCode() const;
253 void SetKeyEvent(const wxKeyEvent& evt);
255 // label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
256 const wxString& GetLabel() const;
257 void SetLabel(const wxString& label);
259 // edit cancel flag (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
260 bool IsEditCancelled() const;
261 void SetEditCanceled(bool editCancelled);
263 // Set the tooltip for the item (for EVT_TREE_ITEM_GETTOOLTIP events)
264 void SetToolTip(const wxString& toolTip);
265 wxString GetToolTip();
268 //---------------------------------------------------------------------------
271 %{ // C++ version of Python aware wxTreeCtrl
272 class wxPyTreeCtrl : public wxTreeCtrl {
273 DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl)
275 wxPyTreeCtrl() : wxTreeCtrl() {}
276 wxPyTreeCtrl(wxWindow *parent, wxWindowID id,
280 const wxValidator& validator,
281 const wxString& name) :
282 wxTreeCtrl(parent, id, pos, size, style, validator, name) {}
284 bool Create(wxWindow *parent, wxWindowID id,
288 const wxValidator& validator,
289 const wxString& name) {
290 return wxTreeCtrl::Create(parent, id, pos, size, style, validator, name);
294 int OnCompareItems(const wxTreeItemId& item1,
295 const wxTreeItemId& item2) {
298 wxPyBlock_t blocked = wxPyBeginBlockThreads();
299 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
300 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), false);
301 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), false);
302 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
306 wxPyEndBlockThreads(blocked);
308 rval = wxTreeCtrl::OnCompareItems(item1, item2);
314 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl);
321 MustHaveApp(wxPyTreeCtrl);
323 %rename(TreeCtrl) wxPyTreeCtrl;
324 class wxPyTreeCtrl : public wxControl {
326 %pythonAppend wxPyTreeCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeCtrl)"
327 %pythonAppend wxPyTreeCtrl() ""
328 %typemap(out) wxPyTreeCtrl*; // turn off this typemap
330 wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1,
331 const wxPoint& pos = wxDefaultPosition,
332 const wxSize& size = wxDefaultSize,
333 long style = wxTR_DEFAULT_STYLE,
334 const wxValidator& validator = wxDefaultValidator,
335 const wxString& name = wxPyTreeCtrlNameStr);
336 %RenameCtor(PreTreeCtrl, wxPyTreeCtrl());
338 // Turn it back on again
339 %typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
341 bool Create(wxWindow *parent, wxWindowID id = -1,
342 const wxPoint& pos = wxDefaultPosition,
343 const wxSize& size = wxDefaultSize,
344 long style = wxTR_DEFAULT_STYLE,
345 const wxValidator& validator = wxDefaultValidator,
346 const wxString& name = wxPyTreeCtrlNameStr);
348 void _setCallbackInfo(PyObject* self, PyObject* _class);
351 // get the total number of items in the control
352 unsigned int GetCount() const;
354 // indent is the number of pixels the children are indented relative to
355 // the parents position. SetIndent() also redraws the control
357 unsigned int GetIndent() const;
358 void SetIndent(unsigned int indent);
360 // spacing is the number of pixels between the start and the Text
361 // not implemented under wxMSW
362 unsigned int GetSpacing() const;
363 void SetSpacing(unsigned int spacing);
366 // image list: these functions allow to associate an image list with
367 // the control and retrieve it. Note that the control does _not_ delete
368 // the associated image list when it's deleted in order to allow image
369 // lists to be shared between different controls.
371 // The normal image list is for the icons which correspond to the
372 // normal tree item state (whether it is selected or not).
373 // Additionally, the application might choose to show a state icon
374 // which corresponds to an app-defined item state (for example,
375 // checked/unchecked) which are taken from the state image list.
376 wxImageList *GetImageList() const;
377 wxImageList *GetStateImageList() const;
379 void SetImageList(wxImageList *imageList);
380 void SetStateImageList(wxImageList *imageList);
382 %disownarg( wxImageList *imageList );
383 void AssignImageList(wxImageList *imageList);
384 void AssignStateImageList(wxImageList *imageList);
385 %cleardisown( wxImageList *imageList );
388 // retrieve items label
389 wxString GetItemText(const wxTreeItemId& item) const;
391 // get one of the images associated with the item (normal by default)
392 int GetItemImage(const wxTreeItemId& item,
393 wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
396 // get the wxPyTreeItemData associated with the tree item
397 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
398 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
400 data = new wxPyTreeItemData();
401 data->SetId(item); // set the id
402 self->SetItemData(item, data);
406 // Get the Python object associated with the tree item
407 PyObject* GetItemPyData(const wxTreeItemId& item) {
408 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
410 data = new wxPyTreeItemData();
411 data->SetId(item); // set the id
412 self->SetItemData(item, data);
414 return data->GetData();
417 %pythoncode { GetPyData = GetItemPyData }
420 // get the item's text colour
421 wxColour GetItemTextColour(const wxTreeItemId& item) const;
423 // get the item's background colour
424 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
426 // get the item's font
427 wxFont GetItemFont(const wxTreeItemId& item) const;
432 void SetItemText(const wxTreeItemId& item, const wxString& text);
434 // get one of the images associated with the item (normal by default)
435 void SetItemImage(const wxTreeItemId& item, int image,
436 wxTreeItemIcon which = wxTreeItemIcon_Normal);
439 // associate a wxPyTreeItemData with the tree item
440 %disownarg( wxPyTreeItemData* data );
441 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
442 data->SetId(item); // set the id
443 self->SetItemData(item, data);
445 %cleardisown( wxPyTreeItemData* data );
447 // associate a Python object with the tree item
448 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
449 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
451 data = new wxPyTreeItemData(obj);
452 data->SetId(item); // set the id
453 self->SetItemData(item, data);
458 %pythoncode { SetPyData = SetItemPyData }
461 // force appearance of [+] button near the item. This is useful to
462 // allow the user to expand the items which don't have any children now
463 // - but instead add them only when needed, thus minimizing memory
464 // usage and loading time.
465 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
467 // the item will be shown in bold
468 void SetItemBold(const wxTreeItemId& item, bool bold = true);
470 // the item will be shown with a drop highlight
471 void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true);
473 // set the items text colour
474 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
476 // set the items background colour
477 void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
479 // set the items font (should be of the same height for all items)
480 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
483 // is the item visible (it might be outside the view or not expanded)?
484 bool IsVisible(const wxTreeItemId& item) const;
486 // does the item has any children?
487 bool ItemHasChildren(const wxTreeItemId& item) const;
489 // is the item expanded (only makes sense if HasChildren())?
490 bool IsExpanded(const wxTreeItemId& item) const;
492 // is this item currently selected (the same as has focus)?
493 bool IsSelected(const wxTreeItemId& item) const;
495 // is item text in bold font?
496 bool IsBold(const wxTreeItemId& item) const;
499 // if 'recursively' is False, only immediate children count, otherwise
500 // the returned number is the number of all items in this branch
501 size_t GetChildrenCount(const wxTreeItemId& item,
502 bool recursively = true) /*const*/;
506 // get the root tree item
507 // wxTreeItemId.IsOk() will return False if there is no such item
508 wxTreeItemId GetRootItem() const;
510 // get the item currently selected
511 // wxTreeItemId.IsOk() will return False if there is no such item
512 wxTreeItemId GetSelection() const;
515 // get the items currently selected, return the number of such item
517 // NB: this operation is expensive and can take a long time for a
518 // control with a lot of items (~ O(number of items)).
519 PyObject* GetSelections() {
520 wxPyBlock_t blocked = wxPyBeginBlockThreads();
521 PyObject* rval = PyList_New(0);
522 wxArrayTreeItemIds array;
524 num = self->GetSelections(array);
525 for (x=0; x < num; x++) {
526 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
527 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
528 PyList_Append(rval, item);
531 wxPyEndBlockThreads(blocked);
536 // get the parent of this item
537 // wxTreeItemId.IsOk() will return False if there is no such item
538 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
541 // NOTE: These are a copy of the same methods in gizmos.i, be sure to
542 // update both at the same time. (Or find a good way to refactor!)
544 // Get the first child of this item. Returns a wxTreeItemId and an
545 // opaque "cookie" value that should be passed to GetNextChild in
546 // order to continue the search.
547 PyObject* GetFirstChild(const wxTreeItemId& item) {
549 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
550 wxPyBlock_t blocked = wxPyBeginBlockThreads();
551 PyObject* tup = PyTuple_New(2);
552 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
553 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
554 wxPyEndBlockThreads(blocked);
559 // Get the next child of this item. The cookie parameter is the 2nd
560 // value returned from GetFirstChild or the previous GetNextChild.
561 // Returns a wxTreeItemId and an opaque "cookie" value that should be
562 // passed to GetNextChild in order to continue the search.
563 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
564 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
565 wxPyBlock_t blocked = wxPyBeginBlockThreads();
566 PyObject* tup = PyTuple_New(2);
567 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
568 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
569 wxPyEndBlockThreads(blocked);
574 // get the last child of this item
575 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
577 // get the next sibling of this item
578 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
580 // get the previous sibling
581 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
583 // get first visible item
584 wxTreeItemId GetFirstVisibleItem() const;
586 // get the next visible item: item must be visible itself!
587 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
588 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
590 // get the previous visible item: item must be visible itself!
591 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
594 %disownarg( wxPyTreeItemData* data );
596 // add the root node to the tree
597 wxTreeItemId AddRoot(const wxString& text,
598 int image = -1, int selectedImage = -1,
599 wxPyTreeItemData *data = NULL);
601 // insert a new item in as the first child of the parent
602 wxTreeItemId PrependItem(const wxTreeItemId& parent,
603 const wxString& text,
604 int image = -1, int selectedImage = -1,
605 wxPyTreeItemData *data = NULL);
607 // insert a new item after a given one
608 wxTreeItemId InsertItem(const wxTreeItemId& parent,
609 const wxTreeItemId& idPrevious,
610 const wxString& text,
611 int image = -1, int selectedImage = -1,
612 wxPyTreeItemData *data = NULL);
614 // insert a new item before the one with the given index
615 %Rename(InsertItemBefore,
616 wxTreeItemId, InsertItem(const wxTreeItemId& parent,
618 const wxString& text,
619 int image = -1, int selectedImage = -1,
620 wxPyTreeItemData *data = NULL));
622 // insert a new item in as the last child of the parent
623 wxTreeItemId AppendItem(const wxTreeItemId& parent,
624 const wxString& text,
625 int image = -1, int selectedImage = -1,
626 wxPyTreeItemData *data = NULL);
629 %cleardisown( wxPyTreeItemData* data );
631 // delete this item and associated data if any
632 void Delete(const wxTreeItemId& item);
634 // delete all children (but don't delete the item itself)
635 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
636 void DeleteChildren(const wxTreeItemId& item);
638 // delete all items from the tree
639 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
640 void DeleteAllItems();
644 void Expand(const wxTreeItemId& item);
646 // collapse the item without removing its children
647 void Collapse(const wxTreeItemId& item);
649 // collapse the item and remove all children
650 void CollapseAndReset(const wxTreeItemId& item);
652 // toggles the current state
653 void Toggle(const wxTreeItemId& item);
656 // remove the selection from currently selected item (if any)
659 // remove the selection from the given one (multiselect mode only)
660 void UnselectItem(const wxTreeItemId& item);
662 // unselect all items (only makes sense for multiple selection control)
666 void SelectItem(const wxTreeItemId& item, bool select = true);
668 // toggle the item selection
669 void ToggleItemSelection(const wxTreeItemId& item);
672 // make sure this item is visible (expanding the parent item and/or
673 // scrolling to this item if necessary)
674 void EnsureVisible(const wxTreeItemId& item);
676 // scroll to this item (but don't expand its parent)
677 void ScrollTo(const wxTreeItemId& item);
681 // start editing the item label: this (temporarily) replaces the item
682 // with a one line edit control. The item will be selected if it hadn't
684 /**wxTextCtrl* */ void EditLabel(const wxTreeItemId& item);
686 // returns the same pointer as StartEdit() if the item is being edited,
687 // NULL otherwise (it's assumed that no more than one item may be
688 // edited simultaneously)
689 wxTextCtrl* GetEditControl() const;
692 // end editing and accept or discard the changes to item label
693 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
697 // Sort the children of this item using OnCompareItems, a member function
698 // that is called to compare 2 items and should return -1, 0 or +1 if the
699 // first item is less than, equal to or greater than the second one. The
700 // base class version performs alphabetic comparaison of item labels
702 void SortChildren(const wxTreeItemId& item);
707 wxTreeItemId, HitTest(const wxPoint& point, int& OUTPUT),
708 "HitTest(Point point) -> (item, where)",
709 "Determine which item (if any) belongs the given point. The coordinates
710 specified are relative to the client area of tree ctrl and the where return
711 value is set to a bitmask of wxTREE_HITTEST_xxx constants.
716 // get the bounding rectangle of the item (or of its label only)
717 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
719 if (self->GetBoundingRect(item, rect, textOnly)) {
720 wxPyBlock_t blocked = wxPyBeginBlockThreads();
721 wxRect* r = new wxRect(rect);
722 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), true);
723 wxPyEndBlockThreads(blocked);
732 // set/get the item state.image (state == -1 means cycle to the next one)
733 void SetState(const wxTreeItemId& node, int state);
734 int GetState(const wxTreeItemId& node);
737 static wxVisualAttributes
738 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
742 //---------------------------------------------------------------------------
744 // Map renamed classes back to their common name for OOR
745 wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData");
746 wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl");
748 //---------------------------------------------------------------------------