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,
51 %pragma(python) code = "
53 def EVT_WIZARD_PAGE_CHANGED(win, id, func):
54 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
56 def EVT_WIZARD_PAGE_CHANGING(win, id, func):
57 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
59 def EVT_WIZARD_CANCEL(win, id, func):
60 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
62 def EVT_WIZARD_HELP(win, id, func):
63 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
65 def EVT_WIZARD_FINISHED(win, id, func):
66 win.Connect(id, -1, wxEVT_WIZARD_FINISHED, func)
70 //----------------------------------------------------------------------
72 class wxWizardEvent : public wxNotifyEvent
75 wxWizardEvent(wxEventType type = wxEVT_NULL,
77 bool direction = TRUE,
78 wxWizardPage* page = NULL);
80 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
81 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
82 // from the previous page and FALSE if we returned from the next one
83 // (this function doesn't make sense for CANCEL events)
84 bool GetDirection() const { return m_direction; }
86 wxWizardPage* GetPage() const { return m_page; }
90 //----------------------------------------------------------------------
92 // wxWizardPage is one of the wizards screen: it must know what are the
93 // following and preceding pages (which may be NULL for the first/last page).
95 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
96 // used as such (i.e. controls may be placed directly on it &c).
97 class wxWizardPage : public wxPanel
100 // // ctor accepts an optional bitmap which will be used for this page instead
101 // // of the default one for this wizard (should be of the same size). Notice
102 // // that no other parameters are needed because the wizard will resize and
103 // // reposition the page anyhow
104 // wxWizardPage(wxWizard *parent,
105 // const wxBitmap& bitmap = wxNullBitmap,
106 // const char* resource = NULL);
107 // %name(wxPreWizardPage)wxWizardPage();
110 bool Create(wxWizard *parent,
111 const wxBitmap& bitmap = wxNullBitmap,
112 const wxString& resource = wxPyEmptyString) {
114 if (resource.Length())
115 res = (wxChar*)resource.c_str();
116 return self->Create(parent, bitmap, res);
121 // these functions are used by the wizard to show another page when the
122 // user chooses "Back" or "Next" button
123 virtual wxWizardPage *GetPrev() const;
124 virtual wxWizardPage *GetNext() const;
126 // default GetBitmap() will just return m_bitmap which is ok in 99% of
127 // cases - override this method if you want to create the bitmap to be used
128 // dynamically or to do something even more fancy. It's ok to return
129 // wxNullBitmap from here - the default one will be used then.
130 virtual wxBitmap GetBitmap() const;
135 %{ // C++ Version of a Python aware class
136 class wxPyWizardPage : public wxWizardPage {
137 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
139 wxPyWizardPage() : wxWizardPage() {}
140 wxPyWizardPage(wxWizard *parent,
141 const wxBitmap& bitmap = wxNullBitmap,
142 const wxChar* resource = NULL)
143 : wxWizardPage(parent, bitmap, resource) {}
145 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
146 DEC_PYCALLBACK_WIZPG__pure(GetNext);
147 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
149 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
150 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
151 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
152 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
154 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
155 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
156 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
158 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
159 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
161 DEC_PYCALLBACK__(InitDialog);
162 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
163 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
164 DEC_PYCALLBACK_BOOL_(Validate);
166 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
167 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
168 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
170 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
171 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
177 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
179 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
180 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
181 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
183 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
184 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
185 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
186 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
188 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
189 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
190 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
192 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
193 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
195 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
196 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
197 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
198 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
200 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
201 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
202 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
204 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
205 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
211 class wxPyWizardPage : public wxWizardPage {
213 // ctor accepts an optional bitmap which will be used for this page instead
214 // of the default one for this wizard (should be of the same size). Notice
215 // that no other parameters are needed because the wizard will resize and
216 // reposition the page anyhow
218 wxPyWizardPage(wxWizard *parent,
219 const wxBitmap* bitmap = &wxNullBitmap,
220 const wxString* resource = &wxPyEmptyString) {
222 if (resource->Length())
223 res = (wxChar*)resource->c_str();
224 return new wxPyWizardPage(parent, *bitmap, res);
228 %name(wxPrePyWizardPage)wxPyWizardPage();
231 bool Create(wxWizard *parent,
232 const wxBitmap& bitmap = wxNullBitmap,
233 const wxString& resource = wxPyEmptyString) {
235 if (resource.Length())
236 res = (wxChar*)resource.c_str();
237 return self->Create(parent, bitmap, res);
241 void _setCallbackInfo(PyObject* self, PyObject* _class);
242 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyWizardPage)"
244 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
245 %pragma(python) addtomethod = "wxPrePyWizardPage:val._setOORInfo(val)"
247 void base_DoMoveWindow(int x, int y, int width, int height);
248 void base_DoSetSize(int x, int y, int width, int height,
249 int sizeFlags = wxSIZE_AUTO);
250 void base_DoSetClientSize(int width, int height);
251 void base_DoSetVirtualSize( int x, int y );
253 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
254 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
255 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
257 wxSize base_DoGetVirtualSize() const;
258 wxSize base_DoGetBestSize() const;
260 void base_InitDialog();
261 bool base_TransferDataToWindow();
262 bool base_TransferDataFromWindow();
263 bool base_Validate();
265 bool base_AcceptsFocus() const;
266 bool base_AcceptsFocusFromKeyboard() const;
267 wxSize base_GetMaxSize() const;
269 void base_AddChild(wxWindow* child);
270 void base_RemoveChild(wxWindow* child);
273 //----------------------------------------------------------------------
276 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
277 // to create a simple wizard where the order of pages never changes.
279 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
280 // depending on the user's choices) as the wizard sample shows - in order to do
281 // this, you must derive from wxWizardPage directly.
282 class wxWizardPageSimple : public wxWizardPage
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(wxPreWizardPageSimple)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 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
300 %pragma(python) addtomethod = "wxPreWizardPageSimple:val._setOORInfo(val)"
302 // the pointers may be also set later - but before starting the wizard
303 void SetPrev(wxWizardPage *prev);
304 void SetNext(wxWizardPage *next);
306 // a convenience function to make the pages follow each other
307 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
311 //----------------------------------------------------------------------
313 class wxWizard : public wxDialog
317 wxWizard(wxWindow *parent,
319 const wxString& title = wxEmptyString,
320 const wxBitmap& bitmap = wxNullBitmap,
321 const wxPoint& pos = wxDefaultPosition,
322 long style = wxDEFAULT_DIALOG_STYLE);
323 %name(wxPreWizard)wxWizard();
325 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
326 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
328 bool Create(wxWindow *parent,
330 const wxString& title = wxEmptyString,
331 const wxBitmap& bitmap = wxNullBitmap,
332 const wxPoint& pos = wxDefaultPosition);
337 // executes the wizard starting from the given page, returns TRUE if it was
338 // successfully finished, FALSE if user cancelled it
339 virtual bool RunWizard(wxWizardPage *firstPage);
341 // get the current page (NULL if RunWizard() isn't running)
342 virtual wxWizardPage *GetCurrentPage() const;
344 // set the min size which should be available for the pages: a
345 // wizard will take into account the size of the bitmap (if any)
346 // itself and will never be less than some predefined fixed size
347 virtual void SetPageSize(const wxSize& size);
349 // get the size available for the page: the wizards are not resizeable, so
350 // this size doesn't change
351 virtual wxSize GetPageSize() const;
353 // set the best size for the wizard, i.e. make it big enough to contain all
354 // of the pages starting from the given one
356 // this function may be called several times and possible with different
357 // pages in which case it will only increase the page size if needed (this
358 // may be useful if not all pages are accessible from the first one by
360 virtual void FitToPage(const wxWizardPage *firstPage);
362 // Adding pages to page area sizer enlarges wizard
363 virtual wxSizer *GetPageAreaSizer() const;
365 // Set border around page area. Default is 0 if you add at least one
366 // page to GetPageAreaSizer and 5 if you don't.
367 virtual void SetBorder(int border);
369 // is the wizard running?
370 bool IsRunning() const { return m_page != NULL; }
372 // show the prev/next page, but call TransferDataFromWindow on the current
373 // page first and return FALSE without changing the page if
374 // TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
375 bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
377 bool HasNextPage(wxWizardPage* page);
378 bool HasPrevPage(wxWizardPage* page);
382 //----------------------------------------------------------------------
387 //----------------------------------------------------------------------
388 // This file gets appended to the shadow class file.
389 //----------------------------------------------------------------------
391 %pragma(python) include="_wizardextras.py";
393 //---------------------------------------------------------------------------