]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
SWIG Runtime update
[wxWidgets.git] / wxPython / src / wizard.i
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 "wx/wxPython/wxPython.h"
17 #include "wx/wxPython/pyclasses.h"
18 #include "wx/wxPython/printfw.h"
19
20 #include <wx/wizard.h>
21
22 static const wxString wxPyEmptyString(wxT(""));
23 %}
24
25 //----------------------------------------------------------------------
26
27 %import windows.i
28 %pythoncode { wx = core }
29
30 %include _wizard_rename.i
31
32 //----------------------------------------------------------------------
33
34 enum {
35 wxWIZARD_EX_HELPBUTTON,
36 };
37
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;
43
44
45
46 %pythoncode {
47 EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
48 EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
49 EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
50 EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
51 EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
52 }
53
54 //----------------------------------------------------------------------
55
56 class wxWizardEvent : public wxNotifyEvent
57 {
58 public:
59 wxWizardEvent(wxEventType type = wxEVT_NULL,
60 int id = -1,
61 bool direction = True,
62 wxWizardPage* page = NULL);
63
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
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).
81 class wxWizardPage : public wxPanel
82 {
83 public:
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);
91 // %name(PreWizardPage)wxWizardPage();
92
93 %extend {
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
104
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
120 class wxPyWizardPage : public wxWizardPage {
121 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
122 public:
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
161 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
162
163 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
164 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
165 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
166
167 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
168 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
169 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
170 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
171
172 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
173 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
174 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
175
176 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
177 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
178
179 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
180 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
181 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
182 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
183
184 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
185 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
186 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
187
188 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
189 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
190
191 %}
192
193
194
195 class wxPyWizardPage : public wxWizardPage {
196 public:
197
198 %addtofunc wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
199 %addtofunc wxPyWizardPage() ""
200
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
205 %extend {
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
216 %name(PrePyWizardPage)wxPyWizardPage();
217
218 %extend {
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 }
228
229 void _setCallbackInfo(PyObject* self, PyObject* _class);
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.
266 class wxWizardPageSimple : public wxWizardPage
267 {
268 public:
269
270 %addtofunc wxWizardPageSimple "self._setOORInfo(self)"
271 %addtofunc wxWizardPageSimple() ""
272
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);
279 %name(PreWizardPageSimple)wxWizardPageSimple();
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
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
298 class wxWizard : public wxDialog
299 {
300 public:
301 %addtofunc wxWizard "self._setOORInfo(self)"
302 %addtofunc wxWizard() ""
303
304 // ctor
305 wxWizard(wxWindow *parent,
306 int id = -1,
307 const wxString& title = wxEmptyString,
308 const wxBitmap& bitmap = wxNullBitmap,
309 const wxPoint& pos = wxDefaultPosition,
310 long style = wxDEFAULT_DIALOG_STYLE);
311 %name(PreWizard)wxWizard();
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
322 // executes the wizard starting from the given page, returns True if it was
323 // successfully finished, False if user cancelled it
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
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
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
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);
361
362 bool HasNextPage(wxWizardPage* page);
363 bool HasPrevPage(wxWizardPage* page);
364 };
365
366
367 //----------------------------------------------------------------------
368
369 %init %{
370 %}
371
372 //---------------------------------------------------------------------------