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>
23 //---------------------------------------------------------------------------
26 %include my_typemaps.i
35 //----------------------------------------------------------------------
38 wxEVT_DYNAMIC_SASH_SPLIT,
39 wxEVT_DYNAMIC_SASH_UNIFY,
41 wxDS_MANAGE_SCROLLBARS,
47 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
48 whenever your view is being split by the user. It is your
49 responsibility to handle this event by creating a new view window as
50 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
51 automatically reparent it to the proper place in its window hierarchy.
53 class wxDynamicSashSplitEvent : public wxCommandEvent {
55 wxDynamicSashSplitEvent(wxObject *target);
60 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
61 whenever the sash which splits your view and its sibling is being
62 reunified such that your view is expanding to replace its sibling.
63 You needn't do anything with this event if you are allowing
64 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
65 if you are managing the scrollbars yourself so that you can keep
66 the scrollbars' event handlers connected to your view's event handler
69 class wxDynamicSashUnifyEvent : public wxCommandEvent {
71 wxDynamicSashUnifyEvent(wxObject *target);
80 wxDynamicSashWindow widgets manages the way other widgets are viewed.
81 When a wxDynamicSashWindow is first shown, it will contain one child
82 view, a viewport for that child, and a pair of scrollbars to allow the
83 user to navigate the child view area. Next to each scrollbar is a small
84 tab. By clicking on either tab and dragging to the appropriate spot, a
85 user can split the view area into two smaller views separated by a
86 draggable sash. Later, when the user wishes to reunify the two subviews,
87 the user simply drags the sash to the side of the window.
88 wxDynamicSashWindow will automatically reparent the appropriate child
89 view back up the window hierarchy, and the wxDynamicSashWindow will have
90 only one child view once again.
92 As an application developer, you will simply create a wxDynamicSashWindow
93 using either the Create() function or the more complex constructor
94 provided below, and then create a view window whose parent is the
95 wxDynamicSashWindow. The child should respond to
96 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
97 constructing a new view window whose parent is also the
98 wxDynamicSashWindow. That's it! Now your users can dynamically split
99 and reunify the view you provided.
101 If you wish to handle the scrollbar events for your view, rather than
102 allowing wxDynamicSashWindow to do it for you, things are a bit more
103 complex. (You might want to handle scrollbar events yourself, if,
104 for instance, you wish to scroll a subwindow of the view you add to
105 your wxDynamicSashWindow object, rather than scrolling the whole view.)
106 In this case, you will need to construct your wxDynamicSashWindow without
107 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
108 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
109 controls and call SetEventHanler() on them to redirect the scrolling
110 events whenever your window is reparented by wxDyanmicSashWindow.
111 You will need to set the scrollbars' event handler at three times:
113 * When your view is created
114 * When your view receives a wxDynamicSashSplitEvent
115 * When your view receives a wxDynamicSashUnifyEvent
117 See the dynsash_switch sample application for an example which does this.
121 class wxDynamicSashWindow : public wxWindow {
123 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
124 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
125 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
126 const char* name = "dynamicSashWindow");
127 %name(wxPreDynamicSashWindow)wxDynamicSashWindow();
129 bool Create(wxWindow *parent, wxWindowID id,
130 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
131 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
132 const char* name = "dynamicSashWindow");
134 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
135 %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)"
137 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
138 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
143 //----------------------------------------------------------------------
144 // Python functions to act like the event macros
146 %pragma(python) code = "
147 def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
148 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
150 def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
151 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
154 //----------------------------------------------------------------------
155 //----------------------------------------------------------------------
158 // This class provides a composite control that lets the
159 // user easily enter list of strings
160 class wxEditableListBox : public wxPanel
163 wxEditableListBox(wxWindow *parent, wxWindowID id,
164 const wxString& label,
165 const wxPoint& pos = wxDefaultPosition,
166 const wxSize& size = wxDefaultSize,
167 const char* name = "editableListBox");
169 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
171 void SetStrings(const wxArrayString& strings);
173 //void GetStrings(wxArrayString& strings);
175 PyObject* GetStrings() {
176 wxArrayString strings;
177 self->GetStrings(strings);
178 return wxArrayString2PyList_helper(strings);
185 //----------------------------------------------------------------------
189 * wxRemotelyScrolledTreeCtrl
191 * This tree control disables its vertical scrollbar and catches scroll
192 * events passed by a scrolled window higher in the hierarchy.
193 * It also updates the scrolled window vertical scrollbar as appropriate.
197 typedef wxTreeCtrl wxPyTreeCtrl;
200 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
203 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
204 const wxPoint& pos = wxDefaultPosition,
205 const wxSize& size = wxDefaultSize,
206 long style = wxTR_HAS_BUTTONS);
207 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
210 void HideVScrollbar();
212 // Adjust the containing wxScrolledWindow's scrollbars appropriately
213 void AdjustRemoteScrollbars();
215 // Find the scrolled window that contains this control
216 wxScrolledWindow* GetScrolledWindow() const;
218 // Scroll to the given line (in scroll units where each unit is
219 // the height of an item)
220 void ScrollToLine(int posHoriz, int posVert);
222 // The companion window is one which will get notified when certain
223 // events happen such as node expansion
224 void SetCompanionWindow(wxWindow* companion);
225 wxWindow* GetCompanionWindow() const;
231 * wxTreeCompanionWindow
233 * A window displaying values associated with tree control items.
237 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
240 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
241 const wxPoint& pos = wxDefaultPosition,
242 const wxSize& size = wxDefaultSize,
244 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
247 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
249 wxPyTState* state = wxPyBeginBlockThreads();
250 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
251 PyObject* dcobj = wxPyMake_wxObject(&dc);
252 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
253 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
254 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
259 wxPyEndBlockThreads(state);
261 wxTreeCompanionWindow::DrawItem(dc, id, rect);
269 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
272 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
273 const wxPoint& pos = wxDefaultPosition,
274 const wxSize& size = wxDefaultSize,
276 void _setCallbackInfo(PyObject* self, PyObject* _class);
277 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
278 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
280 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
281 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
287 * wxThinSplitterWindow
289 * Implements a splitter with a less obvious sash
290 * than the usual one.
293 class wxThinSplitterWindow: public wxSplitterWindow
296 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
297 const wxPoint& pos = wxDefaultPosition,
298 const wxSize& size = wxDefaultSize,
299 long style = wxSP_3D | wxCLIP_CHILDREN);
300 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
306 * wxSplitterScrolledWindow
308 * This scrolled window is aware of the fact that one of its
309 * children is a splitter window. It passes on its scroll events
310 * (after some processing) to both splitter children for them
311 * scroll appropriately.
314 class wxSplitterScrolledWindow: public wxScrolledWindow
317 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
318 const wxPoint& pos = wxDefaultPosition,
319 const wxSize& size = wxDefaultSize,
321 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
325 //----------------------------------------------------------------------
329 wxClassInfo::CleanUpClasses();
330 wxClassInfo::InitializeClasses();
332 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
336 %pragma(python) include="_gizmoextras.py";
338 //----------------------------------------------------------------------
339 //----------------------------------------------------------------------