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 /////////////////////////////////////////////////////////////////////////////
17 #include <wx/wizard.h>
20 //----------------------------------------------------------------------
23 %include my_typemaps.i
25 // Import some definitions of other classes, etc.
33 //----------------------------------------------------------------------
35 // Put some wx default wxChar* values into wxStrings.
36 static const wxString wxPyEmptyString(wxT(""));
38 //----------------------------------------------------------------------
41 wxWIZARD_EX_HELPBUTTON,
43 wxEVT_WIZARD_PAGE_CHANGED,
44 wxEVT_WIZARD_PAGE_CHANGING,
50 %pragma(python) code = "
52 def EVT_WIZARD_PAGE_CHANGED(win, id, func):
53 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
55 def EVT_WIZARD_PAGE_CHANGING(win, id, func):
56 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
58 def EVT_WIZARD_CANCEL(win, id, func):
59 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
61 def EVT_WIZARD_HELP(win, id, func):
62 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
66 //----------------------------------------------------------------------
68 class wxWizardEvent : public wxNotifyEvent
71 wxWizardEvent(wxEventType type = wxEVT_NULL,
73 bool direction = TRUE,
74 wxWizardPage* page = NULL);
76 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
77 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
78 // from the previous page and FALSE if we returned from the next one
79 // (this function doesn't make sense for CANCEL events)
80 bool GetDirection() const { return m_direction; }
82 wxWizardPage* GetPage() const { return m_page; }
86 //----------------------------------------------------------------------
88 // wxWizardPage is one of the wizards screen: it must know what are the
89 // following and preceding pages (which may be NULL for the first/last page).
91 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
92 // used as such (i.e. controls may be placed directly on it &c).
93 class wxWizardPage : public wxPanel
96 // // ctor accepts an optional bitmap which will be used for this page instead
97 // // of the default one for this wizard (should be of the same size). Notice
98 // // that no other parameters are needed because the wizard will resize and
99 // // reposition the page anyhow
100 // wxWizardPage(wxWizard *parent,
101 // const wxBitmap& bitmap = wxNullBitmap,
102 // const char* resource = NULL);
103 // %name(wxPreWizardPage)wxWizardPage();
106 bool Create(wxWizard *parent,
107 const wxBitmap& bitmap = wxNullBitmap,
108 const wxString& resource = wxPyEmptyString) {
110 if (resource.Length())
111 res = (wxChar*)resource.c_str();
112 return self->Create(parent, bitmap, res);
117 // these functions are used by the wizard to show another page when the
118 // user chooses "Back" or "Next" button
119 virtual wxWizardPage *GetPrev() const;
120 virtual wxWizardPage *GetNext() const;
122 // default GetBitmap() will just return m_bitmap which is ok in 99% of
123 // cases - override this method if you want to create the bitmap to be used
124 // dynamically or to do something even more fancy. It's ok to return
125 // wxNullBitmap from here - the default one will be used then.
126 virtual wxBitmap GetBitmap() const;
131 %{ // C++ Version of a Python aware class
132 class wxPyWizardPage : public wxWizardPage {
133 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
135 wxPyWizardPage() : wxWizardPage() {}
136 wxPyWizardPage(wxWizard *parent,
137 const wxBitmap& bitmap = wxNullBitmap,
138 const wxChar* resource = NULL)
139 : wxWizardPage(parent, bitmap, resource) {}
141 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
142 DEC_PYCALLBACK_WIZPG__pure(GetNext);
143 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
145 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
146 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
147 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
148 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
150 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
151 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
152 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
154 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
155 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
157 DEC_PYCALLBACK__(InitDialog);
158 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
159 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
160 DEC_PYCALLBACK_BOOL_(Validate);
162 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
163 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
164 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
166 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
167 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
173 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
175 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
176 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
177 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
179 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
180 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
181 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
182 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
184 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
185 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
186 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
188 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
189 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
191 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
192 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
193 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
194 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
196 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
197 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
198 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
200 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
201 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
207 class wxPyWizardPage : public wxWizardPage {
209 // ctor accepts an optional bitmap which will be used for this page instead
210 // of the default one for this wizard (should be of the same size). Notice
211 // that no other parameters are needed because the wizard will resize and
212 // reposition the page anyhow
214 wxPyWizardPage(wxWizard *parent,
215 const wxBitmap* bitmap = &wxNullBitmap,
216 const wxString* resource = &wxPyEmptyString) {
218 if (resource->Length())
219 res = (wxChar*)resource->c_str();
220 return new wxPyWizardPage(parent, *bitmap, res);
224 %name(wxPrePyWizardPage)wxPyWizardPage();
227 bool Create(wxWizard *parent,
228 const wxBitmap& bitmap = wxNullBitmap,
229 const wxString& resource = wxPyEmptyString) {
231 if (resource.Length())
232 res = (wxChar*)resource.c_str();
233 return self->Create(parent, bitmap, res);
237 void _setCallbackInfo(PyObject* self, PyObject* _class);
238 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyWizardPage)"
240 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
241 %pragma(python) addtomethod = "wxPrePyWizardPage:val._setOORInfo(val)"
243 void base_DoMoveWindow(int x, int y, int width, int height);
244 void base_DoSetSize(int x, int y, int width, int height,
245 int sizeFlags = wxSIZE_AUTO);
246 void base_DoSetClientSize(int width, int height);
247 void base_DoSetVirtualSize( int x, int y );
249 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
250 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
251 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
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
281 // ctor takes the previous and next pages
282 wxWizardPageSimple(wxWizard *parent,
283 wxWizardPage *prev = NULL,
284 wxWizardPage *next = NULL,
285 const wxBitmap& bitmap = wxNullBitmap,
286 const wxChar* resource = NULL);
287 %name(wxPreWizardPageSimple)wxWizardPageSimple();
289 bool Create(wxWizard *parent = NULL,
290 wxWizardPage *prev = NULL,
291 wxWizardPage *next = NULL,
292 const wxBitmap& bitmap = wxNullBitmap,
293 const wxChar* resource = NULL);
295 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
296 %pragma(python) addtomethod = "wxPreWizardPageSimple:val._setOORInfo(val)"
298 // the pointers may be also set later - but before starting the wizard
299 void SetPrev(wxWizardPage *prev);
300 void SetNext(wxWizardPage *next);
302 // a convenience function to make the pages follow each other
303 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
307 //----------------------------------------------------------------------
309 class wxWizard : public wxDialog
313 wxWizard(wxWindow *parent,
315 const wxString& title = wxEmptyString,
316 const wxBitmap& bitmap = wxNullBitmap,
317 const wxPoint& pos = wxDefaultPosition);
318 %name(wxPreWizard)wxWizard();
320 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
321 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
323 bool Create(wxWindow *parent,
325 const wxString& title = wxEmptyString,
326 const wxBitmap& bitmap = wxNullBitmap,
327 const wxPoint& pos = wxDefaultPosition);
332 // executes the wizard starting from the given page, returns TRUE if it was
333 // successfully finished, FALSE if user cancelled it
334 virtual bool RunWizard(wxWizardPage *firstPage);
336 // get the current page (NULL if RunWizard() isn't running)
337 virtual wxWizardPage *GetCurrentPage() const;
339 // set the min size which should be available for the pages: a
340 // wizard will take into account the size of the bitmap (if any)
341 // itself and will never be less than some predefined fixed size
342 virtual void SetPageSize(const wxSize& size);
344 // get the size available for the page: the wizards are not resizeable, so
345 // this size doesn't change
346 virtual wxSize GetPageSize() const;
348 // set the best size for the wizard, i.e. make it big enough to contain all
349 // of the pages starting from the given one
351 // this function may be called several times and possible with different
352 // pages in which case it will only increase the page size if needed (this
353 // may be useful if not all pages are accessible from the first one by
355 virtual void FitToPage(const wxWizardPage *firstPage);
357 // is the wizard running?
358 bool IsRunning() const { return m_page != NULL; }
360 // show the prev/next page, but call TransferDataFromWindow on the current
361 // page first and return FALSE without changing the page if
362 // TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
363 bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
367 //----------------------------------------------------------------------
370 wxClassInfo::CleanUpClasses();
371 wxClassInfo::InitializeClasses();
374 //----------------------------------------------------------------------
375 // This file gets appended to the shadow class file.
376 //----------------------------------------------------------------------
378 %pragma(python) include="_wizardextras.py";
380 //---------------------------------------------------------------------------