]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/gizmos/gizmos.i
Another package name fix
[wxWidgets.git] / wxPython / contrib / gizmos / gizmos.i
CommitLineData
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
c8fac2b6
RD
13%define DOCSTRING
14"Various *gizmo* classes: `DynamicSashWindow`, `EditableListBox`,
15`LEDNumberCtrl`, `TreeListCtrl`, etc."
16%enddef
17
b2eb030f 18%module(package="wx", docstring=DOCSTRING) gizmos
ebf4302c
RD
19
20
21%{
d14a1e28
RD
22#include "wx/wxPython/wxPython.h"
23#include "wx/wxPython/pyclasses.h"
28eab81f 24
611dc22c
RD
25#include <wx/gizmos/dynamicsash.h>
26#include <wx/gizmos/editlbox.h>
27#include <wx/gizmos/splittree.h>
950e7faf 28#include <wx/gizmos/ledctrl.h>
7e4b7f9a 29#include <wx/gizmos/statpict.h>
1fded56b 30
7c379a20 31#include <wx/listctrl.h>
1fded56b
RD
32#include <wx/treectrl.h>
33#include <wx/imaglist.h>
28eab81f 34
137b5242
RD
35%}
36
d14a1e28
RD
37//---------------------------------------------------------------------------
38
39%import windows.i
40%import controls.i
648d396c
RD
41%pythoncode { import wx }
42%pythoncode { __docfilter__ = wx._core.__DocFilter(globals()) }
d14a1e28 43
b2dc1044 44
089142a5
RD
45MAKE_CONST_WXSTRING2(DynamicSashNameStr, wxT("dynamicSashWindow"));
46MAKE_CONST_WXSTRING2(EditableListBoxNameStr, wxT("editableListBox"));
d3397f6a 47MAKE_CONST_WXSTRING(StaticPictureNameStr);
7e4b7f9a 48
b2dc1044
RD
49MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
50
d14a1e28 51//---------------------------------------------------------------------------
137b5242 52
ebf4302c 53enum {
ebf4302c
RD
54 wxDS_MANAGE_SCROLLBARS,
55 wxDS_DRAG_CORNER,
56};
57
6c56259a
RD
58%constant wxEventType wxEVT_DYNAMIC_SASH_SPLIT;
59%constant wxEventType wxEVT_DYNAMIC_SASH_UNIFY;
60
ebf4302c
RD
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*/
69class wxDynamicSashSplitEvent : public wxCommandEvent {
70public:
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*/
85class wxDynamicSashUnifyEvent : public wxCommandEvent {
86public:
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
611dc22c 110 provided below, and then create a view window whose parent is the
ebf4302c
RD
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.)
611dc22c 122 In this case, you will need to construct your wxDynamicSashWindow without
ebf4302c
RD
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
ab1f7d2a
RD
137MustHaveApp(wxDynamicSashWindow);
138
ebf4302c
RD
139class wxDynamicSashWindow : public wxWindow {
140public:
2b9048c5
RD
141 %pythonAppend wxDynamicSashWindow "self._setOORInfo(self)"
142 %pythonAppend wxDynamicSashWindow() ""
d14a1e28 143
d5573410 144 wxDynamicSashWindow(wxWindow *parent, wxWindowID id=-1,
ebf4302c
RD
145 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
146 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
137b5242 147 const wxString& name = wxPyDynamicSashNameStr);
1b8c7ba6 148 %RenameCtor(PreDynamicSashWindow, wxDynamicSashWindow());
ebf4302c 149
d5573410 150 bool Create(wxWindow *parent, wxWindowID id=-1,
ebf4302c
RD
151 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
152 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
137b5242 153 const wxString& name = wxPyDynamicSashNameStr);
ebf4302c 154
ebf4302c
RD
155 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
156 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
157};
158
159
160
d14a1e28
RD
161%pythoncode {
162EVT_DYNAMIC_SASH_SPLIT = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_SPLIT, 1 )
163EVT_DYNAMIC_SASH_UNIFY = wx.PyEventBinder( wxEVT_DYNAMIC_SASH_UNIFY, 1 )
164}
ebf4302c 165
d14a1e28
RD
166//---------------------------------------------------------------------------
167//---------------------------------------------------------------------------
7b7ac0ab 168
6187ec8f
RD
169enum {
170 wxEL_ALLOW_NEW,
171 wxEL_ALLOW_EDIT,
172 wxEL_ALLOW_DELETE,
173};
7b7ac0ab 174
3ecece7e
RD
175
176%typemap(out) wxPyListCtrl*
177{ $result = wxPyMake_wxObject((wxObject*)$1, (bool)$owner); }
178
179
7b7ac0ab
RD
180// This class provides a composite control that lets the
181// user easily enter list of strings
ab1f7d2a 182MustHaveApp(wxEditableListBox);
7b7ac0ab
RD
183class wxEditableListBox : public wxPanel
184{
185public:
2b9048c5
RD
186 %pythonAppend wxEditableListBox "self._setOORInfo(self)"
187 %pythonAppend wxEditableListBox() ""
d14a1e28 188
d5573410
RD
189 wxEditableListBox(wxWindow *parent, wxWindowID id=-1,
190 const wxString& label = wxPyEmptyString,
7b7ac0ab
RD
191 const wxPoint& pos = wxDefaultPosition,
192 const wxSize& size = wxDefaultSize,
6187ec8f 193 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
137b5242 194 const wxString& name = wxPyEditableListBoxNameStr);
7b7ac0ab 195
611dc22c 196
7b7ac0ab
RD
197 void SetStrings(const wxArrayString& strings);
198
199 //void GetStrings(wxArrayString& strings);
d14a1e28 200 %extend {
7b7ac0ab
RD
201 PyObject* GetStrings() {
202 wxArrayString strings;
203 self->GetStrings(strings);
204 return wxArrayString2PyList_helper(strings);
205 }
206 }
366d7bd6 207
15f80007 208 wxPyListCtrl* GetListCtrl();
d14a1e28
RD
209 wxBitmapButton* GetDelButton();
210 wxBitmapButton* GetNewButton();
211 wxBitmapButton* GetUpButton();
212 wxBitmapButton* GetDownButton();
213 wxBitmapButton* GetEditButton();
e70b4d2d
RD
214
215 %property(DelButton, GetDelButton, doc="See `GetDelButton`");
216 %property(DownButton, GetDownButton, doc="See `GetDownButton`");
217 %property(EditButton, GetEditButton, doc="See `GetEditButton`");
218 %property(ListCtrl, GetListCtrl, doc="See `GetListCtrl`");
219 %property(NewButton, GetNewButton, doc="See `GetNewButton`");
220 %property(Strings, GetStrings, SetStrings, doc="See `GetStrings` and `SetStrings`");
221 %property(UpButton, GetUpButton, doc="See `GetUpButton`");
7b7ac0ab
RD
222};
223
224
225
d14a1e28 226//---------------------------------------------------------------------------
611dc22c
RD
227
228
229/*
230 * wxRemotelyScrolledTreeCtrl
231 *
232 * This tree control disables its vertical scrollbar and catches scroll
233 * events passed by a scrolled window higher in the hierarchy.
234 * It also updates the scrolled window vertical scrollbar as appropriate.
235 */
236
237%{
238 typedef wxTreeCtrl wxPyTreeCtrl;
239%}
240
ab1f7d2a
RD
241MustHaveApp(wxRemotelyScrolledTreeCtrl);
242
611dc22c
RD
243class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
244{
245public:
2b9048c5
RD
246 %pythonAppend wxRemotelyScrolledTreeCtrl "self._setOORInfo(self)"
247 %pythonAppend wxRemotelyScrolledTreeCtrl() ""
d14a1e28 248
611dc22c
RD
249 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
250 const wxPoint& pos = wxDefaultPosition,
251 const wxSize& size = wxDefaultSize,
252 long style = wxTR_HAS_BUTTONS);
611dc22c
RD
253
254
255 void HideVScrollbar();
256
257 // Adjust the containing wxScrolledWindow's scrollbars appropriately
258 void AdjustRemoteScrollbars();
259
260 // Find the scrolled window that contains this control
261 wxScrolledWindow* GetScrolledWindow() const;
262
263 // Scroll to the given line (in scroll units where each unit is
264 // the height of an item)
265 void ScrollToLine(int posHoriz, int posVert);
266
267 // The companion window is one which will get notified when certain
268 // events happen such as node expansion
269 void SetCompanionWindow(wxWindow* companion);
270 wxWindow* GetCompanionWindow() const;
e70b4d2d
RD
271
272 %property(CompanionWindow, GetCompanionWindow, SetCompanionWindow, doc="See `GetCompanionWindow` and `SetCompanionWindow`");
273 %property(ScrolledWindow, GetScrolledWindow, doc="See `GetScrolledWindow`");
611dc22c
RD
274};
275
276
277
278/*
279 * wxTreeCompanionWindow
280 *
281 * A window displaying values associated with tree control items.
282 */
283
284%{
285class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
286{
287public:
288 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
289 const wxPoint& pos = wxDefaultPosition,
290 const wxSize& size = wxDefaultSize,
291 long style = 0)
292 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
293
294
295 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
296 bool found;
6e6b3557 297 wxPyBlock_t blocked = wxPyBeginBlockThreads();
611dc22c 298 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
6d450e1a 299 PyObject* dcobj = wxPyMake_wxObject(&dc,false);
a72f4631
RD
300 PyObject* idobj = wxPyConstructObject((void*)&id, wxT("wxTreeItemId"), false);
301 PyObject* recobj= wxPyConstructObject((void*)&rect, wxT("wxRect"), false);
611dc22c
RD
302 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
303 Py_DECREF(dcobj);
304 Py_DECREF(idobj);
305 Py_DECREF(recobj);
306 }
da32eb53 307 wxPyEndBlockThreads(blocked);
611dc22c
RD
308 if (! found)
309 wxTreeCompanionWindow::DrawItem(dc, id, rect);
310 }
311
312 PYPRIVATE;
313};
314%}
315
316
ab1f7d2a
RD
317MustHaveApp(wxPyTreeCompanionWindow);
318
1b8c7ba6
RD
319%rename(TreeCompanionWindow) wxPyTreeCompanionWindow;
320class wxPyTreeCompanionWindow: public wxWindow
611dc22c
RD
321{
322public:
c25f90f6 323 %pythonAppend wxPyTreeCompanionWindow "self._setOORInfo(self);" setCallbackInfo(TreeCompanionWindow)
2b9048c5 324 %pythonAppend wxPyTreeCompanionWindow() ""
d14a1e28 325
611dc22c
RD
326 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
327 const wxPoint& pos = wxDefaultPosition,
328 const wxSize& size = wxDefaultSize,
329 long style = 0);
330 void _setCallbackInfo(PyObject* self, PyObject* _class);
611dc22c
RD
331
332 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
333 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
e70b4d2d
RD
334
335 %property(TreeCtrl, GetTreeCtrl, SetTreeCtrl, doc="See `GetTreeCtrl` and `SetTreeCtrl`");
611dc22c
RD
336};
337
338
339
340/*
341 * wxThinSplitterWindow
342 *
343 * Implements a splitter with a less obvious sash
344 * than the usual one.
345 */
346
ab1f7d2a
RD
347MustHaveApp(wxThinSplitterWindow);
348
611dc22c
RD
349class wxThinSplitterWindow: public wxSplitterWindow
350{
351public:
2b9048c5
RD
352 %pythonAppend wxThinSplitterWindow "self._setOORInfo(self)"
353 %pythonAppend wxThinSplitterWindow() ""
d14a1e28 354
611dc22c
RD
355 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
356 const wxPoint& pos = wxDefaultPosition,
357 const wxSize& size = wxDefaultSize,
358 long style = wxSP_3D | wxCLIP_CHILDREN);
611dc22c
RD
359};
360
361
d14a1e28 362
611dc22c
RD
363/*
364 * wxSplitterScrolledWindow
365 *
366 * This scrolled window is aware of the fact that one of its
367 * children is a splitter window. It passes on its scroll events
368 * (after some processing) to both splitter children for them
369 * scroll appropriately.
370 */
371
ab1f7d2a
RD
372MustHaveApp(wxSplitterScrolledWindow);
373
611dc22c
RD
374class wxSplitterScrolledWindow: public wxScrolledWindow
375{
376public:
2b9048c5
RD
377 %pythonAppend wxSplitterScrolledWindow "self._setOORInfo(self)"
378 %pythonAppend wxSplitterScrolledWindow() ""
d14a1e28 379
611dc22c
RD
380 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
381 const wxPoint& pos = wxDefaultPosition,
382 const wxSize& size = wxDefaultSize,
383 long style = 0);
611dc22c
RD
384};
385
386
d14a1e28
RD
387//---------------------------------------------------------------------------
388//---------------------------------------------------------------------------
950e7faf
RD
389
390
391enum wxLEDValueAlign
392{
393 wxLED_ALIGN_LEFT,
394 wxLED_ALIGN_RIGHT,
395 wxLED_ALIGN_CENTER,
396
397 wxLED_ALIGN_MASK,
398
399 wxLED_DRAW_FADED,
400};
401
402
ab1f7d2a
RD
403MustHaveApp(wxLEDNumberCtrl);
404
950e7faf
RD
405class wxLEDNumberCtrl : public wxControl
406{
407public:
2b9048c5
RD
408 %pythonAppend wxLEDNumberCtrl "self._setOORInfo(self)"
409 %pythonAppend wxLEDNumberCtrl() ""
d14a1e28 410
950e7faf
RD
411 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
412 const wxPoint& pos = wxDefaultPosition,
413 const wxSize& size = wxDefaultSize,
414 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
1b8c7ba6 415 %RenameCtor(PreLEDNumberCtrl, wxLEDNumberCtrl());
950e7faf 416
950e7faf
RD
417 bool Create(wxWindow *parent, wxWindowID id = -1,
418 const wxPoint& pos = wxDefaultPosition,
419 const wxSize& size = wxDefaultSize,
420 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
421
d14a1e28
RD
422 wxLEDValueAlign GetAlignment() const;
423 bool GetDrawFaded() const;
424 const wxString &GetValue() const;
950e7faf
RD
425
426 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
427 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
428 void SetValue(const wxString &Value, bool Redraw = true);
429
e70b4d2d
RD
430 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
431 %property(DrawFaded, GetDrawFaded, SetDrawFaded, doc="See `GetDrawFaded` and `SetDrawFaded`");
432 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
950e7faf
RD
433};
434
1fded56b
RD
435
436
33328cd8 437//----------------------------------------------------------------------
1fded56b 438
33328cd8 439%include _treelist.i
1fded56b 440
7e4b7f9a
RD
441//----------------------------------------------------------------------
442
443enum
444{
445 wxSCALE_HORIZONTAL,
446 wxSCALE_VERTICAL,
447 wxSCALE_UNIFORM,
448 wxSCALE_CUSTOM
449};
450
451MustHaveApp(wxStaticPicture);
452
453class wxStaticPicture : public wxControl
454{
455public:
456 %pythonAppend wxStaticPicture "self._setOORInfo(self)"
457 %pythonAppend wxStaticPicture() ""
458
d3397f6a
RD
459 wxStaticPicture( wxWindow* parent, wxWindowID id=-1,
460 const wxBitmap& label=wxNullBitmap,
7e4b7f9a
RD
461 const wxPoint& pos = wxDefaultPosition,
462 const wxSize& size = wxDefaultSize,
463 long style = 0,
464 const wxString& name = wxPyStaticPictureNameStr );
465
466 %RenameCtor(PreStaticPicture, wxStaticPicture());
467
d3397f6a
RD
468 bool Create( wxWindow* parent, wxWindowID id=-1,
469 const wxBitmap& label=wxNullBitmap,
7e4b7f9a
RD
470 const wxPoint& pos = wxDefaultPosition,
471 const wxSize& size = wxDefaultSize,
472 long style = 0,
473 const wxString& name = wxPyStaticPictureNameStr );
474
475 void SetBitmap( const wxBitmap& bmp );
476 wxBitmap GetBitmap() const;
477 void SetIcon( const wxIcon& icon );
478 wxIcon GetIcon() const;
1fded56b 479
7e4b7f9a
RD
480 void SetAlignment( int align );
481 int GetAlignment() const;
482
483 void SetScale( int scale );
484 int GetScale() const;
485
486 void SetCustomScale( float sx, float sy );
487 void GetCustomScale( float* OUTPUT, float* OUTPUT ) const;
488
e70b4d2d
RD
489 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
490 %property(Bitmap, GetBitmap, SetBitmap, doc="See `GetBitmap` and `SetBitmap`");
491 %property(Icon, GetIcon, SetIcon, doc="See `GetIcon` and `SetIcon`");
492 %property(Scale, GetScale, SetScale, doc="See `GetScale` and `SetScale`");
7e4b7f9a 493};
1fded56b
RD
494
495
950e7faf 496//----------------------------------------------------------------------
ebf4302c
RD
497//----------------------------------------------------------------------
498
499%init %{
611dc22c 500 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
ebf4302c
RD
501%}
502
ebf4302c
RD
503//----------------------------------------------------------------------
504//----------------------------------------------------------------------
505