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 //----------------------------------------------------------------------
159 // This class provides a composite control that lets the
160 // user easily enter list of strings
161 class wxEditableListBox : public wxPanel
164 wxEditableListBox(wxWindow *parent, wxWindowID id,
165 const wxString& label,
166 const wxPoint& pos = wxDefaultPosition,
167 const wxSize& size = wxDefaultSize,
168 const char* name = "editableListBox");
170 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
172 void SetStrings(const wxArrayString& strings);
174 //void GetStrings(wxArrayString& strings);
176 PyObject* GetStrings() {
177 wxArrayString strings;
178 self->GetStrings(strings);
179 return wxArrayString2PyList_helper(strings);
186 //----------------------------------------------------------------------
190 * wxRemotelyScrolledTreeCtrl
192 * This tree control disables its vertical scrollbar and catches scroll
193 * events passed by a scrolled window higher in the hierarchy.
194 * It also updates the scrolled window vertical scrollbar as appropriate.
198 typedef wxTreeCtrl wxPyTreeCtrl;
201 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
204 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
205 const wxPoint& pos = wxDefaultPosition,
206 const wxSize& size = wxDefaultSize,
207 long style = wxTR_HAS_BUTTONS);
208 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
211 void HideVScrollbar();
213 // Adjust the containing wxScrolledWindow's scrollbars appropriately
214 void AdjustRemoteScrollbars();
216 // Find the scrolled window that contains this control
217 wxScrolledWindow* GetScrolledWindow() const;
219 // Scroll to the given line (in scroll units where each unit is
220 // the height of an item)
221 void ScrollToLine(int posHoriz, int posVert);
223 // The companion window is one which will get notified when certain
224 // events happen such as node expansion
225 void SetCompanionWindow(wxWindow* companion);
226 wxWindow* GetCompanionWindow() const;
232 * wxTreeCompanionWindow
234 * A window displaying values associated with tree control items.
238 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
241 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
242 const wxPoint& pos = wxDefaultPosition,
243 const wxSize& size = wxDefaultSize,
245 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
248 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
250 wxPyBeginBlockThreads();
251 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
252 PyObject* dcobj = wxPyMake_wxObject(&dc);
253 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
254 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
255 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
260 wxPyEndBlockThreads();
262 wxTreeCompanionWindow::DrawItem(dc, id, rect);
270 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
273 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
274 const wxPoint& pos = wxDefaultPosition,
275 const wxSize& size = wxDefaultSize,
277 void _setCallbackInfo(PyObject* self, PyObject* _class);
278 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
279 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
281 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
282 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
288 * wxThinSplitterWindow
290 * Implements a splitter with a less obvious sash
291 * than the usual one.
294 class wxThinSplitterWindow: public wxSplitterWindow
297 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
298 const wxPoint& pos = wxDefaultPosition,
299 const wxSize& size = wxDefaultSize,
300 long style = wxSP_3D | wxCLIP_CHILDREN);
301 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
307 * wxSplitterScrolledWindow
309 * This scrolled window is aware of the fact that one of its
310 * children is a splitter window. It passes on its scroll events
311 * (after some processing) to both splitter children for them
312 * scroll appropriately.
315 class wxSplitterScrolledWindow: public wxScrolledWindow
318 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
322 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
326 //----------------------------------------------------------------------
327 //----------------------------------------------------------------------
342 class wxLEDNumberCtrl : public wxControl
346 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
347 const wxPoint& pos = wxDefaultPosition,
348 const wxSize& size = wxDefaultSize,
349 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
350 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
352 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
353 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
356 bool Create(wxWindow *parent, wxWindowID id = -1,
357 const wxPoint& pos = wxDefaultPosition,
358 const wxSize& size = wxDefaultSize,
359 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
361 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
362 bool GetDrawFaded() const { return m_DrawFaded; }
363 const wxString &GetValue() const { return m_Value; }
365 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
366 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
367 void SetValue(const wxString &Value, bool Redraw = true);
371 //----------------------------------------------------------------------
372 //----------------------------------------------------------------------
376 wxClassInfo::CleanUpClasses();
377 wxClassInfo::InitializeClasses();
379 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
383 %pragma(python) include="_gizmoextras.py";
385 //----------------------------------------------------------------------
386 //----------------------------------------------------------------------