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 bool blocked = 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(blocked);
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 bool blocked = 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(blocked);
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);
657 %pythoncode { GetPyData = GetItemPyData }
658 %pythoncode { SetPyData = SetItemPyData }
661 // force appearance of [+] button near the item. This is useful to
662 // allow the user to expand the items which don't have any children now
663 // - but instead add them only when needed, thus minimizing memory
664 // usage and loading time.
665 void SetItemHasChildren(const wxTreeItemId& item, bool has = True);
667 // the item will be shown in bold
668 void SetItemBold(const wxTreeItemId& item, bool bold = True);
670 // set the item's text colour
671 void SetItemTextColour(const wxTreeItemId& item, const wxColour& col);
673 // set the item's background colour
674 void SetItemBackgroundColour(const wxTreeItemId& item,
675 const wxColour& col);
677 // set the item's font (should be of the same height for all items)
678 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
681 bool GetItemBold(const wxTreeItemId& item) const;
682 wxColour GetItemTextColour(const wxTreeItemId& item) const;
683 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
684 wxFont GetItemFont(const wxTreeItemId& item) const;
686 // is the item visible (it might be outside the view or not expanded)?
687 bool IsVisible(const wxTreeItemId& item) const;
689 // does the item has any children?
690 bool ItemHasChildren(const wxTreeItemId& item) const;
692 // is the item expanded (only makes sense if HasChildren())?
693 bool IsExpanded(const wxTreeItemId& item) const;
695 // is this item currently selected (the same as has focus)?
696 bool IsSelected(const wxTreeItemId& item) const;
698 // is item text in bold font?
699 bool IsBold(const wxTreeItemId& item) const;
701 // if 'recursively' is False, only immediate children count, otherwise
702 // the returned number is the number of all items in this branch
703 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = True);
706 // wxTreeItemId.IsOk() will return False if there is no such item
708 // get the root tree item
709 wxTreeItemId GetRootItem() const;
711 // get the item currently selected (may return NULL if no selection)
712 wxTreeItemId GetSelection() const;
714 // get the items currently selected, return the number of such item
715 //size_t GetSelections(wxArrayTreeItemIds&) const;
717 PyObject* GetSelections() {
718 bool blocked = wxPyBeginBlockThreads();
719 PyObject* rval = PyList_New(0);
720 wxArrayTreeItemIds array;
722 num = self->GetSelections(array);
723 for (x=0; x < num; x++) {
724 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
725 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), True);
726 PyList_Append(rval, item);
728 wxPyEndBlockThreads(blocked);
734 // get the parent of this item (may return NULL if root)
735 %name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
737 // for this enumeration function you must pass in a "cookie" parameter
738 // which is opaque for the application but is necessary for the library
739 // to make these functions reentrant (i.e. allow more than one
740 // enumeration on one and the same object simultaneously). Of course,
741 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
746 // Get the first child of this item. Returns a wxTreeItemId and an
747 // opaque "cookie" value that should be passed to GetNextChild in
748 // order to continue the search.
749 PyObject* GetFirstChild(const wxTreeItemId& item) {
751 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
752 bool blocked = wxPyBeginBlockThreads();
753 PyObject* tup = PyTuple_New(2);
754 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
755 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
756 wxPyEndBlockThreads(blocked);
761 // Get the next child of this item. The cookie parameter is the 2nd
762 // value returned from GetFirstChild or the previous GetNextChild.
763 // Returns a wxTreeItemId and an opaque "cookie" value that should be
764 // passed to GetNextChild in order to continue the search.
765 PyObject* GetNextChild(const wxTreeItemId& item, long cookie) {
766 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
767 bool blocked = wxPyBeginBlockThreads();
768 PyObject* tup = PyTuple_New(2);
769 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
770 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(cookie));
771 wxPyEndBlockThreads(blocked);
776 // get the last child of this item - this method doesn't use cookies
777 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
779 // get the next sibling of this item
780 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
782 // get the previous sibling
783 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
785 // get first visible item
786 wxTreeItemId GetFirstVisibleItem() const;
788 // get the next visible item: item must be visible itself!
789 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
790 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
792 // get the previous visible item: item must be visible itself!
793 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
795 // Only for internal use right now, but should probably be public
796 wxTreeItemId GetNext(const wxTreeItemId& item) const;
799 // add the root node to the tree
800 wxTreeItemId AddRoot(const wxString& text,
801 int image = -1, int selectedImage = -1,
802 wxPyTreeItemData *data = NULL);
804 // insert a new item in as the first child of the parent
805 wxTreeItemId PrependItem(const wxTreeItemId& parent,
806 const wxString& text,
807 int image = -1, int selectedImage = -1,
808 wxPyTreeItemData *data = NULL);
810 // insert a new item after a given one
811 wxTreeItemId InsertItem(const wxTreeItemId& parent,
812 const wxTreeItemId& idPrevious,
813 const wxString& text,
814 int image = -1, int selectedImage = -1,
815 wxPyTreeItemData *data = NULL);
817 // insert a new item before the one with the given index
818 %name(InsertItemBefore)
819 wxTreeItemId InsertItem(const wxTreeItemId& parent,
821 const wxString& text,
822 int image = -1, int selectedImage = -1,
823 wxPyTreeItemData *data = NULL);
825 // insert a new item in as the last child of the parent
826 wxTreeItemId AppendItem(const wxTreeItemId& parent,
827 const wxString& text,
828 int image = -1, int selectedImage = -1,
829 wxPyTreeItemData *data = NULL);
831 // delete this item and associated data if any
832 void Delete(const wxTreeItemId& item);
834 // delete all children (but don't delete the item itself)
835 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
836 void DeleteChildren(const wxTreeItemId& item);
838 // delete all items from the tree
839 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
840 void DeleteAllItems();
843 void Expand(const wxTreeItemId& item);
845 // expand this item and all subitems recursively
846 void ExpandAll(const wxTreeItemId& item);
848 // collapse the item without removing its children
849 void Collapse(const wxTreeItemId& item);
851 // collapse the item and remove all children
852 void CollapseAndReset(const wxTreeItemId& item);
854 // toggles the current state
855 void Toggle(const wxTreeItemId& item);
857 // remove the selection from currently selected item (if any)
862 void SelectItem(const wxTreeItemId& item, bool unselect_others=True,
863 bool extended_select=False);
865 // make sure this item is visible (expanding the parent item and/or
866 // scrolling to this item if necessary)
867 void EnsureVisible(const wxTreeItemId& item);
869 // scroll to this item (but don't expand its parent)
870 void ScrollTo(const wxTreeItemId& item);
872 // Returns wxTreeItemId, flags, and column
873 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
876 // get the bounding rectangle of the item (or of its label only)
877 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = False) {
879 if (self->GetBoundingRect(item, rect, textOnly)) {
880 bool blocked = wxPyBeginBlockThreads();
881 wxRect* r = new wxRect(rect);
882 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
883 wxPyEndBlockThreads(blocked);
893 // Start editing the item label: this (temporarily) replaces the item
894 // with a one line edit control. The item will be selected if it hadn't
896 void EditLabel( const wxTreeItemId& item );
897 void Edit( const wxTreeItemId& item );
899 // sort the children of this item using OnCompareItems
900 void SortChildren(const wxTreeItemId& item);
902 // get the selected item image
903 int GetItemSelectedImage(const wxTreeItemId& item) const;
905 // set the selected item image
906 void SetItemSelectedImage(const wxTreeItemId& item, int image);
909 wxWindow* GetHeaderWindow() const;
910 wxWindow* GetMainWindow() const;
917 //----------------------------------------------------------------------
918 //----------------------------------------------------------------------
922 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
923 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
927 %pragma(python) include="_gizmoextras.py";
929 //----------------------------------------------------------------------
930 //----------------------------------------------------------------------