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