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