1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Classes for wxWizard and etc.
7 // Created: 16-Aug-2002
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
14 "`Wizard` is a dialog class that guides the user through a sequence of steps,
18 %module(package="wx", docstring=DOCSTRING) wizard
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "wx/wxPython/printfw.h"
25 #include <wx/wizard.h>
29 //----------------------------------------------------------------------
32 %pythoncode { wx = _core }
33 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
35 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
37 //----------------------------------------------------------------------
40 wxWIZARD_EX_HELPBUTTON,
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;
52 EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
53 EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
54 EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
55 EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
56 EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
59 //----------------------------------------------------------------------
61 class wxWizardEvent : public wxNotifyEvent
64 wxWizardEvent(wxEventType type = wxEVT_NULL,
66 bool direction = true,
67 wxWizardPage* page = NULL);
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
72 // (this function doesn't make sense for CANCEL events)
73 bool GetDirection() const;
75 wxWizardPage* GetPage() const;
77 %property(Direction, GetDirection, doc="See `GetDirection`");
78 %property(Page, GetPage, doc="See `GetPage`");
82 //----------------------------------------------------------------------
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).
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).
89 MustHaveApp(wxWizardPage);
90 class wxWizardPage : public wxPanel
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 // %RenameCtor(PreWizardPage, wxWizardPage());
101 bool Create(wxWizard *parent,
102 const wxBitmap& bitmap = wxNullBitmap);
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;
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;
116 %property(Bitmap, GetBitmap, doc="See `GetBitmap`");
117 %property(Next, GetNext, doc="See `GetNext`");
118 %property(Prev, GetPrev, doc="See `GetPrev`");
123 %{ // C++ Version of a Python aware class
124 class wxPyWizardPage : public wxWizardPage {
125 DECLARE_ABSTRACT_CLASS(wxPyWizardPage)
127 wxPyWizardPage() : wxWizardPage() {}
128 wxPyWizardPage(wxWizard *parent,
129 const wxBitmap& bitmap = wxNullBitmap)
130 : wxWizardPage(parent, bitmap) {}
132 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
133 DEC_PYCALLBACK_WIZPG__pure(GetNext);
134 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
136 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
137 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
138 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
139 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
141 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
142 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
143 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
145 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
146 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
148 DEC_PYCALLBACK__(InitDialog);
149 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
150 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
151 DEC_PYCALLBACK_BOOL_(Validate);
153 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
154 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
155 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
157 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
158 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
164 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
166 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
167 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
168 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
170 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
171 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
172 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
173 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
175 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
176 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
177 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
179 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
180 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
182 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
183 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
184 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
185 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
187 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
188 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
189 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
191 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
192 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
198 MustHaveApp(wxPyWizardPage);
200 class wxPyWizardPage : public wxWizardPage {
203 %pythonAppend wxPyWizardPage "self._setOORInfo(self);" setCallbackInfo(PyWizardPage)
204 %pythonAppend wxPyWizardPage() ""
205 %typemap(out) wxPyWizardPage*; // turn off this typemap
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
211 wxPyWizardPage(wxWizard *parent,
212 const wxBitmap& bitmap = wxNullBitmap);
214 %RenameCtor(PrePyWizardPage, wxPyWizardPage());
216 // Turn it back on again
217 %typemap(out) wxPyWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
219 bool Create(wxWizard *parent,
220 const wxBitmap& bitmap = wxNullBitmap);
222 void _setCallbackInfo(PyObject* self, PyObject* _class);
224 void DoMoveWindow(int x, int y, int width, int height);
225 void DoSetSize(int x, int y, int width, int height,
226 int sizeFlags = wxSIZE_AUTO);
227 void DoSetClientSize(int width, int height);
228 void DoSetVirtualSize( int x, int y );
231 void, DoGetSize( int *OUTPUT, int *OUTPUT ) const,
232 "DoGetSize() -> (width, height)");
234 void, DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
235 "DoGetClientSize() -> (width, height)");
237 void, DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
238 "DoGetPosition() -> (x,y)");
240 wxSize DoGetVirtualSize() const;
241 wxSize DoGetBestSize() const;
244 bool TransferDataToWindow();
245 bool TransferDataFromWindow();
248 bool AcceptsFocus() const;
249 bool AcceptsFocusFromKeyboard() const;
250 wxSize GetMaxSize() const;
252 void AddChild(wxWindow* child);
253 void RemoveChild(wxWindow* child);
255 bool ShouldInheritColours() const;
256 wxVisualAttributes GetDefaultAttributes();
258 void OnInternalIdle();
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);
284 //----------------------------------------------------------------------
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.
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.
293 MustHaveApp(wxWizardPageSimple);
294 class wxWizardPageSimple : public wxWizardPage
298 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
299 %pythonAppend wxWizardPageSimple() ""
301 // ctor takes the previous and next pages
302 wxWizardPageSimple(wxWizard *parent,
303 wxWizardPage *prev = NULL,
304 wxWizardPage *next = NULL,
305 const wxBitmap& bitmap = wxNullBitmap);
306 %RenameCtor(PreWizardPageSimple, wxWizardPageSimple());
308 bool Create(wxWizard *parent = NULL,
309 wxWizardPage *prev = NULL,
310 wxWizardPage *next = NULL,
311 const wxBitmap& bitmap = wxNullBitmap);
313 // the pointers may be also set later - but before starting the wizard
314 void SetPrev(wxWizardPage *prev);
315 void SetNext(wxWizardPage *next);
317 // a convenience function to make the pages follow each other
318 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
322 //----------------------------------------------------------------------
324 MustHaveApp(wxWizard);
326 class wxWizard : public wxDialog
329 %pythonAppend wxWizard "self._setOORInfo(self)"
330 %pythonAppend wxWizard() ""
333 wxWizard(wxWindow *parent,
335 const wxString& title = wxPyEmptyString,
336 const wxBitmap& bitmap = wxNullBitmap,
337 const wxPoint& pos = wxDefaultPosition,
338 long style = wxDEFAULT_DIALOG_STYLE);
339 %RenameCtor(PreWizard, wxWizard());
341 bool Create(wxWindow *parent,
343 const wxString& title = wxPyEmptyString,
344 const wxBitmap& bitmap = wxNullBitmap,
345 const wxPoint& pos = wxDefaultPosition);
350 // executes the wizard starting from the given page, returns True if it was
351 // successfully finished, False if user cancelled it
352 virtual bool RunWizard(wxWizardPage *firstPage);
354 // get the current page (NULL if RunWizard() isn't running)
355 virtual wxWizardPage *GetCurrentPage() const;
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);
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;
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
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
373 virtual void FitToPage(const wxWizardPage *firstPage);
375 // Adding pages to page area sizer enlarges wizard
376 virtual wxSizer *GetPageAreaSizer() const;
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);
382 // is the wizard running?
383 bool IsRunning() const;
385 // show the prev/next page, but call TransferDataFromWindow on the current
386 // page first and return False without changing the page if
387 // TransferDataFromWindow() returns False - otherwise, returns True
388 bool ShowPage(wxWizardPage *page, bool goingForward = true);
390 bool HasNextPage(wxWizardPage* page);
391 bool HasPrevPage(wxWizardPage* page);
393 %property(CurrentPage, GetCurrentPage, doc="See `GetCurrentPage`");
394 %property(PageAreaSizer, GetPageAreaSizer, doc="See `GetPageAreaSizer`");
395 %property(PageSize, GetPageSize, SetPageSize, doc="See `GetPageSize` and `SetPageSize`");
399 //----------------------------------------------------------------------
404 //---------------------------------------------------------------------------