]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/gizmos/gizmos.i
added patch for theme savvy checkbox metrics
[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 "export.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
198
199
200 //----------------------------------------------------------------------
201
202
203 /*
204 * wxRemotelyScrolledTreeCtrl
205 *
206 * This tree control disables its vertical scrollbar and catches scroll
207 * events passed by a scrolled window higher in the hierarchy.
208 * It also updates the scrolled window vertical scrollbar as appropriate.
209 */
210
211 %{
212 typedef wxTreeCtrl wxPyTreeCtrl;
213 %}
214
215 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
216 {
217 public:
218 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
219 const wxPoint& pos = wxDefaultPosition,
220 const wxSize& size = wxDefaultSize,
221 long style = wxTR_HAS_BUTTONS);
222 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
223
224
225 void HideVScrollbar();
226
227 // Adjust the containing wxScrolledWindow's scrollbars appropriately
228 void AdjustRemoteScrollbars();
229
230 // Find the scrolled window that contains this control
231 wxScrolledWindow* GetScrolledWindow() const;
232
233 // Scroll to the given line (in scroll units where each unit is
234 // the height of an item)
235 void ScrollToLine(int posHoriz, int posVert);
236
237 // The companion window is one which will get notified when certain
238 // events happen such as node expansion
239 void SetCompanionWindow(wxWindow* companion);
240 wxWindow* GetCompanionWindow() const;
241 };
242
243
244
245 /*
246 * wxTreeCompanionWindow
247 *
248 * A window displaying values associated with tree control items.
249 */
250
251 %{
252 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
253 {
254 public:
255 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
256 const wxPoint& pos = wxDefaultPosition,
257 const wxSize& size = wxDefaultSize,
258 long style = 0)
259 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
260
261
262 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
263 bool found;
264 wxPyBeginBlockThreads();
265 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
266 PyObject* dcobj = wxPyMake_wxObject(&dc);
267 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
268 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
269 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
270 Py_DECREF(dcobj);
271 Py_DECREF(idobj);
272 Py_DECREF(recobj);
273 }
274 wxPyEndBlockThreads();
275 if (! found)
276 wxTreeCompanionWindow::DrawItem(dc, id, rect);
277 }
278
279 PYPRIVATE;
280 };
281 %}
282
283
284 %name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
285 {
286 public:
287 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
288 const wxPoint& pos = wxDefaultPosition,
289 const wxSize& size = wxDefaultSize,
290 long style = 0);
291 void _setCallbackInfo(PyObject* self, PyObject* _class);
292 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
293 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
294
295 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
296 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
297 };
298
299
300
301 /*
302 * wxThinSplitterWindow
303 *
304 * Implements a splitter with a less obvious sash
305 * than the usual one.
306 */
307
308 class wxThinSplitterWindow: public wxSplitterWindow
309 {
310 public:
311 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
312 const wxPoint& pos = wxDefaultPosition,
313 const wxSize& size = wxDefaultSize,
314 long style = wxSP_3D | wxCLIP_CHILDREN);
315 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
316
317 };
318
319
320 /*
321 * wxSplitterScrolledWindow
322 *
323 * This scrolled window is aware of the fact that one of its
324 * children is a splitter window. It passes on its scroll events
325 * (after some processing) to both splitter children for them
326 * scroll appropriately.
327 */
328
329 class wxSplitterScrolledWindow: public wxScrolledWindow
330 {
331 public:
332 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
333 const wxPoint& pos = wxDefaultPosition,
334 const wxSize& size = wxDefaultSize,
335 long style = 0);
336 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
337 };
338
339
340 //----------------------------------------------------------------------
341 //----------------------------------------------------------------------
342
343
344 enum wxLEDValueAlign
345 {
346 wxLED_ALIGN_LEFT,
347 wxLED_ALIGN_RIGHT,
348 wxLED_ALIGN_CENTER,
349
350 wxLED_ALIGN_MASK,
351
352 wxLED_DRAW_FADED,
353 };
354
355
356 class wxLEDNumberCtrl : public wxControl
357 {
358 public:
359 // Constructors.
360 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
361 const wxPoint& pos = wxDefaultPosition,
362 const wxSize& size = wxDefaultSize,
363 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
364 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
365
366 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
367 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
368
369 // Create functions.
370 bool Create(wxWindow *parent, wxWindowID id = -1,
371 const wxPoint& pos = wxDefaultPosition,
372 const wxSize& size = wxDefaultSize,
373 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
374
375 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
376 bool GetDrawFaded() const { return m_DrawFaded; }
377 const wxString &GetValue() const { return m_Value; }
378
379 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
380 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
381 void SetValue(const wxString &Value, bool Redraw = true);
382
383 };
384
385 //----------------------------------------------------------------------
386 //----------------------------------------------------------------------
387
388 %init %{
389
390 wxClassInfo::CleanUpClasses();
391 wxClassInfo::InitializeClasses();
392
393 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
394 %}
395
396
397 %pragma(python) include="_gizmoextras.py";
398
399 //----------------------------------------------------------------------
400 //----------------------------------------------------------------------
401
402
403
404
405
406