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>
37 //---------------------------------------------------------------------------
41 %pythoncode { import wx }
42 %pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
45 MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
46 MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
47 MAKE_CONST_WXSTRING(StaticPictureNameStr);
49 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
51 //---------------------------------------------------------------------------
54 wxDS_MANAGE_SCROLLBARS,
58 %constant wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
59 %constant wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
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 MustHaveApp(wxDynamicSashWindow);
139 class wxDynamicSashWindow : public wxWindow {
141 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
142 %pythonAppend wxDynamicSashWindow() ""
144 wxDynamicSashWindow(wxWindow *parent, wxWindowID id=-1,
145 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
146 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
147 const wxString& name = wxPyDynamicSashNameStr);
148 %RenameCtor(PreDynamicSashWindow, wxDynamicSashWindow());
150 bool Create(wxWindow *parent, wxWindowID id=-1,
151 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
152 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
153 const wxString& name = wxPyDynamicSashNameStr);
155 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
156 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
162 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
163 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
166 //---------------------------------------------------------------------------
167 //---------------------------------------------------------------------------
175 // This class provides a composite control that lets the
176 // user easily enter list of strings
177 MustHaveApp(wxEditableListBox);
178 class wxEditableListBox : public wxPanel
181 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
182 %pythonAppend wxEditableListBox() ""
184 wxEditableListBox(wxWindow *parent, wxWindowID id=-1,
185 const wxString& label = wxPyEmptyString,
186 const wxPoint& pos = wxDefaultPosition,
187 const wxSize& size = wxDefaultSize,
188 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
189 const wxString& name = wxPyEditableListBoxNameStr);
192 void SetStrings(const wxArrayString& strings);
194 //void GetStrings(wxArrayString& strings);
196 PyObject* GetStrings() {
197 wxArrayString strings;
198 self->GetStrings(strings);
199 return wxArrayString2PyList_helper(strings);
203 wxPyListCtrl* GetListCtrl();
204 wxBitmapButton* GetDelButton();
205 wxBitmapButton* GetNewButton();
206 wxBitmapButton* GetUpButton();
207 wxBitmapButton* GetDownButton();
208 wxBitmapButton* GetEditButton();
210 %property(DelButton, GetDelButton, doc="See `GetDelButton`");
211 %property(DownButton, GetDownButton, doc="See `GetDownButton`");
212 %property(EditButton, GetEditButton, doc="See `GetEditButton`");
213 %property(ListCtrl, GetListCtrl, doc="See `GetListCtrl`");
214 %property(NewButton, GetNewButton, doc="See `GetNewButton`");
215 %property(Strings, GetStrings, SetStrings, doc="See `GetStrings` and `SetStrings`");
216 %property(UpButton, GetUpButton, doc="See `GetUpButton`");
221 //---------------------------------------------------------------------------
225 * wxRemotelyScrolledTreeCtrl
227 * This tree control disables its vertical scrollbar and catches scroll
228 * events passed by a scrolled window higher in the hierarchy.
229 * It also updates the scrolled window vertical scrollbar as appropriate.
233 typedef wxTreeCtrl wxPyTreeCtrl;
236 MustHaveApp(wxRemotelyScrolledTreeCtrl);
238 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
241 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
242 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
244 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
245 const wxPoint& pos = wxDefaultPosition,
246 const wxSize& size = wxDefaultSize,
247 long style = wxTR_HAS_BUTTONS);
250 void HideVScrollbar();
252 // Adjust the containing wxScrolledWindow's scrollbars appropriately
253 void AdjustRemoteScrollbars();
255 // Find the scrolled window that contains this control
256 wxScrolledWindow* GetScrolledWindow() const;
258 // Scroll to the given line (in scroll units where each unit is
259 // the height of an item)
260 void ScrollToLine(int posHoriz, int posVert);
262 // The companion window is one which will get notified when certain
263 // events happen such as node expansion
264 void SetCompanionWindow(wxWindow* companion);
265 wxWindow* GetCompanionWindow() const;
267 %property(CompanionWindow, GetCompanionWindow, SetCompanionWindow, doc="See `GetCompanionWindow` and `SetCompanionWindow`");
268 %property(ScrolledWindow, GetScrolledWindow, doc="See `GetScrolledWindow`");
274 * wxTreeCompanionWindow
276 * A window displaying values associated with tree control items.
280 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
283 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
284 const wxPoint& pos = wxDefaultPosition,
285 const wxSize& size = wxDefaultSize,
287 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
290 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
292 wxPyBlock_t blocked = wxPyBeginBlockThreads();
293 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
294 PyObject* dcobj = wxPyMake_wxObject(&dc,false);
295 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), false);
296 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), false);
297 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
302 wxPyEndBlockThreads(blocked);
304 wxTreeCompanionWindow::DrawItem(dc, id, rect);
312 MustHaveApp(wxPyTreeCompanionWindow);
314 %rename(TreeCompanionWindow) wxPyTreeCompanionWindow;
315 class wxPyTreeCompanionWindow: public wxWindow
318 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);self._setCallbackInfo(self, TreeCompanionWindow)"
319 %pythonAppend wxPyTreeCompanionWindow() ""
321 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
322 const wxPoint& pos = wxDefaultPosition,
323 const wxSize& size = wxDefaultSize,
325 void _setCallbackInfo(PyObject* self, PyObject* _class);
327 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
328 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
330 %property(TreeCtrl, GetTreeCtrl, SetTreeCtrl, doc="See `GetTreeCtrl` and `SetTreeCtrl`");
336 * wxThinSplitterWindow
338 * Implements a splitter with a less obvious sash
339 * than the usual one.
342 MustHaveApp(wxThinSplitterWindow);
344 class wxThinSplitterWindow: public wxSplitterWindow
347 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
348 %pythonAppend wxThinSplitterWindow() ""
350 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
351 const wxPoint& pos = wxDefaultPosition,
352 const wxSize& size = wxDefaultSize,
353 long style = wxSP_3D | wxCLIP_CHILDREN);
359 * wxSplitterScrolledWindow
361 * This scrolled window is aware of the fact that one of its
362 * children is a splitter window. It passes on its scroll events
363 * (after some processing) to both splitter children for them
364 * scroll appropriately.
367 MustHaveApp(wxSplitterScrolledWindow);
369 class wxSplitterScrolledWindow: public wxScrolledWindow
372 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
373 %pythonAppend wxSplitterScrolledWindow() ""
375 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
376 const wxPoint& pos = wxDefaultPosition,
377 const wxSize& size = wxDefaultSize,
382 //---------------------------------------------------------------------------
383 //---------------------------------------------------------------------------
398 MustHaveApp(wxLEDNumberCtrl);
400 class wxLEDNumberCtrl : public wxControl
403 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
404 %pythonAppend wxLEDNumberCtrl() ""
406 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
407 const wxPoint& pos = wxDefaultPosition,
408 const wxSize& size = wxDefaultSize,
409 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
410 %RenameCtor(PreLEDNumberCtrl, wxLEDNumberCtrl());
412 bool Create(wxWindow *parent, wxWindowID id = -1,
413 const wxPoint& pos = wxDefaultPosition,
414 const wxSize& size = wxDefaultSize,
415 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
417 wxLEDValueAlign GetAlignment() const;
418 bool GetDrawFaded() const;
419 const wxString &GetValue() const;
421 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
422 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
423 void SetValue(const wxString &Value, bool Redraw = true);
425 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
426 %property(DrawFaded, GetDrawFaded, SetDrawFaded, doc="See `GetDrawFaded` and `SetDrawFaded`");
427 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
432 //----------------------------------------------------------------------
436 //----------------------------------------------------------------------
446 MustHaveApp(wxStaticPicture);
448 class wxStaticPicture : public wxControl
451 %pythonAppend wxStaticPicture "self._setOORInfo(self)"
452 %pythonAppend wxStaticPicture() ""
454 wxStaticPicture( wxWindow* parent, wxWindowID id=-1,
455 const wxBitmap& label=wxNullBitmap,
456 const wxPoint& pos = wxDefaultPosition,
457 const wxSize& size = wxDefaultSize,
459 const wxString& name = wxPyStaticPictureNameStr );
461 %RenameCtor(PreStaticPicture, wxStaticPicture());
463 bool Create( wxWindow* parent, wxWindowID id=-1,
464 const wxBitmap& label=wxNullBitmap,
465 const wxPoint& pos = wxDefaultPosition,
466 const wxSize& size = wxDefaultSize,
468 const wxString& name = wxPyStaticPictureNameStr );
470 void SetBitmap( const wxBitmap& bmp );
471 wxBitmap GetBitmap() const;
472 void SetIcon( const wxIcon& icon );
473 wxIcon GetIcon() const;
475 void SetAlignment( int align );
476 int GetAlignment() const;
478 void SetScale( int scale );
479 int GetScale() const;
481 void SetCustomScale( float sx, float sy );
482 void GetCustomScale( float* OUTPUT, float* OUTPUT ) const;
484 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
485 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
486 %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
487 %property(Scale, GetScale, SetScale, doc="See `GetScale` and `SetScale`");
491 //----------------------------------------------------------------------
492 //----------------------------------------------------------------------
495 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
498 //----------------------------------------------------------------------
499 //----------------------------------------------------------------------