]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/wizard.i
Added bakefile for the OGL contrib
[wxWidgets.git] / wxPython / src / wizard.i
CommitLineData
af83019e
RD
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
dd4a4b90
RD
33//----------------------------------------------------------------------
34%{
35 // Put some wx default wxChar* values into wxStrings.
36 static const wxString wxPyEmptyString(wxT(""));
37%}
af83019e
RD
38//----------------------------------------------------------------------
39
40enum {
41 wxWIZARD_EX_HELPBUTTON,
42
43 wxEVT_WIZARD_PAGE_CHANGED,
44 wxEVT_WIZARD_PAGE_CHANGING,
45 wxEVT_WIZARD_CANCEL,
1e4a197e
RD
46 wxEVT_WIZARD_HELP,
47 wxEVT_WIZARD_FINISHED
af83019e
RD
48};
49
50
51%pragma(python) code = "
52# wizard events
53def EVT_WIZARD_PAGE_CHANGED(win, id, func):
54 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGED, func)
55
56def EVT_WIZARD_PAGE_CHANGING(win, id, func):
57 win.Connect(id, -1, wxEVT_WIZARD_PAGE_CHANGING, func)
58
59def EVT_WIZARD_CANCEL(win, id, func):
60 win.Connect(id, -1, wxEVT_WIZARD_CANCEL, func)
61
62def EVT_WIZARD_HELP(win, id, func):
63 win.Connect(id, -1, wxEVT_WIZARD_HELP, func)
64
1e4a197e
RD
65def EVT_WIZARD_FINISHED(win, id, func):
66 win.Connect(id, -1, wxEVT_WIZARD_FINISHED, func)
67
af83019e
RD
68"
69
70//----------------------------------------------------------------------
71
72class wxWizardEvent : public wxNotifyEvent
73{
74public:
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).
97class wxWizardPage : public wxPanel
98{
99public:
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
dd4a4b90
RD
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
af83019e 120
af83019e
RD
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
136class wxPyWizardPage : public wxWizardPage {
137 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
138public:
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
177IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
178
179IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
180IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
181IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
182
183IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
184IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
185IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
186IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
187
188IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
189IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
190IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
191
192IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
193IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
194
195IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
196IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
197IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
198IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
199
200IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
201IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
202IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
203
204IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
205IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
206
207%}
208
209
210
211class wxPyWizardPage : public wxWizardPage {
212public:
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
dd4a4b90
RD
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
af83019e
RD
228 %name(wxPrePyWizardPage)wxPyWizardPage();
229
dd4a4b90
RD
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 }
af83019e
RD
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.
282class wxWizardPageSimple : public wxWizardPage
283{
284public:
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
af83019e
RD
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
313class wxWizard : public wxDialog
314{
315public:
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 %name(wxPreWizard)wxWizard();
323
324 %pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
325 %pragma(python) addtomethod = "wxPreWizard:val._setOORInfo(val)"
326
327 bool Create(wxWindow *parent,
328 int id = -1,
329 const wxString& title = wxEmptyString,
330 const wxBitmap& bitmap = wxNullBitmap,
331 const wxPoint& pos = wxDefaultPosition);
332
333 void Init();
334
335
336 // executes the wizard starting from the given page, returns TRUE if it was
337 // successfully finished, FALSE if user cancelled it
338 virtual bool RunWizard(wxWizardPage *firstPage);
339
340 // get the current page (NULL if RunWizard() isn't running)
341 virtual wxWizardPage *GetCurrentPage() const;
342
343 // set the min size which should be available for the pages: a
344 // wizard will take into account the size of the bitmap (if any)
345 // itself and will never be less than some predefined fixed size
346 virtual void SetPageSize(const wxSize& size);
347
348 // get the size available for the page: the wizards are not resizeable, so
349 // this size doesn't change
350 virtual wxSize GetPageSize() const;
351
352 // set the best size for the wizard, i.e. make it big enough to contain all
353 // of the pages starting from the given one
354 //
355 // this function may be called several times and possible with different
356 // pages in which case it will only increase the page size if needed (this
357 // may be useful if not all pages are accessible from the first one by
358 // default)
359 virtual void FitToPage(const wxWizardPage *firstPage);
360
361 // is the wizard running?
362 bool IsRunning() const { return m_page != NULL; }
363
364 // show the prev/next page, but call TransferDataFromWindow on the current
365 // page first and return FALSE without changing the page if
366 // TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
367 bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
1e4a197e
RD
368
369 bool HasNextPage(wxWizardPage* page);
370 bool HasPrevPage(wxWizardPage* page);
af83019e
RD
371};
372
373
374//----------------------------------------------------------------------
85260f24
RD
375
376%init %{
377 wxClassInfo::CleanUpClasses();
378 wxClassInfo::InitializeClasses();
379%}
380
af83019e
RD
381//----------------------------------------------------------------------
382// This file gets appended to the shadow class file.
383//----------------------------------------------------------------------
384
385%pragma(python) include="_wizardextras.py";
386
387//---------------------------------------------------------------------------