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);
197 wxListCtrl* GetListCtrl() { return m_listCtrl; }
198 wxBitmapButton* GetDelButton() { return m_bDel; }
199 wxBitmapButton* GetNewButton() { return m_bNew; }
200 wxBitmapButton* GetUpButton() { return m_bUp; }
201 wxBitmapButton* GetDownButton() { return m_bDown; }
202 wxBitmapButton* GetEditButton() { return m_bEdit; }
207 //----------------------------------------------------------------------
211 * wxRemotelyScrolledTreeCtrl
213 * This tree control disables its vertical scrollbar and catches scroll
214 * events passed by a scrolled window higher in the hierarchy.
215 * It also updates the scrolled window vertical scrollbar as appropriate.
219 typedef wxTreeCtrl wxPyTreeCtrl;
222 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
225 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
226 const wxPoint& pos = wxDefaultPosition,
227 const wxSize& size = wxDefaultSize,
228 long style = wxTR_HAS_BUTTONS);
229 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
232 void HideVScrollbar();
234 // Adjust the containing wxScrolledWindow's scrollbars appropriately
235 void AdjustRemoteScrollbars();
237 // Find the scrolled window that contains this control
238 wxScrolledWindow* GetScrolledWindow() const;
240 // Scroll to the given line (in scroll units where each unit is
241 // the height of an item)
242 void ScrollToLine(int posHoriz, int posVert);
244 // The companion window is one which will get notified when certain
245 // events happen such as node expansion
246 void SetCompanionWindow(wxWindow* companion);
247 wxWindow* GetCompanionWindow() const;
253 * wxTreeCompanionWindow
255 * A window displaying values associated with tree control items.
259 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
262 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
263 const wxPoint& pos = wxDefaultPosition,
264 const wxSize& size = wxDefaultSize,
266 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
269 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
271 wxPyBeginBlockThreads();
272 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
273 PyObject* dcobj = wxPyMake_wxObject(&dc);
274 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
275 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
276 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
281 wxPyEndBlockThreads();
283 wxTreeCompanionWindow::DrawItem(dc, id, rect);
291 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
294 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
298 void _setCallbackInfo(PyObject* self, PyObject* _class);
299 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
300 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
302 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
303 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
309 * wxThinSplitterWindow
311 * Implements a splitter with a less obvious sash
312 * than the usual one.
315 class wxThinSplitterWindow: public wxSplitterWindow
318 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
321 long style = wxSP_3D | wxCLIP_CHILDREN);
322 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
328 * wxSplitterScrolledWindow
330 * This scrolled window is aware of the fact that one of its
331 * children is a splitter window. It passes on its scroll events
332 * (after some processing) to both splitter children for them
333 * scroll appropriately.
336 class wxSplitterScrolledWindow: public wxScrolledWindow
339 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
340 const wxPoint& pos = wxDefaultPosition,
341 const wxSize& size = wxDefaultSize,
343 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
347 //----------------------------------------------------------------------
348 //----------------------------------------------------------------------
363 class wxLEDNumberCtrl : public wxControl
367 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
368 const wxPoint& pos = wxDefaultPosition,
369 const wxSize& size = wxDefaultSize,
370 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
371 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
373 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
374 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
377 bool Create(wxWindow *parent, wxWindowID id = -1,
378 const wxPoint& pos = wxDefaultPosition,
379 const wxSize& size = wxDefaultSize,
380 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
382 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
383 bool GetDrawFaded() const { return m_DrawFaded; }
384 const wxString &GetValue() const { return m_Value; }
386 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
387 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
388 void SetValue(const wxString &Value, bool Redraw = true);
392 //----------------------------------------------------------------------
393 //----------------------------------------------------------------------
397 wxClassInfo::CleanUpClasses();
398 wxClassInfo::InitializeClasses();
400 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
404 %pragma(python) include="_gizmoextras.py";
406 //----------------------------------------------------------------------
407 //----------------------------------------------------------------------