1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     Wrappers for the "gizmo" classes in wx/contrib
 
   7 // Created:     23-Nov-2001
 
   9 // Copyright:   (c) 2001 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  14 "Various *gizmo* classes: `DynamicSashWindow`, `EditableListBox`,
 
  15 `LEDNumberCtrl`, `TreeListCtrl`, etc."
 
  18 %module(package="wx", docstring=DOCSTRING) gizmos
 
  22 #include "wx/wxPython/wxPython.h"
 
  23 #include "wx/wxPython/pyclasses.h"
 
  25 #include <wx/gizmos/dynamicsash.h>
 
  26 #include <wx/gizmos/editlbox.h>
 
  27 #include <wx/gizmos/splittree.h>
 
  28 #include <wx/gizmos/ledctrl.h>
 
  29 #include <wx/gizmos/statpict.h>
 
  31 #include <wx/listctrl.h>
 
  32 #include <wx/treectrl.h>
 
  33 #include <wx/imaglist.h>
 
  35 #include "wx/treelistctrl.h"
 
  36 #include "wx/wxPython/pytree.h"
 
  40 //---------------------------------------------------------------------------
 
  44 %pythoncode { import wx }
 
  45 %pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
 
  48 MAKE_CONST_WXSTRING2(DynamicSashNameStr,     wxT("dynamicSashWindow"));
 
  49 MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
 
  50 MAKE_CONST_WXSTRING2(TreeListCtrlNameStr,    wxT("treelistctrl"));
 
  51 MAKE_CONST_WXSTRING(StaticPictureNameStr);                     
 
  53 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
 
  56 %include _gizmos_rename.i
 
  58 //---------------------------------------------------------------------------
 
  61     wxDS_MANAGE_SCROLLBARS,
 
  65 %constant wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
 
  66 %constant wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
 
  70     wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
 
  71     whenever your view is being split by the user.  It is your
 
  72     responsibility to handle this event by creating a new view window as
 
  73     a child of the wxDynamicSashWindow.  wxDynamicSashWindow will
 
  74     automatically reparent it to the proper place in its window hierarchy.
 
  76 class wxDynamicSashSplitEvent : public wxCommandEvent {
 
  78     wxDynamicSashSplitEvent(wxObject *target);
 
  83     wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
 
  84     whenever the sash which splits your view and its sibling is being
 
  85     reunified such that your view is expanding to replace its sibling.
 
  86     You needn't do anything with this event if you are allowing
 
  87     wxDynamicSashWindow to manage your view's scrollbars, but it is useful
 
  88     if you are managing the scrollbars yourself so that you can keep
 
  89     the scrollbars' event handlers connected to your view's event handler
 
  92 class wxDynamicSashUnifyEvent : public wxCommandEvent {
 
  94     wxDynamicSashUnifyEvent(wxObject *target);
 
 103     wxDynamicSashWindow widgets manages the way other widgets are viewed.
 
 104     When a wxDynamicSashWindow is first shown, it will contain one child
 
 105     view, a viewport for that child, and a pair of scrollbars to allow the
 
 106     user to navigate the child view area.  Next to each scrollbar is a small
 
 107     tab.  By clicking on either tab and dragging to the appropriate spot, a
 
 108     user can split the view area into two smaller views separated by a
 
 109     draggable sash.  Later, when the user wishes to reunify the two subviews,
 
 110     the user simply drags the sash to the side of the window.
 
 111     wxDynamicSashWindow will automatically reparent the appropriate child
 
 112     view back up the window hierarchy, and the wxDynamicSashWindow will have
 
 113     only one child view once again.
 
 115     As an application developer, you will simply create a wxDynamicSashWindow
 
 116     using either the Create() function or the more complex constructor
 
 117     provided below, and then create a view window whose parent is the
 
 118     wxDynamicSashWindow.  The child should respond to
 
 119     wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
 
 120     constructing a new view window whose parent is also the
 
 121     wxDynamicSashWindow.  That's it!  Now your users can dynamically split
 
 122     and reunify the view you provided.
 
 124     If you wish to handle the scrollbar events for your view, rather than
 
 125     allowing wxDynamicSashWindow to do it for you, things are a bit more
 
 126     complex.  (You might want to handle scrollbar events yourself, if,
 
 127     for instance, you wish to scroll a subwindow of the view you add to
 
 128     your wxDynamicSashWindow object, rather than scrolling the whole view.)
 
 129     In this case, you will need to construct your wxDynamicSashWindow without
 
 130     the wxDS_MANAGE_SCROLLBARS style and  you will need to use the
 
 131     GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
 
 132     controls and call SetEventHanler() on them to redirect the scrolling
 
 133     events whenever your window is reparented by wxDyanmicSashWindow.
 
 134     You will need to set the scrollbars' event handler at three times:
 
 136         *  When your view is created
 
 137         *  When your view receives a wxDynamicSashSplitEvent
 
 138         *  When your view receives a wxDynamicSashUnifyEvent
 
 140     See the dynsash_switch sample application for an example which does this.
 
 144 MustHaveApp(wxDynamicSashWindow);
 
 146 class wxDynamicSashWindow : public wxWindow {
 
 148     %pythonAppend wxDynamicSashWindow         "self._setOORInfo(self)"
 
 149     %pythonAppend wxDynamicSashWindow()       ""
 
 151     wxDynamicSashWindow(wxWindow *parent, wxWindowID id=-1,
 
 152                         const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
 
 153                         long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
 
 154                         const wxString& name = wxPyDynamicSashNameStr);
 
 155     %RenameCtor(PreDynamicSashWindow, wxDynamicSashWindow());
 
 157     bool Create(wxWindow *parent, wxWindowID id=-1,
 
 158                 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
 
 159                 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
 
 160                 const wxString& name = wxPyDynamicSashNameStr);
 
 162     wxScrollBar *GetHScrollBar(const wxWindow *child) const;
 
 163     wxScrollBar *GetVScrollBar(const wxWindow *child) const;
 
 169 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
 
 170 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
 
 173 //---------------------------------------------------------------------------
 
 174 //---------------------------------------------------------------------------
 
 182 // This class provides a composite control that lets the
 
 183 // user easily enter list of strings
 
 184 MustHaveApp(wxEditableListBox);
 
 185 class wxEditableListBox : public wxPanel
 
 188     %pythonAppend wxEditableListBox         "self._setOORInfo(self)"
 
 189     %pythonAppend wxEditableListBox()       ""
 
 191     wxEditableListBox(wxWindow *parent, wxWindowID id=-1,
 
 192                       const wxString& label = wxPyEmptyString,
 
 193                       const wxPoint& pos = wxDefaultPosition,
 
 194                       const wxSize& size = wxDefaultSize,
 
 195                       long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
 
 196                       const wxString& name = wxPyEditableListBoxNameStr);
 
 199     void SetStrings(const wxArrayString& strings);
 
 201     //void GetStrings(wxArrayString& strings);
 
 203         PyObject* GetStrings() {
 
 204             wxArrayString strings;
 
 205             self->GetStrings(strings);
 
 206             return wxArrayString2PyList_helper(strings);
 
 210     wxPyListCtrl* GetListCtrl();
 
 211     wxBitmapButton* GetDelButton();
 
 212     wxBitmapButton* GetNewButton();
 
 213     wxBitmapButton* GetUpButton();
 
 214     wxBitmapButton* GetDownButton();
 
 215     wxBitmapButton* GetEditButton();
 
 220 //---------------------------------------------------------------------------
 
 224  * wxRemotelyScrolledTreeCtrl
 
 226  * This tree control disables its vertical scrollbar and catches scroll
 
 227  * events passed by a scrolled window higher in the hierarchy.
 
 228  * It also updates the scrolled window vertical scrollbar as appropriate.
 
 232     typedef wxTreeCtrl wxPyTreeCtrl;
 
 235 MustHaveApp(wxRemotelyScrolledTreeCtrl);
 
 237 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
 
 240     %pythonAppend wxRemotelyScrolledTreeCtrl         "self._setOORInfo(self)"
 
 241     %pythonAppend wxRemotelyScrolledTreeCtrl()       ""
 
 243     wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
 
 244                                const wxPoint& pos = wxDefaultPosition,
 
 245                                const wxSize& size = wxDefaultSize,
 
 246                                long style = wxTR_HAS_BUTTONS);
 
 249     void HideVScrollbar();
 
 251     // Adjust the containing wxScrolledWindow's scrollbars appropriately
 
 252     void AdjustRemoteScrollbars();
 
 254     // Find the scrolled window that contains this control
 
 255     wxScrolledWindow* GetScrolledWindow() const;
 
 257     // Scroll to the given line (in scroll units where each unit is
 
 258     // the height of an item)
 
 259     void ScrollToLine(int posHoriz, int posVert);
 
 261     // The companion window is one which will get notified when certain
 
 262     // events happen such as node expansion
 
 263     void SetCompanionWindow(wxWindow* companion);
 
 264     wxWindow* GetCompanionWindow() const;
 
 270  * wxTreeCompanionWindow
 
 272  * A window displaying values associated with tree control items.
 
 276 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
 
 279     wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
 
 280                             const wxPoint& pos = wxDefaultPosition,
 
 281                             const wxSize& size = wxDefaultSize,
 
 283         : wxTreeCompanionWindow(parent, id, pos, size, style) {}
 
 286     virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
 
 288         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 289         if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
 
 290             PyObject* dcobj = wxPyMake_wxObject(&dc,false);
 
 291             PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), false);
 
 292             PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), false);
 
 293             wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
 
 298         wxPyEndBlockThreads(blocked);
 
 300             wxTreeCompanionWindow::DrawItem(dc, id, rect);
 
 308 MustHaveApp(wxPyTreeCompanionWindow);
 
 310 %rename(TreeCompanionWindow) wxPyTreeCompanionWindow;
 
 311 class wxPyTreeCompanionWindow: public wxWindow
 
 314     %pythonAppend wxPyTreeCompanionWindow         "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
 
 315     %pythonAppend wxPyTreeCompanionWindow()       ""
 
 317     wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
 
 318                             const wxPoint& pos = wxDefaultPosition,
 
 319                             const wxSize& size = wxDefaultSize,
 
 321     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 323     wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
 
 324     void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
 
 330  * wxThinSplitterWindow
 
 332  * Implements a splitter with a less obvious sash
 
 333  * than the usual one.
 
 336 MustHaveApp(wxThinSplitterWindow);
 
 338 class wxThinSplitterWindow: public wxSplitterWindow
 
 341     %pythonAppend wxThinSplitterWindow         "self._setOORInfo(self)"
 
 342     %pythonAppend wxThinSplitterWindow()       ""
 
 344     wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
 
 345                          const wxPoint& pos = wxDefaultPosition,
 
 346                          const wxSize& size = wxDefaultSize,
 
 347                          long style = wxSP_3D | wxCLIP_CHILDREN);
 
 353  * wxSplitterScrolledWindow
 
 355  * This scrolled window is aware of the fact that one of its
 
 356  * children is a splitter window. It passes on its scroll events
 
 357  * (after some processing) to both splitter children for them
 
 358  * scroll appropriately.
 
 361 MustHaveApp(wxSplitterScrolledWindow);
 
 363 class wxSplitterScrolledWindow: public wxScrolledWindow
 
 366     %pythonAppend wxSplitterScrolledWindow         "self._setOORInfo(self)"
 
 367     %pythonAppend wxSplitterScrolledWindow()       ""
 
 369     wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
 
 370                              const wxPoint& pos = wxDefaultPosition,
 
 371                              const wxSize& size = wxDefaultSize,
 
 376 //---------------------------------------------------------------------------
 
 377 //---------------------------------------------------------------------------
 
 392 MustHaveApp(wxLEDNumberCtrl);
 
 394 class wxLEDNumberCtrl : public wxControl
 
 397     %pythonAppend wxLEDNumberCtrl         "self._setOORInfo(self)"
 
 398     %pythonAppend wxLEDNumberCtrl()       ""
 
 400     wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
 
 401                     const wxPoint& pos = wxDefaultPosition,
 
 402                     const wxSize& size = wxDefaultSize,
 
 403                     long style =  wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
 
 404     %RenameCtor(PreLEDNumberCtrl,  wxLEDNumberCtrl());
 
 406     bool Create(wxWindow *parent, wxWindowID id = -1,
 
 407                     const wxPoint& pos = wxDefaultPosition,
 
 408                     const wxSize& size = wxDefaultSize,
 
 409                     long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
 
 411     wxLEDValueAlign GetAlignment() const;
 
 412     bool GetDrawFaded() const;
 
 413     const wxString &GetValue() const;
 
 415     void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
 
 416     void SetDrawFaded(bool DrawFaded, bool Redraw = true);
 
 417     void SetValue(const wxString &Value, bool Redraw = true);
 
 423 //----------------------------------------------------------------------------
 
 424 // wxTreeListCtrl - the multicolumn tree control
 
 425 //----------------------------------------------------------------------------
 
 427 enum wxTreeListColumnAlign {
 
 436     wxTREE_HITTEST_ONITEMCOLUMN
 
 441     // flags for FindItem
 
 453 %pythoncode { wx.TR_DONT_ADJUST_MAC = TR_DONT_ADJUST_MAC }
 
 456 class wxTreeListColumnInfo: public wxObject {
 
 458     wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
 
 462                          wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
 
 464     bool GetShown() const;
 
 465     wxTreeListColumnAlign GetAlignment() const;
 
 466     wxString GetText() const;
 
 467     int GetImage() const;
 
 468     int GetSelectedImage() const;
 
 469     size_t GetWidth() const;
 
 471     // TODO:  These all actually return wxTreeListColumnInfo&, any problem with doing it for Python too?
 
 472     void SetShown(bool shown);
 
 473     void SetAlignment(wxTreeListColumnAlign alignment);
 
 474     void SetText(const wxString& text);
 
 475     void SetImage(int image);
 
 476     void SetSelectedImage(int image);
 
 477     void SetWidth(size_t with);
 
 483 %{ // C++ version of Python aware control
 
 484 class wxPyTreeListCtrl : public wxTreeListCtrl {
 
 485     DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
 
 487     wxPyTreeListCtrl() : wxTreeListCtrl() {}
 
 488     wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
 
 492                      const wxValidator &validator,
 
 493                      const wxString& name) :
 
 494         wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
 
 496     int OnCompareItems(const wxTreeItemId& item1,
 
 497                        const wxTreeItemId& item2) {
 
 500         wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 501         if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
 
 502             PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
 
 503             PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
 
 504             rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
 
 508         wxPyEndBlockThreads(blocked);
 
 510             rval = wxTreeListCtrl::OnCompareItems(item1, item2);
 
 516 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
 
 525 MustHaveApp(wxPyTreeListCtrl);
 
 527 %rename(TreeListCtrl) wxPyTreeListCtrl;
 
 528 class wxPyTreeListCtrl : public wxControl
 
 531     %pythonAppend wxPyTreeListCtrl         "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
 
 532     %pythonAppend wxPyTreeListCtrl()       ""
 
 534     wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
 
 535                    const wxPoint& pos = wxDefaultPosition,
 
 536                    const wxSize& size = wxDefaultSize,
 
 537                    long style = wxTR_DEFAULT_STYLE,
 
 538                    const wxValidator &validator = wxDefaultValidator,
 
 539                    const wxString& name = wxPyTreeListCtrlNameStr );
 
 540     %RenameCtor(PreTreeListCtrl, wxPyTreeListCtrl());
 
 542     bool Create(wxWindow *parent, wxWindowID id = -1,
 
 543                 const wxPoint& pos = wxDefaultPosition,
 
 544                 const wxSize& size = wxDefaultSize,
 
 545                 long style = wxTR_DEFAULT_STYLE,
 
 546                 const wxValidator &validator = wxDefaultValidator,
 
 547                 const wxString& name = wxPyTreeListCtrlNameStr );
 
 549     void _setCallbackInfo(PyObject* self, PyObject* _class);
 
 552     // get the total number of items in the control
 
 553     size_t GetCount() const;
 
 555     // indent is the number of pixels the children are indented relative to
 
 556     // the parents position. SetIndent() also redraws the control
 
 558     unsigned int GetIndent() const;
 
 559     void SetIndent(unsigned int indent);
 
 561     // line spacing is the space above and below the text on each line
 
 562     unsigned int GetLineSpacing() const;
 
 563     void SetLineSpacing(unsigned int spacing);
 
 565     // image list: these functions allow to associate an image list with
 
 566     // the control and retrieve it. Note that when assigned with
 
 567     // SetImageList, the control does _not_ delete
 
 568     // the associated image list when it's deleted in order to allow image
 
 569     // lists to be shared between different controls. If you use
 
 570     // AssignImageList, the control _does_ delete the image list.
 
 572     // The normal image list is for the icons which correspond to the
 
 573     // normal tree item state (whether it is selected or not).
 
 574     // Additionally, the application might choose to show a state icon
 
 575     // which corresponds to an app-defined item state (for example,
 
 576     // checked/unchecked) which are taken from the state image list.
 
 577     wxImageList *GetImageList() const;
 
 578     wxImageList *GetStateImageList() const;
 
 579     wxImageList *GetButtonsImageList() const;
 
 581     void SetImageList(wxImageList *imageList);
 
 582     void SetStateImageList(wxImageList *imageList);
 
 583     void SetButtonsImageList(wxImageList *imageList);
 
 585     %apply SWIGTYPE *DISOWN { wxImageList *imageList };
 
 586     void AssignImageList(wxImageList *imageList);
 
 587     void AssignStateImageList(wxImageList *imageList);
 
 588     void AssignButtonsImageList(wxImageList *imageList);
 
 589     %clear wxImageList *imageList;
 
 593     void AddColumn(const wxString& text);
 
 594 //     void AddColumn(const wxString& text,
 
 596 //                    wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
 
 597     %Rename(AddColumnInfo,  void,  AddColumn(const wxTreeListColumnInfo& col));
 
 599     // inserts a column before the given one
 
 600     void InsertColumn(size_t before, const wxString& text);
 
 601     %Rename(InsertColumnInfo,  void,  InsertColumn(size_t before, const wxTreeListColumnInfo& col));
 
 603     // deletes the given column - does not delete the corresponding column
 
 605     void RemoveColumn(size_t column);
 
 607     // returns the number of columns in the ctrl
 
 608     size_t GetColumnCount() const;
 
 610     void SetColumnWidth(size_t column, size_t width);
 
 611     int GetColumnWidth(size_t column) const;
 
 613     // tells which column is the "main" one, i.e. the "threaded" one
 
 614     void SetMainColumn(size_t column);
 
 615     size_t GetMainColumn() const;
 
 617     void SetColumnText(size_t column, const wxString& text);
 
 618     wxString GetColumnText(size_t column) const;
 
 620     void SetColumn(size_t column, const wxTreeListColumnInfo& info);
 
 621     wxTreeListColumnInfo& GetColumn(size_t column);
 
 623     // other column-related methods
 
 624     void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
 
 625     wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
 
 627     void SetColumnImage(size_t column, int image);
 
 628     int GetColumnImage(size_t column) const;
 
 630     void ShowColumn(size_t column, bool shown);
 
 631     bool IsColumnShown(size_t column) const;
 
 634         // retrieves item's label of the given column (main column by default)
 
 635         wxString GetItemText(const wxTreeItemId& item, int column = -1) {
 
 636             if (column < 0) column = self->GetMainColumn();
 
 637             return self->GetItemText(item, column);
 
 640         // get one of the images associated with the item (normal by default)
 
 641         int GetItemImage(const wxTreeItemId& item, int column = -1,
 
 642                          wxTreeItemIcon which = wxTreeItemIcon_Normal) {
 
 643             if (column < 0) column = self->GetMainColumn();
 
 644             return self->GetItemImage(item, column, which);
 
 647         // set item's label (main column by default)
 
 648         void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
 
 649             if (column < 0) column = self->GetMainColumn();
 
 650             self->SetItemText(item, column, text);
 
 653         // set one of the images associated with the item (normal by default)
 
 654         // the which parameter is ignored for all columns but the main one
 
 655         void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
 
 656                           wxTreeItemIcon which = wxTreeItemIcon_Normal) {
 
 657             if (column < 0) column = self->GetMainColumn();
 
 658             self->SetItemImage(item, column, image, which);
 
 662         // [Get|Set]ItemData substitutes.  Automatically create wxPyTreeItemData
 
 664         wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
 
 665             wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
 
 667                 data = new wxPyTreeItemData();
 
 668                 data->SetId(item); // set the id
 
 669                 self->SetItemData(item, data);
 
 674         void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
 
 675             data->SetId(item); // set the id
 
 676             self->SetItemData(item, data);
 
 679         // [Get|Set]ItemPyData are short-cuts.  Also made somewhat crash-proof by
 
 680         // automatically creating data classes.
 
 681         PyObject* GetItemPyData(const wxTreeItemId& item) {
 
 682             wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
 
 684                 data = new wxPyTreeItemData();
 
 685                 data->SetId(item); // set the id
 
 686                 self->SetItemData(item, data);
 
 688             return data->GetData();
 
 691         void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
 
 692             wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
 
 694                 data = new wxPyTreeItemData(obj);
 
 695                 data->SetId(item); // set the id
 
 696                 self->SetItemData(item, data);
 
 701     %pythoncode { GetPyData = GetItemPyData }
 
 702     %pythoncode { SetPyData = SetItemPyData }
 
 705     // force appearance of [+] button near the item. This is useful to
 
 706     // allow the user to expand the items which don't have any children now
 
 707     // - but instead add them only when needed, thus minimizing memory
 
 708     // usage and loading time.
 
 709     void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
 
 711     // the item will be shown in bold
 
 712     void SetItemBold(const wxTreeItemId& item, bool bold = true);
 
 714     // set the item's text colour
 
 715     void SetItemTextColour(const wxTreeItemId& item, const wxColour& colour);
 
 717     // set the item's background colour
 
 718     void SetItemBackgroundColour(const wxTreeItemId& item,
 
 719                                  const wxColour& colour);
 
 721     // set the item's font (should be of the same height for all items)
 
 722     void SetItemFont(const wxTreeItemId& item, const wxFont& font);
 
 725     bool GetItemBold(const wxTreeItemId& item) const;
 
 726     wxColour GetItemTextColour(const wxTreeItemId& item) const;
 
 727     wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
 
 728     wxFont GetItemFont(const wxTreeItemId& item) const;
 
 730     // is the item visible (it might be outside the view or not expanded)?
 
 731     bool IsVisible(const wxTreeItemId& item) const;
 
 733     // does the item has any children?
 
 734     bool ItemHasChildren(const wxTreeItemId& item) const;
 
 736     // is the item expanded (only makes sense if HasChildren())?
 
 737     bool IsExpanded(const wxTreeItemId& item) const;
 
 739     // is this item currently selected (the same as has focus)?
 
 740     bool IsSelected(const wxTreeItemId& item) const;
 
 742     // is item text in bold font?
 
 743     bool IsBold(const wxTreeItemId& item) const;
 
 745     // if 'recursively' is False, only immediate children count, otherwise
 
 746     // the returned number is the number of all items in this branch
 
 747     size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true);
 
 750     // wxTreeItemId.IsOk() will return False if there is no such item
 
 752     // get the root tree item
 
 753     wxTreeItemId GetRootItem() const;
 
 755     // get the item currently selected (may return NULL if no selection)
 
 756     wxTreeItemId GetSelection() const;
 
 758     // get the items currently selected, return the number of such item
 
 759     //size_t GetSelections(wxArrayTreeItemIds&) const;
 
 761         PyObject* GetSelections() {
 
 762             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 763             PyObject*           rval = PyList_New(0);
 
 764             wxArrayTreeItemIds  array;
 
 766             num = self->GetSelections(array);
 
 767             for (x=0; x < num; x++) {
 
 768                 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
 
 769                 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
 
 770                 PyList_Append(rval, item);
 
 772             wxPyEndBlockThreads(blocked);
 
 778     // get the parent of this item (may return NULL if root)
 
 779     wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
 
 781     // for this enumeration function you must pass in a "cookie" parameter
 
 782     // which is opaque for the application but is necessary for the library
 
 783     // to make these functions reentrant (i.e. allow more than one
 
 784     // enumeration on one and the same object simultaneously). Of course,
 
 785     // the "cookie" passed to GetFirstChild() and GetNextChild() should be
 
 789     // NOTE: These are a copy of the same methods in _treectrl.i, be sure to
 
 790     // update both at the same time.  (Or find a good way to refactor!)
 
 792         // Get the first child of this item.  Returns a wxTreeItemId and an
 
 793         // opaque "cookie" value that should be passed to GetNextChild in
 
 794         // order to continue the search.
 
 795         PyObject* GetFirstChild(const wxTreeItemId& item) {
 
 797             wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
 
 798             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 799             PyObject* tup = PyTuple_New(2);
 
 800             PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
 
 801             PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
 
 802             wxPyEndBlockThreads(blocked);
 
 807         // Get the next child of this item.  The cookie parameter is the 2nd
 
 808         // value returned from GetFirstChild or the previous GetNextChild.
 
 809         // Returns a wxTreeItemId and an opaque "cookie" value that should be
 
 810         // passed to GetNextChild in order to continue the search.
 
 811         PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
 
 812             wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
 
 813             wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 814             PyObject* tup = PyTuple_New(2);
 
 815             PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
 
 816             PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
 
 817             wxPyEndBlockThreads(blocked);
 
 822         // TODO:  GetPrevChild
 
 826     // get the last child of this item - this method doesn't use cookies
 
 827     wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
 
 829     // get the next sibling of this item
 
 830     wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
 
 832     // get the previous sibling
 
 833     wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
 
 835     // get first visible item
 
 836     wxTreeItemId GetFirstVisibleItem() const;
 
 838     // get the next visible item: item must be visible itself!
 
 839     // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
 
 840     wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
 
 842     // get the previous visible item: item must be visible itself!
 
 843     wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
 
 845     // Only for internal use right now, but should probably be public
 
 846     wxTreeItemId GetNext(const wxTreeItemId& item) const;
 
 849     // add the root node to the tree
 
 850     wxTreeItemId AddRoot(const wxString& text,
 
 851                          int image = -1, int selectedImage = -1,
 
 852                          wxPyTreeItemData *data = NULL);
 
 854     // insert a new item in as the first child of the parent
 
 855     wxTreeItemId PrependItem(const wxTreeItemId& parent,
 
 856                              const wxString& text,
 
 857                              int image = -1, int selectedImage = -1,
 
 858                              wxPyTreeItemData *data = NULL);
 
 860     // insert a new item after a given one
 
 861     wxTreeItemId InsertItem(const wxTreeItemId& parent,
 
 862                             const wxTreeItemId& idPrevious,
 
 863                             const wxString& text,
 
 864                             int image = -1, int selectedImage = -1,
 
 865                             wxPyTreeItemData *data = NULL);
 
 867     // insert a new item before the one with the given index
 
 868     %Rename(InsertItemBefore, 
 
 869         wxTreeItemId,  InsertItem(const wxTreeItemId& parent,
 
 871                                 const wxString& text,
 
 872                                 int image = -1, int selectedImage = -1,
 
 873                                 wxPyTreeItemData *data = NULL));
 
 875     // insert a new item in as the last child of the parent
 
 876     wxTreeItemId AppendItem(const wxTreeItemId& parent,
 
 877                             const wxString& text,
 
 878                             int image = -1, int selectedImage = -1,
 
 879                             wxPyTreeItemData *data = NULL);
 
 881     // delete this item and associated data if any
 
 882     void Delete(const wxTreeItemId& item);
 
 884     // delete all children (but don't delete the item itself)
 
 885     // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
 
 886     void DeleteChildren(const wxTreeItemId& item);
 
 888     // delete all items from the tree
 
 889     // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
 
 890     void DeleteAllItems();
 
 893     void Expand(const wxTreeItemId& item);
 
 895     // expand this item and all subitems recursively
 
 896     void ExpandAll(const wxTreeItemId& item);
 
 898     // collapse the item without removing its children
 
 899     void Collapse(const wxTreeItemId& item);
 
 901     // collapse the item and remove all children
 
 902     void CollapseAndReset(const wxTreeItemId& item);
 
 904     // toggles the current state
 
 905     void Toggle(const wxTreeItemId& item);
 
 907     // remove the selection from currently selected item (if any)
 
 912     void SelectItem(const wxTreeItemId& item, bool unselect_others=true,
 
 913                     bool extended_select=false);
 
 915     void SelectAll(bool extended_select=false);
 
 917     // make sure this item is visible (expanding the parent item and/or
 
 918     // scrolling to this item if necessary)
 
 919     void EnsureVisible(const wxTreeItemId& item);
 
 921     // scroll to this item (but don't expand its parent)
 
 922     void ScrollTo(const wxTreeItemId& item);
 
 924     // Returns wxTreeItemId, flags, and column
 
 925     wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
 
 928         // get the bounding rectangle of the item (or of its label only)
 
 929         PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
 
 931             if (self->GetBoundingRect(item, rect, textOnly)) {
 
 932                 wxPyBlock_t blocked = wxPyBeginBlockThreads();
 
 933                 wxRect* r = new wxRect(rect);
 
 934                 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
 
 935                 wxPyEndBlockThreads(blocked);
 
 945     // Start editing the item label: this (temporarily) replaces the item
 
 946     // with a one line edit control. The item will be selected if it hadn't
 
 948     void EditLabel( const wxTreeItemId& item );
 
 949     void Edit( const wxTreeItemId& item );
 
 951     // sort the children of this item using OnCompareItems
 
 952     void SortChildren(const wxTreeItemId& item);
 
 955     wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, int flags = 0);
 
 957     wxWindow* GetHeaderWindow() const;
 
 958     wxScrolledWindow* GetMainWindow() const;
 
 962 //----------------------------------------------------------------------
 
 972 MustHaveApp(wxStaticPicture);
 
 974 class wxStaticPicture : public wxControl
 
 977     %pythonAppend wxStaticPicture         "self._setOORInfo(self)"
 
 978     %pythonAppend wxStaticPicture()       ""
 
 980     wxStaticPicture( wxWindow* parent, wxWindowID id=-1,
 
 981                      const wxBitmap& label=wxNullBitmap,
 
 982                      const wxPoint& pos = wxDefaultPosition,
 
 983                      const wxSize& size = wxDefaultSize,
 
 985                      const wxString& name = wxPyStaticPictureNameStr );
 
 987     %RenameCtor(PreStaticPicture, wxStaticPicture());
 
 989     bool Create( wxWindow* parent, wxWindowID id=-1,
 
 990                  const wxBitmap& label=wxNullBitmap,
 
 991                  const wxPoint& pos = wxDefaultPosition,
 
 992                  const wxSize& size = wxDefaultSize,
 
 994                  const wxString& name = wxPyStaticPictureNameStr );
 
 996     void SetBitmap( const wxBitmap& bmp );
 
 997     wxBitmap GetBitmap() const;
 
 998     void SetIcon( const wxIcon& icon );
 
 999     wxIcon GetIcon() const;
 
1001     void SetAlignment( int align );
 
1002     int GetAlignment() const;
 
1004     void SetScale( int scale );
 
1005     int GetScale() const; 
 
1007     void SetCustomScale( float sx, float sy );
 
1008     void GetCustomScale( float* OUTPUT, float* OUTPUT ) const;
 
1013 //----------------------------------------------------------------------
 
1014 //----------------------------------------------------------------------
 
1018     wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
 
1019     wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
 
1023 %pragma(python) include="_gizmoextras.py";
 
1025 //----------------------------------------------------------------------
 
1026 //----------------------------------------------------------------------