]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/wizard.i
reSWIGged
[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%{
d14a1e28
RD
16#include "wx/wxPython/wxPython.h"
17#include "wx/wxPython/pyclasses.h"
18#include "wx/wxPython/printfw.h"
19
af83019e 20#include <wx/wizard.h>
d14a1e28
RD
21
22 static const wxString wxPyEmptyString(wxT(""));
af83019e
RD
23%}
24
25//----------------------------------------------------------------------
26
af83019e 27%import windows.i
d14a1e28 28%pythoncode { wx = core }
af83019e 29
d14a1e28 30%include _wizard_rename.i
af83019e
RD
31
32//----------------------------------------------------------------------
33
34enum {
35 wxWIZARD_EX_HELPBUTTON,
af83019e
RD
36};
37
d14a1e28
RD
38%constant wxEventType wxEVT_WIZARD_PAGE_CHANGED;
39%constant wxEventType wxEVT_WIZARD_PAGE_CHANGING;
40%constant wxEventType wxEVT_WIZARD_CANCEL;
41%constant wxEventType wxEVT_WIZARD_HELP;
42%constant wxEventType wxEVT_WIZARD_FINISHED;
af83019e 43
af83019e 44
af83019e 45
d14a1e28
RD
46%pythoncode {
47EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
48EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
49EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
50EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
51EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
52}
af83019e
RD
53
54//----------------------------------------------------------------------
55
56class wxWizardEvent : public wxNotifyEvent
57{
58public:
59 wxWizardEvent(wxEventType type = wxEVT_NULL,
60 int id = -1,
dd9f7fea 61 bool direction = True,
af83019e
RD
62 wxWizardPage* page = NULL);
63
dd9f7fea
RD
64 // for EVT_WIZARD_PAGE_CHANGING, return True if we're going forward or
65 // False otherwise and for EVT_WIZARD_PAGE_CHANGED return True if we came
66 // from the previous page and False if we returned from the next one
af83019e
RD
67 // (this function doesn't make sense for CANCEL events)
68 bool GetDirection() const { return m_direction; }
69
70 wxWizardPage* GetPage() const { return m_page; }
71};
72
73
74//----------------------------------------------------------------------
75
76// wxWizardPage is one of the wizards screen: it must know what are the
77// following and preceding pages (which may be NULL for the first/last page).
78//
79// Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
80// used as such (i.e. controls may be placed directly on it &c).
81class wxWizardPage : public wxPanel
82{
83public:
84// // ctor accepts an optional bitmap which will be used for this page instead
85// // of the default one for this wizard (should be of the same size). Notice
86// // that no other parameters are needed because the wizard will resize and
87// // reposition the page anyhow
88// wxWizardPage(wxWizard *parent,
89// const wxBitmap& bitmap = wxNullBitmap,
90// const char* resource = NULL);
d14a1e28 91// %name(PreWizardPage)wxWizardPage();
af83019e 92
d14a1e28 93 %extend {
dd4a4b90
RD
94 bool Create(wxWizard *parent,
95 const wxBitmap& bitmap = wxNullBitmap,
96 const wxString& resource = wxPyEmptyString) {
97 wxChar* res = NULL;
98 if (resource.Length())
99 res = (wxChar*)resource.c_str();
100 return self->Create(parent, bitmap, res);
101 }
102 }
103
af83019e 104
af83019e
RD
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
117
118
119%{ // C++ Version of a Python aware class
120class wxPyWizardPage : public wxWizardPage {
121 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
122public:
123 wxPyWizardPage() : wxWizardPage() {}
124 wxPyWizardPage(wxWizard *parent,
125 const wxBitmap& bitmap = wxNullBitmap,
126 const wxChar* resource = NULL)
127 : wxWizardPage(parent, bitmap, resource) {}
128
129 DEC_PYCALLBACK_WIZPG__pure(GetPrev);
130 DEC_PYCALLBACK_WIZPG__pure(GetNext);
131 DEC_PYCALLBACK_BITMAP__pure(GetBitmap);
132
133 DEC_PYCALLBACK_VOID_INT4(DoMoveWindow);
134 DEC_PYCALLBACK_VOID_INT5(DoSetSize);
135 DEC_PYCALLBACK_VOID_INTINT(DoSetClientSize);
136 DEC_PYCALLBACK_VOID_INTINT(DoSetVirtualSize);
137
138 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetSize);
139 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetClientSize);
140 DEC_PYCALLBACK_VOID_INTPINTP_const(DoGetPosition);
141
142 DEC_PYCALLBACK_SIZE_const(DoGetVirtualSize);
143 DEC_PYCALLBACK_SIZE_const(DoGetBestSize);
144
145 DEC_PYCALLBACK__(InitDialog);
146 DEC_PYCALLBACK_BOOL_(TransferDataFromWindow);
147 DEC_PYCALLBACK_BOOL_(TransferDataToWindow);
148 DEC_PYCALLBACK_BOOL_(Validate);
149
150 DEC_PYCALLBACK_BOOL_const(AcceptsFocus);
151 DEC_PYCALLBACK_BOOL_const(AcceptsFocusFromKeyboard);
152 DEC_PYCALLBACK_SIZE_const(GetMaxSize);
153
154 DEC_PYCALLBACK_VOID_WXWINBASE(AddChild);
155 DEC_PYCALLBACK_VOID_WXWINBASE(RemoveChild);
156
157 PYPRIVATE;
158};
159
160
161IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
162
163IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
164IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
165IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
166
167IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
168IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
169IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
170IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
171
172IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
173IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
174IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
175
176IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
177IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
178
179IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
180IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
181IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
182IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
183
184IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
185IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
186IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
187
188IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
189IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
190
191%}
192
193
194
195class wxPyWizardPage : public wxWizardPage {
196public:
d14a1e28
RD
197
198 %addtofunc wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
199 %addtofunc wxPyWizardPage() ""
200
af83019e
RD
201 // ctor accepts an optional bitmap which will be used for this page instead
202 // of the default one for this wizard (should be of the same size). Notice
203 // that no other parameters are needed because the wizard will resize and
204 // reposition the page anyhow
d14a1e28 205 %extend {
dd4a4b90
RD
206 wxPyWizardPage(wxWizard *parent,
207 const wxBitmap* bitmap = &wxNullBitmap,
208 const wxString* resource = &wxPyEmptyString) {
209 wxChar* res = NULL;
210 if (resource->Length())
211 res = (wxChar*)resource->c_str();
212 return new wxPyWizardPage(parent, *bitmap, res);
213 }
214 }
215
d14a1e28 216 %name(PrePyWizardPage)wxPyWizardPage();
af83019e 217
d14a1e28 218 %extend {
dd4a4b90
RD
219 bool Create(wxWizard *parent,
220 const wxBitmap& bitmap = wxNullBitmap,
221 const wxString& resource = wxPyEmptyString) {
222 wxChar* res = NULL;
223 if (resource.Length())
224 res = (wxChar*)resource.c_str();
225 return self->Create(parent, bitmap, res);
226 }
227 }
af83019e
RD
228
229 void _setCallbackInfo(PyObject* self, PyObject* _class);
af83019e
RD
230
231 void base_DoMoveWindow(int x, int y, int width, int height);
232 void base_DoSetSize(int x, int y, int width, int height,
233 int sizeFlags = wxSIZE_AUTO);
234 void base_DoSetClientSize(int width, int height);
235 void base_DoSetVirtualSize( int x, int y );
236
237 void base_DoGetSize( int *OUTPUT, int *OUTPUT ) const;
238 void base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const;
239 void base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const;
240
241 wxSize base_DoGetVirtualSize() const;
242 wxSize base_DoGetBestSize() const;
243
244 void base_InitDialog();
245 bool base_TransferDataToWindow();
246 bool base_TransferDataFromWindow();
247 bool base_Validate();
248
249 bool base_AcceptsFocus() const;
250 bool base_AcceptsFocusFromKeyboard() const;
251 wxSize base_GetMaxSize() const;
252
253 void base_AddChild(wxWindow* child);
254 void base_RemoveChild(wxWindow* child);
255};
256
257//----------------------------------------------------------------------
258
259
260// wxWizardPageSimple just returns the pointers given to the ctor and is useful
261// to create a simple wizard where the order of pages never changes.
262//
263// OTOH, it is also possible to dynamicly decide which page to return (i.e.
264// depending on the user's choices) as the wizard sample shows - in order to do
265// this, you must derive from wxWizardPage directly.
266class wxWizardPageSimple : public wxWizardPage
267{
268public:
d14a1e28
RD
269
270 %addtofunc wxWizardPageSimple "self._setOORInfo(self)"
271 %addtofunc wxWizardPageSimple() ""
272
af83019e
RD
273 // ctor takes the previous and next pages
274 wxWizardPageSimple(wxWizard *parent,
275 wxWizardPage *prev = NULL,
276 wxWizardPage *next = NULL,
277 const wxBitmap& bitmap = wxNullBitmap,
278 const wxChar* resource = NULL);
d14a1e28 279 %name(PreWizardPageSimple)wxWizardPageSimple();
af83019e
RD
280
281 bool Create(wxWizard *parent = NULL,
282 wxWizardPage *prev = NULL,
283 wxWizardPage *next = NULL,
284 const wxBitmap& bitmap = wxNullBitmap,
285 const wxChar* resource = NULL);
286
af83019e
RD
287 // the pointers may be also set later - but before starting the wizard
288 void SetPrev(wxWizardPage *prev);
289 void SetNext(wxWizardPage *next);
290
291 // a convenience function to make the pages follow each other
292 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
293};
294
295
296//----------------------------------------------------------------------
297
298class wxWizard : public wxDialog
299{
300public:
d14a1e28
RD
301 %addtofunc wxWizard "self._setOORInfo(self)"
302 %addtofunc wxWizard() ""
303
af83019e
RD
304 // ctor
305 wxWizard(wxWindow *parent,
306 int id = -1,
307 const wxString& title = wxEmptyString,
308 const wxBitmap& bitmap = wxNullBitmap,
3ef86e32
RD
309 const wxPoint& pos = wxDefaultPosition,
310 long style = wxDEFAULT_DIALOG_STYLE);
d14a1e28 311 %name(PreWizard)wxWizard();
af83019e
RD
312
313 bool Create(wxWindow *parent,
314 int id = -1,
315 const wxString& title = wxEmptyString,
316 const wxBitmap& bitmap = wxNullBitmap,
317 const wxPoint& pos = wxDefaultPosition);
318
319 void Init();
320
321
dd9f7fea
RD
322 // executes the wizard starting from the given page, returns True if it was
323 // successfully finished, False if user cancelled it
af83019e
RD
324 virtual bool RunWizard(wxWizardPage *firstPage);
325
326 // get the current page (NULL if RunWizard() isn't running)
327 virtual wxWizardPage *GetCurrentPage() const;
328
329 // set the min size which should be available for the pages: a
330 // wizard will take into account the size of the bitmap (if any)
331 // itself and will never be less than some predefined fixed size
332 virtual void SetPageSize(const wxSize& size);
333
334 // get the size available for the page: the wizards are not resizeable, so
335 // this size doesn't change
336 virtual wxSize GetPageSize() const;
337
338 // set the best size for the wizard, i.e. make it big enough to contain all
339 // of the pages starting from the given one
340 //
341 // this function may be called several times and possible with different
342 // pages in which case it will only increase the page size if needed (this
343 // may be useful if not all pages are accessible from the first one by
344 // default)
345 virtual void FitToPage(const wxWizardPage *firstPage);
346
3ef86e32
RD
347 // Adding pages to page area sizer enlarges wizard
348 virtual wxSizer *GetPageAreaSizer() const;
349
350 // Set border around page area. Default is 0 if you add at least one
351 // page to GetPageAreaSizer and 5 if you don't.
352 virtual void SetBorder(int border);
353
af83019e
RD
354 // is the wizard running?
355 bool IsRunning() const { return m_page != NULL; }
356
357 // show the prev/next page, but call TransferDataFromWindow on the current
dd9f7fea
RD
358 // page first and return False without changing the page if
359 // TransferDataFromWindow() returns False - otherwise, returns True
360 bool ShowPage(wxWizardPage *page, bool goingForward = True);
1e4a197e
RD
361
362 bool HasNextPage(wxWizardPage* page);
363 bool HasPrevPage(wxWizardPage* page);
af83019e
RD
364};
365
366
367//----------------------------------------------------------------------
85260f24
RD
368
369%init %{
85260f24
RD
370%}
371
af83019e 372//---------------------------------------------------------------------------