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 /////////////////////////////////////////////////////////////////////////////
14 "Various *gizmo* classes: `DynamicSashWindow`, `EditableListBox`,
15 `LEDNumberCtrl`, `TreeListCtrl`, etc."
18 %module(package="wx", docstring=DOCSTRING) gizmos
22 #include "wx/wxPython/wxPython.h"
23 #include "wx/wxPython/pyclasses.h"
25 #include <wx/gizmos/dynamicsash.h>
26 #include <wx/gizmos/editlbox.h>
27 #include <wx/gizmos/splittree.h>
28 #include <wx/gizmos/ledctrl.h>
29 #include <wx/gizmos/statpict.h>
31 #include <wx/listctrl.h>
32 #include <wx/treectrl.h>
33 #include <wx/imaglist.h>
35 #include "wx/treelistctrl.h"
36 #include "wx/wxPython/pytree.h"
40 //---------------------------------------------------------------------------
44 %pythoncode { import wx }
45 %pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
48 MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
49 MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
50 MAKE_CONST_WXSTRING2(TreeListCtrlNameStr, wxT("treelistctrl"));
51 MAKE_CONST_WXSTRING(StaticPictureNameStr);
53 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
55 //---------------------------------------------------------------------------
58 wxDS_MANAGE_SCROLLBARS,
62 %constant wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
63 %constant wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
67 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
68 whenever your view is being split by the user. It is your
69 responsibility to handle this event by creating a new view window as
70 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
71 automatically reparent it to the proper place in its window hierarchy.
73 class wxDynamicSashSplitEvent : public wxCommandEvent {
75 wxDynamicSashSplitEvent(wxObject *target);
80 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
81 whenever the sash which splits your view and its sibling is being
82 reunified such that your view is expanding to replace its sibling.
83 You needn't do anything with this event if you are allowing
84 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
85 if you are managing the scrollbars yourself so that you can keep
86 the scrollbars' event handlers connected to your view's event handler
89 class wxDynamicSashUnifyEvent : public wxCommandEvent {
91 wxDynamicSashUnifyEvent(wxObject *target);
100 wxDynamicSashWindow widgets manages the way other widgets are viewed.
101 When a wxDynamicSashWindow is first shown, it will contain one child
102 view, a viewport for that child, and a pair of scrollbars to allow the
103 user to navigate the child view area. Next to each scrollbar is a small
104 tab. By clicking on either tab and dragging to the appropriate spot, a
105 user can split the view area into two smaller views separated by a
106 draggable sash. Later, when the user wishes to reunify the two subviews,
107 the user simply drags the sash to the side of the window.
108 wxDynamicSashWindow will automatically reparent the appropriate child
109 view back up the window hierarchy, and the wxDynamicSashWindow will have
110 only one child view once again.
112 As an application developer, you will simply create a wxDynamicSashWindow
113 using either the Create() function or the more complex constructor
114 provided below, and then create a view window whose parent is the
115 wxDynamicSashWindow. The child should respond to
116 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
117 constructing a new view window whose parent is also the
118 wxDynamicSashWindow. That's it! Now your users can dynamically split
119 and reunify the view you provided.
121 If you wish to handle the scrollbar events for your view, rather than
122 allowing wxDynamicSashWindow to do it for you, things are a bit more
123 complex. (You might want to handle scrollbar events yourself, if,
124 for instance, you wish to scroll a subwindow of the view you add to
125 your wxDynamicSashWindow object, rather than scrolling the whole view.)
126 In this case, you will need to construct your wxDynamicSashWindow without
127 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
128 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
129 controls and call SetEventHanler() on them to redirect the scrolling
130 events whenever your window is reparented by wxDyanmicSashWindow.
131 You will need to set the scrollbars' event handler at three times:
133 * When your view is created
134 * When your view receives a wxDynamicSashSplitEvent
135 * When your view receives a wxDynamicSashUnifyEvent
137 See the dynsash_switch sample application for an example which does this.
141 MustHaveApp(wxDynamicSashWindow);
143 class wxDynamicSashWindow : public wxWindow {
145 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
146 %pythonAppend wxDynamicSashWindow() ""
148 wxDynamicSashWindow(wxWindow *parent, wxWindowID id=-1,
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);
152 %RenameCtor(PreDynamicSashWindow, wxDynamicSashWindow());
154 bool Create(wxWindow *parent, wxWindowID id=-1,
155 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
156 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
157 const wxString& name = wxPyDynamicSashNameStr);
159 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
160 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
166 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
167 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
170 //---------------------------------------------------------------------------
171 //---------------------------------------------------------------------------
179 // This class provides a composite control that lets the
180 // user easily enter list of strings
181 MustHaveApp(wxEditableListBox);
182 class wxEditableListBox : public wxPanel
185 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
186 %pythonAppend wxEditableListBox() ""
188 wxEditableListBox(wxWindow *parent, wxWindowID id=-1,
189 const wxString& label = wxPyEmptyString,
190 const wxPoint& pos = wxDefaultPosition,
191 const wxSize& size = wxDefaultSize,
192 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
193 const wxString& name = wxPyEditableListBoxNameStr);
196 void SetStrings(const wxArrayString& strings);
198 //void GetStrings(wxArrayString& strings);
200 PyObject* GetStrings() {
201 wxArrayString strings;
202 self->GetStrings(strings);
203 return wxArrayString2PyList_helper(strings);
207 wxPyListCtrl* GetListCtrl();
208 wxBitmapButton* GetDelButton();
209 wxBitmapButton* GetNewButton();
210 wxBitmapButton* GetUpButton();
211 wxBitmapButton* GetDownButton();
212 wxBitmapButton* GetEditButton();
217 //---------------------------------------------------------------------------
221 * wxRemotelyScrolledTreeCtrl
223 * This tree control disables its vertical scrollbar and catches scroll
224 * events passed by a scrolled window higher in the hierarchy.
225 * It also updates the scrolled window vertical scrollbar as appropriate.
229 typedef wxTreeCtrl wxPyTreeCtrl;
232 MustHaveApp(wxRemotelyScrolledTreeCtrl);
234 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
237 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
238 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
240 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
241 const wxPoint& pos = wxDefaultPosition,
242 const wxSize& size = wxDefaultSize,
243 long style = wxTR_HAS_BUTTONS);
246 void HideVScrollbar();
248 // Adjust the containing wxScrolledWindow's scrollbars appropriately
249 void AdjustRemoteScrollbars();
251 // Find the scrolled window that contains this control
252 wxScrolledWindow* GetScrolledWindow() const;
254 // Scroll to the given line (in scroll units where each unit is
255 // the height of an item)
256 void ScrollToLine(int posHoriz, int posVert);
258 // The companion window is one which will get notified when certain
259 // events happen such as node expansion
260 void SetCompanionWindow(wxWindow* companion);
261 wxWindow* GetCompanionWindow() const;
267 * wxTreeCompanionWindow
269 * A window displaying values associated with tree control items.
273 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
276 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
277 const wxPoint& pos = wxDefaultPosition,
278 const wxSize& size = wxDefaultSize,
280 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
283 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
285 wxPyBlock_t blocked = wxPyBeginBlockThreads();
286 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
287 PyObject* dcobj = wxPyMake_wxObject(&dc,false);
288 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), false);
289 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), false);
290 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
295 wxPyEndBlockThreads(blocked);
297 wxTreeCompanionWindow::DrawItem(dc, id, rect);
305 MustHaveApp(wxPyTreeCompanionWindow);
307 %rename(TreeCompanionWindow) wxPyTreeCompanionWindow;
308 class wxPyTreeCompanionWindow: public wxWindow
311 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
312 %pythonAppend wxPyTreeCompanionWindow() ""
314 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
315 const wxPoint& pos = wxDefaultPosition,
316 const wxSize& size = wxDefaultSize,
318 void _setCallbackInfo(PyObject* self, PyObject* _class);
320 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
321 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
327 * wxThinSplitterWindow
329 * Implements a splitter with a less obvious sash
330 * than the usual one.
333 MustHaveApp(wxThinSplitterWindow);
335 class wxThinSplitterWindow: public wxSplitterWindow
338 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
339 %pythonAppend wxThinSplitterWindow() ""
341 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
342 const wxPoint& pos = wxDefaultPosition,
343 const wxSize& size = wxDefaultSize,
344 long style = wxSP_3D | wxCLIP_CHILDREN);
350 * wxSplitterScrolledWindow
352 * This scrolled window is aware of the fact that one of its
353 * children is a splitter window. It passes on its scroll events
354 * (after some processing) to both splitter children for them
355 * scroll appropriately.
358 MustHaveApp(wxSplitterScrolledWindow);
360 class wxSplitterScrolledWindow: public wxScrolledWindow
363 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
364 %pythonAppend wxSplitterScrolledWindow() ""
366 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
367 const wxPoint& pos = wxDefaultPosition,
368 const wxSize& size = wxDefaultSize,
373 //---------------------------------------------------------------------------
374 //---------------------------------------------------------------------------
389 MustHaveApp(wxLEDNumberCtrl);
391 class wxLEDNumberCtrl : public wxControl
394 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
395 %pythonAppend wxLEDNumberCtrl() ""
397 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
398 const wxPoint& pos = wxDefaultPosition,
399 const wxSize& size = wxDefaultSize,
400 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
401 %RenameCtor(PreLEDNumberCtrl, wxLEDNumberCtrl());
403 bool Create(wxWindow *parent, wxWindowID id = -1,
404 const wxPoint& pos = wxDefaultPosition,
405 const wxSize& size = wxDefaultSize,
406 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
408 wxLEDValueAlign GetAlignment() const;
409 bool GetDrawFaded() const;
410 const wxString &GetValue() const;
412 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
413 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
414 void SetValue(const wxString &Value, bool Redraw = true);
420 //----------------------------------------------------------------------------
421 // wxTreeListCtrl - the multicolumn tree control
422 //----------------------------------------------------------------------------
424 enum wxTreeListColumnAlign {
433 wxTREE_HITTEST_ONITEMCOLUMN
438 // flags for FindItem
450 %pythoncode { wx.TR_DONT_ADJUST_MAC = TR_DONT_ADJUST_MAC }
453 class wxTreeListColumnInfo: public wxObject {
455 wxTreeListColumnInfo(const wxString& text = wxPyEmptyString,
459 wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
461 ~wxTreeListColumnInfo();
463 bool GetShown() const;
464 wxTreeListColumnAlign GetAlignment() const;
465 wxString GetText() const;
466 int GetImage() const;
467 int GetSelectedImage() const;
468 size_t GetWidth() const;
470 // TODO: These all actually return wxTreeListColumnInfo&, any problem with doing it for Python too?
471 void SetShown(bool shown);
472 void SetAlignment(wxTreeListColumnAlign alignment);
473 void SetText(const wxString& text);
474 void SetImage(int image);
475 void SetSelectedImage(int image);
476 void SetWidth(size_t with);
482 %{ // C++ version of Python aware control
483 class wxPyTreeListCtrl : public wxTreeListCtrl {
484 DECLARE_ABSTRACT_CLASS(wxPyTreeListCtrl);
486 wxPyTreeListCtrl() : wxTreeListCtrl() {}
487 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id,
491 const wxValidator &validator,
492 const wxString& name) :
493 wxTreeListCtrl(parent, id, pos, size, style, validator, name) {}
495 int OnCompareItems(const wxTreeItemId& item1,
496 const wxTreeItemId& item2) {
499 wxPyBlock_t blocked = wxPyBeginBlockThreads();
500 if ((found = wxPyCBH_findCallback(m_myInst, "OnCompareItems"))) {
501 PyObject *o1 = wxPyConstructObject((void*)&item1, wxT("wxTreeItemId"), 0);
502 PyObject *o2 = wxPyConstructObject((void*)&item2, wxT("wxTreeItemId"), 0);
503 rval = wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OO)",o1,o2));
507 wxPyEndBlockThreads(blocked);
509 rval = wxTreeListCtrl::OnCompareItems(item1, item2);
515 IMPLEMENT_ABSTRACT_CLASS(wxPyTreeListCtrl, wxTreeListCtrl)
524 MustHaveApp(wxPyTreeListCtrl);
526 %rename(TreeListCtrl) wxPyTreeListCtrl;
527 class wxPyTreeListCtrl : public wxControl
530 %pythonAppend wxPyTreeListCtrl "self._setOORInfo(self);self._setCallbackInfo(self, TreeListCtrl)"
531 %pythonAppend wxPyTreeListCtrl() ""
533 wxPyTreeListCtrl(wxWindow *parent, wxWindowID id = -1,
534 const wxPoint& pos = wxDefaultPosition,
535 const wxSize& size = wxDefaultSize,
536 long style = wxTR_DEFAULT_STYLE,
537 const wxValidator &validator = wxDefaultValidator,
538 const wxString& name = wxPyTreeListCtrlNameStr );
539 %RenameCtor(PreTreeListCtrl, wxPyTreeListCtrl());
541 bool Create(wxWindow *parent, wxWindowID id = -1,
542 const wxPoint& pos = wxDefaultPosition,
543 const wxSize& size = wxDefaultSize,
544 long style = wxTR_DEFAULT_STYLE,
545 const wxValidator &validator = wxDefaultValidator,
546 const wxString& name = wxPyTreeListCtrlNameStr );
548 void _setCallbackInfo(PyObject* self, PyObject* _class);
551 // get the total number of items in the control
552 size_t GetCount() const;
554 // indent is the number of pixels the children are indented relative to
555 // the parents position. SetIndent() also redraws the control
557 unsigned int GetIndent() const;
558 void SetIndent(unsigned int indent);
560 // line spacing is the space above and below the text on each line
561 unsigned int GetLineSpacing() const;
562 void SetLineSpacing(unsigned int spacing);
564 // image list: these functions allow to associate an image list with
565 // the control and retrieve it. Note that when assigned with
566 // SetImageList, the control does _not_ delete
567 // the associated image list when it's deleted in order to allow image
568 // lists to be shared between different controls. If you use
569 // AssignImageList, the control _does_ delete the image list.
571 // The normal image list is for the icons which correspond to the
572 // normal tree item state (whether it is selected or not).
573 // Additionally, the application might choose to show a state icon
574 // which corresponds to an app-defined item state (for example,
575 // checked/unchecked) which are taken from the state image list.
576 wxImageList *GetImageList() const;
577 wxImageList *GetStateImageList() const;
578 wxImageList *GetButtonsImageList() const;
580 void SetImageList(wxImageList *imageList);
581 void SetStateImageList(wxImageList *imageList);
582 void SetButtonsImageList(wxImageList *imageList);
584 %disownarg( wxImageList *imageList );
585 void AssignImageList(wxImageList *imageList);
586 void AssignStateImageList(wxImageList *imageList);
587 void AssignButtonsImageList(wxImageList *imageList);
588 %cleardisown( wxImageList *imageList );
592 void AddColumn(const wxString& text);
593 // void AddColumn(const wxString& text,
595 // wxTreeListColumnAlign alignment = wxTL_ALIGN_LEFT);
596 %Rename(AddColumnInfo, void, AddColumn(const wxTreeListColumnInfo& col));
598 // inserts a column before the given one
599 void InsertColumn(size_t before, const wxString& text);
600 %Rename(InsertColumnInfo, void, InsertColumn(size_t before, const wxTreeListColumnInfo& col));
602 // deletes the given column - does not delete the corresponding column
604 void RemoveColumn(size_t column);
606 // returns the number of columns in the ctrl
607 size_t GetColumnCount() const;
609 void SetColumnWidth(size_t column, size_t width);
610 int GetColumnWidth(size_t column) const;
612 // tells which column is the "main" one, i.e. the "threaded" one
613 void SetMainColumn(size_t column);
614 size_t GetMainColumn() const;
616 void SetColumnText(size_t column, const wxString& text);
617 wxString GetColumnText(size_t column) const;
619 void SetColumn(size_t column, const wxTreeListColumnInfo& info);
620 wxTreeListColumnInfo& GetColumn(size_t column);
622 // other column-related methods
623 void SetColumnAlignment(size_t column, wxTreeListColumnAlign align);
624 wxTreeListColumnAlign GetColumnAlignment(size_t column) const;
626 void SetColumnImage(size_t column, int image);
627 int GetColumnImage(size_t column) const;
629 void ShowColumn(size_t column, bool shown);
630 bool IsColumnShown(size_t column) const;
633 // retrieves item's label of the given column (main column by default)
634 wxString GetItemText(const wxTreeItemId& item, int column = -1) {
635 if (column < 0) column = self->GetMainColumn();
636 return self->GetItemText(item, column);
639 // get one of the images associated with the item (normal by default)
640 int GetItemImage(const wxTreeItemId& item, int column = -1,
641 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
642 if (column < 0) column = self->GetMainColumn();
643 return self->GetItemImage(item, column, which);
646 // set item's label (main column by default)
647 void SetItemText(const wxTreeItemId& item, const wxString& text, int column = -1) {
648 if (column < 0) column = self->GetMainColumn();
649 self->SetItemText(item, column, text);
652 // set one of the images associated with the item (normal by default)
653 // the which parameter is ignored for all columns but the main one
654 void SetItemImage(const wxTreeItemId& item, int image, int column = -1,
655 wxTreeItemIcon which = wxTreeItemIcon_Normal) {
656 if (column < 0) column = self->GetMainColumn();
657 self->SetItemImage(item, column, image, which);
661 // [Get|Set]ItemData substitutes. Automatically create wxPyTreeItemData
663 wxPyTreeItemData* GetItemData(const wxTreeItemId& item) {
664 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
666 data = new wxPyTreeItemData();
667 data->SetId(item); // set the id
668 self->SetItemData(item, data);
673 %disownarg( wxPyTreeItemData* data );
674 void SetItemData(const wxTreeItemId& item, wxPyTreeItemData* data) {
675 data->SetId(item); // set the id
676 self->SetItemData(item, data);
678 %cleardisown(wxPyTreeItemData* data );
680 // [Get|Set]ItemPyData are short-cuts. Also made somewhat crash-proof by
681 // automatically creating data classes.
682 PyObject* GetItemPyData(const wxTreeItemId& item) {
683 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
685 data = new wxPyTreeItemData();
686 data->SetId(item); // set the id
687 self->SetItemData(item, data);
689 return data->GetData();
692 void SetItemPyData(const wxTreeItemId& item, PyObject* obj) {
693 wxPyTreeItemData* data = (wxPyTreeItemData*)self->GetItemData(item);
695 data = new wxPyTreeItemData(obj);
696 data->SetId(item); // set the id
697 self->SetItemData(item, data);
702 %pythoncode { GetPyData = GetItemPyData }
703 %pythoncode { SetPyData = SetItemPyData }
706 // force appearance of [+] button near the item. This is useful to
707 // allow the user to expand the items which don't have any children now
708 // - but instead add them only when needed, thus minimizing memory
709 // usage and loading time.
710 void SetItemHasChildren(const wxTreeItemId& item, bool has = true);
712 // the item will be shown in bold
713 void SetItemBold(const wxTreeItemId& item, bool bold = true);
715 // set the item's text colour
716 void SetItemTextColour(const wxTreeItemId& item, const wxColour& colour);
718 // set the item's background colour
719 void SetItemBackgroundColour(const wxTreeItemId& item,
720 const wxColour& colour);
722 // set the item's font (should be of the same height for all items)
723 void SetItemFont(const wxTreeItemId& item, const wxFont& font);
726 bool GetItemBold(const wxTreeItemId& item) const;
727 wxColour GetItemTextColour(const wxTreeItemId& item) const;
728 wxColour GetItemBackgroundColour(const wxTreeItemId& item) const;
729 wxFont GetItemFont(const wxTreeItemId& item) const;
731 // is the item visible (it might be outside the view or not expanded)?
732 bool IsVisible(const wxTreeItemId& item) const;
734 // does the item has any children?
735 bool ItemHasChildren(const wxTreeItemId& item) const;
737 // is the item expanded (only makes sense if HasChildren())?
738 bool IsExpanded(const wxTreeItemId& item) const;
740 // is this item currently selected (the same as has focus)?
741 bool IsSelected(const wxTreeItemId& item) const;
743 // is item text in bold font?
744 bool IsBold(const wxTreeItemId& item) const;
746 // if 'recursively' is False, only immediate children count, otherwise
747 // the returned number is the number of all items in this branch
748 size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true);
751 // wxTreeItemId.IsOk() will return False if there is no such item
753 // get the root tree item
754 wxTreeItemId GetRootItem() const;
756 // get the item currently selected (may return NULL if no selection)
757 wxTreeItemId GetSelection() const;
759 // get the items currently selected, return the number of such item
760 //size_t GetSelections(wxArrayTreeItemIds&) const;
762 PyObject* GetSelections() {
763 wxPyBlock_t blocked = wxPyBeginBlockThreads();
764 PyObject* rval = PyList_New(0);
765 wxArrayTreeItemIds array;
767 num = self->GetSelections(array);
768 for (x=0; x < num; x++) {
769 wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
770 PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), true);
771 PyList_Append(rval, item);
774 wxPyEndBlockThreads(blocked);
780 // get the parent of this item (may return NULL if root)
781 wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
783 // for this enumeration function you must pass in a "cookie" parameter
784 // which is opaque for the application but is necessary for the library
785 // to make these functions reentrant (i.e. allow more than one
786 // enumeration on one and the same object simultaneously). Of course,
787 // the "cookie" passed to GetFirstChild() and GetNextChild() should be
791 // NOTE: These are a copy of the same methods in _treectrl.i, be sure to
792 // update both at the same time. (Or find a good way to refactor!)
794 // Get the first child of this item. Returns a wxTreeItemId and an
795 // opaque "cookie" value that should be passed to GetNextChild in
796 // order to continue the search.
797 PyObject* GetFirstChild(const wxTreeItemId& item) {
799 wxTreeItemId* ritem = new wxTreeItemId(self->GetFirstChild(item, cookie));
800 wxPyBlock_t blocked = wxPyBeginBlockThreads();
801 PyObject* tup = PyTuple_New(2);
802 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
803 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
804 wxPyEndBlockThreads(blocked);
809 // Get the next child of this item. The cookie parameter is the 2nd
810 // value returned from GetFirstChild or the previous GetNextChild.
811 // Returns a wxTreeItemId and an opaque "cookie" value that should be
812 // passed to GetNextChild in order to continue the search.
813 PyObject* GetNextChild(const wxTreeItemId& item, void* cookie) {
814 wxTreeItemId* ritem = new wxTreeItemId(self->GetNextChild(item, cookie));
815 wxPyBlock_t blocked = wxPyBeginBlockThreads();
816 PyObject* tup = PyTuple_New(2);
817 PyTuple_SET_ITEM(tup, 0, wxPyConstructObject(ritem, wxT("wxTreeItemId"), true));
818 PyTuple_SET_ITEM(tup, 1, wxPyMakeSwigPtr(cookie, wxT("void")));
819 wxPyEndBlockThreads(blocked);
824 // TODO: GetPrevChild
828 // get the last child of this item - this method doesn't use cookies
829 wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
831 // get the next sibling of this item
832 wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
834 // get the previous sibling
835 wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
837 // get first visible item
838 wxTreeItemId GetFirstVisibleItem() const;
840 // get the next visible item: item must be visible itself!
841 // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
842 wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
844 // get the previous visible item: item must be visible itself!
845 wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
847 // Only for internal use right now, but should probably be public
848 wxTreeItemId GetNext(const wxTreeItemId& item) const;
851 %disownarg( wxPyTreeItemData* data );
853 // add the root node to the tree
854 wxTreeItemId AddRoot(const wxString& text,
855 int image = -1, int selectedImage = -1,
856 wxPyTreeItemData *data = NULL);
858 // insert a new item in as the first child of the parent
859 wxTreeItemId PrependItem(const wxTreeItemId& parent,
860 const wxString& text,
861 int image = -1, int selectedImage = -1,
862 wxPyTreeItemData *data = NULL);
864 // insert a new item after a given one
865 wxTreeItemId InsertItem(const wxTreeItemId& parent,
866 const wxTreeItemId& idPrevious,
867 const wxString& text,
868 int image = -1, int selectedImage = -1,
869 wxPyTreeItemData *data = NULL);
871 // insert a new item before the one with the given index
872 %Rename(InsertItemBefore,
873 wxTreeItemId, InsertItem(const wxTreeItemId& parent,
875 const wxString& text,
876 int image = -1, int selectedImage = -1,
877 wxPyTreeItemData *data = NULL));
879 // insert a new item in as the last child of the parent
880 wxTreeItemId AppendItem(const wxTreeItemId& parent,
881 const wxString& text,
882 int image = -1, int selectedImage = -1,
883 wxPyTreeItemData *data = NULL);
885 %cleardisown(wxPyTreeItemData* data );
887 // delete this item and associated data if any
888 void Delete(const wxTreeItemId& item);
890 // delete all children (but don't delete the item itself)
891 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
892 void DeleteChildren(const wxTreeItemId& item);
894 // delete all items from the tree
895 // NB: this won't send wxEVT_COMMAND_TREE_ITEM_DELETED events
896 void DeleteAllItems();
899 void Expand(const wxTreeItemId& item);
901 // expand this item and all subitems recursively
902 void ExpandAll(const wxTreeItemId& item);
904 // collapse the item without removing its children
905 void Collapse(const wxTreeItemId& item);
907 // collapse the item and remove all children
908 void CollapseAndReset(const wxTreeItemId& item);
910 // toggles the current state
911 void Toggle(const wxTreeItemId& item);
913 // remove the selection from currently selected item (if any)
918 void SelectItem(const wxTreeItemId& item, bool unselect_others=true,
919 bool extended_select=false);
921 void SelectAll(bool extended_select=false);
923 // make sure this item is visible (expanding the parent item and/or
924 // scrolling to this item if necessary)
925 void EnsureVisible(const wxTreeItemId& item);
927 // scroll to this item (but don't expand its parent)
928 void ScrollTo(const wxTreeItemId& item);
930 // Returns wxTreeItemId, flags, and column
931 wxTreeItemId HitTest(const wxPoint& point, int& OUTPUT, int& OUTPUT);
934 // get the bounding rectangle of the item (or of its label only)
935 PyObject* GetBoundingRect(const wxTreeItemId& item, bool textOnly = false) {
937 if (self->GetBoundingRect(item, rect, textOnly)) {
938 wxPyBlock_t blocked = wxPyBeginBlockThreads();
939 wxRect* r = new wxRect(rect);
940 PyObject* val = wxPyConstructObject((void*)r, wxT("wxRect"), 1);
941 wxPyEndBlockThreads(blocked);
951 // Start editing the item label: this (temporarily) replaces the item
952 // with a one line edit control. The item will be selected if it hadn't
954 void EditLabel( const wxTreeItemId& item );
955 void Edit( const wxTreeItemId& item );
957 // sort the children of this item using OnCompareItems
958 void SortChildren(const wxTreeItemId& item);
961 wxTreeItemId FindItem (const wxTreeItemId& item, const wxString& str, int flags = 0);
963 wxWindow* GetHeaderWindow() const;
964 wxScrolledWindow* GetMainWindow() const;
968 //----------------------------------------------------------------------
978 MustHaveApp(wxStaticPicture);
980 class wxStaticPicture : public wxControl
983 %pythonAppend wxStaticPicture "self._setOORInfo(self)"
984 %pythonAppend wxStaticPicture() ""
986 wxStaticPicture( wxWindow* parent, wxWindowID id=-1,
987 const wxBitmap& label=wxNullBitmap,
988 const wxPoint& pos = wxDefaultPosition,
989 const wxSize& size = wxDefaultSize,
991 const wxString& name = wxPyStaticPictureNameStr );
993 %RenameCtor(PreStaticPicture, wxStaticPicture());
995 bool Create( wxWindow* parent, wxWindowID id=-1,
996 const wxBitmap& label=wxNullBitmap,
997 const wxPoint& pos = wxDefaultPosition,
998 const wxSize& size = wxDefaultSize,
1000 const wxString& name = wxPyStaticPictureNameStr );
1002 void SetBitmap( const wxBitmap& bmp );
1003 wxBitmap GetBitmap() const;
1004 void SetIcon( const wxIcon& icon );
1005 wxIcon GetIcon() const;
1007 void SetAlignment( int align );
1008 int GetAlignment() const;
1010 void SetScale( int scale );
1011 int GetScale() const;
1013 void SetCustomScale( float sx, float sy );
1014 void GetCustomScale( float* OUTPUT, float* OUTPUT ) const;
1019 //----------------------------------------------------------------------
1020 //----------------------------------------------------------------------
1024 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
1025 wxPyPtrTypeMap_Add("wxTreeListCtrl", "wxPyTreeListCtrl");
1029 %pragma(python) include="_gizmoextras.py";
1031 //----------------------------------------------------------------------
1032 //----------------------------------------------------------------------