]> git.saurik.com Git - wxWidgets.git/blame - wxPython/contrib/gizmos/gizmos.i
Forgot to move update and clear regions when scrolling.
[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
38enum {
39 wxEVT_DYNAMIC_SASH_SPLIT,
40 wxEVT_DYNAMIC_SASH_UNIFY,
41
42 wxDS_MANAGE_SCROLLBARS,
43 wxDS_DRAG_CORNER,
44};
45
46
47/*
48 wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow
49 whenever your view is being split by the user. It is your
50 responsibility to handle this event by creating a new view window as
51 a child of the wxDynamicSashWindow. wxDynamicSashWindow will
52 automatically reparent it to the proper place in its window hierarchy.
53*/
54class wxDynamicSashSplitEvent : public wxCommandEvent {
55public:
56 wxDynamicSashSplitEvent(wxObject *target);
57};
58
59
60/*
61 wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow
62 whenever the sash which splits your view and its sibling is being
63 reunified such that your view is expanding to replace its sibling.
64 You needn't do anything with this event if you are allowing
65 wxDynamicSashWindow to manage your view's scrollbars, but it is useful
66 if you are managing the scrollbars yourself so that you can keep
67 the scrollbars' event handlers connected to your view's event handler
68 class.
69*/
70class wxDynamicSashUnifyEvent : public wxCommandEvent {
71public:
72 wxDynamicSashUnifyEvent(wxObject *target);
73};
74
75
76
77/*
78
79 wxDynamicSashWindow
80
81 wxDynamicSashWindow widgets manages the way other widgets are viewed.
82 When a wxDynamicSashWindow is first shown, it will contain one child
83 view, a viewport for that child, and a pair of scrollbars to allow the
84 user to navigate the child view area. Next to each scrollbar is a small
85 tab. By clicking on either tab and dragging to the appropriate spot, a
86 user can split the view area into two smaller views separated by a
87 draggable sash. Later, when the user wishes to reunify the two subviews,
88 the user simply drags the sash to the side of the window.
89 wxDynamicSashWindow will automatically reparent the appropriate child
90 view back up the window hierarchy, and the wxDynamicSashWindow will have
91 only one child view once again.
92
93 As an application developer, you will simply create a wxDynamicSashWindow
94 using either the Create() function or the more complex constructor
611dc22c 95 provided below, and then create a view window whose parent is the
ebf4302c
RD
96 wxDynamicSashWindow. The child should respond to
97 wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by
98 constructing a new view window whose parent is also the
99 wxDynamicSashWindow. That's it! Now your users can dynamically split
100 and reunify the view you provided.
101
102 If you wish to handle the scrollbar events for your view, rather than
103 allowing wxDynamicSashWindow to do it for you, things are a bit more
104 complex. (You might want to handle scrollbar events yourself, if,
105 for instance, you wish to scroll a subwindow of the view you add to
106 your wxDynamicSashWindow object, rather than scrolling the whole view.)
611dc22c 107 In this case, you will need to construct your wxDynamicSashWindow without
ebf4302c
RD
108 the wxDS_MANAGE_SCROLLBARS style and you will need to use the
109 GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar
110 controls and call SetEventHanler() on them to redirect the scrolling
111 events whenever your window is reparented by wxDyanmicSashWindow.
112 You will need to set the scrollbars' event handler at three times:
113
114 * When your view is created
115 * When your view receives a wxDynamicSashSplitEvent
116 * When your view receives a wxDynamicSashUnifyEvent
117
118 See the dynsash_switch sample application for an example which does this.
119
120*/
121
122class wxDynamicSashWindow : public wxWindow {
123public:
124 wxDynamicSashWindow(wxWindow *parent, wxWindowID id,
125 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
126 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
127 const char* name = "dynamicSashWindow");
128 %name(wxPreDynamicSashWindow)wxDynamicSashWindow();
129
130 bool Create(wxWindow *parent, wxWindowID id,
131 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
132 long style = wxCLIP_CHILDREN | wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER,
133 const char* name = "dynamicSashWindow");
134
135 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
136 %pragma(python) addtomethod = "wxPreDynamicSashWindow:val._setOORInfo(val)"
137
138 wxScrollBar *GetHScrollBar(const wxWindow *child) const;
139 wxScrollBar *GetVScrollBar(const wxWindow *child) const;
140};
141
142
143
144//----------------------------------------------------------------------
145// Python functions to act like the event macros
146
147%pragma(python) code = "
148def EVT_DYNAMIC_SASH_SPLIT(win, id, func):
149 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_SPLIT, func)
150
151def EVT_DYNAMIC_SASH_UNIFY(win, id, func):
152 win.Connect(id, -1, wxEVT_DYNAMIC_SASH_UNIFY, func)
153"
154
7b7ac0ab
RD
155//----------------------------------------------------------------------
156//----------------------------------------------------------------------
157
158
159// This class provides a composite control that lets the
160// user easily enter list of strings
161class wxEditableListBox : public wxPanel
162{
163public:
164 wxEditableListBox(wxWindow *parent, wxWindowID id,
165 const wxString& label,
166 const wxPoint& pos = wxDefaultPosition,
167 const wxSize& size = wxDefaultSize,
168 const char* name = "editableListBox");
169
611dc22c
RD
170 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
171
7b7ac0ab
RD
172 void SetStrings(const wxArrayString& strings);
173
174 //void GetStrings(wxArrayString& strings);
175 %addmethods {
176 PyObject* GetStrings() {
177 wxArrayString strings;
178 self->GetStrings(strings);
179 return wxArrayString2PyList_helper(strings);
180 }
181 }
182};
183
184
185
611dc22c
RD
186//----------------------------------------------------------------------
187
188
189/*
190 * wxRemotelyScrolledTreeCtrl
191 *
192 * This tree control disables its vertical scrollbar and catches scroll
193 * events passed by a scrolled window higher in the hierarchy.
194 * It also updates the scrolled window vertical scrollbar as appropriate.
195 */
196
197%{
198 typedef wxTreeCtrl wxPyTreeCtrl;
199%}
200
201class wxRemotelyScrolledTreeCtrl: public wxPyTreeCtrl
202{
203public:
204 wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id,
205 const wxPoint& pos = wxDefaultPosition,
206 const wxSize& size = wxDefaultSize,
207 long style = wxTR_HAS_BUTTONS);
208 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
209
210
211 void HideVScrollbar();
212
213 // Adjust the containing wxScrolledWindow's scrollbars appropriately
214 void AdjustRemoteScrollbars();
215
216 // Find the scrolled window that contains this control
217 wxScrolledWindow* GetScrolledWindow() const;
218
219 // Scroll to the given line (in scroll units where each unit is
220 // the height of an item)
221 void ScrollToLine(int posHoriz, int posVert);
222
223 // The companion window is one which will get notified when certain
224 // events happen such as node expansion
225 void SetCompanionWindow(wxWindow* companion);
226 wxWindow* GetCompanionWindow() const;
227};
228
229
230
231/*
232 * wxTreeCompanionWindow
233 *
234 * A window displaying values associated with tree control items.
235 */
236
237%{
238class wxPyTreeCompanionWindow: public wxTreeCompanionWindow
239{
240public:
241 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
242 const wxPoint& pos = wxDefaultPosition,
243 const wxSize& size = wxDefaultSize,
244 long style = 0)
245 : wxTreeCompanionWindow(parent, id, pos, size, style) {}
246
247
248 virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) {
249 bool found;
4268f798 250 wxPyBeginBlockThreads();
611dc22c
RD
251 if ((found = wxPyCBH_findCallback(m_myInst, "DrawItem"))) {
252 PyObject* dcobj = wxPyMake_wxObject(&dc);
253 PyObject* idobj = wxPyConstructObject((void*)&id, "wxTreeItemId", FALSE);
254 PyObject* recobj= wxPyConstructObject((void*)&rect, "wxRect", FALSE);
255 wxPyCBH_callCallback(m_myInst, Py_BuildValue("(OOO)", dcobj, idobj, recobj));
256 Py_DECREF(dcobj);
257 Py_DECREF(idobj);
258 Py_DECREF(recobj);
259 }
4268f798 260 wxPyEndBlockThreads();
611dc22c
RD
261 if (! found)
262 wxTreeCompanionWindow::DrawItem(dc, id, rect);
263 }
264
265 PYPRIVATE;
266};
267%}
268
269
270%name(wxTreeCompanionWindow) class wxPyTreeCompanionWindow: public wxWindow
271{
272public:
273 wxPyTreeCompanionWindow(wxWindow* parent, wxWindowID id = -1,
274 const wxPoint& pos = wxDefaultPosition,
275 const wxSize& size = wxDefaultSize,
276 long style = 0);
277 void _setCallbackInfo(PyObject* self, PyObject* _class);
278 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxTreeCompanionWindow)"
279 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
280
281 wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const;
282 void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl);
283};
284
285
286
287/*
288 * wxThinSplitterWindow
289 *
290 * Implements a splitter with a less obvious sash
291 * than the usual one.
292 */
293
294class wxThinSplitterWindow: public wxSplitterWindow
295{
296public:
297 wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1,
298 const wxPoint& pos = wxDefaultPosition,
299 const wxSize& size = wxDefaultSize,
300 long style = wxSP_3D | wxCLIP_CHILDREN);
301 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
302
303};
304
305
306/*
307 * wxSplitterScrolledWindow
308 *
309 * This scrolled window is aware of the fact that one of its
310 * children is a splitter window. It passes on its scroll events
311 * (after some processing) to both splitter children for them
312 * scroll appropriately.
313 */
314
315class wxSplitterScrolledWindow: public wxScrolledWindow
316{
317public:
318 wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1,
319 const wxPoint& pos = wxDefaultPosition,
320 const wxSize& size = wxDefaultSize,
321 long style = 0);
322 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
323};
324
325
950e7faf
RD
326//----------------------------------------------------------------------
327//----------------------------------------------------------------------
328
329
330enum wxLEDValueAlign
331{
332 wxLED_ALIGN_LEFT,
333 wxLED_ALIGN_RIGHT,
334 wxLED_ALIGN_CENTER,
335
336 wxLED_ALIGN_MASK,
337
338 wxLED_DRAW_FADED,
339};
340
341
342class wxLEDNumberCtrl : public wxControl
343{
344public:
345 // Constructors.
346 wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = -1,
347 const wxPoint& pos = wxDefaultPosition,
348 const wxSize& size = wxDefaultSize,
349 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
350 %name(wxPreLEDNumberCtrl) wxLEDNumberCtrl();
351
352 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
353 %pragma(python) addtomethod = "wxPreLEDNumberCtrl:val._setOORInfo(val)"
354
355 // Create functions.
356 bool Create(wxWindow *parent, wxWindowID id = -1,
357 const wxPoint& pos = wxDefaultPosition,
358 const wxSize& size = wxDefaultSize,
359 long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED);
360
361 wxLEDValueAlign GetAlignment() const { return m_Alignment; }
362 bool GetDrawFaded() const { return m_DrawFaded; }
363 const wxString &GetValue() const { return m_Value; }
364
365 void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true);
366 void SetDrawFaded(bool DrawFaded, bool Redraw = true);
367 void SetValue(const wxString &Value, bool Redraw = true);
368
369};
370
371//----------------------------------------------------------------------
ebf4302c
RD
372//----------------------------------------------------------------------
373
374%init %{
375
376 wxClassInfo::CleanUpClasses();
377 wxClassInfo::InitializeClasses();
378
611dc22c 379 wxPyPtrTypeMap_Add("wxTreeCompanionWindow", "wxPyTreeCompanionWindow");
ebf4302c
RD
380%}
381
382
ebf4302c
RD
383%pragma(python) include="_gizmoextras.py";
384
385//----------------------------------------------------------------------
386//----------------------------------------------------------------------
387
388
611dc22c
RD
389
390
391
392