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 /////////////////////////////////////////////////////////////////////////////
17 #include "wx/wxPython/wxPython.h"
18 #include "wx/wxPython/pyclasses.h"
20 #include <wx/gizmos/dynamicsash.h>
21 #include <wx/gizmos/editlbox.h>
22 #include <wx/gizmos/splittree.h>
23 #include <wx/gizmos/ledctrl.h>
25 #include <wx/listctrl.h>
26 #include <wx/treectrl.h>
27 #include <wx/imaglist.h>
29 #include "treelistctrl.h"
30 #include "wx/wxPython/pytree.h"
33 static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow"));
34 static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox"));
35 static const wxString wxPyTreeListCtrlNameStr(wxT("treelistctrl"));
36 static const wxString wxPyEmptyString(wxT(""));
39 //---------------------------------------------------------------------------
43 %pythoncode { wx = core }
45 %include _gizmos_rename.i
47 //---------------------------------------------------------------------------
50 wxEVT_DYNAMIC_SASH_SPLIT,
51 wxEVT_DYNAMIC_SASH_UNIFY,
53 wxDS_MANAGE_SCROLLBARS,
59 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
60 whenever your view is being split by the user. It is your
61 responsibility to handle this event by creating a new view window as
62 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
63 automatically reparent it to the proper place in its window hierarchy.
65 class wxDynamicSashSplitEvent : public wxCommandEvent {
67 wxDynamicSashSplitEvent(wxObject *target);
72 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
73 whenever the sash which splits your view and its sibling is being
74 reunified such that your view is expanding to replace its sibling.
75 You needn't do anything with this event if you are allowing
76 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
77 if you are managing the scrollbars yourself so that you can keep
78 the scrollbars' event handlers connected to your view's event handler
81 class wxDynamicSashUnifyEvent : public wxCommandEvent {
83 wxDynamicSashUnifyEvent(wxObject *target);
92 wxDynamicSashWindow widgets manages the way other widgets are viewed.
93 When a wxDynamicSashWindow is first shown, it will contain one child
94 view, a viewport for that child, and a pair of scrollbars to allow the
95 user to navigate the child view area. Next to each scrollbar is a small
96 tab. By clicking on either tab and dragging to the appropriate spot, a
97 user can split the view area into two smaller views separated by a
98 draggable sash. Later, when the user wishes to reunify the two subviews,
99 the user simply drags the sash to the side of the window.
100 wxDynamicSashWindow will automatically reparent the appropriate child
101 view back up the window hierarchy, and the wxDynamicSashWindow will have
102 only one child view once again.
104 As an application developer, you will simply create a wxDynamicSashWindow
105 using either the Create() function or the more complex constructor
106 provided below, and then create a view window whose parent is the
107 wxDynamicSashWindow. The child should respond to
108 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
109 constructing a new view window whose parent is also the
110 wxDynamicSashWindow. That's it! Now your users can dynamically split
111 and reunify the view you provided.
113 If you wish to handle the scrollbar events for your view, rather than
114 allowing wxDynamicSashWindow to do it for you, things are a bit more
115 complex. (You might want to handle scrollbar events yourself, if,
116 for instance, you wish to scroll a subwindow of the view you add to
117 your wxDynamicSashWindow object, rather than scrolling the whole view.)
118 In this case, you will need to construct your wxDynamicSashWindow without
119 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
120 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
121 controls and call SetEventHanler() on them to redirect the scrolling
122 events whenever your window is reparented by wxDyanmicSashWindow.
123 You will need to set the scrollbars' event handler at three times:
125 * When your view is created
126 * When your view receives a wxDynamicSashSplitEvent
127 * When your view receives a wxDynamicSashUnifyEvent
129 See the dynsash_switch sample application for an example which does this.
133 class wxDynamicSashWindow : public wxWindow {
135 %addtofunc wxDynamicSashWindow "self._setOORInfo(self)"
136 %addtofunc wxDynamicSashWindow() ""
138 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
139 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
140 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
141 const wxString& name = wxPyDynamicSashNameStr);
142 %name(PreDynamicSashWindow)wxDynamicSashWindow();
144 bool Create(wxWindow *parent, wxWindowID id,
145 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
146 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
147 const wxString& name = wxPyDynamicSashNameStr);
149 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
150 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
156 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
157 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
160 //---------------------------------------------------------------------------
161 //---------------------------------------------------------------------------
169 // This class provides a composite control that lets the
170 // user easily enter list of strings
171 class wxEditableListBox : public wxPanel
174 %addtofunc wxEditableListBox "self._setOORInfo(self)"
175 %addtofunc wxEditableListBox() ""
177 wxEditableListBox(wxWindow *parent, wxWindowID id,
178 const wxString& label,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
182 const wxString& name = wxPyEditableListBoxNameStr);
185 void SetStrings(const wxArrayString& strings);
187 //void GetStrings(wxArrayString& strings);
189 PyObject* GetStrings() {
190 wxArrayString strings;
191 self->GetStrings(strings);
192 return wxArrayString2PyList_helper(strings);
196 wxListCtrl* GetListCtrl();
197 wxBitmapButton* GetDelButton();
198 wxBitmapButton* GetNewButton();
199 wxBitmapButton* GetUpButton();
200 wxBitmapButton* GetDownButton();
201 wxBitmapButton* GetEditButton();
206 //---------------------------------------------------------------------------
210 * wxRemotelyScrolledTreeCtrl
212 * This tree control disables its vertical scrollbar and catches scroll
213 * events passed by a scrolled window higher in the hierarchy.
214 * It also updates the scrolled window vertical scrollbar as appropriate.
218 typedef wxTreeCtrl wxPyTreeCtrl;
221 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
224 %addtofunc wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
225 %addtofunc wxRemotelyScrolledTreeCtrl() ""
227 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
228 const wxPoint& pos = wxDefaultPosition,
229 const wxSize& size = wxDefaultSize,
230 long style = wxTR_HAS_BUTTONS);
233 void HideVScrollbar();
235 // Adjust the containing wxScrolledWindow's scrollbars appropriately
236 void AdjustRemoteScrollbars();
238 // Find the scrolled window that contains this control
239 wxScrolledWindow* GetScrolledWindow() const;
241 // Scroll to the given line (in scroll units where each unit is
242 // the height of an item)
243 void ScrollToLine(int posHoriz, int posVert);
245 // The companion window is one which will get notified when certain
246 // events happen such as node expansion
247 void SetCompanionWindow(wxWindow* companion);
248 wxWindow* GetCompanionWindow() const;
254 * wxTreeCompanionWindow
256 * A window displaying values associated with tree control items.
260 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
263 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
264 const wxPoint& pos = wxDefaultPosition,
265 const wxSize& size = wxDefaultSize,
267 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
270 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
272 wxPyBeginBlockThreads();
273 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
274 PyObject* dcobj = wxPyMake_wxObject(&dc);
275 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), False);
276 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), False);
277 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
282 wxPyEndBlockThreads();
284 wxTreeCompanionWindow::DrawItem(dc, id, rect);
292 %name(TreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
295 %addtofunc wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
296 %addtofunc wxPyTreeCompanionWindow() ""
298 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
299 const wxPoint& pos = wxDefaultPosition,
300 const wxSize& size = wxDefaultSize,
302 void _setCallbackInfo(PyObject* self, PyObject* _class);
304 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
305 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
311 * wxThinSplitterWindow
313 * Implements a splitter with a less obvious sash
314 * than the usual one.
317 class wxThinSplitterWindow: public wxSplitterWindow
320 %addtofunc wxThinSplitterWindow "self._setOORInfo(self)"
321 %addtofunc wxThinSplitterWindow() ""
323 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
324 const wxPoint& pos = wxDefaultPosition,
325 const wxSize& size = wxDefaultSize,
326 long style = wxSP_3D | wxCLIP_CHILDREN);
332 * wxSplitterScrolledWindow
334 * This scrolled window is aware of the fact that one of its
335 * children is a splitter window. It passes on its scroll events
336 * (after some processing) to both splitter children for them
337 * scroll appropriately.
340 class wxSplitterScrolledWindow: public wxScrolledWindow
343 %addtofunc wxSplitterScrolledWindow "self._setOORInfo(self)"
344 %addtofunc wxSplitterScrolledWindow() ""
346 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
347 const wxPoint& pos = wxDefaultPosition,
348 const wxSize& size = wxDefaultSize,
353 //---------------------------------------------------------------------------
354 //---------------------------------------------------------------------------
369 class wxLEDNumberCtrl : public wxControl
372 %addtofunc wxLEDNumberCtrl "self._setOORInfo(self)"
373 %addtofunc wxLEDNumberCtrl() ""
375 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
376 const wxPoint& pos = wxDefaultPosition,
377 const wxSize& size = wxDefaultSize,
378 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
379 %name(PreLEDNumberCtrl) wxLEDNumberCtrl();
381 bool Create(wxWindow *parent, wxWindowID id = -1,
382 const wxPoint& pos = wxDefaultPosition,
383 const wxSize& size = wxDefaultSize,
384 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
386 wxLEDValueAlign GetAlignment() const;
387 bool GetDrawFaded() const;
388 const wxString &GetValue() const;
390 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
391 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
392 void SetValue(const wxString &Value, bool Redraw = true);
398 //----------------------------------------------------------------------------
399 // wxTreeListCtrl - the multicolumn tree control
400 //----------------------------------------------------------------------------
402 enum wxTreeListColumnAlign {
411 wxTREE_HITTEST_ONITEMCOLUMN
417 class wxTreeListColumnInfo: public wxObject {
419 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
422 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
424 wxTreeListColumnAlign GetAlignment() const;
425 wxString GetText() const;
426 int GetImage() const;
427 int GetSelectedImage() const;
428 size_t GetWidth() const;
430 void SetAlignment(wxTreeListColumnAlign alignment);
431 void SetText(const wxString& text);
432 void SetImage(int image);
433 void SetSelectedImage(int image);
434 void SetWidth(size_t with);
440 %{ // C++ version of Python aware control
441 class wxPyTreeListCtrl : public wxTreeListCtrl {
442 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
444 wxPyTreeListCtrl() : wxTreeListCtrl() {}
445 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
449 const wxValidator &validator,
450 const wxString& name) :
451 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
453 int OnCompareItems(const wxTreeItemId& item1,
454 const wxTreeItemId& item2) {
457 wxPyBeginBlockThreads();
458 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
459 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
460 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
461 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
465 wxPyEndBlockThreads();
467 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
473 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
482 %name(TreeListCtrl) class wxPyTreeListCtrl : public wxControl
485 %addtofunc wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
486 %addtofunc wxPyTreeListCtrl() ""
488 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
489 const wxPoint& pos = wxDefaultPosition,
490 const wxSize& size = wxDefaultSize,
491 long style = wxTR_DEFAULT_STYLE,
492 const wxValidator &validator = wxDefaultValidator,
493 const wxString& name = wxPyTreeListCtrlNameStr );
494 %name(PreTreeListCtrl)wxPyTreeListCtrl();
496 bool Create(wxWindow *parent, wxWindowID id = -1,
497 const wxPoint& pos = wxDefaultPosition,
498 const wxSize& size = wxDefaultSize,
499 long style = wxTR_DEFAULT_STYLE,
500 const wxValidator &validator = wxDefaultValidator,
501 const wxString& name = wxPyTreeListCtrlNameStr );
503 void _setCallbackInfo(PyObject* self, PyObject* _class);
506 // get the total number of items in the control
507 size_t GetCount() const;
509 // indent is the number of pixels the children are indented relative to
510 // the parents position. SetIndent() also redraws the control
512 unsigned int GetIndent() const;
513 void SetIndent(unsigned int indent);
515 // spacing is the number of pixels between the start and the Text
516 unsigned int GetSpacing() const;
517 void SetSpacing(unsigned int spacing);
519 // line spacing is the space above and below the text on each line
520 unsigned int GetLineSpacing() const;
521 void SetLineSpacing(unsigned int spacing);
523 // image list: these functions allow to associate an image list with
524 // the control and retrieve it. Note that when assigned with
525 // SetImageList, the control does _not_ delete
526 // the associated image list when it's deleted in order to allow image
527 // lists to be shared between different controls. If you use
528 // AssignImageList, the control _does_ delete the image list.
530 // The normal image list is for the icons which correspond to the
531 // normal tree item state (whether it is selected or not).
532 // Additionally, the application might choose to show a state icon
533 // which corresponds to an app-defined item state (for example,
534 // checked/unchecked) which are taken from the state image list.
535 wxImageList *GetImageList() const;
536 wxImageList *GetStateImageList() const;
537 wxImageList *GetButtonsImageList() const;
539 void SetImageList(wxImageList *imageList);
540 void SetStateImageList(wxImageList *imageList);
541 void SetButtonsImageList(wxImageList *imageList);
543 %addtofunc AssignImageList "args[1].thisown = 0";
544 void AssignImageList(wxImageList *imageList);
546 %addtofunc AssignStateImageList "args[1].thisown = 0";
547 void AssignStateImageList(wxImageList *imageList);
549 %addtofunc AssignButtonsImageList "args[1].thisown = 0";
550 void AssignButtonsImageList(wxImageList *imageList);
555 void AddColumn(const wxString& text);
556 %name(AddColumnInfo) void AddColumn(const wxTreeListColumnInfo& col);
558 // inserts a column before the given one
559 void InsertColumn(size_t before, const wxString& text);
560 %name(InsertColumnInfo) void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
562 // deletes the given column - does not delete the corresponding column
564 void RemoveColumn(size_t column);
566 // returns the number of columns in the ctrl
567 size_t GetColumnCount() const;
569 void SetColumnWidth(size_t column, size_t width);
570 int GetColumnWidth(size_t column) const;
572 // tells which column is the "main" one, i.e. the "threaded" one
573 void SetMainColumn(size_t column);
574 size_t GetMainColumn() const;
576 void SetColumnText(size_t column, const wxString& text);
577 wxString GetColumnText(size_t column) const;
579 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
580 wxTreeListColumnInfo& GetColumn(size_t column);
582 // other column-related methods
583 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
584 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
586 void SetColumnImage(size_t column, int image);
587 int GetColumnImage(size_t column) const;
591 // retrieves item's label of the given column (main column by default)
592 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
593 if (column < 0) column = self->GetMainColumn();
594 return self->GetItemText(item, column);
597 // get one of the images associated with the item (normal by default)
598 int GetItemImage(const wxTreeItemId& item, int column = -1,
599 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
600 if (column < 0) column = self->GetMainColumn();
601 return self->GetItemImage(item, column, which);
604 // set item's label (main column by default)
605 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
606 if (column < 0) column = self->GetMainColumn();
607 self->SetItemText(item, column, text);
610 // set one of the images associated with the item (normal by default)
611 // the which parameter is ignored for all columns but the main one
612 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
613 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
614 if (column < 0) column = self->GetMainColumn();
615 self->SetItemImage(item, column, image, which);
619 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
621 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
622 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
624 data = new wxPyTreeItemData();
625 data->SetId(item); // set the id
626 self->SetItemData(item, data);
631 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
632 data->SetId(item); // set the id
633 self->SetItemData(item, data);
636 // [Get|Set]ItemPyData are short-cuts. Also made somewhat crash-proof by
637 // automatically creating data classes.
638 PyObject* GetItemPyData(const wxTreeItemId& item) {
639 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
641 data = new wxPyTreeItemData();
642 data->SetId(item); // set the id
643 self->SetItemData(item, data);
645 return data->GetData();
648 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
649 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
651 data = new wxPyTreeItemData(obj);
652 data->SetId(item); // set the id
653 self->SetItemData(item, data);
660 // force appearance of [+] button near the item. This is useful to
661 // allow the user to expand the items which don't have any children now
662 // - but instead add them only when needed, thus minimizing memory
663 // usage and loading time.
664 void SetItemHasChildren(const wxTreeItemId& item, bool has = True);
666 // the item will be shown in bold
667 void SetItemBold(const wxTreeItemId& item, bool bold = True);
669 // set the item's text colour
670 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
672 // set the item's background colour
673 void SetItemBackgroundColour(const wxTreeItemId& item,
674 const wxColour& col);
676 // set the item's font (should be of the same height for all items)
677 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
680 bool GetItemBold(const wxTreeItemId& item) const;
681 wxColour GetItemTextColour(const wxTreeItemId& item) const;
682 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
683 wxFont GetItemFont(const wxTreeItemId& item) const;
685 // is the item visible (it might be outside the view or not expanded)?
686 bool IsVisible(const wxTreeItemId& item) const;
688 // does the item has any children?
689 bool ItemHasChildren(const wxTreeItemId& item) const;
691 // is the item expanded (only makes sense if HasChildren())?
692 bool IsExpanded(const wxTreeItemId& item) const;
694 // is this item currently selected (the same as has focus)?
695 bool IsSelected(const wxTreeItemId& item) const;
697 // is item text in bold font?
698 bool IsBold(const wxTreeItemId& item) const;
700 // if 'recursively' is False, only immediate children count, otherwise
701 // the returned number is the number of all items in this branch
702 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = True);
705 // wxTreeItemId.IsOk() will return False if there is no such item
707 // get the root tree item
708 wxTreeItemId GetRootItem() const;
710 // get the item currently selected (may return NULL if no selection)
711 wxTreeItemId GetSelection() const;
713 // get the items currently selected, return the number of such item
714 //size_t GetSelections(wxArrayTreeItemIds&) const;
716 PyObject* GetSelections() {
717 wxPyBeginBlockThreads();
718 PyObject* rval = PyList_New(0);
719 wxArrayTreeItemIds array;
721 num = self->GetSelections(array);
722 for (x=0; x < num; x++) {
723 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
724 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), True);
725 PyList_Append(rval, item);
727 wxPyEndBlockThreads();
733 // get the parent of this item (may return NULL if root)
734 %name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
736 // for this enumeration function you must pass in a "cookie" parameter
737 // which is opaque for the application but is necessary for the library
738 // to make these functions reentrant (i.e. allow more than one
739 // enumeration on one and the same object simultaneously). Of course,
740 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
745 // Get the first child of this item. Returns a wxTreeItemId and an
746 // opaque "cookie" value that should be passed to GetNextChild in
747 // order to continue the search.
748 PyObject* GetFirstChild(const wxTreeItemId& item) {
750 wxTreeItemId ritem = self->GetFirstChild(item, cookie);
751 wxPyBeginBlockThreads();
752 PyObject* tup = PyTuple_New(2);
753 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(&ritem, wxT("wxTreeItemId"), true));
754 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
755 wxPyEndBlockThreads();
760 // Get the next child of this item. The cookie parameter is the 2nd
761 // value returned from GetFirstChild or the previous GetNextChild.
762 // Returns a wxTreeItemId and an opaque "cookie" value that should be
763 // passed to GetNextChild in order to continue the search.
764 PyObject* GetNextChild(const wxTreeItemId& item, long cookie) {
765 wxTreeItemId ritem = self->GetNextChild(item, cookie);
766 wxPyBeginBlockThreads();
767 PyObject* tup = PyTuple_New(2);
768 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(&ritem, wxT("wxTreeItemId"), true));
769 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
770 wxPyEndBlockThreads();
775 // get the last child of this item - this method doesn't use cookies
776 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
778 // get the next sibling of this item
779 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
781 // get the previous sibling
782 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
784 // get first visible item
785 wxTreeItemId GetFirstVisibleItem() const;
787 // get the next visible item: item must be visible itself!
788 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
789 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
791 // get the previous visible item: item must be visible itself!
792 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
794 // Only for internal use right now, but should probably be public
795 wxTreeItemId GetNext(const wxTreeItemId& item) const;
798 // add the root node to the tree
799 wxTreeItemId AddRoot(const wxString& text,
800 int image = -1, int selectedImage = -1,
801 wxPyTreeItemData *data = NULL);
803 // insert a new item in as the first child of the parent
804 wxTreeItemId PrependItem(const wxTreeItemId& parent,
805 const wxString& text,
806 int image = -1, int selectedImage = -1,
807 wxPyTreeItemData *data = NULL);
809 // insert a new item after a given one
810 wxTreeItemId InsertItem(const wxTreeItemId& parent,
811 const wxTreeItemId& idPrevious,
812 const wxString& text,
813 int image = -1, int selectedImage = -1,
814 wxPyTreeItemData *data = NULL);
816 // insert a new item before the one with the given index
817 %name(InsertItemBefore)
818 wxTreeItemId InsertItem(const wxTreeItemId& parent,
820 const wxString& text,
821 int image = -1, int selectedImage = -1,
822 wxPyTreeItemData *data = NULL);
824 // insert a new item in as the last child of the parent
825 wxTreeItemId AppendItem(const wxTreeItemId& parent,
826 const wxString& text,
827 int image = -1, int selectedImage = -1,
828 wxPyTreeItemData *data = NULL);
830 // delete this item and associated data if any
831 void Delete(const wxTreeItemId& item);
833 // delete all children (but don't delete the item itself)
834 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
835 void DeleteChildren(const wxTreeItemId& item);
837 // delete all items from the tree
838 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
839 void DeleteAllItems();
842 void Expand(const wxTreeItemId& item);
844 // expand this item and all subitems recursively
845 void ExpandAll(const wxTreeItemId& item);
847 // collapse the item without removing its children
848 void Collapse(const wxTreeItemId& item);
850 // collapse the item and remove all children
851 void CollapseAndReset(const wxTreeItemId& item);
853 // toggles the current state
854 void Toggle(const wxTreeItemId& item);
856 // remove the selection from currently selected item (if any)
861 void SelectItem(const wxTreeItemId& item, bool unselect_others=True,
862 bool extended_select=False);
864 // make sure this item is visible (expanding the parent item and/or
865 // scrolling to this item if necessary)
866 void EnsureVisible(const wxTreeItemId& item);
868 // scroll to this item (but don't expand its parent)
869 void ScrollTo(const wxTreeItemId& item);
871 // Returns wxTreeItemId, flags, and column
872 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
875 // get the bounding rectangle of the item (or of its label only)
876 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = False) {
878 if (self->GetBoundingRect(item, rect, textOnly)) {
879 wxPyBeginBlockThreads();
880 wxRect* r = new wxRect(rect);
881 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
882 wxPyEndBlockThreads();
892 // Start editing the item label: this (temporarily) replaces the item
893 // with a one line edit control. The item will be selected if it hadn't
895 void EditLabel( const wxTreeItemId& item );
896 void Edit( const wxTreeItemId& item );
898 // sort the children of this item using OnCompareItems
899 void SortChildren(const wxTreeItemId& item);
901 // get the selected item image
902 int GetItemSelectedImage(const wxTreeItemId& item) const;
904 // set the selected item image
905 void SetItemSelectedImage(const wxTreeItemId& item, int image);
908 wxWindow* GetHeaderWindow() const;
909 wxWindow* GetMainWindow() const;
916 //----------------------------------------------------------------------
917 //----------------------------------------------------------------------
921 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
922 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
926 %pragma(python) include="_gizmoextras.py";
928 //----------------------------------------------------------------------
929 //----------------------------------------------------------------------