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 /////////////////////////////////////////////////////////////////////////////
18 #include <wx/gizmos/dynamicsash.h>
19 #include <wx/gizmos/editlbox.h>
20 #include <wx/gizmos/splittree.h>
21 #include <wx/gizmos/ledctrl.h>
24 //---------------------------------------------------------------------------
27 %include my_typemaps.i
36 //----------------------------------------------------------------------
39 wxEVT_DYNAMIC_SASH_SPLIT,
40 wxEVT_DYNAMIC_SASH_UNIFY,
42 wxDS_MANAGE_SCROLLBARS,
48 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
49 whenever your view is being split by the user. It is your
50 responsibility to handle this event by creating a new view window as
51 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
52 automatically reparent it to the proper place in its window hierarchy.
54 class wxDynamicSashSplitEvent : public wxCommandEvent {
56 wxDynamicSashSplitEvent(wxObject *target);
61 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
62 whenever the sash which splits your view and its sibling is being
63 reunified such that your view is expanding to replace its sibling.
64 You needn't do anything with this event if you are allowing
65 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
66 if you are managing the scrollbars yourself so that you can keep
67 the scrollbars' event handlers connected to your view's event handler
70 class wxDynamicSashUnifyEvent : public wxCommandEvent {
72 wxDynamicSashUnifyEvent(wxObject *target);
81 wxDynamicSashWindow widgets manages the way other widgets are viewed.
82 When a wxDynamicSashWindow is first shown, it will contain one child
83 view, a viewport for that child, and a pair of scrollbars to allow the
84 user to navigate the child view area. Next to each scrollbar is a small
85 tab. By clicking on either tab and dragging to the appropriate spot, a
86 user can split the view area into two smaller views separated by a
87 draggable sash. Later, when the user wishes to reunify the two subviews,
88 the user simply drags the sash to the side of the window.
89 wxDynamicSashWindow will automatically reparent the appropriate child
90 view back up the window hierarchy, and the wxDynamicSashWindow will have
91 only one child view once again.
93 As an application developer, you will simply create a wxDynamicSashWindow
94 using either the Create() function or the more complex constructor
95 provided below, and then create a view window whose parent is the
96 wxDynamicSashWindow. The child should respond to
97 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
98 constructing a new view window whose parent is also the
99 wxDynamicSashWindow. That's it! Now your users can dynamically split
100 and reunify the view you provided.
102 If you wish to handle the scrollbar events for your view, rather than
103 allowing wxDynamicSashWindow to do it for you, things are a bit more
104 complex. (You might want to handle scrollbar events yourself, if,
105 for instance, you wish to scroll a subwindow of the view you add to
106 your wxDynamicSashWindow object, rather than scrolling the whole view.)
107 In this case, you will need to construct your wxDynamicSashWindow without
108 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
109 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
110 controls and call SetEventHanler() on them to redirect the scrolling
111 events whenever your window is reparented by wxDyanmicSashWindow.
112 You will need to set the scrollbars' event handler at three times:
114 * When your view is created
115 * When your view receives a wxDynamicSashSplitEvent
116 * When your view receives a wxDynamicSashUnifyEvent
118 See the dynsash_switch sample application for an example which does this.
122 class wxDynamicSashWindow : public wxWindow {
124 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
125 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
126 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
127 const char* name = "dynamicSashWindow");
128 %name(wxPreDynamicSashWindow)wxDynamicSashWindow();
130 bool Create(wxWindow *parent, wxWindowID id,
131 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
132 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
133 const char* name = "dynamicSashWindow");
135 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
136 %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)"
138 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
139 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
144 //----------------------------------------------------------------------
145 // Python functions to act like the event macros
147 %pragma(python) code = "
148 def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
149 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
151 def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
152 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
155 //----------------------------------------------------------------------
156 //----------------------------------------------------------------------
164 // This class provides a composite control that lets the
165 // user easily enter list of strings
166 class wxEditableListBox : public wxPanel
169 wxEditableListBox(wxWindow *parent, wxWindowID id,
170 const wxString& label,
171 const wxPoint& pos = wxDefaultPosition,
172 const wxSize& size = wxDefaultSize,
173 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
174 const char* name = "editableListBox");
176 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
178 void SetStrings(const wxArrayString& strings);
180 //void GetStrings(wxArrayString& strings);
182 PyObject* GetStrings() {
183 wxArrayString strings;
184 self->GetStrings(strings);
185 return wxArrayString2PyList_helper(strings);
192 //----------------------------------------------------------------------
196 * wxRemotelyScrolledTreeCtrl
198 * This tree control disables its vertical scrollbar and catches scroll
199 * events passed by a scrolled window higher in the hierarchy.
200 * It also updates the scrolled window vertical scrollbar as appropriate.
204 typedef wxTreeCtrl wxPyTreeCtrl;
207 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
210 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
211 const wxPoint& pos = wxDefaultPosition,
212 const wxSize& size = wxDefaultSize,
213 long style = wxTR_HAS_BUTTONS);
214 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
217 void HideVScrollbar();
219 // Adjust the containing wxScrolledWindow's scrollbars appropriately
220 void AdjustRemoteScrollbars();
222 // Find the scrolled window that contains this control
223 wxScrolledWindow* GetScrolledWindow() const;
225 // Scroll to the given line (in scroll units where each unit is
226 // the height of an item)
227 void ScrollToLine(int posHoriz, int posVert);
229 // The companion window is one which will get notified when certain
230 // events happen such as node expansion
231 void SetCompanionWindow(wxWindow* companion);
232 wxWindow* GetCompanionWindow() const;
238 * wxTreeCompanionWindow
240 * A window displaying values associated with tree control items.
244 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
247 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
248 const wxPoint& pos = wxDefaultPosition,
249 const wxSize& size = wxDefaultSize,
251 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
254 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
256 wxPyBeginBlockThreads();
257 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
258 PyObject* dcobj = wxPyMake_wxObject(&dc);
259 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
260 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
261 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
266 wxPyEndBlockThreads();
268 wxTreeCompanionWindow::DrawItem(dc, id, rect);
276 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
279 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
280 const wxPoint& pos = wxDefaultPosition,
281 const wxSize& size = wxDefaultSize,
283 void _setCallbackInfo(PyObject* self, PyObject* _class);
284 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
285 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
287 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
288 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
294 * wxThinSplitterWindow
296 * Implements a splitter with a less obvious sash
297 * than the usual one.
300 class wxThinSplitterWindow: public wxSplitterWindow
303 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
304 const wxPoint& pos = wxDefaultPosition,
305 const wxSize& size = wxDefaultSize,
306 long style = wxSP_3D | wxCLIP_CHILDREN);
307 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
313 * wxSplitterScrolledWindow
315 * This scrolled window is aware of the fact that one of its
316 * children is a splitter window. It passes on its scroll events
317 * (after some processing) to both splitter children for them
318 * scroll appropriately.
321 class wxSplitterScrolledWindow: public wxScrolledWindow
324 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
325 const wxPoint& pos = wxDefaultPosition,
326 const wxSize& size = wxDefaultSize,
328 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
332 //----------------------------------------------------------------------
333 //----------------------------------------------------------------------
348 class wxLEDNumberCtrl : public wxControl
352 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
353 const wxPoint& pos = wxDefaultPosition,
354 const wxSize& size = wxDefaultSize,
355 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
356 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
358 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
359 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
362 bool Create(wxWindow *parent, wxWindowID id = -1,
363 const wxPoint& pos = wxDefaultPosition,
364 const wxSize& size = wxDefaultSize,
365 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
367 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
368 bool GetDrawFaded() const { return m_DrawFaded; }
369 const wxString &GetValue() const { return m_Value; }
371 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
372 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
373 void SetValue(const wxString &Value, bool Redraw = true);
377 //----------------------------------------------------------------------
378 //----------------------------------------------------------------------
382 wxClassInfo::CleanUpClasses();
383 wxClassInfo::InitializeClasses();
385 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
389 %pragma(python) include="_gizmoextras.py";
391 //----------------------------------------------------------------------
392 //----------------------------------------------------------------------