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);
557 void AssignImageList(wxImageList *imageList);
558 %pragma(python) addtomethod = "AssignImageList:_args[0].thisown = 0"
560 void AssignStateImageList(wxImageList *imageList);
561 %pragma(python) addtomethod = "AssignStateImageList:_args[0].thisown = 0"
563 void AssignButtonsImageList(wxImageList *imageList);
564 %pragma(python) addtomethod = "AssignButtonsImageList:_args[0].thisown = 0"
569 void AddColumn(const wxString& text);
570 %name(AddColumnInfo) void AddColumn(const wxTreeListColumnInfo& col);
572 // inserts a column before the given one
573 void InsertColumn(size_t before, const wxString& text);
574 %name(InsertColumnInfo) void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
576 // deletes the given column - does not delete the corresponding column
578 void RemoveColumn(size_t column);
580 // returns the number of columns in the ctrl
581 size_t GetColumnCount() const;
583 void SetColumnWidth(size_t column, size_t width);
584 int GetColumnWidth(size_t column) const;
586 // tells which column is the "main" one, i.e. the "threaded" one
587 void SetMainColumn(size_t column);
588 size_t GetMainColumn() const;
590 void SetColumnText(size_t column, const wxString& text);
591 wxString GetColumnText(size_t column) const;
593 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
594 wxTreeListColumnInfo& GetColumn(size_t column);
596 // other column-related methods
597 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
598 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
600 void SetColumnImage(size_t column, int image);
601 int GetColumnImage(size_t column) const;
605 // retrieves item's label of the given column (main column by default)
606 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
607 if (column < 0) column = self->GetMainColumn();
608 return self->GetItemText(item, column);
611 // get one of the images associated with the item (normal by default)
612 int GetItemImage(const wxTreeItemId& item, int column = -1,
613 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
614 if (column < 0) column = self->GetMainColumn();
615 return self->GetItemImage(item, column, which);
618 // set item's label (main column by default)
619 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
620 if (column < 0) column = self->GetMainColumn();
621 self->SetItemText(item, column, text);
624 // set one of the images associated with the item (normal by default)
625 // the which parameter is ignored for all columns but the main one
626 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
627 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
628 if (column < 0) column = self->GetMainColumn();
629 self->SetItemImage(item, column, image, which);
633 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
635 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
636 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
638 data = new wxPyTreeItemData();
639 data->SetId(item); // set the id
640 self->SetItemData(item, data);
645 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
646 data->SetId(item); // set the id
647 self->SetItemData(item, data);
650 // [Get|Set]PyData are short-cuts. Also made somewhat crash-proof by
651 // automatically creating data classes.
652 PyObject* GetPyData(const wxTreeItemId& item) {
653 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
655 data = new wxPyTreeItemData();
656 data->SetId(item); // set the id
657 self->SetItemData(item, data);
659 return data->GetData();
662 void SetPyData(const wxTreeItemId& item, PyObject* obj) {
663 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
665 data = new wxPyTreeItemData(obj);
666 data->SetId(item); // set the id
667 self->SetItemData(item, data);
674 // force appearance of [+] button near the item. This is useful to
675 // allow the user to expand the items which don't have any children now
676 // - but instead add them only when needed, thus minimizing memory
677 // usage and loading time.
678 void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
680 // the item will be shown in bold
681 void SetItemBold(const wxTreeItemId& item, bool bold = TRUE);
683 // set the item's text colour
684 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
686 // set the item's background colour
687 void SetItemBackgroundColour(const wxTreeItemId& item,
688 const wxColour& col);
690 // set the item's font (should be of the same height for all items)
691 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
694 bool GetItemBold(const wxTreeItemId& item) const;
695 wxColour GetItemTextColour(const wxTreeItemId& item) const;
696 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
697 wxFont GetItemFont(const wxTreeItemId& item) const;
699 // is the item visible (it might be outside the view or not expanded)?
700 bool IsVisible(const wxTreeItemId& item) const;
702 // does the item has any children?
703 bool ItemHasChildren(const wxTreeItemId& item) const;
705 // is the item expanded (only makes sense if HasChildren())?
706 bool IsExpanded(const wxTreeItemId& item) const;
708 // is this item currently selected (the same as has focus)?
709 bool IsSelected(const wxTreeItemId& item) const;
711 // is item text in bold font?
712 bool IsBold(const wxTreeItemId& item) const;
714 // if 'recursively' is FALSE, only immediate children count, otherwise
715 // the returned number is the number of all items in this branch
716 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
719 // wxTreeItemId.IsOk() will return FALSE if there is no such item
721 // get the root tree item
722 wxTreeItemId GetRootItem() const;
724 // get the item currently selected (may return NULL if no selection)
725 wxTreeItemId GetSelection() const;
727 // get the items currently selected, return the number of such item
728 //size_t GetSelections(wxArrayTreeItemIds&) const;
730 PyObject* GetSelections() {
731 wxPyBeginBlockThreads();
732 PyObject* rval = PyList_New(0);
733 wxArrayTreeItemIds array;
735 num = self->GetSelections(array);
736 for (x=0; x < num; x++) {
737 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
738 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), TRUE);
739 PyList_Append(rval, item);
741 wxPyEndBlockThreads();
747 // get the parent of this item (may return NULL if root)
748 %name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
750 // for this enumeration function you must pass in a "cookie" parameter
751 // which is opaque for the application but is necessary for the library
752 // to make these functions reentrant (i.e. allow more than one
753 // enumeration on one and the same object simultaneously). Of course,
754 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
757 // get the first child of this item
758 wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& INOUT = longzero) const;
760 // get the next child
761 wxTreeItemId GetNextChild(const wxTreeItemId& item, long& INOUT) const;
763 // get the last child of this item - this method doesn't use cookies
764 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
766 // get the next sibling of this item
767 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
769 // get the previous sibling
770 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
772 // get first visible item
773 wxTreeItemId GetFirstVisibleItem() const;
775 // get the next visible item: item must be visible itself!
776 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
777 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
779 // get the previous visible item: item must be visible itself!
780 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
782 // Only for internal use right now, but should probably be public
783 wxTreeItemId GetNext(const wxTreeItemId& item) const;
786 // add the root node to the tree
787 wxTreeItemId AddRoot(const wxString& text,
788 int image = -1, int selectedImage = -1,
789 wxPyTreeItemData *data = NULL);
791 // insert a new item in as the first child of the parent
792 wxTreeItemId PrependItem(const wxTreeItemId& parent,
793 const wxString& text,
794 int image = -1, int selectedImage = -1,
795 wxPyTreeItemData *data = NULL);
797 // insert a new item after a given one
798 wxTreeItemId InsertItem(const wxTreeItemId& parent,
799 const wxTreeItemId& idPrevious,
800 const wxString& text,
801 int image = -1, int selectedImage = -1,
802 wxPyTreeItemData *data = NULL);
804 // insert a new item before the one with the given index
805 %name(InsertItemBefore)
806 wxTreeItemId InsertItem(const wxTreeItemId& parent,
808 const wxString& text,
809 int image = -1, int selectedImage = -1,
810 wxPyTreeItemData *data = NULL);
812 // insert a new item in as the last child of the parent
813 wxTreeItemId AppendItem(const wxTreeItemId& parent,
814 const wxString& text,
815 int image = -1, int selectedImage = -1,
816 wxPyTreeItemData *data = NULL);
818 // delete this item and associated data if any
819 void Delete(const wxTreeItemId& item);
821 // delete all children (but don't delete the item itself)
822 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
823 void DeleteChildren(const wxTreeItemId& item);
825 // delete all items from the tree
826 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
827 void DeleteAllItems();
830 void Expand(const wxTreeItemId& item);
832 // expand this item and all subitems recursively
833 void ExpandAll(const wxTreeItemId& item);
835 // collapse the item without removing its children
836 void Collapse(const wxTreeItemId& item);
838 // collapse the item and remove all children
839 void CollapseAndReset(const wxTreeItemId& item);
841 // toggles the current state
842 void Toggle(const wxTreeItemId& item);
844 // remove the selection from currently selected item (if any)
849 void SelectItem(const wxTreeItemId& item, bool unselect_others=TRUE,
850 bool extended_select=FALSE);
852 // make sure this item is visible (expanding the parent item and/or
853 // scrolling to this item if necessary)
854 void EnsureVisible(const wxTreeItemId& item);
856 // scroll to this item (but don't expand its parent)
857 void ScrollTo(const wxTreeItemId& item);
859 // Returns wxTreeItemId, flags, and column
860 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
863 // get the bounding rectangle of the item (or of its label only)
864 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = FALSE) {
866 if (self->GetBoundingRect(item, rect, textOnly)) {
867 wxPyBeginBlockThreads();
868 wxRect* r = new wxRect(rect);
869 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
870 wxPyEndBlockThreads();
881 // Start editing the item label: this (temporarily) replaces the item
882 // with a one line edit control. The item will be selected if it hadn't
884 void EditLabel( const wxTreeItemId& item );
885 void Edit( const wxTreeItemId& item );
887 // sort the children of this item using OnCompareItems
888 void SortChildren(const wxTreeItemId& item);
890 // get the selected item image
891 int GetItemSelectedImage(const wxTreeItemId& item) const;
893 // set the selected item image
894 void SetItemSelectedImage(const wxTreeItemId& item, int image);
897 wxWindow* GetHeaderWindow() const;
898 wxWindow* GetMainWindow() const;
900 %pragma(python) addtoclass = "
901 # Redefine some methods that SWIG gets a bit confused on...
902 def GetFirstChild(self, *_args, **_kwargs):
903 val1,val2 = gizmosc.wxTreeListCtrl_GetFirstChild(self, *_args, **_kwargs)
904 val1 = wxTreeItemIdPtr(val1)
907 def GetNextChild(self, *_args, **_kwargs):
908 val1,val2 = gizmosc.wxTreeListCtrl_GetNextChild(self, *_args, **_kwargs)
909 val1 = wxTreeItemIdPtr(val1)
912 def HitTest(self, *_args, **_kwargs):
913 val1, val2, val3 = gizmosc.wxTreeListCtrl_HitTest(self, *_args, **_kwargs)
914 val1 = wxTreeItemIdPtr(val1)
916 return (val1, val2, val3)
923 //----------------------------------------------------------------------
924 //----------------------------------------------------------------------
928 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
929 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
933 %pragma(python) include="_gizmoextras.py";
935 //----------------------------------------------------------------------
936 //----------------------------------------------------------------------