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 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/gizmos/dynamicsash.h>
19 #include <wx/gizmos/editlbox.h>
20 #include <wx/gizmos/splittree.h>
21 #include <wx/gizmos/ledctrl.h>
23 #include <wx/listctrl.h>
24 #include <wx/treectrl.h>
25 #include <wx/imaglist.h>
26 #include "treelistctrl.h"
30 //---------------------------------------------------------------------------
33 %include my_typemaps.i
44 //----------------------------------------------------------------------
47 // Put some wx default wxChar* values into wxStrings.
48 static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow"));
49 static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox"));
50 static const wxString wxPyTreeListCtrlNameStr(wxT("treelistctrl"));
51 static const wxString wxPyEmptyString(wxT(""));
54 ///----------------------------------------------------------------------
57 wxEVT_DYNAMIC_SASH_SPLIT,
58 wxEVT_DYNAMIC_SASH_UNIFY,
60 wxDS_MANAGE_SCROLLBARS,
66 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
67 whenever your view is being split by the user. It is your
68 responsibility to handle this event by creating a new view window as
69 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
70 automatically reparent it to the proper place in its window hierarchy.
72 class wxDynamicSashSplitEvent : public wxCommandEvent {
74 wxDynamicSashSplitEvent(wxObject *target);
79 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
80 whenever the sash which splits your view and its sibling is being
81 reunified such that your view is expanding to replace its sibling.
82 You needn't do anything with this event if you are allowing
83 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
84 if you are managing the scrollbars yourself so that you can keep
85 the scrollbars' event handlers connected to your view's event handler
88 class wxDynamicSashUnifyEvent : public wxCommandEvent {
90 wxDynamicSashUnifyEvent(wxObject *target);
99 wxDynamicSashWindow widgets manages the way other widgets are viewed.
100 When a wxDynamicSashWindow is first shown, it will contain one child
101 view, a viewport for that child, and a pair of scrollbars to allow the
102 user to navigate the child view area. Next to each scrollbar is a small
103 tab. By clicking on either tab and dragging to the appropriate spot, a
104 user can split the view area into two smaller views separated by a
105 draggable sash. Later, when the user wishes to reunify the two subviews,
106 the user simply drags the sash to the side of the window.
107 wxDynamicSashWindow will automatically reparent the appropriate child
108 view back up the window hierarchy, and the wxDynamicSashWindow will have
109 only one child view once again.
111 As an application developer, you will simply create a wxDynamicSashWindow
112 using either the Create() function or the more complex constructor
113 provided below, and then create a view window whose parent is the
114 wxDynamicSashWindow. The child should respond to
115 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
116 constructing a new view window whose parent is also the
117 wxDynamicSashWindow. That's it! Now your users can dynamically split
118 and reunify the view you provided.
120 If you wish to handle the scrollbar events for your view, rather than
121 allowing wxDynamicSashWindow to do it for you, things are a bit more
122 complex. (You might want to handle scrollbar events yourself, if,
123 for instance, you wish to scroll a subwindow of the view you add to
124 your wxDynamicSashWindow object, rather than scrolling the whole view.)
125 In this case, you will need to construct your wxDynamicSashWindow without
126 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
127 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
128 controls and call SetEventHanler() on them to redirect the scrolling
129 events whenever your window is reparented by wxDyanmicSashWindow.
130 You will need to set the scrollbars' event handler at three times:
132 * When your view is created
133 * When your view receives a wxDynamicSashSplitEvent
134 * When your view receives a wxDynamicSashUnifyEvent
136 See the dynsash_switch sample application for an example which does this.
140 class wxDynamicSashWindow : public wxWindow {
142 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
143 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
144 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
145 const wxString& name = wxPyDynamicSashNameStr);
146 %name(wxPreDynamicSashWindow)wxDynamicSashWindow();
148 bool Create(wxWindow *parent, wxWindowID id,
149 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
150 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
151 const wxString& name = wxPyDynamicSashNameStr);
153 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
154 %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)"
156 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
157 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
162 //----------------------------------------------------------------------
163 // Python functions to act like the event macros
165 %pragma(python) code = "
166 def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
167 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
169 def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
170 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
173 //----------------------------------------------------------------------
174 //----------------------------------------------------------------------
182 // This class provides a composite control that lets the
183 // user easily enter list of strings
184 class wxEditableListBox : public wxPanel
187 wxEditableListBox(wxWindow *parent, wxWindowID id,
188 const wxString& label,
189 const wxPoint& pos = wxDefaultPosition,
190 const wxSize& size = wxDefaultSize,
191 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
192 const wxString& name = wxPyEditableListBoxNameStr);
194 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
196 void SetStrings(const wxArrayString& strings);
198 //void GetStrings(wxArrayString& strings);
200 PyObject* GetStrings() {
201 wxArrayString strings;
202 self->GetStrings(strings);
203 return wxArrayString2PyList_helper(strings);
207 wxListCtrl* GetListCtrl() { return m_listCtrl; }
208 wxBitmapButton* GetDelButton() { return m_bDel; }
209 wxBitmapButton* GetNewButton() { return m_bNew; }
210 wxBitmapButton* GetUpButton() { return m_bUp; }
211 wxBitmapButton* GetDownButton() { return m_bDown; }
212 wxBitmapButton* GetEditButton() { return m_bEdit; }
217 //----------------------------------------------------------------------
221 * wxRemotelyScrolledTreeCtrl
223 * This tree control disables its vertical scrollbar and catches scroll
224 * events passed by a scrolled window higher in the hierarchy.
225 * It also updates the scrolled window vertical scrollbar as appropriate.
229 typedef wxTreeCtrl wxPyTreeCtrl;
232 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
235 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
236 const wxPoint& pos = wxDefaultPosition,
237 const wxSize& size = wxDefaultSize,
238 long style = wxTR_HAS_BUTTONS);
239 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
242 void HideVScrollbar();
244 // Adjust the containing wxScrolledWindow's scrollbars appropriately
245 void AdjustRemoteScrollbars();
247 // Find the scrolled window that contains this control
248 wxScrolledWindow* GetScrolledWindow() const;
250 // Scroll to the given line (in scroll units where each unit is
251 // the height of an item)
252 void ScrollToLine(int posHoriz, int posVert);
254 // The companion window is one which will get notified when certain
255 // events happen such as node expansion
256 void SetCompanionWindow(wxWindow* companion);
257 wxWindow* GetCompanionWindow() const;
263 * wxTreeCompanionWindow
265 * A window displaying values associated with tree control items.
269 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
272 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
273 const wxPoint& pos = wxDefaultPosition,
274 const wxSize& size = wxDefaultSize,
276 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
279 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
281 wxPyBeginBlockThreads();
282 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
283 PyObject* dcobj = wxPyMake_wxObject(&dc);
284 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), FALSE);
285 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), FALSE);
286 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
291 wxPyEndBlockThreads();
293 wxTreeCompanionWindow::DrawItem(dc, id, rect);
301 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
304 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
305 const wxPoint& pos = wxDefaultPosition,
306 const wxSize& size = wxDefaultSize,
308 void _setCallbackInfo(PyObject* self, PyObject* _class);
309 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
310 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
312 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
313 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
319 * wxThinSplitterWindow
321 * Implements a splitter with a less obvious sash
322 * than the usual one.
325 class wxThinSplitterWindow: public wxSplitterWindow
328 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
329 const wxPoint& pos = wxDefaultPosition,
330 const wxSize& size = wxDefaultSize,
331 long style = wxSP_3D | wxCLIP_CHILDREN);
332 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
338 * wxSplitterScrolledWindow
340 * This scrolled window is aware of the fact that one of its
341 * children is a splitter window. It passes on its scroll events
342 * (after some processing) to both splitter children for them
343 * scroll appropriately.
346 class wxSplitterScrolledWindow: public wxScrolledWindow
349 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
350 const wxPoint& pos = wxDefaultPosition,
351 const wxSize& size = wxDefaultSize,
353 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
357 //----------------------------------------------------------------------
358 //----------------------------------------------------------------------
373 class wxLEDNumberCtrl : public wxControl
377 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
378 const wxPoint& pos = wxDefaultPosition,
379 const wxSize& size = wxDefaultSize,
380 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
381 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
383 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
384 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
387 bool Create(wxWindow *parent, wxWindowID id = -1,
388 const wxPoint& pos = wxDefaultPosition,
389 const wxSize& size = wxDefaultSize,
390 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
392 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
393 bool GetDrawFaded() const { return m_DrawFaded; }
394 const wxString &GetValue() const { return m_Value; }
396 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
397 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
398 void SetValue(const wxString &Value, bool Redraw = true);
404 //----------------------------------------------------------------------------
405 // wxTreeListCtrl - the multicolumn tree control
406 //----------------------------------------------------------------------------
408 enum wxTreeListColumnAlign {
417 wxTREE_HITTEST_ONITEMCOLUMN
423 class wxTreeListColumnInfo: public wxObject {
425 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
428 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
430 wxTreeListColumnAlign GetAlignment() const;
431 wxString GetText() const;
432 int GetImage() const;
433 int GetSelectedImage() const;
434 size_t GetWidth() const;
436 void SetAlignment(wxTreeListColumnAlign alignment);
437 void SetText(const wxString& text);
438 void SetImage(int image);
439 void SetSelectedImage(int image);
440 void SetWidth(size_t with);
446 %{ // C++ version of Python aware control
447 class wxPyTreeListCtrl : public wxTreeListCtrl {
448 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
450 wxPyTreeListCtrl() : wxTreeListCtrl() {}
451 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
455 const wxValidator &validator,
456 const wxString& name) :
457 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
459 int OnCompareItems(const wxTreeItemId& item1,
460 const wxTreeItemId& item2) {
463 wxPyBeginBlockThreads();
464 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
465 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
466 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
467 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
471 wxPyEndBlockThreads();
473 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
479 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
486 // These are for the GetFirstChild/GetNextChild methods below
488 static const long longzero = 0;
490 %typemap(python, in) long& INOUT = long* INOUT;
491 %typemap(python, argout) long& INOUT = long* INOUT;
494 %name(wxTreeListCtrl) class wxPyTreeListCtrl : public wxControl
497 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
498 const wxPoint& pos = wxDefaultPosition,
499 const wxSize& size = wxDefaultSize,
500 long style = wxTR_DEFAULT_STYLE,
501 const wxValidator &validator = wxDefaultValidator,
502 const wxString& name = wxPyTreeListCtrlNameStr );
503 %name(wxPreTreeListCtrl)wxPyTreeListCtrl();
505 bool Create(wxWindow *parent, wxWindowID id = -1,
506 const wxPoint& pos = wxDefaultPosition,
507 const wxSize& size = wxDefaultSize,
508 long style = wxTR_DEFAULT_STYLE,
509 const wxValidator &validator = wxDefaultValidator,
510 const wxString& name = wxPyTreeListCtrlNameStr );
512 void _setCallbackInfo(PyObject* self, PyObject* _class);
513 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeListCtrl)"
515 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
516 %pragma(python) addtomethod = "wxPreTreeListCtrl:val._setOORInfo(val)"
520 // get the total number of items in the control
521 size_t GetCount() const;
523 // indent is the number of pixels the children are indented relative to
524 // the parents position. SetIndent() also redraws the control
526 unsigned int GetIndent() const;
527 void SetIndent(unsigned int indent);
529 // spacing is the number of pixels between the start and the Text
530 unsigned int GetSpacing() const;
531 void SetSpacing(unsigned int spacing);
533 // line spacing is the space above and below the text on each line
534 unsigned int GetLineSpacing() const;
535 void SetLineSpacing(unsigned int spacing);
537 // image list: these functions allow to associate an image list with
538 // the control and retrieve it. Note that when assigned with
539 // SetImageList, the control does _not_ delete
540 // the associated image list when it's deleted in order to allow image
541 // lists to be shared between different controls. If you use
542 // AssignImageList, the control _does_ delete the image list.
544 // The normal image list is for the icons which correspond to the
545 // normal tree item state (whether it is selected or not).
546 // Additionally, the application might choose to show a state icon
547 // which corresponds to an app-defined item state (for example,
548 // checked/unchecked) which are taken from the state image list.
549 wxImageList *GetImageList() const;
550 wxImageList *GetStateImageList() const;
551 wxImageList *GetButtonsImageList() const;
553 void SetImageList(wxImageList *imageList);
554 void SetStateImageList(wxImageList *imageList);
555 void SetButtonsImageList(wxImageList *imageList);
556 void AssignImageList(wxImageList *imageList);
557 void AssignStateImageList(wxImageList *imageList);
558 void AssignButtonsImageList(wxImageList *imageList);
563 void AddColumn(const wxString& text);
564 %name(AddColumnInfo) void AddColumn(const wxTreeListColumnInfo& col);
566 // inserts a column before the given one
567 void InsertColumn(size_t before, const wxString& text);
568 %name(InsertColumnInfo) void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
570 // deletes the given column - does not delete the corresponding column
572 void RemoveColumn(size_t column);
574 // returns the number of columns in the ctrl
575 size_t GetColumnCount() const;
577 void SetColumnWidth(size_t column, size_t width);
578 int GetColumnWidth(size_t column) const;
580 // tells which column is the "main" one, i.e. the "threaded" one
581 void SetMainColumn(size_t column);
582 size_t GetMainColumn() const;
584 void SetColumnText(size_t column, const wxString& text);
585 wxString GetColumnText(size_t column) const;
587 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
588 wxTreeListColumnInfo& GetColumn(size_t column);
590 // other column-related methods
591 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
592 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
594 void SetColumnImage(size_t column, int image);
595 int GetColumnImage(size_t column) const;
599 // retrieves item's label of the given column (main column by default)
600 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
601 if (column < 0) column = self->GetMainColumn();
602 return self->GetItemText(item, column);
605 // get one of the images associated with the item (normal by default)
606 int GetItemImage(const wxTreeItemId& item, int column = -1,
607 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
608 if (column < 0) column = self->GetMainColumn();
609 return self->GetItemImage(item, column, which);
612 // set item's label (main column by default)
613 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
614 if (column < 0) column = self->GetMainColumn();
615 self->SetItemText(item, column, text);
618 // set one of the images associated with the item (normal by default)
619 // the which parameter is ignored for all columns but the main one
620 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
621 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
622 if (column < 0) column = self->GetMainColumn();
623 self->SetItemImage(item, column, image, which);
627 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
629 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
630 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
632 data = new wxPyTreeItemData();
633 data->SetId(item); // set the id
634 self->SetItemData(item, data);
639 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
640 data->SetId(item); // set the id
641 self->SetItemData(item, data);
644 // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by
645 // automatically creating data classes.
646 PyObject* GetPyData(const wxTreeItemId& item) {
647 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
649 data = new wxPyTreeItemData();
650 data->SetId(item); // set the id
651 self->SetItemData(item, data);
653 return data->GetData();
656 void SetPyData(const wxTreeItemId& item, PyObject* obj) {
657 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
659 data = new wxPyTreeItemData(obj);
660 data->SetId(item); // set the id
661 self->SetItemData(item, data);
668 // force appearance of [+] button near the item. This is useful to
669 // allow the user to expand the items which don't have any children now
670 // - but instead add them only when needed, thus minimizing memory
671 // usage and loading time.
672 void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
674 // the item will be shown in bold
675 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
677 // set the item's text colour
678 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
680 // set the item's background colour
681 void SetItemBackgroundColour(const wxTreeItemId& item,
682 const wxColour& col);
684 // set the item's font (should be of the same height for all items)
685 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
688 bool GetItemBold(const wxTreeItemId& item) const;
689 wxColour GetItemTextColour(const wxTreeItemId& item) const;
690 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
691 wxFont GetItemFont(const wxTreeItemId& item) const;
693 // is the item visible (it might be outside the view or not expanded)?
694 bool IsVisible(const wxTreeItemId& item) const;
696 // does the item has any children?
697 bool ItemHasChildren(const wxTreeItemId& item) const;
699 // is the item expanded (only makes sense if HasChildren())?
700 bool IsExpanded(const wxTreeItemId& item) const;
702 // is this item currently selected (the same as has focus)?
703 bool IsSelected(const wxTreeItemId& item) const;
705 // is item text in bold font?
706 bool IsBold(const wxTreeItemId& item) const;
708 // if 'recursively' is FALSE, only immediate children count, otherwise
709 // the returned number is the number of all items in this branch
710 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
713 // wxTreeItemId.IsOk() will return FALSE if there is no such item
715 // get the root tree item
716 wxTreeItemId GetRootItem() const;
718 // get the item currently selected (may return NULL if no selection)
719 wxTreeItemId GetSelection() const;
721 // get the items currently selected, return the number of such item
722 //size_t GetSelections(wxArrayTreeItemIds&) const;
724 PyObject* GetSelections() {
725 wxPyBeginBlockThreads();
726 PyObject* rval = PyList_New(0);
727 wxArrayTreeItemIds array;
729 num = self->GetSelections(array);
730 for (x=0; x < num; x++) {
731 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
732 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), TRUE);
733 PyList_Append(rval, item);
735 wxPyEndBlockThreads();
741 // get the parent of this item (may return NULL if root)
742 %name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
744 // for this enumeration function you must pass in a "cookie" parameter
745 // which is opaque for the application but is necessary for the library
746 // to make these functions reentrant (i.e. allow more than one
747 // enumeration on one and the same object simultaneously). Of course,
748 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
751 // get the first child of this item
752 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT = longzero) const;
754 // get the next child
755 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT) const;
757 // get the last child of this item - this method doesn't use cookies
758 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
760 // get the next sibling of this item
761 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
763 // get the previous sibling
764 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
766 // get first visible item
767 wxTreeItemId GetFirstVisibleItem() const;
769 // get the next visible item: item must be visible itself!
770 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
771 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
773 // get the previous visible item: item must be visible itself!
774 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
776 // Only for internal use right now, but should probably be public
777 wxTreeItemId GetNext(const wxTreeItemId& item) const;
780 // add the root node to the tree
781 wxTreeItemId AddRoot(const wxString& text,
782 int image = -1, int selectedImage = -1,
783 wxPyTreeItemData *data = NULL);
785 // insert a new item in as the first child of the parent
786 wxTreeItemId PrependItem(const wxTreeItemId& parent,
787 const wxString& text,
788 int image = -1, int selectedImage = -1,
789 wxPyTreeItemData *data = NULL);
791 // insert a new item after a given one
792 wxTreeItemId InsertItem(const wxTreeItemId& parent,
793 const wxTreeItemId& idPrevious,
794 const wxString& text,
795 int image = -1, int selectedImage = -1,
796 wxPyTreeItemData *data = NULL);
798 // insert a new item before the one with the given index
799 %name(InsertItemBefore)
800 wxTreeItemId InsertItem(const wxTreeItemId& parent,
802 const wxString& text,
803 int image = -1, int selectedImage = -1,
804 wxPyTreeItemData *data = NULL);
806 // insert a new item in as the last child of the parent
807 wxTreeItemId AppendItem(const wxTreeItemId& parent,
808 const wxString& text,
809 int image = -1, int selectedImage = -1,
810 wxPyTreeItemData *data = NULL);
812 // delete this item and associated data if any
813 void Delete(const wxTreeItemId& item);
815 // delete all children (but don't delete the item itself)
816 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
817 void DeleteChildren(const wxTreeItemId& item);
819 // delete all items from the tree
820 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
821 void DeleteAllItems();
824 void Expand(const wxTreeItemId& item);
826 // expand this item and all subitems recursively
827 void ExpandAll(const wxTreeItemId& item);
829 // collapse the item without removing its children
830 void Collapse(const wxTreeItemId& item);
832 // collapse the item and remove all children
833 void CollapseAndReset(const wxTreeItemId& item);
835 // toggles the current state
836 void Toggle(const wxTreeItemId& item);
838 // remove the selection from currently selected item (if any)
843 void SelectItem(const wxTreeItemId& item, bool unselect_others=TRUE,
844 bool extended_select=FALSE);
846 // make sure this item is visible (expanding the parent item and/or
847 // scrolling to this item if necessary)
848 void EnsureVisible(const wxTreeItemId& item);
850 // scroll to this item (but don't expand its parent)
851 void ScrollTo(const wxTreeItemId& item);
853 // Returns wxTreeItemId, flags, and column
854 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
857 // get the bounding rectangle of the item (or of its label only)
858 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = FALSE) {
860 if (self->GetBoundingRect(item, rect, textOnly)) {
861 wxPyBeginBlockThreads();
862 wxRect* r = new wxRect(rect);
863 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
864 wxPyEndBlockThreads();
875 // Start editing the item label: this (temporarily) replaces the item
876 // with a one line edit control. The item will be selected if it hadn't
878 void EditLabel( const wxTreeItemId& item );
879 void Edit( const wxTreeItemId& item );
881 // sort the children of this item using OnCompareItems
882 void SortChildren(const wxTreeItemId& item);
884 // get the selected item image
885 int GetItemSelectedImage(const wxTreeItemId& item) const;
887 // set the selected item image
888 void SetItemSelectedImage(const wxTreeItemId& item, int image);
891 wxWindow* GetHeaderWindow() const;
892 wxWindow* GetMainWindow() const;
894 %pragma(python) addtoclass = "
895 # Redefine some methods that SWIG gets a bit confused on...
896 def GetFirstChild(self, *_args, **_kwargs):
897 val1,val2 = gizmosc.wxTreeListCtrl_GetFirstChild(self, *_args, **_kwargs)
898 val1 = wxTreeItemIdPtr(val1)
901 def GetNextChild(self, *_args, **_kwargs):
902 val1,val2 = gizmosc.wxTreeListCtrl_GetNextChild(self, *_args, **_kwargs)
903 val1 = wxTreeItemIdPtr(val1)
906 def HitTest(self, *_args, **_kwargs):
907 val1, val2, val3 = gizmosc.wxTreeListCtrl_HitTest(self, *_args, **_kwargs)
908 val1 = wxTreeItemIdPtr(val1)
910 return (val1, val2, val3)
917 //----------------------------------------------------------------------
918 //----------------------------------------------------------------------
922 wxClassInfo::CleanUpClasses();
923 wxClassInfo::InitializeClasses();
925 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
926 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
930 %pragma(python) include="_gizmoextras.py";
932 //----------------------------------------------------------------------
933 //----------------------------------------------------------------------