]>
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 | %{ | |
6e2129f9 | 17 | #include "wxPython.h" |
611dc22c RD |
18 | #include <wx/gizmos/dynamicsash.h> |
19 | #include <wx/gizmos/editlbox.h> | |
20 | #include <wx/gizmos/splittree.h> | |
950e7faf | 21 | #include <wx/gizmos/ledctrl.h> |
7c379a20 | 22 | #include <wx/listctrl.h> |
ebf4302c RD |
23 | %} |
24 | ||
25 | //--------------------------------------------------------------------------- | |
26 | ||
27 | %include typemaps.i | |
28 | %include my_typemaps.i | |
29 | ||
30 | %extern wx.i | |
31 | %extern windows.i | |
32 | %extern _defs.i | |
33 | %extern events.i | |
34 | %extern controls.i | |
35 | ||
36 | ||
37 | //---------------------------------------------------------------------- | |
38 | ||
137b5242 RD |
39 | %{ |
40 | // Put some wx default wxChar* values into wxStrings. | |
41 | static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow")); | |
42 | static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox")); | |
43 | %} | |
44 | ||
45 | ///---------------------------------------------------------------------- | |
46 | ||
ebf4302c RD |
47 | enum { |
48 | wxEVT_DYNAMIC_SASH_SPLIT, | |
49 | wxEVT_DYNAMIC_SASH_UNIFY, | |
50 | ||
51 | wxDS_MANAGE_SCROLLBARS, | |
52 | wxDS_DRAG_CORNER, | |
53 | }; | |
54 | ||
55 | ||
56 | /* | |
57 | wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow | |
58 | whenever your view is being split by the user. It is your | |
59 | responsibility to handle this event by creating a new view window as | |
60 | a child of the wxDynamicSashWindow. wxDynamicSashWindow will | |
61 | automatically reparent it to the proper place in its window hierarchy. | |
62 | */ | |
63 | class wxDynamicSashSplitEvent : public wxCommandEvent { | |
64 | public: | |
65 | wxDynamicSashSplitEvent(wxObject *target); | |
66 | }; | |
67 | ||
68 | ||
69 | /* | |
70 | wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow | |
71 | whenever the sash which splits your view and its sibling is being | |
72 | reunified such that your view is expanding to replace its sibling. | |
73 | You needn't do anything with this event if you are allowing | |
74 | wxDynamicSashWindow to manage your view's scrollbars, but it is useful | |
75 | if you are managing the scrollbars yourself so that you can keep | |
76 | the scrollbars' event handlers connected to your view's event handler | |
77 | class. | |
78 | */ | |
79 | class wxDynamicSashUnifyEvent : public wxCommandEvent { | |
80 | public: | |
81 | wxDynamicSashUnifyEvent(wxObject *target); | |
82 | }; | |
83 | ||
84 | ||
85 | ||
86 | /* | |
87 | ||
88 | wxDynamicSashWindow | |
89 | ||
90 | wxDynamicSashWindow widgets manages the way other widgets are viewed. | |
91 | When a wxDynamicSashWindow is first shown, it will contain one child | |
92 | view, a viewport for that child, and a pair of scrollbars to allow the | |
93 | user to navigate the child view area. Next to each scrollbar is a small | |
94 | tab. By clicking on either tab and dragging to the appropriate spot, a | |
95 | user can split the view area into two smaller views separated by a | |
96 | draggable sash. Later, when the user wishes to reunify the two subviews, | |
97 | the user simply drags the sash to the side of the window. | |
98 | wxDynamicSashWindow will automatically reparent the appropriate child | |
99 | view back up the window hierarchy, and the wxDynamicSashWindow will have | |
100 | only one child view once again. | |
101 | ||
102 | As an application developer, you will simply create a wxDynamicSashWindow | |
103 | using either the Create() function or the more complex constructor | |
611dc22c | 104 | provided below, and then create a view window whose parent is the |
ebf4302c RD |
105 | wxDynamicSashWindow. The child should respond to |
106 | wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by | |
107 | constructing a new view window whose parent is also the | |
108 | wxDynamicSashWindow. That's it! Now your users can dynamically split | |
109 | and reunify the view you provided. | |
110 | ||
111 | If you wish to handle the scrollbar events for your view, rather than | |
112 | allowing wxDynamicSashWindow to do it for you, things are a bit more | |
113 | complex. (You might want to handle scrollbar events yourself, if, | |
114 | for instance, you wish to scroll a subwindow of the view you add to | |
115 | your wxDynamicSashWindow object, rather than scrolling the whole view.) | |
611dc22c | 116 | In this case, you will need to construct your wxDynamicSashWindow without |
ebf4302c RD |
117 | the wxDS_MANAGE_SCROLLBARS style and you will need to use the |
118 | GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar | |
119 | controls and call SetEventHanler() on them to redirect the scrolling | |
120 | events whenever your window is reparented by wxDyanmicSashWindow. | |
121 | You will need to set the scrollbars' event handler at three times: | |
122 | ||
123 | * When your view is created | |
124 | * When your view receives a wxDynamicSashSplitEvent | |
125 | * When your view receives a wxDynamicSashUnifyEvent | |
126 | ||
127 | See the dynsash_switch sample application for an example which does this. | |
128 | ||
129 | */ | |
130 | ||
131 | class wxDynamicSashWindow : public wxWindow { | |
132 | public: | |
133 | wxDynamicSashWindow(wxWindow *parent, wxWindowID id, | |
134 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
135 | long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER, | |
137b5242 | 136 | const wxString& name = wxPyDynamicSashNameStr); |
ebf4302c RD |
137 | %name(wxPreDynamicSashWindow)wxDynamicSashWindow(); |
138 | ||
139 | bool Create(wxWindow *parent, wxWindowID id, | |
140 | const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
141 | long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER, | |
137b5242 | 142 | const wxString& name = wxPyDynamicSashNameStr); |
ebf4302c RD |
143 | |
144 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
145 | %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)" | |
146 | ||
147 | wxScrollBar *GetHScrollBar(const wxWindow *child) const; | |
148 | wxScrollBar *GetVScrollBar(const wxWindow *child) const; | |
149 | }; | |
150 | ||
151 | ||
152 | ||
153 | //---------------------------------------------------------------------- | |
154 | // Python functions to act like the event macros | |
155 | ||
156 | %pragma(python) code = " | |
157 | def EVT_DYNAMIC_SASH_SPLIT(win, id, func): | |
158 | win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func) | |
159 | ||
160 | def EVT_DYNAMIC_SASH_UNIFY(win, id, func): | |
161 | win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func) | |
162 | " | |
163 | ||
7b7ac0ab RD |
164 | //---------------------------------------------------------------------- |
165 | //---------------------------------------------------------------------- | |
166 | ||
6187ec8f RD |
167 | enum { |
168 | wxEL_ALLOW_NEW, | |
169 | wxEL_ALLOW_EDIT, | |
170 | wxEL_ALLOW_DELETE, | |
171 | }; | |
7b7ac0ab RD |
172 | |
173 | // This class provides a composite control that lets the | |
174 | // user easily enter list of strings | |
175 | class wxEditableListBox : public wxPanel | |
176 | { | |
177 | public: | |
178 | wxEditableListBox(wxWindow *parent, wxWindowID id, | |
179 | const wxString& label, | |
180 | const wxPoint& pos = wxDefaultPosition, | |
181 | const wxSize& size = wxDefaultSize, | |
6187ec8f | 182 | long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE, |
137b5242 | 183 | const wxString& name = wxPyEditableListBoxNameStr); |
7b7ac0ab | 184 | |
611dc22c RD |
185 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" |
186 | ||
7b7ac0ab RD |
187 | void SetStrings(const wxArrayString& strings); |
188 | ||
189 | //void GetStrings(wxArrayString& strings); | |
190 | %addmethods { | |
191 | PyObject* GetStrings() { | |
192 | wxArrayString strings; | |
193 | self->GetStrings(strings); | |
194 | return wxArrayString2PyList_helper(strings); | |
195 | } | |
196 | } | |
366d7bd6 RD |
197 | |
198 | wxListCtrl* GetListCtrl() { return m_listCtrl; } | |
199 | wxBitmapButton* GetDelButton() { return m_bDel; } | |
200 | wxBitmapButton* GetNewButton() { return m_bNew; } | |
201 | wxBitmapButton* GetUpButton() { return m_bUp; } | |
202 | wxBitmapButton* GetDownButton() { return m_bDown; } | |
203 | wxBitmapButton* GetEditButton() { return m_bEdit; } | |
7b7ac0ab RD |
204 | }; |
205 | ||
206 | ||
207 | ||
611dc22c RD |
208 | //---------------------------------------------------------------------- |
209 | ||
210 | ||
211 | /* | |
212 | * wxRemotelyScrolledTreeCtrl | |
213 | * | |
214 | * This tree control disables its vertical scrollbar and catches scroll | |
215 | * events passed by a scrolled window higher in the hierarchy. | |
216 | * It also updates the scrolled window vertical scrollbar as appropriate. | |
217 | */ | |
218 | ||
219 | %{ | |
220 | typedef wxTreeCtrl wxPyTreeCtrl; | |
221 | %} | |
222 | ||
223 | class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl | |
224 | { | |
225 | public: | |
226 | wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, | |
227 | const wxPoint& pos = wxDefaultPosition, | |
228 | const wxSize& size = wxDefaultSize, | |
229 | long style = wxTR_HAS_BUTTONS); | |
230 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
231 | ||
232 | ||
233 | void HideVScrollbar(); | |
234 | ||
235 | // Adjust the containing wxScrolledWindow's scrollbars appropriately | |
236 | void AdjustRemoteScrollbars(); | |
237 | ||
238 | // Find the scrolled window that contains this control | |
239 | wxScrolledWindow* GetScrolledWindow() const; | |
240 | ||
241 | // Scroll to the given line (in scroll units where each unit is | |
242 | // the height of an item) | |
243 | void ScrollToLine(int posHoriz, int posVert); | |
244 | ||
245 | // The companion window is one which will get notified when certain | |
246 | // events happen such as node expansion | |
247 | void SetCompanionWindow(wxWindow* companion); | |
248 | wxWindow* GetCompanionWindow() const; | |
249 | }; | |
250 | ||
251 | ||
252 | ||
253 | /* | |
254 | * wxTreeCompanionWindow | |
255 | * | |
256 | * A window displaying values associated with tree control items. | |
257 | */ | |
258 | ||
259 | %{ | |
260 | class wxPyTreeCompanionWindow: public wxTreeCompanionWindow | |
261 | { | |
262 | public: | |
263 | wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1, | |
264 | const wxPoint& pos = wxDefaultPosition, | |
265 | const wxSize& size = wxDefaultSize, | |
266 | long style = 0) | |
267 | : wxTreeCompanionWindow(parent, id, pos, size, style) {} | |
268 | ||
269 | ||
270 | virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) { | |
271 | bool found; | |
4268f798 | 272 | wxPyBeginBlockThreads(); |
611dc22c RD |
273 | if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) { |
274 | PyObject* dcobj = wxPyMake_wxObject(&dc); | |
275 | PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE); | |
276 | PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE); | |
277 | wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj)); | |
278 | Py_DECREF(dcobj); | |
279 | Py_DECREF(idobj); | |
280 | Py_DECREF(recobj); | |
281 | } | |
4268f798 | 282 | wxPyEndBlockThreads(); |
611dc22c RD |
283 | if (! found) |
284 | wxTreeCompanionWindow::DrawItem(dc, id, rect); | |
285 | } | |
286 | ||
287 | PYPRIVATE; | |
288 | }; | |
289 | %} | |
290 | ||
291 | ||
292 | %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow | |
293 | { | |
294 | public: | |
295 | wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1, | |
296 | const wxPoint& pos = wxDefaultPosition, | |
297 | const wxSize& size = wxDefaultSize, | |
298 | long style = 0); | |
299 | void _setCallbackInfo(PyObject* self, PyObject* _class); | |
300 | %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)" | |
301 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
302 | ||
303 | wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const; | |
304 | void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl); | |
305 | }; | |
306 | ||
307 | ||
308 | ||
309 | /* | |
310 | * wxThinSplitterWindow | |
311 | * | |
312 | * Implements a splitter with a less obvious sash | |
313 | * than the usual one. | |
314 | */ | |
315 | ||
316 | class wxThinSplitterWindow: public wxSplitterWindow | |
317 | { | |
318 | public: | |
319 | wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1, | |
320 | const wxPoint& pos = wxDefaultPosition, | |
321 | const wxSize& size = wxDefaultSize, | |
322 | long style = wxSP_3D | wxCLIP_CHILDREN); | |
323 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
324 | ||
325 | }; | |
326 | ||
327 | ||
328 | /* | |
329 | * wxSplitterScrolledWindow | |
330 | * | |
331 | * This scrolled window is aware of the fact that one of its | |
332 | * children is a splitter window. It passes on its scroll events | |
333 | * (after some processing) to both splitter children for them | |
334 | * scroll appropriately. | |
335 | */ | |
336 | ||
337 | class wxSplitterScrolledWindow: public wxScrolledWindow | |
338 | { | |
339 | public: | |
340 | wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1, | |
341 | const wxPoint& pos = wxDefaultPosition, | |
342 | const wxSize& size = wxDefaultSize, | |
343 | long style = 0); | |
344 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
345 | }; | |
346 | ||
347 | ||
950e7faf RD |
348 | //---------------------------------------------------------------------- |
349 | //---------------------------------------------------------------------- | |
350 | ||
351 | ||
352 | enum wxLEDValueAlign | |
353 | { | |
354 | wxLED_ALIGN_LEFT, | |
355 | wxLED_ALIGN_RIGHT, | |
356 | wxLED_ALIGN_CENTER, | |
357 | ||
358 | wxLED_ALIGN_MASK, | |
359 | ||
360 | wxLED_DRAW_FADED, | |
361 | }; | |
362 | ||
363 | ||
364 | class wxLEDNumberCtrl : public wxControl | |
365 | { | |
366 | public: | |
367 | // Constructors. | |
368 | wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1, | |
369 | const wxPoint& pos = wxDefaultPosition, | |
370 | const wxSize& size = wxDefaultSize, | |
371 | long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED); | |
372 | %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl(); | |
373 | ||
374 | %pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
375 | %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)" | |
376 | ||
377 | // Create functions. | |
378 | bool Create(wxWindow *parent, wxWindowID id = -1, | |
379 | const wxPoint& pos = wxDefaultPosition, | |
380 | const wxSize& size = wxDefaultSize, | |
381 | long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED); | |
382 | ||
383 | wxLEDValueAlign GetAlignment() const { return m_Alignment; } | |
384 | bool GetDrawFaded() const { return m_DrawFaded; } | |
385 | const wxString &GetValue() const { return m_Value; } | |
386 | ||
387 | void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true); | |
388 | void SetDrawFaded(bool DrawFaded, bool Redraw = true); | |
389 | void SetValue(const wxString &Value, bool Redraw = true); | |
390 | ||
391 | }; | |
392 | ||
393 | //---------------------------------------------------------------------- | |
ebf4302c RD |
394 | //---------------------------------------------------------------------- |
395 | ||
396 | %init %{ | |
397 | ||
398 | wxClassInfo::CleanUpClasses(); | |
399 | wxClassInfo::InitializeClasses(); | |
400 | ||
611dc22c | 401 | wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow"); |
ebf4302c RD |
402 | %} |
403 | ||
404 | ||
ebf4302c RD |
405 | %pragma(python) include="_gizmoextras.py"; |
406 | ||
407 | //---------------------------------------------------------------------- | |
408 | //---------------------------------------------------------------------- | |
409 | ||
410 | ||
611dc22c RD |
411 | |
412 | ||
413 | ||
414 |