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 }
41 MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
42 MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
43 MAKE_CONST_WXSTRING2(TreeListCtrlNameStr, wxT("treelistctrl"));
45 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
48 %include _gizmos_rename.i
50 //---------------------------------------------------------------------------
53 wxEVT_DYNAMIC_SASH_SPLIT,
54 wxEVT_DYNAMIC_SASH_UNIFY,
56 wxDS_MANAGE_SCROLLBARS,
62 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
63 whenever your view is being split by the user. It is your
64 responsibility to handle this event by creating a new view window as
65 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
66 automatically reparent it to the proper place in its window hierarchy.
68 class wxDynamicSashSplitEvent : public wxCommandEvent {
70 wxDynamicSashSplitEvent(wxObject *target);
75 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
76 whenever the sash which splits your view and its sibling is being
77 reunified such that your view is expanding to replace its sibling.
78 You needn't do anything with this event if you are allowing
79 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
80 if you are managing the scrollbars yourself so that you can keep
81 the scrollbars' event handlers connected to your view's event handler
84 class wxDynamicSashUnifyEvent : public wxCommandEvent {
86 wxDynamicSashUnifyEvent(wxObject *target);
95 wxDynamicSashWindow widgets manages the way other widgets are viewed.
96 When a wxDynamicSashWindow is first shown, it will contain one child
97 view, a viewport for that child, and a pair of scrollbars to allow the
98 user to navigate the child view area. Next to each scrollbar is a small
99 tab. By clicking on either tab and dragging to the appropriate spot, a
100 user can split the view area into two smaller views separated by a
101 draggable sash. Later, when the user wishes to reunify the two subviews,
102 the user simply drags the sash to the side of the window.
103 wxDynamicSashWindow will automatically reparent the appropriate child
104 view back up the window hierarchy, and the wxDynamicSashWindow will have
105 only one child view once again.
107 As an application developer, you will simply create a wxDynamicSashWindow
108 using either the Create() function or the more complex constructor
109 provided below, and then create a view window whose parent is the
110 wxDynamicSashWindow. The child should respond to
111 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
112 constructing a new view window whose parent is also the
113 wxDynamicSashWindow. That's it! Now your users can dynamically split
114 and reunify the view you provided.
116 If you wish to handle the scrollbar events for your view, rather than
117 allowing wxDynamicSashWindow to do it for you, things are a bit more
118 complex. (You might want to handle scrollbar events yourself, if,
119 for instance, you wish to scroll a subwindow of the view you add to
120 your wxDynamicSashWindow object, rather than scrolling the whole view.)
121 In this case, you will need to construct your wxDynamicSashWindow without
122 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
123 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
124 controls and call SetEventHanler() on them to redirect the scrolling
125 events whenever your window is reparented by wxDyanmicSashWindow.
126 You will need to set the scrollbars' event handler at three times:
128 * When your view is created
129 * When your view receives a wxDynamicSashSplitEvent
130 * When your view receives a wxDynamicSashUnifyEvent
132 See the dynsash_switch sample application for an example which does this.
136 class wxDynamicSashWindow : public wxWindow {
138 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
139 %pythonAppend wxDynamicSashWindow() ""
141 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
142 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
143 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
144 const wxString& name = wxPyDynamicSashNameStr);
145 %name(PreDynamicSashWindow)wxDynamicSashWindow();
147 bool Create(wxWindow *parent, wxWindowID id,
148 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
149 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
150 const wxString& name = wxPyDynamicSashNameStr);
152 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
153 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
159 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
160 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
163 //---------------------------------------------------------------------------
164 //---------------------------------------------------------------------------
172 // This class provides a composite control that lets the
173 // user easily enter list of strings
174 class wxEditableListBox : public wxPanel
177 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
178 %pythonAppend wxEditableListBox() ""
180 wxEditableListBox(wxWindow *parent, wxWindowID id,
181 const wxString& label,
182 const wxPoint& pos = wxDefaultPosition,
183 const wxSize& size = wxDefaultSize,
184 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
185 const wxString& name = wxPyEditableListBoxNameStr);
188 void SetStrings(const wxArrayString& strings);
190 //void GetStrings(wxArrayString& strings);
192 PyObject* GetStrings() {
193 wxArrayString strings;
194 self->GetStrings(strings);
195 return wxArrayString2PyList_helper(strings);
199 wxListCtrl* GetListCtrl();
200 wxBitmapButton* GetDelButton();
201 wxBitmapButton* GetNewButton();
202 wxBitmapButton* GetUpButton();
203 wxBitmapButton* GetDownButton();
204 wxBitmapButton* GetEditButton();
209 //---------------------------------------------------------------------------
213 * wxRemotelyScrolledTreeCtrl
215 * This tree control disables its vertical scrollbar and catches scroll
216 * events passed by a scrolled window higher in the hierarchy.
217 * It also updates the scrolled window vertical scrollbar as appropriate.
221 typedef wxTreeCtrl wxPyTreeCtrl;
224 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
227 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
228 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
230 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
231 const wxPoint& pos = wxDefaultPosition,
232 const wxSize& size = wxDefaultSize,
233 long style = wxTR_HAS_BUTTONS);
236 void HideVScrollbar();
238 // Adjust the containing wxScrolledWindow's scrollbars appropriately
239 void AdjustRemoteScrollbars();
241 // Find the scrolled window that contains this control
242 wxScrolledWindow* GetScrolledWindow() const;
244 // Scroll to the given line (in scroll units where each unit is
245 // the height of an item)
246 void ScrollToLine(int posHoriz, int posVert);
248 // The companion window is one which will get notified when certain
249 // events happen such as node expansion
250 void SetCompanionWindow(wxWindow* companion);
251 wxWindow* GetCompanionWindow() const;
257 * wxTreeCompanionWindow
259 * A window displaying values associated with tree control items.
263 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
266 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
267 const wxPoint& pos = wxDefaultPosition,
268 const wxSize& size = wxDefaultSize,
270 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
273 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
275 wxPyBeginBlockThreads();
276 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
277 PyObject* dcobj = wxPyMake_wxObject(&dc);
278 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), False);
279 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), False);
280 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
285 wxPyEndBlockThreads();
287 wxTreeCompanionWindow::DrawItem(dc, id, rect);
295 %name(TreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
298 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
299 %pythonAppend wxPyTreeCompanionWindow() ""
301 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
302 const wxPoint& pos = wxDefaultPosition,
303 const wxSize& size = wxDefaultSize,
305 void _setCallbackInfo(PyObject* self, PyObject* _class);
307 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
308 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
314 * wxThinSplitterWindow
316 * Implements a splitter with a less obvious sash
317 * than the usual one.
320 class wxThinSplitterWindow: public wxSplitterWindow
323 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
324 %pythonAppend wxThinSplitterWindow() ""
326 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
327 const wxPoint& pos = wxDefaultPosition,
328 const wxSize& size = wxDefaultSize,
329 long style = wxSP_3D | wxCLIP_CHILDREN);
335 * wxSplitterScrolledWindow
337 * This scrolled window is aware of the fact that one of its
338 * children is a splitter window. It passes on its scroll events
339 * (after some processing) to both splitter children for them
340 * scroll appropriately.
343 class wxSplitterScrolledWindow: public wxScrolledWindow
346 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
347 %pythonAppend wxSplitterScrolledWindow() ""
349 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
350 const wxPoint& pos = wxDefaultPosition,
351 const wxSize& size = wxDefaultSize,
356 //---------------------------------------------------------------------------
357 //---------------------------------------------------------------------------
372 class wxLEDNumberCtrl : public wxControl
375 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
376 %pythonAppend wxLEDNumberCtrl() ""
378 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
379 const wxPoint& pos = wxDefaultPosition,
380 const wxSize& size = wxDefaultSize,
381 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
382 %name(PreLEDNumberCtrl) wxLEDNumberCtrl();
384 bool Create(wxWindow *parent, wxWindowID id = -1,
385 const wxPoint& pos = wxDefaultPosition,
386 const wxSize& size = wxDefaultSize,
387 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
389 wxLEDValueAlign GetAlignment() const;
390 bool GetDrawFaded() const;
391 const wxString &GetValue() const;
393 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
394 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
395 void SetValue(const wxString &Value, bool Redraw = true);
401 //----------------------------------------------------------------------------
402 // wxTreeListCtrl - the multicolumn tree control
403 //----------------------------------------------------------------------------
405 enum wxTreeListColumnAlign {
414 wxTREE_HITTEST_ONITEMCOLUMN
420 class wxTreeListColumnInfo: public wxObject {
422 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
425 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
427 wxTreeListColumnAlign GetAlignment() const;
428 wxString GetText() const;
429 int GetImage() const;
430 int GetSelectedImage() const;
431 size_t GetWidth() const;
433 void SetAlignment(wxTreeListColumnAlign alignment);
434 void SetText(const wxString& text);
435 void SetImage(int image);
436 void SetSelectedImage(int image);
437 void SetWidth(size_t with);
443 %{ // C++ version of Python aware control
444 class wxPyTreeListCtrl : public wxTreeListCtrl {
445 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
447 wxPyTreeListCtrl() : wxTreeListCtrl() {}
448 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
452 const wxValidator &validator,
453 const wxString& name) :
454 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
456 int OnCompareItems(const wxTreeItemId& item1,
457 const wxTreeItemId& item2) {
460 wxPyBeginBlockThreads();
461 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
462 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
463 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
464 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
468 wxPyEndBlockThreads();
470 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
476 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
485 %name(TreeListCtrl) class wxPyTreeListCtrl : public wxControl
488 %pythonAppend wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
489 %pythonAppend wxPyTreeListCtrl() ""
491 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
492 const wxPoint& pos = wxDefaultPosition,
493 const wxSize& size = wxDefaultSize,
494 long style = wxTR_DEFAULT_STYLE,
495 const wxValidator &validator = wxDefaultValidator,
496 const wxString& name = wxPyTreeListCtrlNameStr );
497 %name(PreTreeListCtrl)wxPyTreeListCtrl();
499 bool Create(wxWindow *parent, wxWindowID id = -1,
500 const wxPoint& pos = wxDefaultPosition,
501 const wxSize& size = wxDefaultSize,
502 long style = wxTR_DEFAULT_STYLE,
503 const wxValidator &validator = wxDefaultValidator,
504 const wxString& name = wxPyTreeListCtrlNameStr );
506 void _setCallbackInfo(PyObject* self, PyObject* _class);
509 // get the total number of items in the control
510 size_t GetCount() const;
512 // indent is the number of pixels the children are indented relative to
513 // the parents position. SetIndent() also redraws the control
515 unsigned int GetIndent() const;
516 void SetIndent(unsigned int indent);
518 // spacing is the number of pixels between the start and the Text
519 unsigned int GetSpacing() const;
520 void SetSpacing(unsigned int spacing);
522 // line spacing is the space above and below the text on each line
523 unsigned int GetLineSpacing() const;
524 void SetLineSpacing(unsigned int spacing);
526 // image list: these functions allow to associate an image list with
527 // the control and retrieve it. Note that when assigned with
528 // SetImageList, the control does _not_ delete
529 // the associated image list when it's deleted in order to allow image
530 // lists to be shared between different controls. If you use
531 // AssignImageList, the control _does_ delete the image list.
533 // The normal image list is for the icons which correspond to the
534 // normal tree item state (whether it is selected or not).
535 // Additionally, the application might choose to show a state icon
536 // which corresponds to an app-defined item state (for example,
537 // checked/unchecked) which are taken from the state image list.
538 wxImageList *GetImageList() const;
539 wxImageList *GetStateImageList() const;
540 wxImageList *GetButtonsImageList() const;
542 void SetImageList(wxImageList *imageList);
543 void SetStateImageList(wxImageList *imageList);
544 void SetButtonsImageList(wxImageList *imageList);
546 %apply SWIGTYPE *DISOWN { wxImageList *imageList };
547 void AssignImageList(wxImageList *imageList);
548 void AssignStateImageList(wxImageList *imageList);
549 void AssignButtonsImageList(wxImageList *imageList);
550 %clear wxImageList *imageList;
554 void AddColumn(const wxString& text);
555 %name(AddColumnInfo) void AddColumn(const wxTreeListColumnInfo& col);
557 // inserts a column before the given one
558 void InsertColumn(size_t before, const wxString& text);
559 %name(InsertColumnInfo) void InsertColumn(size_t before, const wxTreeListColumnInfo& col);
561 // deletes the given column - does not delete the corresponding column
563 void RemoveColumn(size_t column);
565 // returns the number of columns in the ctrl
566 size_t GetColumnCount() const;
568 void SetColumnWidth(size_t column, size_t width);
569 int GetColumnWidth(size_t column) const;
571 // tells which column is the "main" one, i.e. the "threaded" one
572 void SetMainColumn(size_t column);
573 size_t GetMainColumn() const;
575 void SetColumnText(size_t column, const wxString& text);
576 wxString GetColumnText(size_t column) const;
578 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
579 wxTreeListColumnInfo& GetColumn(size_t column);
581 // other column-related methods
582 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
583 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
585 void SetColumnImage(size_t column, int image);
586 int GetColumnImage(size_t column) const;
590 // retrieves item's label of the given column (main column by default)
591 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
592 if (column < 0) column = self->GetMainColumn();
593 return self->GetItemText(item, column);
596 // get one of the images associated with the item (normal by default)
597 int GetItemImage(const wxTreeItemId& item, int column = -1,
598 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
599 if (column < 0) column = self->GetMainColumn();
600 return self->GetItemImage(item, column, which);
603 // set item's label (main column by default)
604 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
605 if (column < 0) column = self->GetMainColumn();
606 self->SetItemText(item, column, text);
609 // set one of the images associated with the item (normal by default)
610 // the which parameter is ignored for all columns but the main one
611 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
612 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
613 if (column < 0) column = self->GetMainColumn();
614 self->SetItemImage(item, column, image, which);
618 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
620 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
621 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
623 data = new wxPyTreeItemData();
624 data->SetId(item); // set the id
625 self->SetItemData(item, data);
630 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
631 data->SetId(item); // set the id
632 self->SetItemData(item, data);
635 // [Get|Set]ItemPyData are short-cuts. Also made somewhat crash-proof by
636 // automatically creating data classes.
637 PyObject* GetItemPyData(const wxTreeItemId& item) {
638 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
640 data = new wxPyTreeItemData();
641 data->SetId(item); // set the id
642 self->SetItemData(item, data);
644 return data->GetData();
647 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
648 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
650 data = new wxPyTreeItemData(obj);
651 data->SetId(item); // set the id
652 self->SetItemData(item, data);
659 // force appearance of [+] button near the item. This is useful to
660 // allow the user to expand the items which don't have any children now
661 // - but instead add them only when needed, thus minimizing memory
662 // usage and loading time.
663 void SetItemHasChildren(const wxTreeItemId& item, bool has = True);
665 // the item will be shown in bold
666 void SetItemBold(const wxTreeItemId& item, bool bold = True);
668 // set the item's text colour
669 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
671 // set the item's background colour
672 void SetItemBackgroundColour(const wxTreeItemId& item,
673 const wxColour& col);
675 // set the item's font (should be of the same height for all items)
676 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
679 bool GetItemBold(const wxTreeItemId& item) const;
680 wxColour GetItemTextColour(const wxTreeItemId& item) const;
681 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
682 wxFont GetItemFont(const wxTreeItemId& item) const;
684 // is the item visible (it might be outside the view or not expanded)?
685 bool IsVisible(const wxTreeItemId& item) const;
687 // does the item has any children?
688 bool ItemHasChildren(const wxTreeItemId& item) const;
690 // is the item expanded (only makes sense if HasChildren())?
691 bool IsExpanded(const wxTreeItemId& item) const;
693 // is this item currently selected (the same as has focus)?
694 bool IsSelected(const wxTreeItemId& item) const;
696 // is item text in bold font?
697 bool IsBold(const wxTreeItemId& item) const;
699 // if 'recursively' is False, only immediate children count, otherwise
700 // the returned number is the number of all items in this branch
701 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = True);
704 // wxTreeItemId.IsOk() will return False if there is no such item
706 // get the root tree item
707 wxTreeItemId GetRootItem() const;
709 // get the item currently selected (may return NULL if no selection)
710 wxTreeItemId GetSelection() const;
712 // get the items currently selected, return the number of such item
713 //size_t GetSelections(wxArrayTreeItemIds&) const;
715 PyObject* GetSelections() {
716 wxPyBeginBlockThreads();
717 PyObject* rval = PyList_New(0);
718 wxArrayTreeItemIds array;
720 num = self->GetSelections(array);
721 for (x=0; x < num; x++) {
722 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
723 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), True);
724 PyList_Append(rval, item);
726 wxPyEndBlockThreads();
732 // get the parent of this item (may return NULL if root)
733 %name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
735 // for this enumeration function you must pass in a "cookie" parameter
736 // which is opaque for the application but is necessary for the library
737 // to make these functions reentrant (i.e. allow more than one
738 // enumeration on one and the same object simultaneously). Of course,
739 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
744 // Get the first child of this item. Returns a wxTreeItemId and an
745 // opaque "cookie" value that should be passed to GetNextChild in
746 // order to continue the search.
747 PyObject* GetFirstChild(const wxTreeItemId& item) {
749 wxTreeItemId ritem = self->GetFirstChild(item, cookie);
750 wxPyBeginBlockThreads();
751 PyObject* tup = PyTuple_New(2);
752 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(&ritem, wxT("wxTreeItemId"), true));
753 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
754 wxPyEndBlockThreads();
759 // Get the next child of this item. The cookie parameter is the 2nd
760 // value returned from GetFirstChild or the previous GetNextChild.
761 // Returns a wxTreeItemId and an opaque "cookie" value that should be
762 // passed to GetNextChild in order to continue the search.
763 PyObject* GetNextChild(const wxTreeItemId& item, long cookie) {
764 wxTreeItemId ritem = self->GetNextChild(item, cookie);
765 wxPyBeginBlockThreads();
766 PyObject* tup = PyTuple_New(2);
767 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(&ritem, wxT("wxTreeItemId"), true));
768 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
769 wxPyEndBlockThreads();
774 // get the last child of this item - this method doesn't use cookies
775 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
777 // get the next sibling of this item
778 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
780 // get the previous sibling
781 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
783 // get first visible item
784 wxTreeItemId GetFirstVisibleItem() const;
786 // get the next visible item: item must be visible itself!
787 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
788 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
790 // get the previous visible item: item must be visible itself!
791 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
793 // Only for internal use right now, but should probably be public
794 wxTreeItemId GetNext(const wxTreeItemId& item) const;
797 // add the root node to the tree
798 wxTreeItemId AddRoot(const wxString& text,
799 int image = -1, int selectedImage = -1,
800 wxPyTreeItemData *data = NULL);
802 // insert a new item in as the first child of the parent
803 wxTreeItemId PrependItem(const wxTreeItemId& parent,
804 const wxString& text,
805 int image = -1, int selectedImage = -1,
806 wxPyTreeItemData *data = NULL);
808 // insert a new item after a given one
809 wxTreeItemId InsertItem(const wxTreeItemId& parent,
810 const wxTreeItemId& idPrevious,
811 const wxString& text,
812 int image = -1, int selectedImage = -1,
813 wxPyTreeItemData *data = NULL);
815 // insert a new item before the one with the given index
816 %name(InsertItemBefore)
817 wxTreeItemId InsertItem(const wxTreeItemId& parent,
819 const wxString& text,
820 int image = -1, int selectedImage = -1,
821 wxPyTreeItemData *data = NULL);
823 // insert a new item in as the last child of the parent
824 wxTreeItemId AppendItem(const wxTreeItemId& parent,
825 const wxString& text,
826 int image = -1, int selectedImage = -1,
827 wxPyTreeItemData *data = NULL);
829 // delete this item and associated data if any
830 void Delete(const wxTreeItemId& item);
832 // delete all children (but don't delete the item itself)
833 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
834 void DeleteChildren(const wxTreeItemId& item);
836 // delete all items from the tree
837 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
838 void DeleteAllItems();
841 void Expand(const wxTreeItemId& item);
843 // expand this item and all subitems recursively
844 void ExpandAll(const wxTreeItemId& item);
846 // collapse the item without removing its children
847 void Collapse(const wxTreeItemId& item);
849 // collapse the item and remove all children
850 void CollapseAndReset(const wxTreeItemId& item);
852 // toggles the current state
853 void Toggle(const wxTreeItemId& item);
855 // remove the selection from currently selected item (if any)
860 void SelectItem(const wxTreeItemId& item, bool unselect_others=True,
861 bool extended_select=False);
863 // make sure this item is visible (expanding the parent item and/or
864 // scrolling to this item if necessary)
865 void EnsureVisible(const wxTreeItemId& item);
867 // scroll to this item (but don't expand its parent)
868 void ScrollTo(const wxTreeItemId& item);
870 // Returns wxTreeItemId, flags, and column
871 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
874 // get the bounding rectangle of the item (or of its label only)
875 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = False) {
877 if (self->GetBoundingRect(item, rect, textOnly)) {
878 wxPyBeginBlockThreads();
879 wxRect* r = new wxRect(rect);
880 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
881 wxPyEndBlockThreads();
891 // Start editing the item label: this (temporarily) replaces the item
892 // with a one line edit control. The item will be selected if it hadn't
894 void EditLabel( const wxTreeItemId& item );
895 void Edit( const wxTreeItemId& item );
897 // sort the children of this item using OnCompareItems
898 void SortChildren(const wxTreeItemId& item);
900 // get the selected item image
901 int GetItemSelectedImage(const wxTreeItemId& item) const;
903 // set the selected item image
904 void SetItemSelectedImage(const wxTreeItemId& item, int image);
907 wxWindow* GetHeaderWindow() const;
908 wxWindow* GetMainWindow() const;
915 //----------------------------------------------------------------------
916 //----------------------------------------------------------------------
920 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
921 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
925 %pragma(python) include="_gizmoextras.py";
927 //----------------------------------------------------------------------
928 //----------------------------------------------------------------------