]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
Various changes needed to get up to date with current CVS
[wxWidgets.git] / wxPython / src / wizard.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wizard.i
3 // Purpose: Classes for wxWizard and etc.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 16-Aug-2002
8 // RCS-ID: $Id$
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 %module wizard
14
15 %{
16 #include "wxPython.h"
17 #include <wx/wizard.h>
18 %}
19
20 //----------------------------------------------------------------------
21
22 %include typemaps.i
23 %include my_typemaps.i
24
25 // Import some definitions of other classes, etc.
26 %import _defs.i
27 %import windows.i
28 %import frames.i
29 %import misc.i
30 %import controls.i
31
32
33 //----------------------------------------------------------------------
34 %{
35 // Put some wx default wxChar* values into wxStrings.
36 static const wxString wxPyEmptyString(wxT(""));
37 %}
38 //----------------------------------------------------------------------
39
40 enum {
41 wxWIZARD_EX_HELPBUTTON,
42
43 wxEVT_WIZARD_PAGE_CHANGED,
44 wxEVT_WIZARD_PAGE_CHANGING,
45 wxEVT_WIZARD_CANCEL,
46 wxEVT_WIZARD_HELP,
47 wxEVT_WIZARD_FINISHED
48 };
49
50
51 %pragma(python) code = "
52 # wizard events
53 def EVT_WIZARD_PAGE_CHANGED(win, id, func):
54 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
55
56 def EVT_WIZARD_PAGE_CHANGING(win, id, func):
57 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
58
59 def EVT_WIZARD_CANCEL(win, id, func):
60 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
61
62 def EVT_WIZARD_HELP(win, id, func):
63 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
64
65 def EVT_WIZARD_FINISHED(win, id, func):
66 win.Connect(id, -1, wxEVT_WIZARD_FINISHED, func)
67
68 "
69
70 //----------------------------------------------------------------------
71
72 class wxWizardEvent : public wxNotifyEvent
73 {
74 public:
75 wxWizardEvent(wxEventType type = wxEVT_NULL,
76 int id = -1,
77 bool direction = TRUE,
78 wxWizardPage* page = NULL);
79
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; }
85
86 wxWizardPage* GetPage() const { return m_page; }
87 };
88
89
90 //----------------------------------------------------------------------
91
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).
94 //
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
98 {
99 public:
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();
108
109 %addmethods {
110 bool Create(wxWizard *parent,
111 const wxBitmap& bitmap = wxNullBitmap,
112 const wxString& resource = wxPyEmptyString) {
113 wxChar* res = NULL;
114 if (resource.Length())
115 res = (wxChar*)resource.c_str();
116 return self->Create(parent, bitmap, res);
117 }
118 }
119
120
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;
125
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;
131 };
132
133
134
135 %{ // C++ Version of a Python aware class
136 class wxPyWizardPage : public wxWizardPage {
137 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
138 public:
139 wxPyWizardPage() : wxWizardPage() {}
140 wxPyWizardPage(wxWizard *parent,
141 const wxBitmap& bitmap = wxNullBitmap,
142 const wxChar* resource = NULL)
143 : wxWizardPage(parent, bitmap, resource) {}
144
145 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
146 DEC_PYCALLBACK_WIZPG__pure(GetNext);
147 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
148
149 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
150 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
151 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
152 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
153
154 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
155 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
156 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
157
158 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
159 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
160
161 DEC_PYCALLBACK__(InitDialog);
162 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
163 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
164 DEC_PYCALLBACK_BOOL_(Validate);
165
166 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
167 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
168 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
169
170 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
171 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
172
173 PYPRIVATE;
174 };
175
176
177 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
178
179 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
180 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
181 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
182
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);
187
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);
191
192 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
193 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
194
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);
199
200 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
201 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
202 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
203
204 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
205 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
206
207 %}
208
209
210
211 class wxPyWizardPage : public wxWizardPage {
212 public:
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
217 %addmethods {
218 wxPyWizardPage(wxWizard *parent,
219 const wxBitmap* bitmap = &wxNullBitmap,
220 const wxString* resource = &wxPyEmptyString) {
221 wxChar* res = NULL;
222 if (resource->Length())
223 res = (wxChar*)resource->c_str();
224 return new wxPyWizardPage(parent, *bitmap, res);
225 }
226 }
227
228 %name(wxPrePyWizardPage)wxPyWizardPage();
229
230 %addmethods {
231 bool Create(wxWizard *parent,
232 const wxBitmap& bitmap = wxNullBitmap,
233 const wxString& resource = wxPyEmptyString) {
234 wxChar* res = NULL;
235 if (resource.Length())
236 res = (wxChar*)resource.c_str();
237 return self->Create(parent, bitmap, res);
238 }
239 }
240
241 void _setCallbackInfo(PyObject* self, PyObject* _class);
242 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyWizardPage)"
243
244 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
245 %pragma(python) addtomethod = "wxPrePyWizardPage:val._setOORInfo(val)"
246
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 );
252
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;
256
257 wxSize base_DoGetVirtualSize() const;
258 wxSize base_DoGetBestSize() const;
259
260 void base_InitDialog();
261 bool base_TransferDataToWindow();
262 bool base_TransferDataFromWindow();
263 bool base_Validate();
264
265 bool base_AcceptsFocus() const;
266 bool base_AcceptsFocusFromKeyboard() const;
267 wxSize base_GetMaxSize() const;
268
269 void base_AddChild(wxWindow* child);
270 void base_RemoveChild(wxWindow* child);
271 };
272
273 //----------------------------------------------------------------------
274
275
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.
278 //
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
283 {
284 public:
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();
292
293 bool Create(wxWizard *parent = NULL,
294 wxWizardPage *prev = NULL,
295 wxWizardPage *next = NULL,
296 const wxBitmap& bitmap = wxNullBitmap,
297 const wxChar* resource = NULL);
298
299 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
300 %pragma(python) addtomethod = "wxPreWizardPageSimple:val._setOORInfo(val)"
301
302 // the pointers may be also set later - but before starting the wizard
303 void SetPrev(wxWizardPage *prev);
304 void SetNext(wxWizardPage *next);
305
306 // a convenience function to make the pages follow each other
307 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
308 };
309
310
311 //----------------------------------------------------------------------
312
313 class wxWizard : public wxDialog
314 {
315 public:
316 // ctor
317 wxWizard(wxWindow *parent,
318 int id = -1,
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();
324
325 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
326 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
327
328 bool Create(wxWindow *parent,
329 int id = -1,
330 const wxString& title = wxEmptyString,
331 const wxBitmap& bitmap = wxNullBitmap,
332 const wxPoint& pos = wxDefaultPosition);
333
334 void Init();
335
336
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);
340
341 // get the current page (NULL if RunWizard() isn't running)
342 virtual wxWizardPage *GetCurrentPage() const;
343
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);
348
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;
352
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
355 //
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
359 // default)
360 virtual void FitToPage(const wxWizardPage *firstPage);
361
362 // Adding pages to page area sizer enlarges wizard
363 virtual wxSizer *GetPageAreaSizer() const;
364
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);
368
369 // is the wizard running?
370 bool IsRunning() const { return m_page != NULL; }
371
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);
376
377 bool HasNextPage(wxWizardPage* page);
378 bool HasPrevPage(wxWizardPage* page);
379 };
380
381
382 //----------------------------------------------------------------------
383
384 %init %{
385 %}
386
387 //----------------------------------------------------------------------
388 // This file gets appended to the shadow class file.
389 //----------------------------------------------------------------------
390
391 %pragma(python) include="_wizardextras.py";
392
393 //---------------------------------------------------------------------------