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 // Put some wx default wxChar* values into wxStrings.
40 static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow"));
41 static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox"));
44 ///----------------------------------------------------------------------
47 wxEVT_DYNAMIC_SASH_SPLIT,
48 wxEVT_DYNAMIC_SASH_UNIFY,
50 wxDS_MANAGE_SCROLLBARS,
56 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
57 whenever your view is being split by the user. It is your
58 responsibility to handle this event by creating a new view window as
59 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
60 automatically reparent it to the proper place in its window hierarchy.
62 class wxDynamicSashSplitEvent : public wxCommandEvent {
64 wxDynamicSashSplitEvent(wxObject *target);
69 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
70 whenever the sash which splits your view and its sibling is being
71 reunified such that your view is expanding to replace its sibling.
72 You needn't do anything with this event if you are allowing
73 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
74 if you are managing the scrollbars yourself so that you can keep
75 the scrollbars' event handlers connected to your view's event handler
78 class wxDynamicSashUnifyEvent : public wxCommandEvent {
80 wxDynamicSashUnifyEvent(wxObject *target);
89 wxDynamicSashWindow widgets manages the way other widgets are viewed.
90 When a wxDynamicSashWindow is first shown, it will contain one child
91 view, a viewport for that child, and a pair of scrollbars to allow the
92 user to navigate the child view area. Next to each scrollbar is a small
93 tab. By clicking on either tab and dragging to the appropriate spot, a
94 user can split the view area into two smaller views separated by a
95 draggable sash. Later, when the user wishes to reunify the two subviews,
96 the user simply drags the sash to the side of the window.
97 wxDynamicSashWindow will automatically reparent the appropriate child
98 view back up the window hierarchy, and the wxDynamicSashWindow will have
99 only one child view once again.
101 As an application developer, you will simply create a wxDynamicSashWindow
102 using either the Create() function or the more complex constructor
103 provided below, and then create a view window whose parent is the
104 wxDynamicSashWindow. The child should respond to
105 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
106 constructing a new view window whose parent is also the
107 wxDynamicSashWindow. That's it! Now your users can dynamically split
108 and reunify the view you provided.
110 If you wish to handle the scrollbar events for your view, rather than
111 allowing wxDynamicSashWindow to do it for you, things are a bit more
112 complex. (You might want to handle scrollbar events yourself, if,
113 for instance, you wish to scroll a subwindow of the view you add to
114 your wxDynamicSashWindow object, rather than scrolling the whole view.)
115 In this case, you will need to construct your wxDynamicSashWindow without
116 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
117 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
118 controls and call SetEventHanler() on them to redirect the scrolling
119 events whenever your window is reparented by wxDyanmicSashWindow.
120 You will need to set the scrollbars' event handler at three times:
122 * When your view is created
123 * When your view receives a wxDynamicSashSplitEvent
124 * When your view receives a wxDynamicSashUnifyEvent
126 See the dynsash_switch sample application for an example which does this.
130 class wxDynamicSashWindow : public wxWindow {
132 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
133 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
134 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
135 const wxString& name = wxPyDynamicSashNameStr);
136 %name(wxPreDynamicSashWindow)wxDynamicSashWindow();
138 bool Create(wxWindow *parent, wxWindowID id,
139 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
140 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
141 const wxString& name = wxPyDynamicSashNameStr);
143 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
144 %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)"
146 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
147 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
152 //----------------------------------------------------------------------
153 // Python functions to act like the event macros
155 %pragma(python) code = "
156 def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
157 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
159 def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
160 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
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 wxEditableListBox(wxWindow *parent, wxWindowID id,
178 const wxString& label,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
181 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
182 const wxString& name = wxPyEditableListBoxNameStr);
184 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
186 void SetStrings(const wxArrayString& strings);
188 //void GetStrings(wxArrayString& strings);
190 PyObject* GetStrings() {
191 wxArrayString strings;
192 self->GetStrings(strings);
193 return wxArrayString2PyList_helper(strings);
200 //----------------------------------------------------------------------
204 * wxRemotelyScrolledTreeCtrl
206 * This tree control disables its vertical scrollbar and catches scroll
207 * events passed by a scrolled window higher in the hierarchy.
208 * It also updates the scrolled window vertical scrollbar as appropriate.
212 typedef wxTreeCtrl wxPyTreeCtrl;
215 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
218 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
219 const wxPoint& pos = wxDefaultPosition,
220 const wxSize& size = wxDefaultSize,
221 long style = wxTR_HAS_BUTTONS);
222 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
225 void HideVScrollbar();
227 // Adjust the containing wxScrolledWindow's scrollbars appropriately
228 void AdjustRemoteScrollbars();
230 // Find the scrolled window that contains this control
231 wxScrolledWindow* GetScrolledWindow() const;
233 // Scroll to the given line (in scroll units where each unit is
234 // the height of an item)
235 void ScrollToLine(int posHoriz, int posVert);
237 // The companion window is one which will get notified when certain
238 // events happen such as node expansion
239 void SetCompanionWindow(wxWindow* companion);
240 wxWindow* GetCompanionWindow() const;
246 * wxTreeCompanionWindow
248 * A window displaying values associated with tree control items.
252 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
255 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
256 const wxPoint& pos = wxDefaultPosition,
257 const wxSize& size = wxDefaultSize,
259 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
262 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
264 wxPyBeginBlockThreads();
265 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
266 PyObject* dcobj = wxPyMake_wxObject(&dc);
267 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
268 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
269 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
274 wxPyEndBlockThreads();
276 wxTreeCompanionWindow::DrawItem(dc, id, rect);
284 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
287 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
288 const wxPoint& pos = wxDefaultPosition,
289 const wxSize& size = wxDefaultSize,
291 void _setCallbackInfo(PyObject* self, PyObject* _class);
292 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
293 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
295 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
296 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
302 * wxThinSplitterWindow
304 * Implements a splitter with a less obvious sash
305 * than the usual one.
308 class wxThinSplitterWindow: public wxSplitterWindow
311 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
312 const wxPoint& pos = wxDefaultPosition,
313 const wxSize& size = wxDefaultSize,
314 long style = wxSP_3D | wxCLIP_CHILDREN);
315 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
321 * wxSplitterScrolledWindow
323 * This scrolled window is aware of the fact that one of its
324 * children is a splitter window. It passes on its scroll events
325 * (after some processing) to both splitter children for them
326 * scroll appropriately.
329 class wxSplitterScrolledWindow: public wxScrolledWindow
332 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
333 const wxPoint& pos = wxDefaultPosition,
334 const wxSize& size = wxDefaultSize,
336 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
340 //----------------------------------------------------------------------
341 //----------------------------------------------------------------------
356 class wxLEDNumberCtrl : public wxControl
360 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
361 const wxPoint& pos = wxDefaultPosition,
362 const wxSize& size = wxDefaultSize,
363 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
364 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
366 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
367 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
370 bool Create(wxWindow *parent, wxWindowID id = -1,
371 const wxPoint& pos = wxDefaultPosition,
372 const wxSize& size = wxDefaultSize,
373 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
375 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
376 bool GetDrawFaded() const { return m_DrawFaded; }
377 const wxString &GetValue() const { return m_Value; }
379 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
380 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
381 void SetValue(const wxString &Value, bool Redraw = true);
385 //----------------------------------------------------------------------
386 //----------------------------------------------------------------------
390 wxClassInfo::CleanUpClasses();
391 wxClassInfo::InitializeClasses();
393 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
397 %pragma(python) include="_gizmoextras.py";
399 //----------------------------------------------------------------------
400 //----------------------------------------------------------------------