]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/gizmos/gizmos.i
466d181c478acd7ee1438a9415760c44968cff1d
[wxWidgets.git] / wxPython / contrib / gizmos / gizmos.i
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 "wxPython.h"
18 #include <wx/gizmos/dynamicsash.h>
19 #include <wx/gizmos/editlbox.h>
20 #include <wx/gizmos/splittree.h>
21 #include <wx/gizmos/ledctrl.h>
22 %}
23
24 //---------------------------------------------------------------------------
25
26 %include typemaps.i
27 %include my_typemaps.i
28
29 %extern wx.i
30 %extern windows.i
31 %extern _defs.i
32 %extern events.i
33 %extern controls.i
34
35
36 //----------------------------------------------------------------------
37
38 %{
39 // Put some wx default wxChar* values into wxStrings.
40 static const wxString wxPyDynamicSashNameStr(wxT("dynamicSashWindow"));
41 static const wxString wxPyEditableListBoxNameStr(wxT("editableListBox"));
42 %}
43
44 ///----------------------------------------------------------------------
45
46 enum {
47 wxEVT_DYNAMIC_SASH_SPLIT,
48 wxEVT_DYNAMIC_SASH_UNIFY,
49
50 wxDS_MANAGE_SCROLLBARS,
51 wxDS_DRAG_CORNER,
52 };
53
54
55 /*
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.
61 */
62 class wxDynamicSashSplitEvent : public wxCommandEvent {
63 public:
64 wxDynamicSashSplitEvent(wxObject *target);
65 };
66
67
68 /*
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
76 class.
77 */
78 class wxDynamicSashUnifyEvent : public wxCommandEvent {
79 public:
80 wxDynamicSashUnifyEvent(wxObject *target);
81 };
82
83
84
85 /*
86
87 wxDynamicSashWindow
88
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.
100
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.
109
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:
121
122 * When your view is created
123 * When your view receives a wxDynamicSashSplitEvent
124 * When your view receives a wxDynamicSashUnifyEvent
125
126 See the dynsash_switch sample application for an example which does this.
127
128 */
129
130 class wxDynamicSashWindow : public wxWindow {
131 public:
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();
137
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);
142
143 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
144 %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)"
145
146 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
147 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
148 };
149
150
151
152 //----------------------------------------------------------------------
153 // Python functions to act like the event macros
154
155 %pragma(python) code = "
156 def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
157 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
158
159 def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
160 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
161 "
162
163 //----------------------------------------------------------------------
164 //----------------------------------------------------------------------
165
166 enum {
167 wxEL_ALLOW_NEW,
168 wxEL_ALLOW_EDIT,
169 wxEL_ALLOW_DELETE,
170 };
171
172 // This class provides a composite control that lets the
173 // user easily enter list of strings
174 class wxEditableListBox : public wxPanel
175 {
176 public:
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);
183
184 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
185
186 void SetStrings(const wxArrayString& strings);
187
188 //void GetStrings(wxArrayString& strings);
189 %addmethods {
190 PyObject* GetStrings() {
191 wxArrayString strings;
192 self->GetStrings(strings);
193 return wxArrayString2PyList_helper(strings);
194 }
195 }
196
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; }
203 };
204
205
206
207 //----------------------------------------------------------------------
208
209
210 /*
211 * wxRemotelyScrolledTreeCtrl
212 *
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.
216 */
217
218 %{
219 typedef wxTreeCtrl wxPyTreeCtrl;
220 %}
221
222 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
223 {
224 public:
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)"
230
231
232 void HideVScrollbar();
233
234 // Adjust the containing wxScrolledWindow's scrollbars appropriately
235 void AdjustRemoteScrollbars();
236
237 // Find the scrolled window that contains this control
238 wxScrolledWindow* GetScrolledWindow() const;
239
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);
243
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;
248 };
249
250
251
252 /*
253 * wxTreeCompanionWindow
254 *
255 * A window displaying values associated with tree control items.
256 */
257
258 %{
259 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
260 {
261 public:
262 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
263 const wxPoint& pos = wxDefaultPosition,
264 const wxSize& size = wxDefaultSize,
265 long style = 0)
266 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
267
268
269 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
270 bool found;
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));
277 Py_DECREF(dcobj);
278 Py_DECREF(idobj);
279 Py_DECREF(recobj);
280 }
281 wxPyEndBlockThreads();
282 if (! found)
283 wxTreeCompanionWindow::DrawItem(dc, id, rect);
284 }
285
286 PYPRIVATE;
287 };
288 %}
289
290
291 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
292 {
293 public:
294 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
295 const wxPoint& pos = wxDefaultPosition,
296 const wxSize& size = wxDefaultSize,
297 long style = 0);
298 void _setCallbackInfo(PyObject* self, PyObject* _class);
299 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
300 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
301
302 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
303 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
304 };
305
306
307
308 /*
309 * wxThinSplitterWindow
310 *
311 * Implements a splitter with a less obvious sash
312 * than the usual one.
313 */
314
315 class wxThinSplitterWindow: public wxSplitterWindow
316 {
317 public:
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)"
323
324 };
325
326
327 /*
328 * wxSplitterScrolledWindow
329 *
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.
334 */
335
336 class wxSplitterScrolledWindow: public wxScrolledWindow
337 {
338 public:
339 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
340 const wxPoint& pos = wxDefaultPosition,
341 const wxSize& size = wxDefaultSize,
342 long style = 0);
343 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
344 };
345
346
347 //----------------------------------------------------------------------
348 //----------------------------------------------------------------------
349
350
351 enum wxLEDValueAlign
352 {
353 wxLED_ALIGN_LEFT,
354 wxLED_ALIGN_RIGHT,
355 wxLED_ALIGN_CENTER,
356
357 wxLED_ALIGN_MASK,
358
359 wxLED_DRAW_FADED,
360 };
361
362
363 class wxLEDNumberCtrl : public wxControl
364 {
365 public:
366 // Constructors.
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();
372
373 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
374 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
375
376 // Create functions.
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);
381
382 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
383 bool GetDrawFaded() const { return m_DrawFaded; }
384 const wxString &GetValue() const { return m_Value; }
385
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);
389
390 };
391
392 //----------------------------------------------------------------------
393 //----------------------------------------------------------------------
394
395 %init %{
396
397 wxClassInfo::CleanUpClasses();
398 wxClassInfo::InitializeClasses();
399
400 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
401 %}
402
403
404 %pragma(python) include="_gizmoextras.py";
405
406 //----------------------------------------------------------------------
407 //----------------------------------------------------------------------
408
409
410
411
412
413