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