]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
generated rename directives are no longer needed
[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 %define DOCSTRING
14 "`Wizard` is a dialog class that guides the user through a sequence of steps,
15 or pages."
16 %enddef
17
18 %module(package="wx", docstring=DOCSTRING) wizard
19
20 %{
21 #include "wx/wxPython/wxPython.h"
22 #include "wx/wxPython/pyclasses.h"
23 #include "wx/wxPython/printfw.h"
24
25 #include <wx/wizard.h>
26
27 %}
28
29 //----------------------------------------------------------------------
30
31 %import windows.i
32 %pythoncode { wx = _core }
33 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
34
35 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
36
37 //----------------------------------------------------------------------
38
39 enum {
40 wxWIZARD_EX_HELPBUTTON,
41 };
42
43 %constant wxEventType wxEVT_WIZARD_PAGE_CHANGED;
44 %constant wxEventType wxEVT_WIZARD_PAGE_CHANGING;
45 %constant wxEventType wxEVT_WIZARD_CANCEL;
46 %constant wxEventType wxEVT_WIZARD_HELP;
47 %constant wxEventType wxEVT_WIZARD_FINISHED;
48
49
50
51 %pythoncode {
52 EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
53 EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
54 EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
55 EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
56 EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
57 }
58
59 //----------------------------------------------------------------------
60
61 class wxWizardEvent : public wxNotifyEvent
62 {
63 public:
64 wxWizardEvent(wxEventType type = wxEVT_NULL,
65 int id = -1,
66 bool direction = true,
67 wxWizardPage* page = NULL);
68
69 // for EVT_WIZARD_PAGE_CHANGING, return True if we're going forward or
70 // False otherwise and for EVT_WIZARD_PAGE_CHANGED return True if we came
71 // from the previous page and False if we returned from the next one
72 // (this function doesn't make sense for CANCEL events)
73 bool GetDirection() const { return m_direction; }
74
75 wxWizardPage* GetPage() const { return m_page; }
76 };
77
78
79 //----------------------------------------------------------------------
80
81 // wxWizardPage is one of the wizards screen: it must know what are the
82 // following and preceding pages (which may be NULL for the first/last page).
83 //
84 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
85 // used as such (i.e. controls may be placed directly on it &c).
86 MustHaveApp(wxWizardPage);
87 class wxWizardPage : public wxPanel
88 {
89 public:
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 // %RenameCtor(PreWizardPage, wxWizardPage());
98
99 %extend {
100 bool Create(wxWizard *parent,
101 const wxBitmap& bitmap = wxNullBitmap,
102 const wxString& resource = wxPyEmptyString) {
103 wxChar* res = NULL;
104 if (resource.length())
105 res = (wxChar*)resource.c_str();
106 return self->Create(parent, bitmap, res);
107 }
108 }
109
110
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;
115
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;
121 };
122
123
124
125 %{ // C++ Version of a Python aware class
126 class wxPyWizardPage : public wxWizardPage {
127 DECLARE_ABSTRACT_CLASS(wxPyWizardPage)
128 public:
129 wxPyWizardPage() : wxWizardPage() {}
130 wxPyWizardPage(wxWizard *parent,
131 const wxBitmap& bitmap = wxNullBitmap,
132 const wxChar* resource = NULL)
133 : wxWizardPage(parent, bitmap, resource) {}
134
135 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
136 DEC_PYCALLBACK_WIZPG__pure(GetNext);
137 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
138
139 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
140 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
141 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
142 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
143
144 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
145 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
146 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
147
148 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
149 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
150
151 DEC_PYCALLBACK__(InitDialog);
152 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
153 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
154 DEC_PYCALLBACK_BOOL_(Validate);
155
156 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
157 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
158 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
159
160 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
161 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
162
163 PYPRIVATE;
164 };
165
166
167 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
168
169 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
170 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
171 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
172
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);
177
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);
181
182 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
183 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
184
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);
189
190 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
191 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
192 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
193
194 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
195 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
196
197 %}
198
199
200
201 MustHaveApp(wxPyWizardPage);
202
203 class wxPyWizardPage : public wxWizardPage {
204 public:
205
206 %pythonAppend wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
207 %pythonAppend wxPyWizardPage() ""
208 %typemap(out) wxPyWizardPage*; // turn off this typemap
209
210 // ctor accepts an optional bitmap which will be used for this page instead
211 // of the default one for this wizard (should be of the same size). Notice
212 // that no other parameters are needed because the wizard will resize and
213 // reposition the page anyhow
214 %extend {
215 wxPyWizardPage(wxWizard *parent,
216 const wxBitmap* bitmap = &wxNullBitmap,
217 const wxString* resource = &wxPyEmptyString) {
218 wxChar* res = NULL;
219 if (resource->length())
220 res = (wxChar*)resource->c_str();
221 return new wxPyWizardPage(parent, *bitmap, res);
222 }
223 }
224
225 %RenameCtor(PrePyWizardPage, wxPyWizardPage());
226
227 // Turn it back on again
228 %typemap(out) wxPyWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
229
230 %extend {
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
243 void DoMoveWindow(int x, int y, int width, int height);
244 void DoSetSize(int x, int y, int width, int height,
245 int sizeFlags = wxSIZE_AUTO);
246 void DoSetClientSize(int width, int height);
247 void DoSetVirtualSize( int x, int y );
248
249 DocDeclA(
250 void, DoGetSize( int *OUTPUT, int *OUTPUT ) const,
251 "DoGetSize() -> (width, height)");
252 DocDeclA(
253 void, DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
254 "DoGetClientSize() -> (width, height)");
255 DocDeclA(
256 void, DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
257 "DoGetPosition() -> (x,y)");
258
259 wxSize DoGetVirtualSize() const;
260 wxSize DoGetBestSize() const;
261
262 void InitDialog();
263 bool TransferDataToWindow();
264 bool TransferDataFromWindow();
265 bool Validate();
266
267 bool AcceptsFocus() const;
268 bool AcceptsFocusFromKeyboard() const;
269 wxSize GetMaxSize() const;
270
271 void AddChild(wxWindow* child);
272 void RemoveChild(wxWindow* child);
273
274 bool ShouldInheritColours() const;
275 wxVisualAttributes GetDefaultAttributes();
276
277 void OnInternalIdle();
278
279 %MAKE_BASE_FUNC(PyWizardPage, DoMoveWindow);
280 %MAKE_BASE_FUNC(PyWizardPage, DoSetSize);
281 %MAKE_BASE_FUNC(PyWizardPage, DoSetClientSize);
282 %MAKE_BASE_FUNC(PyWizardPage, DoSetVirtualSize);
283 %MAKE_BASE_FUNC(PyWizardPage, DoGetSize);
284 %MAKE_BASE_FUNC(PyWizardPage, DoGetClientSize);
285 %MAKE_BASE_FUNC(PyWizardPage, DoGetPosition);
286 %MAKE_BASE_FUNC(PyWizardPage, DoGetVirtualSize);
287 %MAKE_BASE_FUNC(PyWizardPage, DoGetBestSize);
288 %MAKE_BASE_FUNC(PyWizardPage, InitDialog);
289 %MAKE_BASE_FUNC(PyWizardPage, TransferDataToWindow);
290 %MAKE_BASE_FUNC(PyWizardPage, TransferDataFromWindow);
291 %MAKE_BASE_FUNC(PyWizardPage, Validate);
292 %MAKE_BASE_FUNC(PyWizardPage, AcceptsFocus);
293 %MAKE_BASE_FUNC(PyWizardPage, AcceptsFocusFromKeyboard);
294 %MAKE_BASE_FUNC(PyWizardPage, GetMaxSize);
295 %MAKE_BASE_FUNC(PyWizardPage, AddChild);
296 %MAKE_BASE_FUNC(PyWizardPage, RemoveChild);
297 %MAKE_BASE_FUNC(PyWizardPage, ShouldInheritColours);
298 %MAKE_BASE_FUNC(PyWizardPage, GetDefaultAttributes);
299 %MAKE_BASE_FUNC(PyWizardPage, OnInternalIdle);
300
301 };
302
303 //----------------------------------------------------------------------
304
305
306 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
307 // to create a simple wizard where the order of pages never changes.
308 //
309 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
310 // depending on the user's choices) as the wizard sample shows - in order to do
311 // this, you must derive from wxWizardPage directly.
312 MustHaveApp(wxWizardPageSimple);
313 class wxWizardPageSimple : public wxWizardPage
314 {
315 public:
316
317 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
318 %pythonAppend wxWizardPageSimple() ""
319
320 // ctor takes the previous and next pages
321 wxWizardPageSimple(wxWizard *parent,
322 wxWizardPage *prev = NULL,
323 wxWizardPage *next = NULL,
324 const wxBitmap& bitmap = wxNullBitmap,
325 const wxChar* resource = NULL);
326 %RenameCtor(PreWizardPageSimple, wxWizardPageSimple());
327
328 bool Create(wxWizard *parent = NULL,
329 wxWizardPage *prev = NULL,
330 wxWizardPage *next = NULL,
331 const wxBitmap& bitmap = wxNullBitmap,
332 const wxChar* resource = NULL);
333
334 // the pointers may be also set later - but before starting the wizard
335 void SetPrev(wxWizardPage *prev);
336 void SetNext(wxWizardPage *next);
337
338 // a convenience function to make the pages follow each other
339 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
340 };
341
342
343 //----------------------------------------------------------------------
344
345 MustHaveApp(wxWizard);
346
347 class wxWizard : public wxDialog
348 {
349 public:
350 %pythonAppend wxWizard "self._setOORInfo(self)"
351 %pythonAppend wxWizard() ""
352
353 // ctor
354 wxWizard(wxWindow *parent,
355 int id = -1,
356 const wxString& title = wxPyEmptyString,
357 const wxBitmap& bitmap = wxNullBitmap,
358 const wxPoint& pos = wxDefaultPosition,
359 long style = wxDEFAULT_DIALOG_STYLE);
360 %RenameCtor(PreWizard, wxWizard());
361
362 bool Create(wxWindow *parent,
363 int id = -1,
364 const wxString& title = wxPyEmptyString,
365 const wxBitmap& bitmap = wxNullBitmap,
366 const wxPoint& pos = wxDefaultPosition);
367
368 void Init();
369
370
371 // executes the wizard starting from the given page, returns True if it was
372 // successfully finished, False if user cancelled it
373 virtual bool RunWizard(wxWizardPage *firstPage);
374
375 // get the current page (NULL if RunWizard() isn't running)
376 virtual wxWizardPage *GetCurrentPage() const;
377
378 // set the min size which should be available for the pages: a
379 // wizard will take into account the size of the bitmap (if any)
380 // itself and will never be less than some predefined fixed size
381 virtual void SetPageSize(const wxSize& size);
382
383 // get the size available for the page: the wizards are not resizeable, so
384 // this size doesn't change
385 virtual wxSize GetPageSize() const;
386
387 // set the best size for the wizard, i.e. make it big enough to contain all
388 // of the pages starting from the given one
389 //
390 // this function may be called several times and possible with different
391 // pages in which case it will only increase the page size if needed (this
392 // may be useful if not all pages are accessible from the first one by
393 // default)
394 virtual void FitToPage(const wxWizardPage *firstPage);
395
396 // Adding pages to page area sizer enlarges wizard
397 virtual wxSizer *GetPageAreaSizer() const;
398
399 // Set border around page area. Default is 0 if you add at least one
400 // page to GetPageAreaSizer and 5 if you don't.
401 virtual void SetBorder(int border);
402
403 // is the wizard running?
404 bool IsRunning() const;
405
406 // show the prev/next page, but call TransferDataFromWindow on the current
407 // page first and return False without changing the page if
408 // TransferDataFromWindow() returns False - otherwise, returns True
409 bool ShowPage(wxWizardPage *page, bool goingForward = true);
410
411 bool HasNextPage(wxWizardPage* page);
412 bool HasPrevPage(wxWizardPage* page);
413 };
414
415
416 //----------------------------------------------------------------------
417
418 %init %{
419 %}
420
421 //---------------------------------------------------------------------------