]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
style required on wxGTK
[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;
74
75 wxWizardPage* GetPage() const;
76
77 %property(Direction, GetDirection, doc="See `GetDirection`");
78 %property(Page, GetPage, doc="See `GetPage`");
79 };
80
81
82 //----------------------------------------------------------------------
83
84 // wxWizardPage is one of the wizards screen: it must know what are the
85 // following and preceding pages (which may be NULL for the first/last page).
86 //
87 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
88 // used as such (i.e. controls may be placed directly on it &c).
89 MustHaveApp(wxWizardPage);
90 class wxWizardPage : public wxPanel
91 {
92 public:
93 // // ctor accepts an optional bitmap which will be used for this page instead
94 // // of the default one for this wizard (should be of the same size). Notice
95 // // that no other parameters are needed because the wizard will resize and
96 // // reposition the page anyhow
97 // wxWizardPage(wxWizard *parent,
98 // const wxBitmap& bitmap = wxNullBitmap);
99 // %RenameCtor(PreWizardPage, wxWizardPage());
100
101 bool Create(wxWizard *parent,
102 const wxBitmap& bitmap = wxNullBitmap);
103
104
105 // these functions are used by the wizard to show another page when the
106 // user chooses "Back" or "Next" button
107 virtual wxWizardPage *GetPrev() const;
108 virtual wxWizardPage *GetNext() const;
109
110 // default GetBitmap() will just return m_bitmap which is ok in 99% of
111 // cases - override this method if you want to create the bitmap to be used
112 // dynamically or to do something even more fancy. It's ok to return
113 // wxNullBitmap from here - the default one will be used then.
114 virtual wxBitmap GetBitmap() const;
115
116 %property(Bitmap, GetBitmap, doc="See `GetBitmap`");
117 %property(Next, GetNext, doc="See `GetNext`");
118 %property(Prev, GetPrev, doc="See `GetPrev`");
119 };
120
121
122
123 %{ // C++ Version of a Python aware class
124 class wxPyWizardPage : public wxWizardPage {
125 DECLARE_ABSTRACT_CLASS(wxPyWizardPage)
126 public:
127 wxPyWizardPage() : wxWizardPage() {}
128 wxPyWizardPage(wxWizard *parent,
129 const wxBitmap& bitmap = wxNullBitmap)
130 : wxWizardPage(parent, bitmap) {}
131
132 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
133 DEC_PYCALLBACK_WIZPG__pure(GetNext);
134 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
135
136 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
137 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
138 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
139 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
140
141 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
142 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
143 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
144
145 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
146 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
147
148 DEC_PYCALLBACK__(InitDialog);
149 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
150 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
151 DEC_PYCALLBACK_BOOL_(Validate);
152
153 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
154 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
155 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
156
157 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
158 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
159
160 PYPRIVATE;
161 };
162
163
164 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
165
166 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
167 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
168 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
169
170 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
171 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
172 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
173 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
174
175 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
176 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
177 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
178
179 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
180 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
181
182 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
183 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
184 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
185 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
186
187 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
188 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
189 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
190
191 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
192 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
193
194 %}
195
196
197
198 MustHaveApp(wxPyWizardPage);
199
200 class wxPyWizardPage : public wxWizardPage {
201 public:
202
203 %pythonAppend wxPyWizardPage "self._setOORInfo(self);" setCallbackInfo(PyWizardPage)
204 %pythonAppend wxPyWizardPage() ""
205 %typemap(out) wxPyWizardPage*; // turn off this typemap
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 wxPyWizardPage(wxWizard *parent,
212 const wxBitmap& bitmap = wxNullBitmap);
213
214 %RenameCtor(PrePyWizardPage, wxPyWizardPage());
215
216 // Turn it back on again
217 %typemap(out) wxPyWizardPage* { $result = wxPyMake_wxObject($1, $owner); }
218
219 bool Create(wxWizard *parent,
220 const wxBitmap& bitmap = wxNullBitmap);
221
222 void _setCallbackInfo(PyObject* self, PyObject* _class);
223
224 void DoMoveWindow(int x, int y, int width, int height);
225 void DoSetSize(int x, int y, int width, int height,
226 int sizeFlags = wxSIZE_AUTO);
227 void DoSetClientSize(int width, int height);
228 void DoSetVirtualSize( int x, int y );
229
230 DocDeclA(
231 void, DoGetSize( int *OUTPUT, int *OUTPUT ) const,
232 "DoGetSize() -> (width, height)");
233 DocDeclA(
234 void, DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
235 "DoGetClientSize() -> (width, height)");
236 DocDeclA(
237 void, DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
238 "DoGetPosition() -> (x,y)");
239
240 wxSize DoGetVirtualSize() const;
241 wxSize DoGetBestSize() const;
242
243 void InitDialog();
244 bool TransferDataToWindow();
245 bool TransferDataFromWindow();
246 bool Validate();
247
248 bool AcceptsFocus() const;
249 bool AcceptsFocusFromKeyboard() const;
250 wxSize GetMaxSize() const;
251
252 void AddChild(wxWindow* child);
253 void RemoveChild(wxWindow* child);
254
255 bool ShouldInheritColours() const;
256 wxVisualAttributes GetDefaultAttributes();
257
258 void OnInternalIdle();
259
260 %MAKE_BASE_FUNC(PyWizardPage, DoMoveWindow);
261 %MAKE_BASE_FUNC(PyWizardPage, DoSetSize);
262 %MAKE_BASE_FUNC(PyWizardPage, DoSetClientSize);
263 %MAKE_BASE_FUNC(PyWizardPage, DoSetVirtualSize);
264 %MAKE_BASE_FUNC(PyWizardPage, DoGetSize);
265 %MAKE_BASE_FUNC(PyWizardPage, DoGetClientSize);
266 %MAKE_BASE_FUNC(PyWizardPage, DoGetPosition);
267 %MAKE_BASE_FUNC(PyWizardPage, DoGetVirtualSize);
268 %MAKE_BASE_FUNC(PyWizardPage, DoGetBestSize);
269 %MAKE_BASE_FUNC(PyWizardPage, InitDialog);
270 %MAKE_BASE_FUNC(PyWizardPage, TransferDataToWindow);
271 %MAKE_BASE_FUNC(PyWizardPage, TransferDataFromWindow);
272 %MAKE_BASE_FUNC(PyWizardPage, Validate);
273 %MAKE_BASE_FUNC(PyWizardPage, AcceptsFocus);
274 %MAKE_BASE_FUNC(PyWizardPage, AcceptsFocusFromKeyboard);
275 %MAKE_BASE_FUNC(PyWizardPage, GetMaxSize);
276 %MAKE_BASE_FUNC(PyWizardPage, AddChild);
277 %MAKE_BASE_FUNC(PyWizardPage, RemoveChild);
278 %MAKE_BASE_FUNC(PyWizardPage, ShouldInheritColours);
279 %MAKE_BASE_FUNC(PyWizardPage, GetDefaultAttributes);
280 %MAKE_BASE_FUNC(PyWizardPage, OnInternalIdle);
281
282 };
283
284 //----------------------------------------------------------------------
285
286
287 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
288 // to create a simple wizard where the order of pages never changes.
289 //
290 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
291 // depending on the user's choices) as the wizard sample shows - in order to do
292 // this, you must derive from wxWizardPage directly.
293 MustHaveApp(wxWizardPageSimple);
294 class wxWizardPageSimple : public wxWizardPage
295 {
296 public:
297
298 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
299 %pythonAppend wxWizardPageSimple() ""
300
301 // ctor takes the previous and next pages
302 wxWizardPageSimple(wxWizard *parent,
303 wxWizardPage *prev = NULL,
304 wxWizardPage *next = NULL,
305 const wxBitmap& bitmap = wxNullBitmap);
306 %RenameCtor(PreWizardPageSimple, wxWizardPageSimple());
307
308 bool Create(wxWizard *parent = NULL,
309 wxWizardPage *prev = NULL,
310 wxWizardPage *next = NULL,
311 const wxBitmap& bitmap = wxNullBitmap);
312
313 // the pointers may be also set later - but before starting the wizard
314 void SetPrev(wxWizardPage *prev);
315 void SetNext(wxWizardPage *next);
316
317 // a convenience function to make the pages follow each other
318 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
319 };
320
321
322 //----------------------------------------------------------------------
323
324 MustHaveApp(wxWizard);
325
326 class wxWizard : public wxDialog
327 {
328 public:
329 %pythonAppend wxWizard "self._setOORInfo(self)"
330 %pythonAppend wxWizard() ""
331
332 // ctor
333 wxWizard(wxWindow *parent,
334 int id = -1,
335 const wxString& title = wxPyEmptyString,
336 const wxBitmap& bitmap = wxNullBitmap,
337 const wxPoint& pos = wxDefaultPosition,
338 long style = wxDEFAULT_DIALOG_STYLE);
339 %RenameCtor(PreWizard, wxWizard());
340
341 bool Create(wxWindow *parent,
342 int id = -1,
343 const wxString& title = wxPyEmptyString,
344 const wxBitmap& bitmap = wxNullBitmap,
345 const wxPoint& pos = wxDefaultPosition);
346
347 void Init();
348
349
350 // executes the wizard starting from the given page, returns True if it was
351 // successfully finished, False if user cancelled it
352 virtual bool RunWizard(wxWizardPage *firstPage);
353
354 // get the current page (NULL if RunWizard() isn't running)
355 virtual wxWizardPage *GetCurrentPage() const;
356
357 // set the min size which should be available for the pages: a
358 // wizard will take into account the size of the bitmap (if any)
359 // itself and will never be less than some predefined fixed size
360 virtual void SetPageSize(const wxSize& size);
361
362 // get the size available for the page: the wizards are not resizeable, so
363 // this size doesn't change
364 virtual wxSize GetPageSize() const;
365
366 // set the best size for the wizard, i.e. make it big enough to contain all
367 // of the pages starting from the given one
368 //
369 // this function may be called several times and possible with different
370 // pages in which case it will only increase the page size if needed (this
371 // may be useful if not all pages are accessible from the first one by
372 // default)
373 virtual void FitToPage(const wxWizardPage *firstPage);
374
375 // Adding pages to page area sizer enlarges wizard
376 virtual wxSizer *GetPageAreaSizer() const;
377
378 // Set border around page area. Default is 0 if you add at least one
379 // page to GetPageAreaSizer and 5 if you don't.
380 virtual void SetBorder(int border);
381
382 // is the wizard running?
383 bool IsRunning() const;
384
385 // show the prev/next page, but call TransferDataFromWindow on the current
386 // page first and return False without changing the page if
387 // TransferDataFromWindow() returns False - otherwise, returns True
388 bool ShowPage(wxWizardPage *page, bool goingForward = true);
389
390 bool HasNextPage(wxWizardPage* page);
391 bool HasPrevPage(wxWizardPage* page);
392
393 %property(CurrentPage, GetCurrentPage, doc="See `GetCurrentPage`");
394 %property(PageAreaSizer, GetPageAreaSizer, doc="See `GetPageAreaSizer`");
395 %property(PageSize, GetPageSize, SetPageSize, doc="See `GetPageSize` and `SetPageSize`");
396 };
397
398
399 //----------------------------------------------------------------------
400
401 %init %{
402 %}
403
404 //---------------------------------------------------------------------------