]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
reSWIGged
[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 %module(docstring=DOCSTRING) wizard
18
19 %{
20 #include "wx/wxPython/wxPython.h"
21 #include "wx/wxPython/pyclasses.h"
22 #include "wx/wxPython/printfw.h"
23
24 #include <wx/wizard.h>
25
26 %}
27
28 //----------------------------------------------------------------------
29
30 %import windows.i
31 %pythoncode { wx = _core }
32 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
33
34 %include _wizard_rename.i
35
36 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
37
38 //----------------------------------------------------------------------
39
40 enum {
41 wxWIZARD_EX_HELPBUTTON,
42 };
43
44 %constant wxEventType wxEVT_WIZARD_PAGE_CHANGED;
45 %constant wxEventType wxEVT_WIZARD_PAGE_CHANGING;
46 %constant wxEventType wxEVT_WIZARD_CANCEL;
47 %constant wxEventType wxEVT_WIZARD_HELP;
48 %constant wxEventType wxEVT_WIZARD_FINISHED;
49
50
51
52 %pythoncode {
53 EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
54 EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
55 EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
56 EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
57 EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
58 }
59
60 //----------------------------------------------------------------------
61
62 class wxWizardEvent : public wxNotifyEvent
63 {
64 public:
65 wxWizardEvent(wxEventType type = wxEVT_NULL,
66 int id = -1,
67 bool direction = True,
68 wxWizardPage* page = NULL);
69
70 // for EVT_WIZARD_PAGE_CHANGING, return True if we're going forward or
71 // False otherwise and for EVT_WIZARD_PAGE_CHANGED return True if we came
72 // from the previous page and False if we returned from the next one
73 // (this function doesn't make sense for CANCEL events)
74 bool GetDirection() const { return m_direction; }
75
76 wxWizardPage* GetPage() const { return m_page; }
77 };
78
79
80 //----------------------------------------------------------------------
81
82 // wxWizardPage is one of the wizards screen: it must know what are the
83 // following and preceding pages (which may be NULL for the first/last page).
84 //
85 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
86 // used as such (i.e. controls may be placed directly on it &c).
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 // %name(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 class wxPyWizardPage : public wxWizardPage {
202 public:
203
204 %pythonAppend wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
205 %pythonAppend wxPyWizardPage() ""
206
207 // ctor accepts an optional bitmap which will be used for this page instead
208 // of the default one for this wizard (should be of the same size). Notice
209 // that no other parameters are needed because the wizard will resize and
210 // reposition the page anyhow
211 %extend {
212 wxPyWizardPage(wxWizard *parent,
213 const wxBitmap* bitmap = &wxNullBitmap,
214 const wxString* resource = &wxPyEmptyString) {
215 wxChar* res = NULL;
216 if (resource->Length())
217 res = (wxChar*)resource->c_str();
218 return new wxPyWizardPage(parent, *bitmap, res);
219 }
220 }
221
222 %name(PrePyWizardPage)wxPyWizardPage();
223
224 %extend {
225 bool Create(wxWizard *parent,
226 const wxBitmap& bitmap = wxNullBitmap,
227 const wxString& resource = wxPyEmptyString) {
228 wxChar* res = NULL;
229 if (resource.Length())
230 res = (wxChar*)resource.c_str();
231 return self->Create(parent, bitmap, res);
232 }
233 }
234
235 void _setCallbackInfo(PyObject* self, PyObject* _class);
236
237 void base_DoMoveWindow(int x, int y, int width, int height);
238 void base_DoSetSize(int x, int y, int width, int height,
239 int sizeFlags = wxSIZE_AUTO);
240 void base_DoSetClientSize(int width, int height);
241 void base_DoSetVirtualSize( int x, int y );
242
243 DocDeclA(
244 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
245 "base_DoGetSize() -> (width, height)");
246 DocDeclA(
247 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
248 "base_DoGetClientSize() -> (width, height)");
249 DocDeclA(
250 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
251 "base_DoGetPosition() -> (x,y)");
252
253 wxSize base_DoGetVirtualSize() const;
254 wxSize base_DoGetBestSize() const;
255
256 void base_InitDialog();
257 bool base_TransferDataToWindow();
258 bool base_TransferDataFromWindow();
259 bool base_Validate();
260
261 bool base_AcceptsFocus() const;
262 bool base_AcceptsFocusFromKeyboard() const;
263 wxSize base_GetMaxSize() const;
264
265 void base_AddChild(wxWindow* child);
266 void base_RemoveChild(wxWindow* child);
267 };
268
269 //----------------------------------------------------------------------
270
271
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.
274 //
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
279 {
280 public:
281
282 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
283 %pythonAppend wxWizardPageSimple() ""
284
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(PreWizardPageSimple)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 // the pointers may be also set later - but before starting the wizard
300 void SetPrev(wxWizardPage *prev);
301 void SetNext(wxWizardPage *next);
302
303 // a convenience function to make the pages follow each other
304 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
305 };
306
307
308 //----------------------------------------------------------------------
309
310 class wxWizard : public wxDialog
311 {
312 public:
313 %pythonAppend wxWizard "self._setOORInfo(self)"
314 %pythonAppend wxWizard() ""
315
316 // ctor
317 wxWizard(wxWindow *parent,
318 int id = -1,
319 const wxString& title = wxPyEmptyString,
320 const wxBitmap& bitmap = wxNullBitmap,
321 const wxPoint& pos = wxDefaultPosition,
322 long style = wxDEFAULT_DIALOG_STYLE);
323 %name(PreWizard)wxWizard();
324
325 bool Create(wxWindow *parent,
326 int id = -1,
327 const wxString& title = wxPyEmptyString,
328 const wxBitmap& bitmap = wxNullBitmap,
329 const wxPoint& pos = wxDefaultPosition);
330
331 void Init();
332
333
334 // executes the wizard starting from the given page, returns True if it was
335 // successfully finished, False if user cancelled it
336 virtual bool RunWizard(wxWizardPage *firstPage);
337
338 // get the current page (NULL if RunWizard() isn't running)
339 virtual wxWizardPage *GetCurrentPage() const;
340
341 // set the min size which should be available for the pages: a
342 // wizard will take into account the size of the bitmap (if any)
343 // itself and will never be less than some predefined fixed size
344 virtual void SetPageSize(const wxSize& size);
345
346 // get the size available for the page: the wizards are not resizeable, so
347 // this size doesn't change
348 virtual wxSize GetPageSize() const;
349
350 // set the best size for the wizard, i.e. make it big enough to contain all
351 // of the pages starting from the given one
352 //
353 // this function may be called several times and possible with different
354 // pages in which case it will only increase the page size if needed (this
355 // may be useful if not all pages are accessible from the first one by
356 // default)
357 virtual void FitToPage(const wxWizardPage *firstPage);
358
359 // Adding pages to page area sizer enlarges wizard
360 virtual wxSizer *GetPageAreaSizer() const;
361
362 // Set border around page area. Default is 0 if you add at least one
363 // page to GetPageAreaSizer and 5 if you don't.
364 virtual void SetBorder(int border);
365
366 // is the wizard running?
367 bool IsRunning() const { return m_page != NULL; }
368
369 // show the prev/next page, but call TransferDataFromWindow on the current
370 // page first and return False without changing the page if
371 // TransferDataFromWindow() returns False - otherwise, returns True
372 bool ShowPage(wxWizardPage *page, bool goingForward = True);
373
374 bool HasNextPage(wxWizardPage* page);
375 bool HasPrevPage(wxWizardPage* page);
376 };
377
378
379 //----------------------------------------------------------------------
380
381 %init %{
382 %}
383
384 //---------------------------------------------------------------------------