]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/gizmos/gizmos.i
corrected thread detection for Darwin / Mac OS X
[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
13%module gizmos
14
15
16%{
17#include "export.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>
ebf4302c
RD
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
137b5242
RD
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
ebf4302c
RD
46enum {
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*/
62class wxDynamicSashSplitEvent : public wxCommandEvent {
63public:
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*/
78class wxDynamicSashUnifyEvent : public wxCommandEvent {
79public:
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
611dc22c 103 provided below, and then create a view window whose parent is the
ebf4302c
RD
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.)
611dc22c 115 In this case, you will need to construct your wxDynamicSashWindow without
ebf4302c
RD
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
130class wxDynamicSashWindow : public wxWindow {
131public:
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,
137b5242 135 const wxString& name = wxPyDynamicSashNameStr);
ebf4302c
RD
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,
137b5242 141 const wxString& name = wxPyDynamicSashNameStr);
ebf4302c
RD
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 = "
156def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
157 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
158
159def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
160 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
161"
162
7b7ac0ab
RD
163//----------------------------------------------------------------------
164//----------------------------------------------------------------------
165
6187ec8f
RD
166enum {
167 wxEL_ALLOW_NEW,
168 wxEL_ALLOW_EDIT,
169 wxEL_ALLOW_DELETE,
170};
7b7ac0ab
RD
171
172// This class provides a composite control that lets the
173// user easily enter list of strings
174class wxEditableListBox : public wxPanel
175{
176public:
177 wxEditableListBox(wxWindow *parent, wxWindowID id,
178 const wxString& label,
179 const wxPoint& pos = wxDefaultPosition,
180 const wxSize& size = wxDefaultSize,
6187ec8f 181 long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE,
137b5242 182 const wxString& name = wxPyEditableListBoxNameStr);
7b7ac0ab 183
611dc22c
RD
184 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
185
7b7ac0ab
RD
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
611dc22c
RD
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
215class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
216{
217public:
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%{
252class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
253{
254public:
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;
4268f798 264 wxPyBeginBlockThreads();
611dc22c
RD
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 }
4268f798 274 wxPyEndBlockThreads();
611dc22c
RD
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{
286public:
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
308class wxThinSplitterWindow: public wxSplitterWindow
309{
310public:
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
329class wxSplitterScrolledWindow: public wxScrolledWindow
330{
331public:
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
950e7faf
RD
340//----------------------------------------------------------------------
341//----------------------------------------------------------------------
342
343
344enum 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
356class wxLEDNumberCtrl : public wxControl
357{
358public:
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//----------------------------------------------------------------------
ebf4302c
RD
386//----------------------------------------------------------------------
387
388%init %{
389
390 wxClassInfo::CleanUpClasses();
391 wxClassInfo::InitializeClasses();
392
611dc22c 393 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
ebf4302c
RD
394%}
395
396
ebf4302c
RD
397%pragma(python) include="_gizmoextras.py";
398
399//----------------------------------------------------------------------
400//----------------------------------------------------------------------
401
402
611dc22c
RD
403
404
405
406