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