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"
34 //---------------------------------------------------------------------------
38 %pythoncode { wx = core }
39 %pythoncode { __docfilter__ = wx.__docfilter__ }
42 MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
43 MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
44 MAKE_CONST_WXSTRING2(TreeListCtrlNameStr, wxT("treelistctrl"));
46 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
49 %include _gizmos_rename.i
51 //---------------------------------------------------------------------------
54 wxEVT_DYNAMIC_SASH_SPLIT,
55 wxEVT_DYNAMIC_SASH_UNIFY,
57 wxDS_MANAGE_SCROLLBARS,
63 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
64 whenever your view is being split by the user. It is your
65 responsibility to handle this event by creating a new view window as
66 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
67 automatically reparent it to the proper place in its window hierarchy.
69 class wxDynamicSashSplitEvent : public wxCommandEvent {
71 wxDynamicSashSplitEvent(wxObject *target);
76 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
77 whenever the sash which splits your view and its sibling is being
78 reunified such that your view is expanding to replace its sibling.
79 You needn't do anything with this event if you are allowing
80 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
81 if you are managing the scrollbars yourself so that you can keep
82 the scrollbars' event handlers connected to your view's event handler
85 class wxDynamicSashUnifyEvent : public wxCommandEvent {
87 wxDynamicSashUnifyEvent(wxObject *target);
96 wxDynamicSashWindow widgets manages the way other widgets are viewed.
97 When a wxDynamicSashWindow is first shown, it will contain one child
98 view, a viewport for that child, and a pair of scrollbars to allow the
99 user to navigate the child view area. Next to each scrollbar is a small
100 tab. By clicking on either tab and dragging to the appropriate spot, a
101 user can split the view area into two smaller views separated by a
102 draggable sash. Later, when the user wishes to reunify the two subviews,
103 the user simply drags the sash to the side of the window.
104 wxDynamicSashWindow will automatically reparent the appropriate child
105 view back up the window hierarchy, and the wxDynamicSashWindow will have
106 only one child view once again.
108 As an application developer, you will simply create a wxDynamicSashWindow
109 using either the Create() function or the more complex constructor
110 provided below, and then create a view window whose parent is the
111 wxDynamicSashWindow. The child should respond to
112 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
113 constructing a new view window whose parent is also the
114 wxDynamicSashWindow. That's it! Now your users can dynamically split
115 and reunify the view you provided.
117 If you wish to handle the scrollbar events for your view, rather than
118 allowing wxDynamicSashWindow to do it for you, things are a bit more
119 complex. (You might want to handle scrollbar events yourself, if,
120 for instance, you wish to scroll a subwindow of the view you add to
121 your wxDynamicSashWindow object, rather than scrolling the whole view.)
122 In this case, you will need to construct your wxDynamicSashWindow without
123 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
124 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
125 controls and call SetEventHanler() on them to redirect the scrolling
126 events whenever your window is reparented by wxDyanmicSashWindow.
127 You will need to set the scrollbars' event handler at three times:
129 * When your view is created
130 * When your view receives a wxDynamicSashSplitEvent
131 * When your view receives a wxDynamicSashUnifyEvent
133 See the dynsash_switch sample application for an example which does this.
137 class wxDynamicSashWindow : public wxWindow {
139 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
140 %pythonAppend wxDynamicSashWindow() ""
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(PreDynamicSashWindow)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 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
154 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
160 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
161 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
164 //---------------------------------------------------------------------------
165 //---------------------------------------------------------------------------
173 // This class provides a composite control that lets the
174 // user easily enter list of strings
175 class wxEditableListBox : public wxPanel
178 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
179 %pythonAppend wxEditableListBox() ""
181 wxEditableListBox(wxWindow *parent, wxWindowID id,
182 const wxString& label,
183 const wxPoint& pos = wxDefaultPosition,
184 const wxSize& size = wxDefaultSize,
185 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
186 const wxString& name = wxPyEditableListBoxNameStr);
189 void SetStrings(const wxArrayString& strings);
191 //void GetStrings(wxArrayString& strings);
193 PyObject* GetStrings() {
194 wxArrayString strings;
195 self->GetStrings(strings);
196 return wxArrayString2PyList_helper(strings);
200 wxListCtrl* GetListCtrl();
201 wxBitmapButton* GetDelButton();
202 wxBitmapButton* GetNewButton();
203 wxBitmapButton* GetUpButton();
204 wxBitmapButton* GetDownButton();
205 wxBitmapButton* GetEditButton();
210 //---------------------------------------------------------------------------
214 * wxRemotelyScrolledTreeCtrl
216 * This tree control disables its vertical scrollbar and catches scroll
217 * events passed by a scrolled window higher in the hierarchy.
218 * It also updates the scrolled window vertical scrollbar as appropriate.
222 typedef wxTreeCtrl wxPyTreeCtrl;
225 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
228 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
229 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
231 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
232 const wxPoint& pos = wxDefaultPosition,
233 const wxSize& size = wxDefaultSize,
234 long style = wxTR_HAS_BUTTONS);
237 void HideVScrollbar();
239 // Adjust the containing wxScrolledWindow's scrollbars appropriately
240 void AdjustRemoteScrollbars();
242 // Find the scrolled window that contains this control
243 wxScrolledWindow* GetScrolledWindow() const;
245 // Scroll to the given line (in scroll units where each unit is
246 // the height of an item)
247 void ScrollToLine(int posHoriz, int posVert);
249 // The companion window is one which will get notified when certain
250 // events happen such as node expansion
251 void SetCompanionWindow(wxWindow* companion);
252 wxWindow* GetCompanionWindow() const;
258 * wxTreeCompanionWindow
260 * A window displaying values associated with tree control items.
264 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
267 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
268 const wxPoint& pos = wxDefaultPosition,
269 const wxSize& size = wxDefaultSize,
271 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
274 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
276 bool blocked = wxPyBeginBlockThreads();
277 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
278 PyObject* dcobj = wxPyMake_wxObject(&dc);
279 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), False);
280 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), False);
281 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
286 wxPyEndBlockThreads(blocked);
288 wxTreeCompanionWindow::DrawItem(dc, id, rect);
296 %name(TreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
299 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
300 %pythonAppend wxPyTreeCompanionWindow() ""
302 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
303 const wxPoint& pos = wxDefaultPosition,
304 const wxSize& size = wxDefaultSize,
306 void _setCallbackInfo(PyObject* self, PyObject* _class);
308 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
309 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
315 * wxThinSplitterWindow
317 * Implements a splitter with a less obvious sash
318 * than the usual one.
321 class wxThinSplitterWindow: public wxSplitterWindow
324 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
325 %pythonAppend wxThinSplitterWindow() ""
327 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
328 const wxPoint& pos = wxDefaultPosition,
329 const wxSize& size = wxDefaultSize,
330 long style = wxSP_3D | wxCLIP_CHILDREN);
336 * wxSplitterScrolledWindow
338 * This scrolled window is aware of the fact that one of its
339 * children is a splitter window. It passes on its scroll events
340 * (after some processing) to both splitter children for them
341 * scroll appropriately.
344 class wxSplitterScrolledWindow: public wxScrolledWindow
347 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
348 %pythonAppend wxSplitterScrolledWindow() ""
350 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
357 //---------------------------------------------------------------------------
358 //---------------------------------------------------------------------------
373 class wxLEDNumberCtrl : public wxControl
376 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
377 %pythonAppend wxLEDNumberCtrl() ""
379 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
380 const wxPoint& pos = wxDefaultPosition,
381 const wxSize& size = wxDefaultSize,
382 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
383 %name(PreLEDNumberCtrl) wxLEDNumberCtrl();
385 bool Create(wxWindow *parent, wxWindowID id = -1,
386 const wxPoint& pos = wxDefaultPosition,
387 const wxSize& size = wxDefaultSize,
388 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
390 wxLEDValueAlign GetAlignment() const;
391 bool GetDrawFaded() const;
392 const wxString &GetValue() const;
394 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
395 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
396 void SetValue(const wxString &Value, bool Redraw = true);
402 //----------------------------------------------------------------------------
403 // wxTreeListCtrl - the multicolumn tree control
404 //----------------------------------------------------------------------------
406 enum wxTreeListColumnAlign {
415 wxTREE_HITTEST_ONITEMCOLUMN
421 class wxTreeListColumnInfo: public wxObject {
423 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
426 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
428 wxTreeListColumnAlign GetAlignment() const;
429 wxString GetText() const;
430 int GetImage() const;
431 int GetSelectedImage() const;
432 size_t GetWidth() const;
434 void SetAlignment(wxTreeListColumnAlign alignment);
435 void SetText(const wxString& text);
436 void SetImage(int image);
437 void SetSelectedImage(int image);
438 void SetWidth(size_t with);
444 %{ // C++ version of Python aware control
445 class wxPyTreeListCtrl : public wxTreeListCtrl {
446 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
448 wxPyTreeListCtrl() : wxTreeListCtrl() {}
449 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
453 const wxValidator &validator,
454 const wxString& name) :
455 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
457 int OnCompareItems(const wxTreeItemId& item1,
458 const wxTreeItemId& item2) {
461 bool blocked = wxPyBeginBlockThreads();
462 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
463 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
464 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
465 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
469 wxPyEndBlockThreads(blocked);
471 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
477 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
486 %name(TreeListCtrl) class wxPyTreeListCtrl : public wxControl
489 %pythonAppend wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
490 %pythonAppend wxPyTreeListCtrl() ""
492 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
493 const wxPoint& pos = wxDefaultPosition,
494 const wxSize& size = wxDefaultSize,
495 long style = wxTR_DEFAULT_STYLE,
496 const wxValidator &validator = wxDefaultValidator,
497 const wxString& name = wxPyTreeListCtrlNameStr );
498 %name(PreTreeListCtrl)wxPyTreeListCtrl();
500 bool Create(wxWindow *parent, wxWindowID id = -1,
501 const wxPoint& pos = wxDefaultPosition,
502 const wxSize& size = wxDefaultSize,
503 long style = wxTR_DEFAULT_STYLE,
504 const wxValidator &validator = wxDefaultValidator,
505 const wxString& name = wxPyTreeListCtrlNameStr );
507 void _setCallbackInfo(PyObject* self, PyObject* _class);
510 // get the total number of items in the control
511 size_t GetCount() const;
513 // indent is the number of pixels the children are indented relative to
514 // the parents position. SetIndent() also redraws the control
516 unsigned int GetIndent() const;
517 void SetIndent(unsigned int indent);
519 // spacing is the number of pixels between the start and the Text
520 unsigned int GetSpacing() const;
521 void SetSpacing(unsigned int spacing);
523 // line spacing is the space above and below the text on each line
524 unsigned int GetLineSpacing() const;
525 void SetLineSpacing(unsigned int spacing);
527 // image list: these functions allow to associate an image list with
528 // the control and retrieve it. Note that when assigned with
529 // SetImageList, the control does _not_ delete
530 // the associated image list when it's deleted in order to allow image
531 // lists to be shared between different controls. If you use
532 // AssignImageList, the control _does_ delete the image list.
534 // The normal image list is for the icons which correspond to the
535 // normal tree item state (whether it is selected or not).
536 // Additionally, the application might choose to show a state icon
537 // which corresponds to an app-defined item state (for example,
538 // checked/unchecked) which are taken from the state image list.
539 wxImageList *GetImageList() const;
540 wxImageList *GetStateImageList() const;
541 wxImageList *GetButtonsImageList() const;
543 void SetImageList(wxImageList *imageList);
544 void SetStateImageList(wxImageList *imageList);
545 void SetButtonsImageList(wxImageList *imageList);
547 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
548 void AssignImageList(wxImageList *imageList);
549 void AssignStateImageList(wxImageList *imageList);
550 void AssignButtonsImageList(wxImageList *imageList);
551 %clear 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);
658 %pythoncode { GetPyData = GetItemPyData }
659 %pythoncode { SetPyData = SetItemPyData }
662 // force appearance of [+] button near the item. This is useful to
663 // allow the user to expand the items which don't have any children now
664 // - but instead add them only when needed, thus minimizing memory
665 // usage and loading time.
666 void SetItemHasChildren(const wxTreeItemId& item, bool has = True);
668 // the item will be shown in bold
669 void SetItemBold(const wxTreeItemId& item, bool bold = True);
671 // set the item's text colour
672 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
674 // set the item's background colour
675 void SetItemBackgroundColour(const wxTreeItemId& item,
676 const wxColour& col);
678 // set the item's font (should be of the same height for all items)
679 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
682 bool GetItemBold(const wxTreeItemId& item) const;
683 wxColour GetItemTextColour(const wxTreeItemId& item) const;
684 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
685 wxFont GetItemFont(const wxTreeItemId& item) const;
687 // is the item visible (it might be outside the view or not expanded)?
688 bool IsVisible(const wxTreeItemId& item) const;
690 // does the item has any children?
691 bool ItemHasChildren(const wxTreeItemId& item) const;
693 // is the item expanded (only makes sense if HasChildren())?
694 bool IsExpanded(const wxTreeItemId& item) const;
696 // is this item currently selected (the same as has focus)?
697 bool IsSelected(const wxTreeItemId& item) const;
699 // is item text in bold font?
700 bool IsBold(const wxTreeItemId& item) const;
702 // if 'recursively' is False, only immediate children count, otherwise
703 // the returned number is the number of all items in this branch
704 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = True);
707 // wxTreeItemId.IsOk() will return False if there is no such item
709 // get the root tree item
710 wxTreeItemId GetRootItem() const;
712 // get the item currently selected (may return NULL if no selection)
713 wxTreeItemId GetSelection() const;
715 // get the items currently selected, return the number of such item
716 //size_t GetSelections(wxArrayTreeItemIds&) const;
718 PyObject* GetSelections() {
719 bool blocked = wxPyBeginBlockThreads();
720 PyObject* rval = PyList_New(0);
721 wxArrayTreeItemIds array;
723 num = self->GetSelections(array);
724 for (x=0; x < num; x++) {
725 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
726 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), True);
727 PyList_Append(rval, item);
729 wxPyEndBlockThreads(blocked);
735 // get the parent of this item (may return NULL if root)
736 %name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
738 // for this enumeration function you must pass in a "cookie" parameter
739 // which is opaque for the application but is necessary for the library
740 // to make these functions reentrant (i.e. allow more than one
741 // enumeration on one and the same object simultaneously). Of course,
742 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
747 // Get the first child of this item. Returns a wxTreeItemId and an
748 // opaque "cookie" value that should be passed to GetNextChild in
749 // order to continue the search.
750 PyObject* GetFirstChild(const wxTreeItemId& item) {
752 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
753 bool blocked = wxPyBeginBlockThreads();
754 PyObject* tup = PyTuple_New(2);
755 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
756 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
757 wxPyEndBlockThreads(blocked);
762 // Get the next child of this item. The cookie parameter is the 2nd
763 // value returned from GetFirstChild or the previous GetNextChild.
764 // Returns a wxTreeItemId and an opaque "cookie" value that should be
765 // passed to GetNextChild in order to continue the search.
766 PyObject* GetNextChild(const wxTreeItemId& item, long cookie) {
767 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
768 bool blocked = wxPyBeginBlockThreads();
769 PyObject* tup = PyTuple_New(2);
770 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
771 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
772 wxPyEndBlockThreads(blocked);
777 // get the last child of this item - this method doesn't use cookies
778 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
780 // get the next sibling of this item
781 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
783 // get the previous sibling
784 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
786 // get first visible item
787 wxTreeItemId GetFirstVisibleItem() const;
789 // get the next visible item: item must be visible itself!
790 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
791 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
793 // get the previous visible item: item must be visible itself!
794 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
796 // Only for internal use right now, but should probably be public
797 wxTreeItemId GetNext(const wxTreeItemId& item) const;
800 // add the root node to the tree
801 wxTreeItemId AddRoot(const wxString& text,
802 int image = -1, int selectedImage = -1,
803 wxPyTreeItemData *data = NULL);
805 // insert a new item in as the first child of the parent
806 wxTreeItemId PrependItem(const wxTreeItemId& parent,
807 const wxString& text,
808 int image = -1, int selectedImage = -1,
809 wxPyTreeItemData *data = NULL);
811 // insert a new item after a given one
812 wxTreeItemId InsertItem(const wxTreeItemId& parent,
813 const wxTreeItemId& idPrevious,
814 const wxString& text,
815 int image = -1, int selectedImage = -1,
816 wxPyTreeItemData *data = NULL);
818 // insert a new item before the one with the given index
819 %name(InsertItemBefore)
820 wxTreeItemId InsertItem(const wxTreeItemId& parent,
822 const wxString& text,
823 int image = -1, int selectedImage = -1,
824 wxPyTreeItemData *data = NULL);
826 // insert a new item in as the last child of the parent
827 wxTreeItemId AppendItem(const wxTreeItemId& parent,
828 const wxString& text,
829 int image = -1, int selectedImage = -1,
830 wxPyTreeItemData *data = NULL);
832 // delete this item and associated data if any
833 void Delete(const wxTreeItemId& item);
835 // delete all children (but don't delete the item itself)
836 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
837 void DeleteChildren(const wxTreeItemId& item);
839 // delete all items from the tree
840 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
841 void DeleteAllItems();
844 void Expand(const wxTreeItemId& item);
846 // expand this item and all subitems recursively
847 void ExpandAll(const wxTreeItemId& item);
849 // collapse the item without removing its children
850 void Collapse(const wxTreeItemId& item);
852 // collapse the item and remove all children
853 void CollapseAndReset(const wxTreeItemId& item);
855 // toggles the current state
856 void Toggle(const wxTreeItemId& item);
858 // remove the selection from currently selected item (if any)
863 void SelectItem(const wxTreeItemId& item, bool unselect_others=True,
864 bool extended_select=False);
866 // make sure this item is visible (expanding the parent item and/or
867 // scrolling to this item if necessary)
868 void EnsureVisible(const wxTreeItemId& item);
870 // scroll to this item (but don't expand its parent)
871 void ScrollTo(const wxTreeItemId& item);
873 // Returns wxTreeItemId, flags, and column
874 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
877 // get the bounding rectangle of the item (or of its label only)
878 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = False) {
880 if (self->GetBoundingRect(item, rect, textOnly)) {
881 bool blocked = wxPyBeginBlockThreads();
882 wxRect* r = new wxRect(rect);
883 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
884 wxPyEndBlockThreads(blocked);
894 // Start editing the item label: this (temporarily) replaces the item
895 // with a one line edit control. The item will be selected if it hadn't
897 void EditLabel( const wxTreeItemId& item );
898 void Edit( const wxTreeItemId& item );
900 // sort the children of this item using OnCompareItems
901 void SortChildren(const wxTreeItemId& item);
903 // get the selected item image
904 int GetItemSelectedImage(const wxTreeItemId& item) const;
906 // set the selected item image
907 void SetItemSelectedImage(const wxTreeItemId& item, int image);
910 wxWindow* GetHeaderWindow() const;
911 wxWindow* GetMainWindow() const;
918 //----------------------------------------------------------------------
919 //----------------------------------------------------------------------
923 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
924 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
928 %pragma(python) include="_gizmoextras.py";
930 //----------------------------------------------------------------------
931 //----------------------------------------------------------------------