]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/gizmos/gizmos.i
remove sole makefile.dmc in tree
[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 %define DOCSTRING
14 "Various *gizmo* classes: `DynamicSashWindow`, `EditableListBox`,
15 `LEDNumberCtrl`, `TreeListCtrl`, etc."
16 %enddef
17
18 %module(package="wx", docstring=DOCSTRING) gizmos
19
20
21 %{
22 #include "wx/wxPython/wxPython.h"
23 #include "wx/wxPython/pyclasses.h"
24
25 #include <wx/gizmos/dynamicsash.h>
26 //#include <wx/gizmos/editlbox.h>
27 #include <wx/gizmos/splittree.h>
28 #include <wx/gizmos/ledctrl.h>
29 #include <wx/gizmos/statpict.h>
30
31 #include <wx/listctrl.h>
32 #include <wx/treectrl.h>
33 #include <wx/imaglist.h>
34 #include <wx/editlbox.h>
35 %}
36
37 //---------------------------------------------------------------------------
38
39 %import windows.i
40 %import controls.i
41 %pythoncode { import wx }
42 %pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
43
44
45 MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
46 MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
47 MAKE_CONST_WXSTRING(StaticPictureNameStr);
48
49 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
50
51 //---------------------------------------------------------------------------
52
53 enum {
54 wxDS_MANAGE_SCROLLBARS,
55 wxDS_DRAG_CORNER,
56 };
57
58 %constant wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
59 %constant wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
60
61
62 /*
63 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
64 whenever your view is being split by the user. It is your
65 responsibility to handle this event by creating a new view window as
66 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
67 automatically reparent it to the proper place in its window hierarchy.
68 */
69 class wxDynamicSashSplitEvent : public wxCommandEvent {
70 public:
71 wxDynamicSashSplitEvent(wxObject *target);
72 };
73
74
75 /*
76 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
77 whenever the sash which splits your view and its sibling is being
78 reunified such that your view is expanding to replace its sibling.
79 You needn't do anything with this event if you are allowing
80 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
81 if you are managing the scrollbars yourself so that you can keep
82 the scrollbars' event handlers connected to your view's event handler
83 class.
84 */
85 class wxDynamicSashUnifyEvent : public wxCommandEvent {
86 public:
87 wxDynamicSashUnifyEvent(wxObject *target);
88 };
89
90
91
92 /*
93
94 wxDynamicSashWindow
95
96 wxDynamicSashWindow widgets manages the way other widgets are viewed.
97 When a wxDynamicSashWindow is first shown, it will contain one child
98 view, a viewport for that child, and a pair of scrollbars to allow the
99 user to navigate the child view area. Next to each scrollbar is a small
100 tab. By clicking on either tab and dragging to the appropriate spot, a
101 user can split the view area into two smaller views separated by a
102 draggable sash. Later, when the user wishes to reunify the two subviews,
103 the user simply drags the sash to the side of the window.
104 wxDynamicSashWindow will automatically reparent the appropriate child
105 view back up the window hierarchy, and the wxDynamicSashWindow will have
106 only one child view once again.
107
108 As an application developer, you will simply create a wxDynamicSashWindow
109 using either the Create() function or the more complex constructor
110 provided below, and then create a view window whose parent is the
111 wxDynamicSashWindow. The child should respond to
112 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
113 constructing a new view window whose parent is also the
114 wxDynamicSashWindow. That's it! Now your users can dynamically split
115 and reunify the view you provided.
116
117 If you wish to handle the scrollbar events for your view, rather than
118 allowing wxDynamicSashWindow to do it for you, things are a bit more
119 complex. (You might want to handle scrollbar events yourself, if,
120 for instance, you wish to scroll a subwindow of the view you add to
121 your wxDynamicSashWindow object, rather than scrolling the whole view.)
122 In this case, you will need to construct your wxDynamicSashWindow without
123 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
124 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
125 controls and call SetEventHanler() on them to redirect the scrolling
126 events whenever your window is reparented by wxDyanmicSashWindow.
127 You will need to set the scrollbars' event handler at three times:
128
129 * When your view is created
130 * When your view receives a wxDynamicSashSplitEvent
131 * When your view receives a wxDynamicSashUnifyEvent
132
133 See the dynsash_switch sample application for an example which does this.
134
135 */
136
137 MustHaveApp(wxDynamicSashWindow);
138
139 class wxDynamicSashWindow : public wxWindow {
140 public:
141 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
142 %pythonAppend wxDynamicSashWindow() ""
143
144 wxDynamicSashWindow(wxWindow *parent, wxWindowID id=-1,
145 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
146 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
147 const wxString& name = wxPyDynamicSashNameStr);
148 %RenameCtor(PreDynamicSashWindow, wxDynamicSashWindow());
149
150 bool Create(wxWindow *parent, wxWindowID id=-1,
151 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
152 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
153 const wxString& name = wxPyDynamicSashNameStr);
154
155 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
156 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
157 };
158
159
160
161 %pythoncode {
162 EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
163 EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
164 }
165
166 //---------------------------------------------------------------------------
167 //---------------------------------------------------------------------------
168
169 enum {
170 wxEL_ALLOW_NEW,
171 wxEL_ALLOW_EDIT,
172 wxEL_ALLOW_DELETE,
173 wxEL_NO_REORDER,
174 wxEL_DEFAULT_STYLE
175 };
176
177
178 %typemap(out) wxPyListCtrl*
179 { $result = wxPyMake_wxObject((wxObject*)$1, (bool)$owner); }
180
181
182 // This class provides a composite control that lets the
183 // user easily enter list of strings
184 MustHaveApp(wxEditableListBox);
185 class wxEditableListBox : public wxPanel
186 {
187 public:
188 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
189 %pythonAppend wxEditableListBox() ""
190
191 wxEditableListBox(wxWindow *parent, wxWindowID id=-1,
192 const wxString& label = wxPyEmptyString,
193 const wxPoint& pos = wxDefaultPosition,
194 const wxSize& size = wxDefaultSize,
195 long style = wxEL_DEFAULT_STYLE,
196 const wxString& name = wxPyEditableListBoxNameStr);
197 %RenameCtor(PreEditableListBox, wxEditableListBox());
198
199 bool Create(wxWindow *parent, wxWindowID id,
200 const wxString& label,
201 const wxPoint& pos = wxDefaultPosition,
202 const wxSize& size = wxDefaultSize,
203 long style = wxEL_DEFAULT_STYLE,
204 const wxString& name = wxEditableListBoxNameStr);
205
206 void SetStrings(const wxArrayString& strings);
207
208 //void GetStrings(wxArrayString& strings);
209 %extend {
210 PyObject* GetStrings() {
211 wxArrayString strings;
212 self->GetStrings(strings);
213 return wxArrayString2PyList_helper(strings);
214 }
215 }
216
217 wxPyListCtrl* GetListCtrl();
218 wxBitmapButton* GetDelButton();
219 wxBitmapButton* GetNewButton();
220 wxBitmapButton* GetUpButton();
221 wxBitmapButton* GetDownButton();
222 wxBitmapButton* GetEditButton();
223
224 %property(DelButton, GetDelButton, doc="See `GetDelButton`");
225 %property(DownButton, GetDownButton, doc="See `GetDownButton`");
226 %property(EditButton, GetEditButton, doc="See `GetEditButton`");
227 %property(ListCtrl, GetListCtrl, doc="See `GetListCtrl`");
228 %property(NewButton, GetNewButton, doc="See `GetNewButton`");
229 %property(Strings, GetStrings, SetStrings, doc="See `GetStrings` and `SetStrings`");
230 %property(UpButton, GetUpButton, doc="See `GetUpButton`");
231 };
232
233
234
235 //---------------------------------------------------------------------------
236
237
238 /*
239 * wxRemotelyScrolledTreeCtrl
240 *
241 * This tree control disables its vertical scrollbar and catches scroll
242 * events passed by a scrolled window higher in the hierarchy.
243 * It also updates the scrolled window vertical scrollbar as appropriate.
244 */
245
246 %{
247 typedef wxTreeCtrl wxPyTreeCtrl;
248 %}
249
250 MustHaveApp(wxRemotelyScrolledTreeCtrl);
251
252 class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
253 {
254 public:
255 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
256 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
257
258 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
259 const wxPoint& pos = wxDefaultPosition,
260 const wxSize& size = wxDefaultSize,
261 long style = wxTR_HAS_BUTTONS);
262
263
264 void HideVScrollbar();
265
266 // Adjust the containing wxScrolledWindow's scrollbars appropriately
267 void AdjustRemoteScrollbars();
268
269 // Find the scrolled window that contains this control
270 wxScrolledWindow* GetScrolledWindow() const;
271
272 // Scroll to the given line (in scroll units where each unit is
273 // the height of an item)
274 void ScrollToLine(int posHoriz, int posVert);
275
276 // The companion window is one which will get notified when certain
277 // events happen such as node expansion
278 void SetCompanionWindow(wxWindow* companion);
279 wxWindow* GetCompanionWindow() const;
280
281 %property(CompanionWindow, GetCompanionWindow, SetCompanionWindow, doc="See `GetCompanionWindow` and `SetCompanionWindow`");
282 %property(ScrolledWindow, GetScrolledWindow, doc="See `GetScrolledWindow`");
283 };
284
285
286
287 /*
288 * wxTreeCompanionWindow
289 *
290 * A window displaying values associated with tree control items.
291 */
292
293 %{
294 class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
295 {
296 public:
297 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
298 const wxPoint& pos = wxDefaultPosition,
299 const wxSize& size = wxDefaultSize,
300 long style = 0)
301 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
302
303
304 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
305 bool found;
306 wxPyBlock_t blocked = wxPyBeginBlockThreads();
307 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
308 PyObject* dcobj = wxPyMake_wxObject(&dc,false);
309 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), false);
310 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), false);
311 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
312 Py_DECREF(dcobj);
313 Py_DECREF(idobj);
314 Py_DECREF(recobj);
315 }
316 wxPyEndBlockThreads(blocked);
317 if (! found)
318 wxTreeCompanionWindow::DrawItem(dc, id, rect);
319 }
320
321 PYPRIVATE;
322 };
323 %}
324
325
326 MustHaveApp(wxPyTreeCompanionWindow);
327
328 %rename(TreeCompanionWindow) wxPyTreeCompanionWindow;
329 class wxPyTreeCompanionWindow: public wxWindow
330 {
331 public:
332 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);" setCallbackInfo(TreeCompanionWindow)
333 %pythonAppend wxPyTreeCompanionWindow() ""
334
335 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
336 const wxPoint& pos = wxDefaultPosition,
337 const wxSize& size = wxDefaultSize,
338 long style = 0);
339 void _setCallbackInfo(PyObject* self, PyObject* _class);
340
341 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
342 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
343
344 %property(TreeCtrl, GetTreeCtrl, SetTreeCtrl, doc="See `GetTreeCtrl` and `SetTreeCtrl`");
345 };
346
347
348
349 /*
350 * wxThinSplitterWindow
351 *
352 * Implements a splitter with a less obvious sash
353 * than the usual one.
354 */
355
356 MustHaveApp(wxThinSplitterWindow);
357
358 class wxThinSplitterWindow: public wxSplitterWindow
359 {
360 public:
361 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
362 %pythonAppend wxThinSplitterWindow() ""
363
364 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
365 const wxPoint& pos = wxDefaultPosition,
366 const wxSize& size = wxDefaultSize,
367 long style = wxSP_3D | wxCLIP_CHILDREN);
368 };
369
370
371
372 /*
373 * wxSplitterScrolledWindow
374 *
375 * This scrolled window is aware of the fact that one of its
376 * children is a splitter window. It passes on its scroll events
377 * (after some processing) to both splitter children for them
378 * scroll appropriately.
379 */
380
381 MustHaveApp(wxSplitterScrolledWindow);
382
383 class wxSplitterScrolledWindow: public wxScrolledWindow
384 {
385 public:
386 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
387 %pythonAppend wxSplitterScrolledWindow() ""
388
389 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
390 const wxPoint& pos = wxDefaultPosition,
391 const wxSize& size = wxDefaultSize,
392 long style = 0);
393 };
394
395
396 //---------------------------------------------------------------------------
397 //---------------------------------------------------------------------------
398
399
400 enum wxLEDValueAlign
401 {
402 wxLED_ALIGN_LEFT,
403 wxLED_ALIGN_RIGHT,
404 wxLED_ALIGN_CENTER,
405
406 wxLED_ALIGN_MASK,
407
408 wxLED_DRAW_FADED,
409 };
410
411
412 MustHaveApp(wxLEDNumberCtrl);
413
414 class wxLEDNumberCtrl : public wxControl
415 {
416 public:
417 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
418 %pythonAppend wxLEDNumberCtrl() ""
419
420 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
421 const wxPoint& pos = wxDefaultPosition,
422 const wxSize& size = wxDefaultSize,
423 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
424 %RenameCtor(PreLEDNumberCtrl, wxLEDNumberCtrl());
425
426 bool Create(wxWindow *parent, wxWindowID id = -1,
427 const wxPoint& pos = wxDefaultPosition,
428 const wxSize& size = wxDefaultSize,
429 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
430
431 wxLEDValueAlign GetAlignment() const;
432 bool GetDrawFaded() const;
433 const wxString &GetValue() const;
434
435 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
436 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
437 void SetValue(const wxString &Value, bool Redraw = true);
438
439 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
440 %property(DrawFaded, GetDrawFaded, SetDrawFaded, doc="See `GetDrawFaded` and `SetDrawFaded`");
441 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
442 };
443
444
445
446 //----------------------------------------------------------------------
447
448 %include _treelist.i
449
450 //----------------------------------------------------------------------
451
452 enum
453 {
454 wxSCALE_HORIZONTAL,
455 wxSCALE_VERTICAL,
456 wxSCALE_UNIFORM,
457 wxSCALE_CUSTOM
458 };
459
460 MustHaveApp(wxStaticPicture);
461
462 class wxStaticPicture : public wxControl
463 {
464 public:
465 %pythonAppend wxStaticPicture "self._setOORInfo(self)"
466 %pythonAppend wxStaticPicture() ""
467
468 wxStaticPicture( wxWindow* parent, wxWindowID id=-1,
469 const wxBitmap& label=wxNullBitmap,
470 const wxPoint& pos = wxDefaultPosition,
471 const wxSize& size = wxDefaultSize,
472 long style = 0,
473 const wxString& name = wxPyStaticPictureNameStr );
474
475 %RenameCtor(PreStaticPicture, wxStaticPicture());
476
477 bool Create( wxWindow* parent, wxWindowID id=-1,
478 const wxBitmap& label=wxNullBitmap,
479 const wxPoint& pos = wxDefaultPosition,
480 const wxSize& size = wxDefaultSize,
481 long style = 0,
482 const wxString& name = wxPyStaticPictureNameStr );
483
484 void SetBitmap( const wxBitmap& bmp );
485 wxBitmap GetBitmap() const;
486 void SetIcon( const wxIcon& icon );
487 wxIcon GetIcon() const;
488
489 void SetAlignment( int align );
490 int GetAlignment() const;
491
492 void SetScale( int scale );
493 int GetScale() const;
494
495 void SetCustomScale( float sx, float sy );
496 void GetCustomScale( float* OUTPUT, float* OUTPUT ) const;
497
498 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
499 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
500 %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
501 %property(Scale, GetScale, SetScale, doc="See `GetScale` and `SetScale`");
502 };
503
504
505 //----------------------------------------------------------------------
506 //----------------------------------------------------------------------
507
508 %init %{
509 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
510 %}
511
512 //----------------------------------------------------------------------
513 //----------------------------------------------------------------------
514