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,
17 %module(docstring=DOCSTRING) wizard
20 #include "wx/wxPython/wxPython.h"
21 #include "wx/wxPython/pyclasses.h"
22 #include "wx/wxPython/printfw.h"
24 #include <wx/wizard.h>
28 //----------------------------------------------------------------------
31 %pythoncode { wx = _core }
32 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
34 %include _wizard_rename.i
36 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
38 //----------------------------------------------------------------------
41 wxWIZARD_EX_HELPBUTTON,
44 %constant wxEventType wxEVT_WIZARD_PAGE_CHANGED;
45 %constant wxEventType wxEVT_WIZARD_PAGE_CHANGING;
46 %constant wxEventType wxEVT_WIZARD_CANCEL;
47 %constant wxEventType wxEVT_WIZARD_HELP;
48 %constant wxEventType wxEVT_WIZARD_FINISHED;
53 EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
54 EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
55 EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
56 EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
57 EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
60 //----------------------------------------------------------------------
62 class wxWizardEvent : public wxNotifyEvent
65 wxWizardEvent(wxEventType type = wxEVT_NULL,
67 bool direction = True,
68 wxWizardPage* page = NULL);
70 // for EVT_WIZARD_PAGE_CHANGING, return True if we're going forward or
71 // False otherwise and for EVT_WIZARD_PAGE_CHANGED return True if we came
72 // from the previous page and False if we returned from the next one
73 // (this function doesn't make sense for CANCEL events)
74 bool GetDirection() const { return m_direction; }
76 wxWizardPage* GetPage() const { return m_page; }
80 //----------------------------------------------------------------------
82 // wxWizardPage is one of the wizards screen: it must know what are the
83 // following and preceding pages (which may be NULL for the first/last page).
85 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
86 // used as such (i.e. controls may be placed directly on it &c).
87 class wxWizardPage : public wxPanel
90 // // ctor accepts an optional bitmap which will be used for this page instead
91 // // of the default one for this wizard (should be of the same size). Notice
92 // // that no other parameters are needed because the wizard will resize and
93 // // reposition the page anyhow
94 // wxWizardPage(wxWizard *parent,
95 // const wxBitmap& bitmap = wxNullBitmap,
96 // const char* resource = NULL);
97 // %name(PreWizardPage)wxWizardPage();
100 bool Create(wxWizard *parent,
101 const wxBitmap& bitmap = wxNullBitmap,
102 const wxString& resource = wxPyEmptyString) {
104 if (resource.Length())
105 res = (wxChar*)resource.c_str();
106 return self->Create(parent, bitmap, res);
111 // these functions are used by the wizard to show another page when the
112 // user chooses "Back" or "Next" button
113 virtual wxWizardPage *GetPrev() const;
114 virtual wxWizardPage *GetNext() const;
116 // default GetBitmap() will just return m_bitmap which is ok in 99% of
117 // cases - override this method if you want to create the bitmap to be used
118 // dynamically or to do something even more fancy. It's ok to return
119 // wxNullBitmap from here - the default one will be used then.
120 virtual wxBitmap GetBitmap() const;
125 %{ // C++ Version of a Python aware class
126 class wxPyWizardPage : public wxWizardPage {
127 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
129 wxPyWizardPage() : wxWizardPage() {}
130 wxPyWizardPage(wxWizard *parent,
131 const wxBitmap& bitmap = wxNullBitmap,
132 const wxChar* resource = NULL)
133 : wxWizardPage(parent, bitmap, resource) {}
135 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
136 DEC_PYCALLBACK_WIZPG__pure(GetNext);
137 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
139 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
140 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
141 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
142 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
144 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
145 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
146 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
148 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
149 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
151 DEC_PYCALLBACK__(InitDialog);
152 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
153 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
154 DEC_PYCALLBACK_BOOL_(Validate);
156 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
157 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
158 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
160 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
161 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
167 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
169 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
170 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
171 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
173 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
174 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
175 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
176 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
178 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
179 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
180 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
182 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
183 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
185 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
186 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
187 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
188 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
190 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
191 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
192 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
194 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
195 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
201 class wxPyWizardPage : public wxWizardPage {
204 %pythonAppend wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
205 %pythonAppend wxPyWizardPage() ""
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
212 wxPyWizardPage(wxWizard *parent,
213 const wxBitmap* bitmap = &wxNullBitmap,
214 const wxString* resource = &wxPyEmptyString) {
216 if (resource->Length())
217 res = (wxChar*)resource->c_str();
218 return new wxPyWizardPage(parent, *bitmap, res);
222 %name(PrePyWizardPage)wxPyWizardPage();
225 bool Create(wxWizard *parent,
226 const wxBitmap& bitmap = wxNullBitmap,
227 const wxString& resource = wxPyEmptyString) {
229 if (resource.Length())
230 res = (wxChar*)resource.c_str();
231 return self->Create(parent, bitmap, res);
235 void _setCallbackInfo(PyObject* self, PyObject* _class);
237 void base_DoMoveWindow(int x, int y, int width, int height);
238 void base_DoSetSize(int x, int y, int width, int height,
239 int sizeFlags = wxSIZE_AUTO);
240 void base_DoSetClientSize(int width, int height);
241 void base_DoSetVirtualSize( int x, int y );
244 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
245 "base_DoGetSize() -> (width, height)");
247 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
248 "base_DoGetClientSize() -> (width, height)");
250 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
251 "base_DoGetPosition() -> (x,y)");
253 wxSize base_DoGetVirtualSize() const;
254 wxSize base_DoGetBestSize() const;
256 void base_InitDialog();
257 bool base_TransferDataToWindow();
258 bool base_TransferDataFromWindow();
259 bool base_Validate();
261 bool base_AcceptsFocus() const;
262 bool base_AcceptsFocusFromKeyboard() const;
263 wxSize base_GetMaxSize() const;
265 void base_AddChild(wxWindow* child);
266 void base_RemoveChild(wxWindow* child);
269 //----------------------------------------------------------------------
272 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
273 // to create a simple wizard where the order of pages never changes.
275 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
276 // depending on the user's choices) as the wizard sample shows - in order to do
277 // this, you must derive from wxWizardPage directly.
278 class wxWizardPageSimple : public wxWizardPage
282 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
283 %pythonAppend wxWizardPageSimple() ""
285 // ctor takes the previous and next pages
286 wxWizardPageSimple(wxWizard *parent,
287 wxWizardPage *prev = NULL,
288 wxWizardPage *next = NULL,
289 const wxBitmap& bitmap = wxNullBitmap,
290 const wxChar* resource = NULL);
291 %name(PreWizardPageSimple)wxWizardPageSimple();
293 bool Create(wxWizard *parent = NULL,
294 wxWizardPage *prev = NULL,
295 wxWizardPage *next = NULL,
296 const wxBitmap& bitmap = wxNullBitmap,
297 const wxChar* resource = NULL);
299 // the pointers may be also set later - but before starting the wizard
300 void SetPrev(wxWizardPage *prev);
301 void SetNext(wxWizardPage *next);
303 // a convenience function to make the pages follow each other
304 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
308 //----------------------------------------------------------------------
310 class wxWizard : public wxDialog
313 %pythonAppend wxWizard "self._setOORInfo(self)"
314 %pythonAppend wxWizard() ""
317 wxWizard(wxWindow *parent,
319 const wxString& title = wxPyEmptyString,
320 const wxBitmap& bitmap = wxNullBitmap,
321 const wxPoint& pos = wxDefaultPosition,
322 long style = wxDEFAULT_DIALOG_STYLE);
323 %name(PreWizard)wxWizard();
325 bool Create(wxWindow *parent,
327 const wxString& title = wxPyEmptyString,
328 const wxBitmap& bitmap = wxNullBitmap,
329 const wxPoint& pos = wxDefaultPosition);
334 // executes the wizard starting from the given page, returns True if it was
335 // successfully finished, False if user cancelled it
336 virtual bool RunWizard(wxWizardPage *firstPage);
338 // get the current page (NULL if RunWizard() isn't running)
339 virtual wxWizardPage *GetCurrentPage() const;
341 // set the min size which should be available for the pages: a
342 // wizard will take into account the size of the bitmap (if any)
343 // itself and will never be less than some predefined fixed size
344 virtual void SetPageSize(const wxSize& size);
346 // get the size available for the page: the wizards are not resizeable, so
347 // this size doesn't change
348 virtual wxSize GetPageSize() const;
350 // set the best size for the wizard, i.e. make it big enough to contain all
351 // of the pages starting from the given one
353 // this function may be called several times and possible with different
354 // pages in which case it will only increase the page size if needed (this
355 // may be useful if not all pages are accessible from the first one by
357 virtual void FitToPage(const wxWizardPage *firstPage);
359 // Adding pages to page area sizer enlarges wizard
360 virtual wxSizer *GetPageAreaSizer() const;
362 // Set border around page area. Default is 0 if you add at least one
363 // page to GetPageAreaSizer and 5 if you don't.
364 virtual void SetBorder(int border);
366 // is the wizard running?
367 bool IsRunning() const { return m_page != NULL; }
369 // show the prev/next page, but call TransferDataFromWindow on the current
370 // page first and return False without changing the page if
371 // TransferDataFromWindow() returns False - otherwise, returns True
372 bool ShowPage(wxWizardPage *page, bool goingForward = True);
374 bool HasNextPage(wxWizardPage* page);
375 bool HasPrevPage(wxWizardPage* page);
379 //----------------------------------------------------------------------
384 //---------------------------------------------------------------------------