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