]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/wizard.i
Moved some enums around to better match the C++ headers
[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 %}
23
24 //----------------------------------------------------------------------
25
26 %import windows.i
27 %pythoncode { wx = core }
28
29 %include _wizard_rename.i
30
31 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
32
33 //----------------------------------------------------------------------
34
35 enum {
36 wxWIZARD_EX_HELPBUTTON,
37 };
38
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;
44
45
46
47 %pythoncode {
48 EVT_WIZARD_PAGE_CHANGED = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGED, 1)
49 EVT_WIZARD_PAGE_CHANGING = wx.PyEventBinder( wxEVT_WIZARD_PAGE_CHANGING, 1)
50 EVT_WIZARD_CANCEL = wx.PyEventBinder( wxEVT_WIZARD_CANCEL, 1)
51 EVT_WIZARD_HELP = wx.PyEventBinder( wxEVT_WIZARD_HELP, 1)
52 EVT_WIZARD_FINISHED = wx.PyEventBinder( wxEVT_WIZARD_FINISHED, 1)
53 }
54
55 //----------------------------------------------------------------------
56
57 class wxWizardEvent : public wxNotifyEvent
58 {
59 public:
60 wxWizardEvent(wxEventType type = wxEVT_NULL,
61 int id = -1,
62 bool direction = True,
63 wxWizardPage* page = NULL);
64
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
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).
82 class wxWizardPage : public wxPanel
83 {
84 public:
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);
92 // %name(PreWizardPage)wxWizardPage();
93
94 %extend {
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
105
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
121 class wxPyWizardPage : public wxWizardPage {
122 DECLARE_ABSTRACT_CLASS(wxPyWizardPage);
123 public:
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
162 IMPLEMENT_ABSTRACT_CLASS(wxPyWizardPage, wxWizardPage);
163
164 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetPrev);
165 IMP_PYCALLBACK_WIZPG__pure(wxPyWizardPage, wxWizardPage, GetNext);
166 IMP_PYCALLBACK_BITMAP__pure(wxPyWizardPage, wxWizardPage, GetBitmap);
167
168 IMP_PYCALLBACK_VOID_INT4(wxPyWizardPage, wxWizardPage, DoMoveWindow);
169 IMP_PYCALLBACK_VOID_INT5(wxPyWizardPage, wxWizardPage, DoSetSize);
170 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetClientSize);
171 IMP_PYCALLBACK_VOID_INTINT(wxPyWizardPage, wxWizardPage, DoSetVirtualSize);
172
173 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetSize);
174 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetClientSize);
175 IMP_PYCALLBACK_VOID_INTPINTP_const(wxPyWizardPage, wxWizardPage, DoGetPosition);
176
177 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetVirtualSize);
178 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, DoGetBestSize);
179
180 IMP_PYCALLBACK__(wxPyWizardPage, wxWizardPage, InitDialog);
181 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataFromWindow);
182 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, TransferDataToWindow);
183 IMP_PYCALLBACK_BOOL_(wxPyWizardPage, wxWizardPage, Validate);
184
185 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocus);
186 IMP_PYCALLBACK_BOOL_const(wxPyWizardPage, wxWizardPage, AcceptsFocusFromKeyboard);
187 IMP_PYCALLBACK_SIZE_const(wxPyWizardPage, wxWizardPage, GetMaxSize);
188
189 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, AddChild);
190 IMP_PYCALLBACK_VOID_WXWINBASE(wxPyWizardPage, wxWizardPage, RemoveChild);
191
192 %}
193
194
195
196 class wxPyWizardPage : public wxWizardPage {
197 public:
198
199 %pythonAppend wxPyWizardPage "self._setCallbackInfo(self, PyWizardPage);self._setOORInfo(self)"
200 %pythonAppend wxPyWizardPage() ""
201
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
206 %extend {
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
217 %name(PrePyWizardPage)wxPyWizardPage();
218
219 %extend {
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 }
229
230 void _setCallbackInfo(PyObject* self, PyObject* _class);
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
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)");
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.
273 class wxWizardPageSimple : public wxWizardPage
274 {
275 public:
276
277 %pythonAppend wxWizardPageSimple "self._setOORInfo(self)"
278 %pythonAppend wxWizardPageSimple() ""
279
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);
286 %name(PreWizardPageSimple)wxWizardPageSimple();
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
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
305 class wxWizard : public wxDialog
306 {
307 public:
308 %pythonAppend wxWizard "self._setOORInfo(self)"
309 %pythonAppend wxWizard() ""
310
311 // ctor
312 wxWizard(wxWindow *parent,
313 int id = -1,
314 const wxString& title = wxPyEmptyString,
315 const wxBitmap& bitmap = wxNullBitmap,
316 const wxPoint& pos = wxDefaultPosition,
317 long style = wxDEFAULT_DIALOG_STYLE);
318 %name(PreWizard)wxWizard();
319
320 bool Create(wxWindow *parent,
321 int id = -1,
322 const wxString& title = wxPyEmptyString,
323 const wxBitmap& bitmap = wxNullBitmap,
324 const wxPoint& pos = wxDefaultPosition);
325
326 void Init();
327
328
329 // executes the wizard starting from the given page, returns True if it was
330 // successfully finished, False if user cancelled it
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
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
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
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);
368
369 bool HasNextPage(wxWizardPage* page);
370 bool HasPrevPage(wxWizardPage* page);
371 };
372
373
374 //----------------------------------------------------------------------
375
376 %init %{
377 %}
378
379 //---------------------------------------------------------------------------