]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/wizard.i
Added generic LoadObject methods that can load any classtype from a
[wxWidgets.git] / wxPython / src / wizard.i
CommitLineData
af83019e
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: wizard.i
3// Purpose: Classes for wxWizard and etc.
4//
5// Author: Robin Dunn
6//
7// Created: 16-Aug-2002
8// RCS-ID: $Id$
9// Copyright: (c) 2002 by Total Control Software
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
13%module wizard
14
15%{
16#include "wxPython.h"
17#include <wx/wizard.h>
18%}
19
20//----------------------------------------------------------------------
21
22%include typemaps.i
23%include my_typemaps.i
24
25// Import some definitions of other classes, etc.
26%import _defs.i
27%import windows.i
28%import frames.i
29%import misc.i
30%import controls.i
31
32
33//----------------------------------------------------------------------
34
35enum {
36 wxWIZARD_EX_HELPBUTTON,
37
38 wxEVT_WIZARD_PAGE_CHANGED,
39 wxEVT_WIZARD_PAGE_CHANGING,
40 wxEVT_WIZARD_CANCEL,
41 wxEVT_WIZARD_HELP
42};
43
44
45%pragma(python) code = "
46# wizard events
47def EVT_WIZARD_PAGE_CHANGED(win, id, func):
48 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
49
50def EVT_WIZARD_PAGE_CHANGING(win, id, func):
51 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
52
53def EVT_WIZARD_CANCEL(win, id, func):
54 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
55
56def EVT_WIZARD_HELP(win, id, func):
57 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
58
59"
60
61//----------------------------------------------------------------------
62
63class wxWizardEvent : public wxNotifyEvent
64{
65public:
66 wxWizardEvent(wxEventType type = wxEVT_NULL,
67 int id = -1,
68 bool direction = TRUE,
69 wxWizardPage* page = NULL);
70
71 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
72 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
73 // from the previous page and FALSE if we returned from the next one
74 // (this function doesn't make sense for CANCEL events)
75 bool GetDirection() const { return m_direction; }
76
77 wxWizardPage* GetPage() const { return m_page; }
78};
79
80
81//----------------------------------------------------------------------
82
83// wxWizardPage is one of the wizards screen: it must know what are the
84// following and preceding pages (which may be NULL for the first/last page).
85//
86// Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
87// used as such (i.e. controls may be placed directly on it &c).
88class wxWizardPage : public wxPanel
89{
90public:
91// // ctor accepts an optional bitmap which will be used for this page instead
92// // of the default one for this wizard (should be of the same size). Notice
93// // that no other parameters are needed because the wizard will resize and
94// // reposition the page anyhow
95// wxWizardPage(wxWizard *parent,
96// const wxBitmap& bitmap = wxNullBitmap,
97// const char* resource = NULL);
98// %name(wxPreWizardPage)wxWizardPage();
99
100 bool Create(wxWizard *parent,
101 const wxBitmap& bitmap = wxNullBitmap,
102 const char* resource = NULL);
103
104 // common part of ctors:
105 void Init();
106
107 // these functions are used by the wizard to show another page when the
108 // user chooses "Back" or "Next" button
109 virtual wxWizardPage *GetPrev() const;
110 virtual wxWizardPage *GetNext() const;
111
112 // default GetBitmap() will just return m_bitmap which is ok in 99% of
113 // cases - override this method if you want to create the bitmap to be used
114 // dynamically or to do something even more fancy. It's ok to return
115 // wxNullBitmap from here - the default one will be used then.
116 virtual wxBitmap GetBitmap() const;
117};
118
119
120
121%{ // C++ Version of a Python aware class
122class wxPyWizardPage : public wxWizardPage {
123 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
124public:
125 wxPyWizardPage() : wxWizardPage() {}
126 wxPyWizardPage(wxWizard *parent,
127 const wxBitmap& bitmap = wxNullBitmap,
128 const wxChar* resource = NULL)
129 : wxWizardPage(parent, bitmap, resource) {}
130
131 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
132 DEC_PYCALLBACK_WIZPG__pure(GetNext);
133 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
134
135 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
136 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
137 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
138 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
139
140 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
141 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
142 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
143
144 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
145 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
146
147 DEC_PYCALLBACK__(InitDialog);
148 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
149 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
150 DEC_PYCALLBACK_BOOL_(Validate);
151
152 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
153 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
154 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
155
156 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
157 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
158
159 PYPRIVATE;
160};
161
162
163IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
164
165IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
166IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
167IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
168
169IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
170IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
171IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
172IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
173
174IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
175IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
176IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
177
178IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
179IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
180
181IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
182IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
183IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
184IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
185
186IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
187IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
188IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
189
190IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
191IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
192
193%}
194
195
196
197class wxPyWizardPage : public wxWizardPage {
198public:
199 // ctor accepts an optional bitmap which will be used for this page instead
200 // of the default one for this wizard (should be of the same size). Notice
201 // that no other parameters are needed because the wizard will resize and
202 // reposition the page anyhow
203 wxPyWizardPage(wxWizard *parent,
204 const wxBitmap& bitmap = wxNullBitmap,
205 const char* resource = NULL);
206 %name(wxPrePyWizardPage)wxPyWizardPage();
207
208 bool Create(wxWizard *parent,
209 const wxBitmap& bitmap = wxNullBitmap,
210 const char* resource = NULL);
211
212 void _setCallbackInfo(PyObject* self, PyObject* _class);
213 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyWizardPage)"
214
215 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
216 %pragma(python) addtomethod = "wxPrePyWizardPage:val._setOORInfo(val)"
217
218 void base_DoMoveWindow(int x, int y, int width, int height);
219 void base_DoSetSize(int x, int y, int width, int height,
220 int sizeFlags = wxSIZE_AUTO);
221 void base_DoSetClientSize(int width, int height);
222 void base_DoSetVirtualSize( int x, int y );
223
224 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
225 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
226 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
227
228 wxSize base_DoGetVirtualSize() const;
229 wxSize base_DoGetBestSize() const;
230
231 void base_InitDialog();
232 bool base_TransferDataToWindow();
233 bool base_TransferDataFromWindow();
234 bool base_Validate();
235
236 bool base_AcceptsFocus() const;
237 bool base_AcceptsFocusFromKeyboard() const;
238 wxSize base_GetMaxSize() const;
239
240 void base_AddChild(wxWindow* child);
241 void base_RemoveChild(wxWindow* child);
242};
243
244//----------------------------------------------------------------------
245
246
247// wxWizardPageSimple just returns the pointers given to the ctor and is useful
248// to create a simple wizard where the order of pages never changes.
249//
250// OTOH, it is also possible to dynamicly decide which page to return (i.e.
251// depending on the user's choices) as the wizard sample shows - in order to do
252// this, you must derive from wxWizardPage directly.
253class wxWizardPageSimple : public wxWizardPage
254{
255public:
256 // ctor takes the previous and next pages
257 wxWizardPageSimple(wxWizard *parent,
258 wxWizardPage *prev = NULL,
259 wxWizardPage *next = NULL,
260 const wxBitmap& bitmap = wxNullBitmap,
261 const wxChar* resource = NULL);
262 %name(wxPreWizardPageSimple)wxWizardPageSimple();
263
264 bool Create(wxWizard *parent = NULL,
265 wxWizardPage *prev = NULL,
266 wxWizardPage *next = NULL,
267 const wxBitmap& bitmap = wxNullBitmap,
268 const wxChar* resource = NULL);
269
270 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
271 %pragma(python) addtomethod = "wxPreWizardPageSimple:val._setOORInfo(val)"
272
273 // common part of ctors:
274 void Init();
275
276 // the pointers may be also set later - but before starting the wizard
277 void SetPrev(wxWizardPage *prev);
278 void SetNext(wxWizardPage *next);
279
280 // a convenience function to make the pages follow each other
281 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
282};
283
284
285//----------------------------------------------------------------------
286
287class wxWizard : public wxDialog
288{
289public:
290 // ctor
291 wxWizard(wxWindow *parent,
292 int id = -1,
293 const wxString& title = wxEmptyString,
294 const wxBitmap& bitmap = wxNullBitmap,
295 const wxPoint& pos = wxDefaultPosition);
296 %name(wxPreWizard)wxWizard();
297
298 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
299 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
300
301 bool Create(wxWindow *parent,
302 int id = -1,
303 const wxString& title = wxEmptyString,
304 const wxBitmap& bitmap = wxNullBitmap,
305 const wxPoint& pos = wxDefaultPosition);
306
307 void Init();
308
309
310 // executes the wizard starting from the given page, returns TRUE if it was
311 // successfully finished, FALSE if user cancelled it
312 virtual bool RunWizard(wxWizardPage *firstPage);
313
314 // get the current page (NULL if RunWizard() isn't running)
315 virtual wxWizardPage *GetCurrentPage() const;
316
317 // set the min size which should be available for the pages: a
318 // wizard will take into account the size of the bitmap (if any)
319 // itself and will never be less than some predefined fixed size
320 virtual void SetPageSize(const wxSize& size);
321
322 // get the size available for the page: the wizards are not resizeable, so
323 // this size doesn't change
324 virtual wxSize GetPageSize() const;
325
326 // set the best size for the wizard, i.e. make it big enough to contain all
327 // of the pages starting from the given one
328 //
329 // this function may be called several times and possible with different
330 // pages in which case it will only increase the page size if needed (this
331 // may be useful if not all pages are accessible from the first one by
332 // default)
333 virtual void FitToPage(const wxWizardPage *firstPage);
334
335 // is the wizard running?
336 bool IsRunning() const { return m_page != NULL; }
337
338 // show the prev/next page, but call TransferDataFromWindow on the current
339 // page first and return FALSE without changing the page if
340 // TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
341 bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
342};
343
344
345//----------------------------------------------------------------------
85260f24
RD
346
347%init %{
348 wxClassInfo::CleanUpClasses();
349 wxClassInfo::InitializeClasses();
350%}
351
af83019e
RD
352//----------------------------------------------------------------------
353// This file gets appended to the shadow class file.
354//----------------------------------------------------------------------
355
356%pragma(python) include="_wizardextras.py";
357
358//---------------------------------------------------------------------------