]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
Some distrib updates for wxPythonOSX
[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 enum {
36 wxWIZARD_EX_HELPBUTTON,
37
38 wxEVT_WIZARD_PAGE_CHANGED,
39 wxEVT_WIZARD_PAGE_CHANGING,
40 wxEVT_WIZARD_CANCEL,
41 wxEVT_WIZARD_HELP
42 };
43
44
45 %pragma(python) code = "
46 # wizard events
47 def EVT_WIZARD_PAGE_CHANGED(win, id, func):
48 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
49
50 def EVT_WIZARD_PAGE_CHANGING(win, id, func):
51 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
52
53 def EVT_WIZARD_CANCEL(win, id, func):
54 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
55
56 def EVT_WIZARD_HELP(win, id, func):
57 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
58
59 "
60
61 //----------------------------------------------------------------------
62
63 class wxWizardEvent : public wxNotifyEvent
64 {
65 public:
66 wxWizardEvent(wxEventType type = wxEVT_NULL,
67 int id = -1,
68 bool direction = TRUE,
69 wxWizardPage* page = NULL);
70
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; }
76
77 wxWizardPage* GetPage() const { return m_page; }
78 };
79
80
81 //----------------------------------------------------------------------
82
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).
85 //
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
89 {
90 public:
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();
99
100 bool Create(wxWizard *parent,
101 const wxBitmap& bitmap = wxNullBitmap,
102 const char* resource = NULL);
103
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;
108
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;
114 };
115
116
117
118 %{ // C++ Version of a Python aware class
119 class wxPyWizardPage : public wxWizardPage {
120 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
121 public:
122 wxPyWizardPage() : wxWizardPage() {}
123 wxPyWizardPage(wxWizard *parent,
124 const wxBitmap& bitmap = wxNullBitmap,
125 const wxChar* resource = NULL)
126 : wxWizardPage(parent, bitmap, resource) {}
127
128 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
129 DEC_PYCALLBACK_WIZPG__pure(GetNext);
130 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
131
132 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
133 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
134 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
135 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
136
137 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
138 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
139 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
140
141 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
142 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
143
144 DEC_PYCALLBACK__(InitDialog);
145 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
146 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
147 DEC_PYCALLBACK_BOOL_(Validate);
148
149 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
150 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
151 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
152
153 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
154 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
155
156 PYPRIVATE;
157 };
158
159
160 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
161
162 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
163 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
164 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
165
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);
170
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);
174
175 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
176 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
177
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);
182
183 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
184 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
185 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
186
187 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
188 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
189
190 %}
191
192
193
194 class wxPyWizardPage : public wxWizardPage {
195 public:
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();
204
205 bool Create(wxWizard *parent,
206 const wxBitmap& bitmap = wxNullBitmap,
207 const char* resource = NULL);
208
209 void _setCallbackInfo(PyObject* self, PyObject* _class);
210 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxPyWizardPage)"
211
212 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
213 %pragma(python) addtomethod = "wxPrePyWizardPage:val._setOORInfo(val)"
214
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 );
220
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;
224
225 wxSize base_DoGetVirtualSize() const;
226 wxSize base_DoGetBestSize() const;
227
228 void base_InitDialog();
229 bool base_TransferDataToWindow();
230 bool base_TransferDataFromWindow();
231 bool base_Validate();
232
233 bool base_AcceptsFocus() const;
234 bool base_AcceptsFocusFromKeyboard() const;
235 wxSize base_GetMaxSize() const;
236
237 void base_AddChild(wxWindow* child);
238 void base_RemoveChild(wxWindow* child);
239 };
240
241 //----------------------------------------------------------------------
242
243
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.
246 //
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
251 {
252 public:
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();
260
261 bool Create(wxWizard *parent = NULL,
262 wxWizardPage *prev = NULL,
263 wxWizardPage *next = NULL,
264 const wxBitmap& bitmap = wxNullBitmap,
265 const wxChar* resource = NULL);
266
267 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
268 %pragma(python) addtomethod = "wxPreWizardPageSimple:val._setOORInfo(val)"
269
270 // the pointers may be also set later - but before starting the wizard
271 void SetPrev(wxWizardPage *prev);
272 void SetNext(wxWizardPage *next);
273
274 // a convenience function to make the pages follow each other
275 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
276 };
277
278
279 //----------------------------------------------------------------------
280
281 class wxWizard : public wxDialog
282 {
283 public:
284 // ctor
285 wxWizard(wxWindow *parent,
286 int id = -1,
287 const wxString& title = wxEmptyString,
288 const wxBitmap& bitmap = wxNullBitmap,
289 const wxPoint& pos = wxDefaultPosition);
290 %name(wxPreWizard)wxWizard();
291
292 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
293 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
294
295 bool Create(wxWindow *parent,
296 int id = -1,
297 const wxString& title = wxEmptyString,
298 const wxBitmap& bitmap = wxNullBitmap,
299 const wxPoint& pos = wxDefaultPosition);
300
301 void Init();
302
303
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);
307
308 // get the current page (NULL if RunWizard() isn't running)
309 virtual wxWizardPage *GetCurrentPage() const;
310
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);
315
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;
319
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
322 //
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
326 // default)
327 virtual void FitToPage(const wxWizardPage *firstPage);
328
329 // is the wizard running?
330 bool IsRunning() const { return m_page != NULL; }
331
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);
336 };
337
338
339 //----------------------------------------------------------------------
340
341 %init %{
342 wxClassInfo::CleanUpClasses();
343 wxClassInfo::InitializeClasses();
344 %}
345
346 //----------------------------------------------------------------------
347 // This file gets appended to the shadow class file.
348 //----------------------------------------------------------------------
349
350 %pragma(python) include="_wizardextras.py";
351
352 //---------------------------------------------------------------------------