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);self._setCallbackInfo(self, 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;
 
 520     // if 'recursively' is False, only immediate children count, otherwise
 
 521     // the returned number is the number of all items in this branch
 
 522     size_t GetChildrenCount(const wxTreeItemId& item,
 
 523                             bool recursively = true) /*const*/;
 
 527     // get the root tree item
 
 528     // wxTreeItemId.IsOk() will return False if there is no such item
 
 529     wxTreeItemId GetRootItem() const;
 
 531     // get the item currently selected 
 
 532     // wxTreeItemId.IsOk() will return False if there is no such item
 
 533     wxTreeItemId GetSelection() const;
 
 536         // get the items currently selected, return the number of such item
 
 538         // NB: this operation is expensive and can take a long time for a
 
 539         //     control with a lot of items (~ O(number of items)).
 
 540         PyObject* GetSelections() {
 
 541             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 542             PyObject*           rval = PyList_New(0);
 
 543             wxArrayTreeItemIds  array;
 
 545             num = self->GetSelections(array);
 
 546             for (x=0; x < num; x++) {
 
 547                 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
 
 548                 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
 
 549                 PyList_Append(rval, item);
 
 552             wxPyEndBlockThreads(blocked);
 
 557     // get the parent of this item
 
 558     // wxTreeItemId.IsOk() will return False if there is no such item
 
 559     wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
 
 562     // NOTE: These are a copy of the same methods in gizmos.i, be sure to
 
 563     // update both at the same time.  (Or find a good way to refactor!)
 
 565         // Get the first child of this item.  Returns a wxTreeItemId and an
 
 566         // opaque "cookie" value that should be passed to GetNextChild in
 
 567         // order to continue the search.
 
 568         PyObject* GetFirstChild(const wxTreeItemId& item) {
 
 570             wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
 
 571             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 572             PyObject* tup = PyTuple_New(2);
 
 573             PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
 
 574             PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
 
 575             wxPyEndBlockThreads(blocked);
 
 580         // Get the next child of this item.  The cookie parameter is the 2nd
 
 581         // value returned from GetFirstChild or the previous GetNextChild.
 
 582         // Returns a wxTreeItemId and an opaque "cookie" value that should be
 
 583         // passed to GetNextChild in order to continue the search.
 
 584         PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
 
 585             wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
 
 586             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 587             PyObject* tup = PyTuple_New(2);
 
 588             PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
 
 589             PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
 
 590             wxPyEndBlockThreads(blocked);
 
 595     // get the last child of this item
 
 596     wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
 
 598     // get the next sibling of this item
 
 599     wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
 
 601     // get the previous sibling
 
 602     wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
 
 604     // get first visible item
 
 605     wxTreeItemId GetFirstVisibleItem() const;
 
 607     // get the next visible item: item must be visible itself!
 
 608     // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
 
 609     wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
 
 611     // get the previous visible item: item must be visible itself!
 
 612     wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
 
 615     %disownarg( wxPyTreeItemData* data );
 
 617     // add the root node to the tree
 
 618     wxTreeItemId AddRoot(const wxString& text,
 
 619                          int image = -1, int selectedImage = -1,
 
 620                          wxPyTreeItemData *data = NULL);
 
 622     // insert a new item in as the first child of the parent
 
 623     wxTreeItemId PrependItem(const wxTreeItemId& parent,
 
 624                              const wxString& text,
 
 625                              int image = -1, int selectedImage = -1,
 
 626                              wxPyTreeItemData *data = NULL);
 
 628     // insert a new item after a given one
 
 629     wxTreeItemId InsertItem(const wxTreeItemId& parent,
 
 630                             const wxTreeItemId& idPrevious,
 
 631                             const wxString& text,
 
 632                             int image = -1, int selectedImage = -1,
 
 633                             wxPyTreeItemData *data = NULL);
 
 635     // insert a new item before the one with the given index
 
 636     %Rename(InsertItemBefore, 
 
 637     wxTreeItemId, InsertItem(const wxTreeItemId& parent,
 
 639                             const wxString& text,
 
 640                             int image = -1, int selectedImage = -1,
 
 641                             wxPyTreeItemData *data = NULL));
 
 643         // insert a new item in as the last child of the parent
 
 644     wxTreeItemId AppendItem(const wxTreeItemId& parent,
 
 645                             const wxString& text,
 
 646                             int image = -1, int selectedImage = -1,
 
 647                             wxPyTreeItemData *data = NULL);
 
 650     %cleardisown( wxPyTreeItemData* data );
 
 652     // delete this item and associated data if any
 
 653     void Delete(const wxTreeItemId& item);
 
 655     // delete all children (but don't delete the item itself)
 
 656     // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
 
 657     void DeleteChildren(const wxTreeItemId& item);
 
 659     // delete all items from the tree
 
 660     // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
 
 661     void DeleteAllItems();
 
 665     void Expand(const wxTreeItemId& item);
 
 667     // expand the item and all its childs and thats childs
 
 668     void ExpandAllChildren(const wxTreeItemId& item);
 
 673     // collapse the item without removing its children
 
 674     void Collapse(const wxTreeItemId& item);
 
 676     // collapse the item and remove all children
 
 677     void CollapseAndReset(const wxTreeItemId& item);
 
 679     // toggles the current state
 
 680     void Toggle(const wxTreeItemId& item);
 
 683     // remove the selection from currently selected item (if any)
 
 686     // remove the selection from the given one (multiselect mode only)
 
 687     void UnselectItem(const wxTreeItemId& item);
 
 689     // unselect all items (only makes sense for multiple selection control)
 
 693     void SelectItem(const wxTreeItemId& item, bool select = true);
 
 695     // toggle the item selection
 
 696     void ToggleItemSelection(const wxTreeItemId& item);
 
 699     // make sure this item is visible (expanding the parent item and/or
 
 700     // scrolling to this item if necessary)
 
 701     void EnsureVisible(const wxTreeItemId& item);
 
 703     // scroll to this item (but don't expand its parent)
 
 704     void ScrollTo(const wxTreeItemId& item);
 
 708     // start editing the item label: this (temporarily) replaces the item
 
 709     // with a one line edit control. The item will be selected if it hadn't
 
 711     /**wxTextCtrl* */ void  EditLabel(const wxTreeItemId& item);
 
 713     // returns the same pointer as StartEdit() if the item is being edited,
 
 714     // NULL otherwise (it's assumed that no more than one item may be
 
 715     // edited simultaneously)
 
 716     wxTextCtrl* GetEditControl() const;
 
 719     // end editing and accept or discard the changes to item label
 
 720     void EndEditLabel(const wxTreeItemId& item, bool discardChanges = false);
 
 724     // Sort the children of this item using OnCompareItems, a member function
 
 725     // that is called to compare 2 items and should return -1, 0 or +1 if the
 
 726     // first item is less than, equal to or greater than the second one. The
 
 727     // base class version performs alphabetic comparaison of item labels
 
 729     void SortChildren(const wxTreeItemId& item);
 
 734         wxTreeItemId, HitTest(const wxPoint& point, int& OUTPUT),
 
 735         "HitTest(Point point) -> (item, where)",
 
 736         "Determine which item (if any) belongs the given point.  The coordinates
 
 737 specified are relative to the client area of tree ctrl and the where return
 
 738 value is set to a bitmask of wxTREE_HITTEST_xxx constants.
 
 743         // get the bounding rectangle of the item (or of its label only)
 
 744         PyObject* GetBoundingRect(const wxTreeItemId& item,  bool textOnly = false) {
 
 746             if (self->GetBoundingRect(item, rect, textOnly)) {
 
 747                 wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 748                 wxRect* r = new wxRect(rect);
 
 749                 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), true);
 
 750                 wxPyEndBlockThreads(blocked);
 
 759     // set/get the item state.image (state == -1 means cycle to the next one)
 
 760     void SetState(const wxTreeItemId& node, int state);
 
 761     int GetState(const wxTreeItemId& node);
 
 764     static wxVisualAttributes
 
 765     GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
 
 767     void SetQuickBestSize(bool q);
 
 768     bool GetQuickBestSize() const;
 
 770     %property(Count, GetCount, doc="See `GetCount`");
 
 771     %property(EditControl, GetEditControl, doc="See `GetEditControl`");
 
 772     %property(FirstVisibleItem, GetFirstVisibleItem, doc="See `GetFirstVisibleItem`");
 
 773     %property(ImageList, GetImageList, SetImageList, doc="See `GetImageList` and `SetImageList`");
 
 774     %property(Indent, GetIndent, SetIndent, doc="See `GetIndent` and `SetIndent`");
 
 775     %property(QuickBestSize, GetQuickBestSize, SetQuickBestSize, doc="See `GetQuickBestSize` and `SetQuickBestSize`");
 
 776     %property(RootItem, GetRootItem, doc="See `GetRootItem`");
 
 777     %property(Selection, GetSelection, doc="See `GetSelection`");
 
 778     %property(Selections, GetSelections, doc="See `GetSelections`");
 
 779     %property(Spacing, GetSpacing, SetSpacing, doc="See `GetSpacing` and `SetSpacing`");
 
 780     %property(StateImageList, GetStateImageList, SetStateImageList, doc="See `GetStateImageList` and `SetStateImageList`");
 
 784 //---------------------------------------------------------------------------
 
 786     // Map renamed classes back to their common name for OOR
 
 787     wxPyPtrTypeMap_Add("wxTreeItemData", "wxPyTreeItemData");
 
 788     wxPyPtrTypeMap_Add("wxTreeCtrl", "wxPyTreeCtrl");
 
 790 //---------------------------------------------------------------------------