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 %pythonPrepend Destroy "args[0].this.own(False)"
136 %extend { void Destroy() { delete self; } }
138 %property(Data, GetData, SetData, doc="See `GetData` and `SetData`");
139 %property(Id, GetId, SetId, doc="See `GetId` and `SetId`");
144 #if 0 // it's not currently used anywhere...
146 // wxTreeItemAttr: a structure containing the visual attributes of an item
151 //wxTreeItemAttr() { }
152 wxTreeItemAttr(const wxColour& colText = wxNullColour,
153 const wxColour& colBack = wxNullColour,
154 const wxFont& font = wxNullFont);
158 void SetTextColour(const wxColour& colText);
159 void SetBackgroundColour(const wxColour& colBack);
160 void SetFont(const wxFont& font);
163 bool HasTextColour();
164 bool HasBackgroundColour();
167 wxColour GetTextColour();
168 wxColour GetBackgroundColour();
171 %pythonAppend Destroy "args[0].thisown = 0"
172 %extend { void Destroy() { delete self; } }
178 //---------------------------------------------------------------------------
181 /* Tree control event types */
182 %constant wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG;
183 %constant wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG;
184 %constant wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT;
185 %constant wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT;
186 %constant wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM;
187 %constant wxEventType wxEVT_COMMAND_TREE_GET_INFO;
188 %constant wxEventType wxEVT_COMMAND_TREE_SET_INFO;
189 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED;
190 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING;
191 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED;
192 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING;
193 %constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED;
194 %constant wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING;
195 %constant wxEventType wxEVT_COMMAND_TREE_KEY_DOWN;
196 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED;
197 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
198 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK;
199 %constant wxEventType wxEVT_COMMAND_TREE_END_DRAG;
200 %constant wxEventType wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK;
201 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP;
202 %constant wxEventType wxEVT_COMMAND_TREE_ITEM_MENU;
205 EVT_TREE_BEGIN_DRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_DRAG , 1)
206 EVT_TREE_BEGIN_RDRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_RDRAG , 1)
207 EVT_TREE_BEGIN_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT , 1)
208 EVT_TREE_END_LABEL_EDIT = wx.PyEventBinder(wxEVT_COMMAND_TREE_END_LABEL_EDIT , 1)
209 EVT_TREE_DELETE_ITEM = wx.PyEventBinder(wxEVT_COMMAND_TREE_DELETE_ITEM , 1)
210 EVT_TREE_GET_INFO = wx.PyEventBinder(wxEVT_COMMAND_TREE_GET_INFO , 1)
211 EVT_TREE_SET_INFO = wx.PyEventBinder(wxEVT_COMMAND_TREE_SET_INFO , 1)
212 EVT_TREE_ITEM_EXPANDED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_EXPANDED , 1)
213 EVT_TREE_ITEM_EXPANDING = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_EXPANDING , 1)
214 EVT_TREE_ITEM_COLLAPSED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_COLLAPSED , 1)
215 EVT_TREE_ITEM_COLLAPSING = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_COLLAPSING , 1)
216 EVT_TREE_SEL_CHANGED = wx.PyEventBinder(wxEVT_COMMAND_TREE_SEL_CHANGED , 1)
217 EVT_TREE_SEL_CHANGING = wx.PyEventBinder(wxEVT_COMMAND_TREE_SEL_CHANGING , 1)
218 EVT_TREE_KEY_DOWN = wx.PyEventBinder(wxEVT_COMMAND_TREE_KEY_DOWN , 1)
219 EVT_TREE_ITEM_ACTIVATED = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_ACTIVATED , 1)
220 EVT_TREE_ITEM_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK , 1)
221 EVT_TREE_ITEM_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, 1)
222 EVT_TREE_END_DRAG = wx.PyEventBinder(wxEVT_COMMAND_TREE_END_DRAG , 1)
223 EVT_TREE_STATE_IMAGE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_TREE_STATE_IMAGE_CLICK, 1)
224 EVT_TREE_ITEM_GETTOOLTIP = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_GETTOOLTIP, 1)
225 EVT_TREE_ITEM_MENU = wx.PyEventBinder(wxEVT_COMMAND_TREE_ITEM_MENU, 1)
230 static wxTreeItemId wxNullTreeItemId;
232 wxTreeItemId wxNullTreeItemId;
235 // wxTreeEvent is a special class for all events associated with tree controls
237 // NB: note that not all accessors make sense for all events, see the event
238 // descriptions below
239 class wxTreeEvent : public wxNotifyEvent {
241 %nokwargs wxTreeEvent;
242 wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
243 wxTreeEvent(wxEventType commandType,
245 wxTreeItemId& item = wxNullTreeItemId);
247 // get the item on which the operation was performed or the newly
248 // selected item for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events
249 wxTreeItemId GetItem() const;
250 void SetItem(const wxTreeItemId& item);
252 // for wxEVT_COMMAND_TREE_SEL_CHANGED/ING events, get the previously
254 wxTreeItemId GetOldItem() const;
255 void SetOldItem(const wxTreeItemId& item);
257 // the point where the mouse was when the drag operation started (for
258 // wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
259 wxPoint GetPoint() const;
260 void SetPoint(const wxPoint& pt);
262 // keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only)
263 const wxKeyEvent& GetKeyEvent() const;
264 int GetKeyCode() const;
265 void SetKeyEvent(const wxKeyEvent& evt);
267 // label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
268 const wxString& GetLabel() const;
269 void SetLabel(const wxString& label);
271 // edit cancel flag (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
272 bool IsEditCancelled() const;
273 void SetEditCanceled(bool editCancelled);
275 // Set the tooltip for the item (for EVT_TREE_ITEM_GETTOOLTIP events)
276 void SetToolTip(const wxString& toolTip);
277 wxString GetToolTip();
279 %property(Item, GetItem, SetItem, doc="See `GetItem` and `SetItem`");
280 %property(KeyCode, GetKeyCode, doc="See `GetKeyCode`");
281 %property(KeyEvent, GetKeyEvent, SetKeyEvent, doc="See `GetKeyEvent` and `SetKeyEvent`");
282 %property(Label, GetLabel, SetLabel, doc="See `GetLabel` and `SetLabel`");
283 %property(OldItem, GetOldItem, SetOldItem, doc="See `GetOldItem` and `SetOldItem`");
284 %property(Point, GetPoint, SetPoint, doc="See `GetPoint` and `SetPoint`");
285 %property(ToolTip, GetToolTip, SetToolTip, doc="See `GetToolTip` and `SetToolTip`");
286 %property(EditCancelled, IsEditCancelled, SetEditCanceled, doc="See `IsEditCancelled` and `SetEditCanceled`");
289 //---------------------------------------------------------------------------
292 %{ // C++ version of Python aware wxTreeCtrl
293 class wxPyTreeCtrl : public wxTreeCtrl {
294 DECLARE_ABSTRACT_CLASS(wxPyTreeCtrl)
296 wxPyTreeCtrl() : wxTreeCtrl() {}
297 wxPyTreeCtrl(wxWindow *parent, wxWindowID id,
301 const wxValidator& validator,
302 const wxString& name) :
303 wxTreeCtrl(parent, id, pos, size, style, validator, name) {}
305 bool Create(wxWindow *parent, wxWindowID id,
309 const wxValidator& validator,
310 const wxString& name) {
311 return wxTreeCtrl::Create(parent, id, pos, size, style, validator, name);
315 int OnCompareItems(const wxTreeItemId& item1,
316 const wxTreeItemId& item2) {
319 wxPyBlock_t blocked = wxPyBeginBlockThreads();
320 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
321 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), false);
322 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), false);
323 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
327 wxPyEndBlockThreads(blocked);
329 rval = wxTreeCtrl::OnCompareItems(item1, item2);
335 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeCtrl, wxTreeCtrl);
342 MustHaveApp(wxPyTreeCtrl);
344 %rename(TreeCtrl) wxPyTreeCtrl;
345 class wxPyTreeCtrl : public wxControl {
347 %pythonAppend wxPyTreeCtrl "self._setOORInfo(self);" setCallbackInfo(TreeCtrl)
348 %pythonAppend wxPyTreeCtrl() ""
349 %typemap(out) wxPyTreeCtrl*; // turn off this typemap
351 wxPyTreeCtrl(wxWindow *parent, wxWindowID id = -1,
352 const wxPoint& pos = wxDefaultPosition,
353 const wxSize& size = wxDefaultSize,
354 long style = wxTR_DEFAULT_STYLE,
355 const wxValidator& validator = wxDefaultValidator,
356 const wxString& name = wxPyTreeCtrlNameStr);
357 %RenameCtor(PreTreeCtrl, wxPyTreeCtrl());
359 // Turn it back on again
360 %typemap(out) wxPyTreeCtrl* { $result = wxPyMake_wxObject($1, $owner); }
362 bool Create(wxWindow *parent, wxWindowID id = -1,
363 const wxPoint& pos = wxDefaultPosition,
364 const wxSize& size = wxDefaultSize,
365 long style = wxTR_DEFAULT_STYLE,
366 const wxValidator& validator = wxDefaultValidator,
367 const wxString& name = wxPyTreeCtrlNameStr);
369 void _setCallbackInfo(PyObject* self, PyObject* _class);
372 // get the total number of items in the control
373 unsigned int GetCount() const;
375 // indent is the number of pixels the children are indented relative to
376 // the parents position. SetIndent() also redraws the control
378 unsigned int GetIndent() const;
379 void SetIndent(unsigned int indent);
381 // spacing is the number of pixels between the start and the Text
382 // not implemented under wxMSW
383 unsigned int GetSpacing() const;
384 void SetSpacing(unsigned int spacing);
387 // image list: these functions allow to associate an image list with
388 // the control and retrieve it. Note that the control does _not_ delete
389 // the associated image list when it's deleted in order to allow image
390 // lists to be shared between different controls.
392 // The normal image list is for the icons which correspond to the
393 // normal tree item state (whether it is selected or not).
394 // Additionally, the application might choose to show a state icon
395 // which corresponds to an app-defined item state (for example,
396 // checked/unchecked) which are taken from the state image list.
397 wxImageList *GetImageList() const;
398 wxImageList *GetStateImageList() const;
400 void SetImageList(wxImageList *imageList);
401 void SetStateImageList(wxImageList *imageList);
403 %disownarg( wxImageList *imageList );
404 void AssignImageList(wxImageList *imageList);
405 void AssignStateImageList(wxImageList *imageList);
406 %cleardisown( wxImageList *imageList );
409 // retrieve items label
410 wxString GetItemText(const wxTreeItemId& item) const;
412 // get one of the images associated with the item (normal by default)
413 int GetItemImage(const wxTreeItemId& item,
414 wxTreeItemIcon which = wxTreeItemIcon_Normal) const;
417 // get the wxPyTreeItemData associated with the tree item
418 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
419 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
421 data = new wxPyTreeItemData();
422 data->SetId(item); // set the id
423 self->SetItemData(item, data);
427 // Get the Python object associated with the tree item
428 PyObject* GetItemPyData(const wxTreeItemId& item) {
429 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
431 data = new wxPyTreeItemData();
432 data->SetId(item); // set the id
433 self->SetItemData(item, data);
435 return data->GetData();
438 %pythoncode { GetPyData = GetItemPyData }
441 // get the item's text colour
442 wxColour GetItemTextColour(const wxTreeItemId& item) const;
444 // get the item's background colour
445 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
447 // get the item's font
448 wxFont GetItemFont(const wxTreeItemId& item) const;
453 void SetItemText(const wxTreeItemId& item, const wxString& text);
455 // get one of the images associated with the item (normal by default)
456 void SetItemImage(const wxTreeItemId& item, int image,
457 wxTreeItemIcon which = wxTreeItemIcon_Normal);
460 // associate a wxPyTreeItemData with the tree item
461 %disownarg( wxPyTreeItemData* data );
462 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
463 data->SetId(item); // set the id
464 self->SetItemData(item, data);
466 %cleardisown( wxPyTreeItemData* data );
468 // associate a Python object with the tree item
469 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
470 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
472 data = new wxPyTreeItemData(obj);
473 data->SetId(item); // set the id
474 self->SetItemData(item, data);
479 %pythoncode { SetPyData = SetItemPyData }
482 // force appearance of [+] button near the item. This is useful to
483 // allow the user to expand the items which don't have any children now
484 // - but instead add them only when needed, thus minimizing memory
485 // usage and loading time.
486 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
488 // the item will be shown in bold
489 void SetItemBold(const wxTreeItemId& item, bool bold = true);
491 // the item will be shown with a drop highlight
492 void SetItemDropHighlight(const wxTreeItemId& item, bool highlight = true);
494 // set the items text colour
495 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
497 // set the items background colour
498 void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col);
500 // set the items font (should be of the same height for all items)
501 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
504 // is the item visible (it might be outside the view or not expanded)?
505 bool IsVisible(const wxTreeItemId& item) const;
507 // does the item has any children?
508 bool ItemHasChildren(const wxTreeItemId& item) const;
510 // is the item expanded (only makes sense if HasChildren())?
511 bool IsExpanded(const wxTreeItemId& item) const;
513 // is this item currently selected (the same as has focus)?
514 bool IsSelected(const wxTreeItemId& item) const;
516 // is item text in bold font?
517 bool IsBold(const wxTreeItemId& item) const;
519 // is the control empty?
520 bool IsEmpty() const;
523 // if 'recursively' is False, only immediate children count, otherwise
524 // the returned number is the number of all items in this branch
525 size_t GetChildrenCount(const wxTreeItemId& item,
526 bool recursively = true) /*const*/;
530 // get the root tree item
531 // wxTreeItemId.IsOk() will return False if there is no such item
532 wxTreeItemId GetRootItem() const;
534 // get the item currently selected
535 // wxTreeItemId.IsOk() will return False if there is no such item
536 wxTreeItemId GetSelection() const;
539 // get the items currently selected, return the number of such item
541 // NB: this operation is expensive and can take a long time for a
542 // control with a lot of items (~ O(number of items)).
543 PyObject* GetSelections() {
544 wxPyBlock_t blocked = wxPyBeginBlockThreads();
545 PyObject* rval = PyList_New(0);
546 wxArrayTreeItemIds array;
548 num = self->GetSelections(array);
549 for (x=0; x < num; x++) {
550 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
551 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
552 PyList_Append(rval, item);
555 wxPyEndBlockThreads(blocked);
560 // get the parent of this item
561 // wxTreeItemId.IsOk() will return False if there is no such item
562 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
565 // NOTE: These are a copy of the same methods in gizmos.i, be sure to
566 // update both at the same time. (Or find a good way to refactor!)
568 // Get the first child of this item. Returns a wxTreeItemId and an
569 // opaque "cookie" value that should be passed to GetNextChild in
570 // order to continue the search.
571 PyObject* GetFirstChild(const wxTreeItemId& item) {
573 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(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 next child of this item. The cookie parameter is the 2nd
584 // value returned from GetFirstChild or the previous GetNextChild.
585 // Returns a wxTreeItemId and an opaque "cookie" value that should be
586 // passed to GetNextChild in order to continue the search.
587 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
588 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
589 wxPyBlock_t blocked = wxPyBeginBlockThreads();
590 PyObject* tup = PyTuple_New(2);
591 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
592 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
593 wxPyEndBlockThreads(blocked);
598 // get the last child of this item
599 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
601 // get the next sibling of this item
602 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
604 // get the previous sibling
605 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
607 // get first visible item
608 wxTreeItemId GetFirstVisibleItem() const;
610 // get the next visible item: item must be visible itself!
611 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
612 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
614 // get the previous visible item: item must be visible itself!
615 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
618 %disownarg( wxPyTreeItemData* data );
620 // add the root node to the tree
621 wxTreeItemId AddRoot(const wxString& text,
622 int image = -1, int selectedImage = -1,
623 wxPyTreeItemData *data = NULL);
625 // insert a new item in as the first child of the parent
626 wxTreeItemId PrependItem(const wxTreeItemId& parent,
627 const wxString& text,
628 int image = -1, int selectedImage = -1,
629 wxPyTreeItemData *data = NULL);
631 // insert a new item after a given one
632 wxTreeItemId InsertItem(const wxTreeItemId& parent,
633 const wxTreeItemId& idPrevious,
634 const wxString& text,
635 int image = -1, int selectedImage = -1,
636 wxPyTreeItemData *data = NULL);
638 // insert a new item before the one with the given index
639 %Rename(InsertItemBefore,
640 wxTreeItemId, InsertItem(const wxTreeItemId& parent,
642 const wxString& text,
643 int image = -1, int selectedImage = -1,
644 wxPyTreeItemData *data = NULL));
646 // insert a new item in as the last child of the parent
647 wxTreeItemId AppendItem(const wxTreeItemId& parent,
648 const wxString& text,
649 int image = -1, int selectedImage = -1,
650 wxPyTreeItemData *data = NULL);
653 %cleardisown( wxPyTreeItemData* data );
655 // delete this item and associated data if any
656 void Delete(const wxTreeItemId& item);
658 // delete all children (but don't delete the item itself)
659 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
660 void DeleteChildren(const wxTreeItemId& item);
662 // delete all items from the tree
663 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
664 void DeleteAllItems();
668 void Expand(const wxTreeItemId& item);
670 // expand the item and all its childs and thats childs
671 void ExpandAllChildren(const wxTreeItemId& item);
676 // collapse the item without removing its children
677 void Collapse(const wxTreeItemId& item);
679 // collapse the item and all its childs and thats childs
680 void CollapseAllChildren(const wxTreeItemId& item);
682 // collapse all items
685 // collapse the item and remove all children
686 void CollapseAndReset(const wxTreeItemId& item);
688 // toggles the current state
689 void Toggle(const wxTreeItemId& item);
692 // remove the selection from currently selected item (if any)
695 // remove the selection from the given one (multiselect mode only)
696 void UnselectItem(const wxTreeItemId& item);
698 // unselect all items (only makes sense for multiple selection control)
702 void SelectItem(const wxTreeItemId& item, bool select = true);
704 // toggle the item selection
705 void ToggleItemSelection(const wxTreeItemId& item);
708 // make sure this item is visible (expanding the parent item and/or
709 // scrolling to this item if necessary)
710 void EnsureVisible(const wxTreeItemId& item);
712 // scroll to this item (but don't expand its parent)
713 void ScrollTo(const wxTreeItemId& item);
717 // start editing the item label: this (temporarily) replaces the item
718 // with a one line edit control. The item will be selected if it hadn't
720 /**wxTextCtrl* */ void EditLabel(const wxTreeItemId& item);
722 // returns the same pointer as StartEdit() if the item is being edited,
723 // NULL otherwise (it's assumed that no more than one item may be
724 // edited simultaneously)
725 wxTextCtrl* GetEditControl() const;
728 // end editing and accept or discard the changes to item label
729 void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
733 // Sort the children of this item using OnCompareItems, a member function
734 // that is called to compare 2 items and should return -1, 0 or +1 if the
735 // first item is less than, equal to or greater than the second one. The
736 // base class version performs alphabetic comparaison of item labels
738 void SortChildren(const wxTreeItemId& item);
743 wxTreeItemId, HitTest(const wxPoint& point, int& OUTPUT),
744 "HitTest(Point point) -> (item, where)",
745 "Determine which item (if any) belongs the given point. The coordinates
746 specified are relative to the client area of tree ctrl and the where return
747 value is set to a bitmask of wxTREE_HITTEST_xxx constants.
752 // get the bounding rectangle of the item (or of its label only)
753 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
755 if (self->GetBoundingRect(item, rect, textOnly)) {
756 wxPyBlock_t blocked = wxPyBeginBlockThreads();
757 wxRect* r = new wxRect(rect);
758 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), true);
759 wxPyEndBlockThreads(blocked);
768 // set/get the item state.image (state == -1 means cycle to the next one)
769 void SetState(const wxTreeItemId& node, int state);
770 int GetState(const wxTreeItemId& node);
773 static wxVisualAttributes
774 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
776 void SetQuickBestSize(bool q);
777 bool GetQuickBestSize() const;
779 %property(Count, GetCount, doc="See `GetCount`");
780 %property(EditControl, GetEditControl, doc="See `GetEditControl`");
781 %property(FirstVisibleItem, GetFirstVisibleItem, doc="See `GetFirstVisibleItem`");
782 %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`");
783 %property(Indent, GetIndent, SetIndent, doc="See `GetIndent` and `SetIndent`");
784 %property(QuickBestSize, GetQuickBestSize, SetQuickBestSize, doc="See `GetQuickBestSize` and `SetQuickBestSize`");
785 %property(RootItem, GetRootItem, doc="See `GetRootItem`");
786 %property(Selection, GetSelection, doc="See `GetSelection`");
787 %property(Selections, GetSelections, doc="See `GetSelections`");
788 %property(Spacing, GetSpacing, SetSpacing, doc="See `GetSpacing` and `SetSpacing`");
789 %property(StateImageList, GetStateImageList, SetStateImageList, doc="See `GetStateImageList` and `SetStateImageList`");
793 //---------------------------------------------------------------------------
795 // Map renamed classes back to their common name for OOR
796 wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData");
797 wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl");
799 //---------------------------------------------------------------------------