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