]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/wizard.i
Cosmetic cleanup (-1 -> wxID_ANY, TRUE->true).
[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
322913ce
RD
237 DocDeclA(
238 void, base_DoGetSize( int *OUTPUT, int *OUTPUT ) const,
239 "base_DoGetSize() -> (width, height)");
240 DocDeclA(
241 void, base_DoGetClientSize( int *OUTPUT, int *OUTPUT ) const,
242 "base_DoGetClientSize() -> (width, height)");
243 DocDeclA(
244 void, base_DoGetPosition( int *OUTPUT, int *OUTPUT ) const,
245 "base_DoGetPosition() -> (x,y)");
af83019e
RD
246
247 wxSize base_DoGetVirtualSize() const;
248 wxSize base_DoGetBestSize() const;
249
250 void base_InitDialog();
251 bool base_TransferDataToWindow();
252 bool base_TransferDataFromWindow();
253 bool base_Validate();
254
255 bool base_AcceptsFocus() const;
256 bool base_AcceptsFocusFromKeyboard() const;
257 wxSize base_GetMaxSize() const;
258
259 void base_AddChild(wxWindow* child);
260 void base_RemoveChild(wxWindow* child);
261};
262
263//----------------------------------------------------------------------
264
265
266// wxWizardPageSimple just returns the pointers given to the ctor and is useful
267// to create a simple wizard where the order of pages never changes.
268//
269// OTOH, it is also possible to dynamicly decide which page to return (i.e.
270// depending on the user's choices) as the wizard sample shows - in order to do
271// this, you must derive from wxWizardPage directly.
272class wxWizardPageSimple : public wxWizardPage
273{
274public:
d14a1e28
RD
275
276 %addtofunc wxWizardPageSimple "self._setOORInfo(self)"
277 %addtofunc wxWizardPageSimple() ""
278
af83019e
RD
279 // ctor takes the previous and next pages
280 wxWizardPageSimple(wxWizard *parent,
281 wxWizardPage *prev = NULL,
282 wxWizardPage *next = NULL,
283 const wxBitmap& bitmap = wxNullBitmap,
284 const wxChar* resource = NULL);
d14a1e28 285 %name(PreWizardPageSimple)wxWizardPageSimple();
af83019e
RD
286
287 bool Create(wxWizard *parent = NULL,
288 wxWizardPage *prev = NULL,
289 wxWizardPage *next = NULL,
290 const wxBitmap& bitmap = wxNullBitmap,
291 const wxChar* resource = NULL);
292
af83019e
RD
293 // the pointers may be also set later - but before starting the wizard
294 void SetPrev(wxWizardPage *prev);
295 void SetNext(wxWizardPage *next);
296
297 // a convenience function to make the pages follow each other
298 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second);
299};
300
301
302//----------------------------------------------------------------------
303
304class wxWizard : public wxDialog
305{
306public:
d14a1e28
RD
307 %addtofunc wxWizard "self._setOORInfo(self)"
308 %addtofunc wxWizard() ""
309
af83019e
RD
310 // ctor
311 wxWizard(wxWindow *parent,
312 int id = -1,
313 const wxString& title = wxEmptyString,
314 const wxBitmap& bitmap = wxNullBitmap,
3ef86e32
RD
315 const wxPoint& pos = wxDefaultPosition,
316 long style = wxDEFAULT_DIALOG_STYLE);
d14a1e28 317 %name(PreWizard)wxWizard();
af83019e
RD
318
319 bool Create(wxWindow *parent,
320 int id = -1,
321 const wxString& title = wxEmptyString,
322 const wxBitmap& bitmap = wxNullBitmap,
323 const wxPoint& pos = wxDefaultPosition);
324
325 void Init();
326
327
dd9f7fea
RD
328 // executes the wizard starting from the given page, returns True if it was
329 // successfully finished, False if user cancelled it
af83019e
RD
330 virtual bool RunWizard(wxWizardPage *firstPage);
331
332 // get the current page (NULL if RunWizard() isn't running)
333 virtual wxWizardPage *GetCurrentPage() const;
334
335 // set the min size which should be available for the pages: a
336 // wizard will take into account the size of the bitmap (if any)
337 // itself and will never be less than some predefined fixed size
338 virtual void SetPageSize(const wxSize& size);
339
340 // get the size available for the page: the wizards are not resizeable, so
341 // this size doesn't change
342 virtual wxSize GetPageSize() const;
343
344 // set the best size for the wizard, i.e. make it big enough to contain all
345 // of the pages starting from the given one
346 //
347 // this function may be called several times and possible with different
348 // pages in which case it will only increase the page size if needed (this
349 // may be useful if not all pages are accessible from the first one by
350 // default)
351 virtual void FitToPage(const wxWizardPage *firstPage);
352
3ef86e32
RD
353 // Adding pages to page area sizer enlarges wizard
354 virtual wxSizer *GetPageAreaSizer() const;
355
356 // Set border around page area. Default is 0 if you add at least one
357 // page to GetPageAreaSizer and 5 if you don't.
358 virtual void SetBorder(int border);
359
af83019e
RD
360 // is the wizard running?
361 bool IsRunning() const { return m_page != NULL; }
362
363 // show the prev/next page, but call TransferDataFromWindow on the current
dd9f7fea
RD
364 // page first and return False without changing the page if
365 // TransferDataFromWindow() returns False - otherwise, returns True
366 bool ShowPage(wxWizardPage *page, bool goingForward = True);
1e4a197e
RD
367
368 bool HasNextPage(wxWizardPage* page);
369 bool HasPrevPage(wxWizardPage* page);
af83019e
RD
370};
371
372
373//----------------------------------------------------------------------
85260f24
RD
374
375%init %{
85260f24
RD
376%}
377
af83019e 378//---------------------------------------------------------------------------