]>
Commit | Line | Data |
---|---|---|
ebf4302c RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: gizmos.i | |
3 | // Purpose: Wrappers for the "gizmo" classes in wx/contrib | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 23-Nov-2001 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2001 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | %module gizmos | |
14 | ||
15 | ||
16 | %{ | |
17 | #include "export.h" | |
611dc22c RD |
18 | #include <wx/gizmos/dynamicsash.h> |
19 | #include <wx/gizmos/editlbox.h> | |
20 | #include <wx/gizmos/splittree.h> | |
ebf4302c RD |
21 | %} |
22 | ||
23 | //--------------------------------------------------------------------------- | |
24 | ||
25 | %include typemaps.i | |
26 | %include my_typemaps.i | |
27 | ||
28 | %extern wx.i | |
29 | %extern windows.i | |
30 | %extern _defs.i | |
31 | %extern events.i | |
32 | %extern controls.i | |
33 | ||
34 | ||
35 | //---------------------------------------------------------------------- | |
36 | ||
37 | enum { | |
38 | wxEVT_DYNAMIC_SASH_SPLIT, | |
39 | wxEVT_DYNAMIC_SASH_UNIFY, | |
40 | ||
41 | wxDS_MANAGE_SCROLLBARS, | |
42 | wxDS_DRAG_CORNER, | |
43 | }; | |
44 | ||
45 | ||
46 | /* | |
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. | |
52 | */ | |
53 | class wxDynamicSashSplitEvent : public wxCommandEvent { | |
54 | public: | |
55 | wxDynamicSashSplitEvent(wxObject *target); | |
56 | }; | |
57 | ||
58 | ||
59 | /* | |
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 | |
67 | class. | |
68 | */ | |
69 | class wxDynamicSashUnifyEvent : public wxCommandEvent { | |
70 | public: | |
71 | wxDynamicSashUnifyEvent(wxObject *target); | |
72 | }; | |
73 | ||
74 | ||
75 | ||
76 | /* | |
77 | ||
78 | wxDynamicSashWindow | |
79 | ||
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. | |
91 | ||
92 | As an application developer, you will simply create a wxDynamicSashWindow | |
93 | using either the Create() function or the more complex constructor | |
611dc22c | 94 | provided below, and then create a view window whose parent is the |
ebf4302c RD |
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. | |
100 | ||
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.) | |
611dc22c | 106 | In this case, you will need to construct your wxDynamicSashWindow without |
ebf4302c RD |
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: | |
112 | ||
113 | * When your view is created | |
114 | * When your view receives a wxDynamicSashSplitEvent | |
115 | * When your view receives a wxDynamicSashUnifyEvent | |
116 | ||
117 | See the dynsash_switch sample application for an example which does this. | |
118 | ||
119 | */ | |
120 | ||
121 | class wxDynamicSashWindow : public wxWindow { | |
122 | public: | |
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(); | |
128 | ||
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"); | |
133 | ||
134 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
135 | %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)" | |
136 | ||
137 | wxScrollBar *GetHScrollBar(const wxWindow *child) const; | |
138 | wxScrollBar *GetVScrollBar(const wxWindow *child) const; | |
139 | }; | |
140 | ||
141 | ||
142 | ||
143 | //---------------------------------------------------------------------- | |
144 | // Python functions to act like the event macros | |
145 | ||
146 | %pragma(python) code = " | |
147 | def EVT_DYNAMIC_SASH_SPLIT(win, id, func): | |
148 | win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func) | |
149 | ||
150 | def EVT_DYNAMIC_SASH_UNIFY(win, id, func): | |
151 | win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func) | |
152 | " | |
153 | ||
7b7ac0ab RD |
154 | //---------------------------------------------------------------------- |
155 | //---------------------------------------------------------------------- | |
156 | ||
157 | ||
158 | // This class provides a composite control that lets the | |
159 | // user easily enter list of strings | |
160 | class wxEditableListBox : public wxPanel | |
161 | { | |
162 | public: | |
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"); | |
168 | ||
611dc22c RD |
169 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
170 | ||
7b7ac0ab RD |
171 | void SetStrings(const wxArrayString& strings); |
172 | ||
173 | //void GetStrings(wxArrayString& strings); | |
174 | %addmethods { | |
175 | PyObject* GetStrings() { | |
176 | wxArrayString strings; | |
177 | self->GetStrings(strings); | |
178 | return wxArrayString2PyList_helper(strings); | |
179 | } | |
180 | } | |
181 | }; | |
182 | ||
183 | ||
184 | ||
611dc22c RD |
185 | //---------------------------------------------------------------------- |
186 | ||
187 | ||
188 | /* | |
189 | * wxRemotelyScrolledTreeCtrl | |
190 | * | |
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. | |
194 | */ | |
195 | ||
196 | %{ | |
197 | typedef wxTreeCtrl wxPyTreeCtrl; | |
198 | %} | |
199 | ||
200 | class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl | |
201 | { | |
202 | public: | |
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)" | |
208 | ||
209 | ||
210 | void HideVScrollbar(); | |
211 | ||
212 | // Adjust the containing wxScrolledWindow's scrollbars appropriately | |
213 | void AdjustRemoteScrollbars(); | |
214 | ||
215 | // Find the scrolled window that contains this control | |
216 | wxScrolledWindow* GetScrolledWindow() const; | |
217 | ||
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); | |
221 | ||
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; | |
226 | }; | |
227 | ||
228 | ||
229 | ||
230 | /* | |
231 | * wxTreeCompanionWindow | |
232 | * | |
233 | * A window displaying values associated with tree control items. | |
234 | */ | |
235 | ||
236 | %{ | |
237 | class wxPyTreeCompanionWindow: public wxTreeCompanionWindow | |
238 | { | |
239 | public: | |
240 | wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1, | |
241 | const wxPoint& pos = wxDefaultPosition, | |
242 | const wxSize& size = wxDefaultSize, | |
243 | long style = 0) | |
244 | : wxTreeCompanionWindow(parent, id, pos, size, style) {} | |
245 | ||
246 | ||
247 | virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) { | |
248 | bool found; | |
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)); | |
255 | Py_DECREF(dcobj); | |
256 | Py_DECREF(idobj); | |
257 | Py_DECREF(recobj); | |
258 | } | |
259 | wxPyEndBlockThreads(state); | |
260 | if (! found) | |
261 | wxTreeCompanionWindow::DrawItem(dc, id, rect); | |
262 | } | |
263 | ||
264 | PYPRIVATE; | |
265 | }; | |
266 | %} | |
267 | ||
268 | ||
269 | %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow | |
270 | { | |
271 | public: | |
272 | wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1, | |
273 | const wxPoint& pos = wxDefaultPosition, | |
274 | const wxSize& size = wxDefaultSize, | |
275 | long style = 0); | |
276 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
277 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)" | |
278 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
279 | ||
280 | wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const; | |
281 | void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl); | |
282 | }; | |
283 | ||
284 | ||
285 | ||
286 | /* | |
287 | * wxThinSplitterWindow | |
288 | * | |
289 | * Implements a splitter with a less obvious sash | |
290 | * than the usual one. | |
291 | */ | |
292 | ||
293 | class wxThinSplitterWindow: public wxSplitterWindow | |
294 | { | |
295 | public: | |
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)" | |
301 | ||
302 | }; | |
303 | ||
304 | ||
305 | /* | |
306 | * wxSplitterScrolledWindow | |
307 | * | |
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. | |
312 | */ | |
313 | ||
314 | class wxSplitterScrolledWindow: public wxScrolledWindow | |
315 | { | |
316 | public: | |
317 | wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1, | |
318 | const wxPoint& pos = wxDefaultPosition, | |
319 | const wxSize& size = wxDefaultSize, | |
320 | long style = 0); | |
321 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
322 | }; | |
323 | ||
324 | ||
ebf4302c RD |
325 | //---------------------------------------------------------------------- |
326 | ||
327 | %init %{ | |
328 | ||
329 | wxClassInfo::CleanUpClasses(); | |
330 | wxClassInfo::InitializeClasses(); | |
331 | ||
611dc22c | 332 | wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow"); |
ebf4302c RD |
333 | %} |
334 | ||
335 | ||
ebf4302c RD |
336 | %pragma(python) include="_gizmoextras.py"; |
337 | ||
338 | //---------------------------------------------------------------------- | |
339 | //---------------------------------------------------------------------- | |
340 | ||
341 | ||
611dc22c RD |
342 | |
343 | ||
344 | ||
345 |