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 //----------------------------------------------------------------------
36 wxWIZARD_EX_HELPBUTTON,
38 wxEVT_WIZARD_PAGE_CHANGED,
39 wxEVT_WIZARD_PAGE_CHANGING,
45 %pragma(python) code = "
47 def EVT_WIZARD_PAGE_CHANGED(win, id, func):
48 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
50 def EVT_WIZARD_PAGE_CHANGING(win, id, func):
51 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
53 def EVT_WIZARD_CANCEL(win, id, func):
54 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
56 def EVT_WIZARD_HELP(win, id, func):
57 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
61 //----------------------------------------------------------------------
63 class wxWizardEvent : public wxNotifyEvent
66 wxWizardEvent(wxEventType type = wxEVT_NULL,
68 bool direction = TRUE,
69 wxWizardPage* page = NULL);
71 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
72 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
73 // from the previous page and FALSE if we returned from the next one
74 // (this function doesn't make sense for CANCEL events)
75 bool GetDirection() const { return m_direction; }
77 wxWizardPage* GetPage() const { return m_page; }
81 //----------------------------------------------------------------------
83 // wxWizardPage is one of the wizards screen: it must know what are the
84 // following and preceding pages (which may be NULL for the first/last page).
86 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
87 // used as such (i.e. controls may be placed directly on it &c).
88 class wxWizardPage : public wxPanel
91 // // ctor accepts an optional bitmap which will be used for this page instead
92 // // of the default one for this wizard (should be of the same size). Notice
93 // // that no other parameters are needed because the wizard will resize and
94 // // reposition the page anyhow
95 // wxWizardPage(wxWizard *parent,
96 // const wxBitmap& bitmap = wxNullBitmap,
97 // const char* resource = NULL);
98 // %name(wxPreWizardPage)wxWizardPage();
100 bool Create(wxWizard *parent,
101 const wxBitmap& bitmap = wxNullBitmap,
102 const char* resource = NULL);
104 // these functions are used by the wizard to show another page when the
105 // user chooses "Back" or "Next" button
106 virtual wxWizardPage *GetPrev() const;
107 virtual wxWizardPage *GetNext() const;
109 // default GetBitmap() will just return m_bitmap which is ok in 99% of
110 // cases - override this method if you want to create the bitmap to be used
111 // dynamically or to do something even more fancy. It's ok to return
112 // wxNullBitmap from here - the default one will be used then.
113 virtual wxBitmap GetBitmap() const;
118 %{ // C++ Version of a Python aware class
119 class wxPyWizardPage : public wxWizardPage {
120 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
122 wxPyWizardPage() : wxWizardPage() {}
123 wxPyWizardPage(wxWizard *parent,
124 const wxBitmap& bitmap = wxNullBitmap,
125 const wxChar* resource = NULL)
126 : wxWizardPage(parent, bitmap, resource) {}
128 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
129 DEC_PYCALLBACK_WIZPG__pure(GetNext);
130 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
132 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
133 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
134 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
135 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
137 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
138 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
139 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
141 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
142 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
144 DEC_PYCALLBACK__(InitDialog);
145 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
146 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
147 DEC_PYCALLBACK_BOOL_(Validate);
149 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
150 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
151 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
153 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
154 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
160 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
162 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
163 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
164 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
166 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
167 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
168 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
169 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
171 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
172 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
173 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
175 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
176 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
178 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
179 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
180 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
181 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
183 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
184 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
185 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
187 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
188 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
194 class wxPyWizardPage : public wxWizardPage {
196 // ctor accepts an optional bitmap which will be used for this page instead
197 // of the default one for this wizard (should be of the same size). Notice
198 // that no other parameters are needed because the wizard will resize and
199 // reposition the page anyhow
200 wxPyWizardPage(wxWizard *parent,
201 const wxBitmap& bitmap = wxNullBitmap,
202 const char* resource = NULL);
203 %name(wxPrePyWizardPage)wxPyWizardPage();
205 bool Create(wxWizard *parent,
206 const wxBitmap& bitmap = wxNullBitmap,
207 const char* resource = NULL);
209 void _setCallbackInfo(PyObject* self, PyObject* _class);
210 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyWizardPage)"
212 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
213 %pragma(python) addtomethod = "wxPrePyWizardPage:val._setOORInfo(val)"
215 void base_DoMoveWindow(int x, int y, int width, int height);
216 void base_DoSetSize(int x, int y, int width, int height,
217 int sizeFlags = wxSIZE_AUTO);
218 void base_DoSetClientSize(int width, int height);
219 void base_DoSetVirtualSize( int x, int y );
221 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
222 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
223 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
225 wxSize base_DoGetVirtualSize() const;
226 wxSize base_DoGetBestSize() const;
228 void base_InitDialog();
229 bool base_TransferDataToWindow();
230 bool base_TransferDataFromWindow();
231 bool base_Validate();
233 bool base_AcceptsFocus() const;
234 bool base_AcceptsFocusFromKeyboard() const;
235 wxSize base_GetMaxSize() const;
237 void base_AddChild(wxWindow* child);
238 void base_RemoveChild(wxWindow* child);
241 //----------------------------------------------------------------------
244 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
245 // to create a simple wizard where the order of pages never changes.
247 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
248 // depending on the user's choices) as the wizard sample shows - in order to do
249 // this, you must derive from wxWizardPage directly.
250 class wxWizardPageSimple : public wxWizardPage
253 // ctor takes the previous and next pages
254 wxWizardPageSimple(wxWizard *parent,
255 wxWizardPage *prev = NULL,
256 wxWizardPage *next = NULL,
257 const wxBitmap& bitmap = wxNullBitmap,
258 const wxChar* resource = NULL);
259 %name(wxPreWizardPageSimple)wxWizardPageSimple();
261 bool Create(wxWizard *parent = NULL,
262 wxWizardPage *prev = NULL,
263 wxWizardPage *next = NULL,
264 const wxBitmap& bitmap = wxNullBitmap,
265 const wxChar* resource = NULL);
267 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
268 %pragma(python) addtomethod = "wxPreWizardPageSimple:val._setOORInfo(val)"
270 // the pointers may be also set later - but before starting the wizard
271 void SetPrev(wxWizardPage *prev);
272 void SetNext(wxWizardPage *next);
274 // a convenience function to make the pages follow each other
275 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
279 //----------------------------------------------------------------------
281 class wxWizard : public wxDialog
285 wxWizard(wxWindow *parent,
287 const wxString& title = wxEmptyString,
288 const wxBitmap& bitmap = wxNullBitmap,
289 const wxPoint& pos = wxDefaultPosition);
290 %name(wxPreWizard)wxWizard();
292 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
293 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
295 bool Create(wxWindow *parent,
297 const wxString& title = wxEmptyString,
298 const wxBitmap& bitmap = wxNullBitmap,
299 const wxPoint& pos = wxDefaultPosition);
304 // executes the wizard starting from the given page, returns TRUE if it was
305 // successfully finished, FALSE if user cancelled it
306 virtual bool RunWizard(wxWizardPage *firstPage);
308 // get the current page (NULL if RunWizard() isn't running)
309 virtual wxWizardPage *GetCurrentPage() const;
311 // set the min size which should be available for the pages: a
312 // wizard will take into account the size of the bitmap (if any)
313 // itself and will never be less than some predefined fixed size
314 virtual void SetPageSize(const wxSize& size);
316 // get the size available for the page: the wizards are not resizeable, so
317 // this size doesn't change
318 virtual wxSize GetPageSize() const;
320 // set the best size for the wizard, i.e. make it big enough to contain all
321 // of the pages starting from the given one
323 // this function may be called several times and possible with different
324 // pages in which case it will only increase the page size if needed (this
325 // may be useful if not all pages are accessible from the first one by
327 virtual void FitToPage(const wxWizardPage *firstPage);
329 // is the wizard running?
330 bool IsRunning() const { return m_page != NULL; }
332 // show the prev/next page, but call TransferDataFromWindow on the current
333 // page first and return FALSE without changing the page if
334 // TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
335 bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
339 //----------------------------------------------------------------------
342 wxClassInfo::CleanUpClasses();
343 wxClassInfo::InitializeClasses();
346 //----------------------------------------------------------------------
347 // This file gets appended to the shadow class file.
348 //----------------------------------------------------------------------
350 %pragma(python) include="_wizardextras.py";
352 //---------------------------------------------------------------------------