]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/wizard.i
applied patch 1378261
[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
c8fac2b6
RD
13%define DOCSTRING
14"`Wizard` is a dialog class that guides the user through a sequence of steps,
15or pages."
16%enddef
b2eb030f
RD
17
18%module(package="wx", docstring=DOCSTRING) wizard
af83019e
RD
19
20%{
d14a1e28
RD
21#include "wx/wxPython/wxPython.h"
22#include "wx/wxPython/pyclasses.h"
23#include "wx/wxPython/printfw.h"
24
af83019e 25#include <wx/wizard.h>
d14a1e28 26
af83019e
RD
27%}
28
29//----------------------------------------------------------------------
30
af83019e 31%import windows.i
54f9ee45 32%pythoncode { wx = _core }
99109c0f 33%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
af83019e 34
d14a1e28 35%include _wizard_rename.i
af83019e 36
b2dc1044
RD
37MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
38
af83019e
RD
39//----------------------------------------------------------------------
40
41enum {
42 wxWIZARD_EX_HELPBUTTON,
af83019e
RD
43};
44
d14a1e28
RD
45%constant wxEventType wxEVT_WIZARD_PAGE_CHANGED;
46%constant wxEventType wxEVT_WIZARD_PAGE_CHANGING;
47%constant wxEventType wxEVT_WIZARD_CANCEL;
48%constant wxEventType wxEVT_WIZARD_HELP;
49%constant wxEventType wxEVT_WIZARD_FINISHED;
af83019e 50
af83019e 51
af83019e 52
d14a1e28
RD
53%pythoncode {
54EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
55EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
56EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
57EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
58EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
59}
af83019e
RD
60
61//----------------------------------------------------------------------
62
63class wxWizardEvent : public wxNotifyEvent
64{
65public:
66 wxWizardEvent(wxEventType type = wxEVT_NULL,
67 int id = -1,
a72f4631 68 bool direction = true,
af83019e
RD
69 wxWizardPage* page = NULL);
70
dd9f7fea
RD
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
af83019e
RD
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).
ab1f7d2a 88MustHaveApp(wxWizardPage);
af83019e
RD
89class wxWizardPage : public wxPanel
90{
91public:
92// // ctor accepts an optional bitmap which will be used for this page instead
93// // of the default one for this wizard (should be of the same size). Notice
94// // that no other parameters are needed because the wizard will resize and
95// // reposition the page anyhow
96// wxWizardPage(wxWizard *parent,
97// const wxBitmap& bitmap = wxNullBitmap,
98// const char* resource = NULL);
1b8c7ba6 99// %RenameCtor(PreWizardPage, wxWizardPage());
af83019e 100
d14a1e28 101 %extend {
dd4a4b90
RD
102 bool Create(wxWizard *parent,
103 const wxBitmap& bitmap = wxNullBitmap,
104 const wxString& resource = wxPyEmptyString) {
105 wxChar* res = NULL;
2fbb702b 106 if (resource.length())
dd4a4b90
RD
107 res = (wxChar*)resource.c_str();
108 return self->Create(parent, bitmap, res);
109 }
110 }
111
af83019e 112
af83019e
RD
113 // these functions are used by the wizard to show another page when the
114 // user chooses "Back" or "Next" button
115 virtual wxWizardPage *GetPrev() const;
116 virtual wxWizardPage *GetNext() const;
117
118 // default GetBitmap() will just return m_bitmap which is ok in 99% of
119 // cases - override this method if you want to create the bitmap to be used
120 // dynamically or to do something even more fancy. It's ok to return
121 // wxNullBitmap from here - the default one will be used then.
122 virtual wxBitmap GetBitmap() const;
123};
124
125
126
127%{ // C++ Version of a Python aware class
128class wxPyWizardPage : public wxWizardPage {
4617be08 129 DECLARE_ABSTRACT_CLASS(wxPyWizardPage)
af83019e
RD
130public:
131 wxPyWizardPage() : wxWizardPage() {}
132 wxPyWizardPage(wxWizard *parent,
133 const wxBitmap& bitmap = wxNullBitmap,
134 const wxChar* resource = NULL)
135 : wxWizardPage(parent, bitmap, resource) {}
136
137 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
138 DEC_PYCALLBACK_WIZPG__pure(GetNext);
139 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
140
141 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
142 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
143 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
144 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
145
146 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
147 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
148 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
149
150 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
151 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
152
153 DEC_PYCALLBACK__(InitDialog);
154 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
155 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
156 DEC_PYCALLBACK_BOOL_(Validate);
157
158 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
159 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
160 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
161
162 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
163 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
164
165 PYPRIVATE;
166};
167
168
169IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
170
171IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
172IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
173IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
174
175IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
176IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
177IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
178IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
179
180IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
181IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
182IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
183
184IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
185IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
186
187IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
188IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
189IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
190IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
191
192IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
193IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
194IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
195
196IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
197IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
198
199%}
200
201
202
ab1f7d2a
RD
203MustHaveApp(wxPyWizardPage);
204
af83019e
RD
205class wxPyWizardPage : public wxWizardPage {
206public:
d14a1e28 207
2b9048c5
RD
208 %pythonAppend wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
209 %pythonAppend wxPyWizardPage() ""
b39c3fa0 210 %typemap(out) wxPyWizardPage*; // turn off this typemap
d14a1e28 211
af83019e
RD
212 // ctor accepts an optional bitmap which will be used for this page instead
213 // of the default one for this wizard (should be of the same size). Notice
214 // that no other parameters are needed because the wizard will resize and
215 // reposition the page anyhow
d14a1e28 216 %extend {
dd4a4b90
RD
217 wxPyWizardPage(wxWizard *parent,
218 const wxBitmap* bitmap = &wxNullBitmap,
219 const wxString* resource = &wxPyEmptyString) {
220 wxChar* res = NULL;
2fbb702b 221 if (resource->length())
dd4a4b90
RD
222 res = (wxChar*)resource->c_str();
223 return new wxPyWizardPage(parent, *bitmap, res);
224 }
225 }
226
1b8c7ba6 227 %RenameCtor(PrePyWizardPage, wxPyWizardPage());
af83019e 228
b39c3fa0
RD
229 // Turn it back on again
230 %typemap(out) wxPyWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
231
d14a1e28 232 %extend {
dd4a4b90
RD
233 bool Create(wxWizard *parent,
234 const wxBitmap& bitmap = wxNullBitmap,
235 const wxString& resource = wxPyEmptyString) {
236 wxChar* res = NULL;
2fbb702b 237 if (resource.length())
dd4a4b90
RD
238 res = (wxChar*)resource.c_str();
239 return self->Create(parent, bitmap, res);
240 }
241 }
af83019e
RD
242
243 void _setCallbackInfo(PyObject* self, PyObject* _class);
af83019e 244
a7a01418
RD
245 void DoMoveWindow(int x, int y, int width, int height);
246 void DoSetSize(int x, int y, int width, int height,
af83019e 247 int sizeFlags = wxSIZE_AUTO);
a7a01418
RD
248 void DoSetClientSize(int width, int height);
249 void DoSetVirtualSize( int x, int y );
af83019e 250
322913ce 251 DocDeclA(
a7a01418
RD
252 void, DoGetSize( int *OUTPUT, int *OUTPUT ) const,
253 "DoGetSize() -> (width, height)");
322913ce 254 DocDeclA(
a7a01418
RD
255 void, DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
256 "DoGetClientSize() -> (width, height)");
322913ce 257 DocDeclA(
a7a01418
RD
258 void, DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
259 "DoGetPosition() -> (x,y)");
260
261 wxSize DoGetVirtualSize() const;
262 wxSize DoGetBestSize() const;
263
264 void InitDialog();
265 bool TransferDataToWindow();
266 bool TransferDataFromWindow();
267 bool Validate();
268
269 bool AcceptsFocus() const;
270 bool AcceptsFocusFromKeyboard() const;
271 wxSize GetMaxSize() const;
272
273 void AddChild(wxWindow* child);
274 void RemoveChild(wxWindow* child);
275
276 bool ShouldInheritColours() const;
277 wxVisualAttributes GetDefaultAttributes();
278
279 void OnInternalIdle();
280
281 %MAKE_BASE_FUNC(PyWizardPage, DoMoveWindow);
282 %MAKE_BASE_FUNC(PyWizardPage, DoSetSize);
283 %MAKE_BASE_FUNC(PyWizardPage, DoSetClientSize);
284 %MAKE_BASE_FUNC(PyWizardPage, DoSetVirtualSize);
285 %MAKE_BASE_FUNC(PyWizardPage, DoGetSize);
286 %MAKE_BASE_FUNC(PyWizardPage, DoGetClientSize);
287 %MAKE_BASE_FUNC(PyWizardPage, DoGetPosition);
288 %MAKE_BASE_FUNC(PyWizardPage, DoGetVirtualSize);
289 %MAKE_BASE_FUNC(PyWizardPage, DoGetBestSize);
290 %MAKE_BASE_FUNC(PyWizardPage, InitDialog);
291 %MAKE_BASE_FUNC(PyWizardPage, TransferDataToWindow);
292 %MAKE_BASE_FUNC(PyWizardPage, TransferDataFromWindow);
293 %MAKE_BASE_FUNC(PyWizardPage, Validate);
294 %MAKE_BASE_FUNC(PyWizardPage, AcceptsFocus);
295 %MAKE_BASE_FUNC(PyWizardPage, AcceptsFocusFromKeyboard);
296 %MAKE_BASE_FUNC(PyWizardPage, GetMaxSize);
297 %MAKE_BASE_FUNC(PyWizardPage, AddChild);
298 %MAKE_BASE_FUNC(PyWizardPage, RemoveChild);
299 %MAKE_BASE_FUNC(PyWizardPage, ShouldInheritColours);
300 %MAKE_BASE_FUNC(PyWizardPage, GetDefaultAttributes);
301 %MAKE_BASE_FUNC(PyWizardPage, OnInternalIdle);
302
af83019e
RD
303};
304
305//----------------------------------------------------------------------
306
307
308// wxWizardPageSimple just returns the pointers given to the ctor and is useful
309// to create a simple wizard where the order of pages never changes.
310//
311// OTOH, it is also possible to dynamicly decide which page to return (i.e.
312// depending on the user's choices) as the wizard sample shows - in order to do
313// this, you must derive from wxWizardPage directly.
ab1f7d2a 314MustHaveApp(wxWizardPageSimple);
af83019e
RD
315class wxWizardPageSimple : public wxWizardPage
316{
317public:
d14a1e28 318
2b9048c5
RD
319 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
320 %pythonAppend wxWizardPageSimple() ""
d14a1e28 321
af83019e
RD
322 // ctor takes the previous and next pages
323 wxWizardPageSimple(wxWizard *parent,
324 wxWizardPage *prev = NULL,
325 wxWizardPage *next = NULL,
326 const wxBitmap& bitmap = wxNullBitmap,
327 const wxChar* resource = NULL);
1b8c7ba6 328 %RenameCtor(PreWizardPageSimple, wxWizardPageSimple());
af83019e
RD
329
330 bool Create(wxWizard *parent = NULL,
331 wxWizardPage *prev = NULL,
332 wxWizardPage *next = NULL,
333 const wxBitmap& bitmap = wxNullBitmap,
334 const wxChar* resource = NULL);
335
af83019e
RD
336 // the pointers may be also set later - but before starting the wizard
337 void SetPrev(wxWizardPage *prev);
338 void SetNext(wxWizardPage *next);
339
340 // a convenience function to make the pages follow each other
341 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
342};
343
344
345//----------------------------------------------------------------------
346
ab1f7d2a
RD
347MustHaveApp(wxWizard);
348
af83019e
RD
349class wxWizard : public wxDialog
350{
351public:
2b9048c5
RD
352 %pythonAppend wxWizard "self._setOORInfo(self)"
353 %pythonAppend wxWizard() ""
d14a1e28 354
af83019e
RD
355 // ctor
356 wxWizard(wxWindow *parent,
357 int id = -1,
b2dc1044 358 const wxString& title = wxPyEmptyString,
af83019e 359 const wxBitmap& bitmap = wxNullBitmap,
3ef86e32
RD
360 const wxPoint& pos = wxDefaultPosition,
361 long style = wxDEFAULT_DIALOG_STYLE);
1b8c7ba6 362 %RenameCtor(PreWizard, wxWizard());
af83019e
RD
363
364 bool Create(wxWindow *parent,
365 int id = -1,
b2dc1044 366 const wxString& title = wxPyEmptyString,
af83019e
RD
367 const wxBitmap& bitmap = wxNullBitmap,
368 const wxPoint& pos = wxDefaultPosition);
369
370 void Init();
371
372
dd9f7fea
RD
373 // executes the wizard starting from the given page, returns True if it was
374 // successfully finished, False if user cancelled it
af83019e
RD
375 virtual bool RunWizard(wxWizardPage *firstPage);
376
377 // get the current page (NULL if RunWizard() isn't running)
378 virtual wxWizardPage *GetCurrentPage() const;
379
380 // set the min size which should be available for the pages: a
381 // wizard will take into account the size of the bitmap (if any)
382 // itself and will never be less than some predefined fixed size
383 virtual void SetPageSize(const wxSize& size);
384
385 // get the size available for the page: the wizards are not resizeable, so
386 // this size doesn't change
387 virtual wxSize GetPageSize() const;
388
389 // set the best size for the wizard, i.e. make it big enough to contain all
390 // of the pages starting from the given one
391 //
392 // this function may be called several times and possible with different
393 // pages in which case it will only increase the page size if needed (this
394 // may be useful if not all pages are accessible from the first one by
395 // default)
396 virtual void FitToPage(const wxWizardPage *firstPage);
397
3ef86e32
RD
398 // Adding pages to page area sizer enlarges wizard
399 virtual wxSizer *GetPageAreaSizer() const;
400
401 // Set border around page area. Default is 0 if you add at least one
402 // page to GetPageAreaSizer and 5 if you don't.
403 virtual void SetBorder(int border);
404
af83019e 405 // is the wizard running?
2fbb702b 406 bool IsRunning() const;
af83019e
RD
407
408 // show the prev/next page, but call TransferDataFromWindow on the current
dd9f7fea
RD
409 // page first and return False without changing the page if
410 // TransferDataFromWindow() returns False - otherwise, returns True
a72f4631 411 bool ShowPage(wxWizardPage *page, bool goingForward = true);
1e4a197e
RD
412
413 bool HasNextPage(wxWizardPage* page);
414 bool HasPrevPage(wxWizardPage* page);
af83019e
RD
415};
416
417
418//----------------------------------------------------------------------
85260f24
RD
419
420%init %{
85260f24
RD
421%}
422
af83019e 423//---------------------------------------------------------------------------