]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/wizard.h
Resolve ambiguity between GetClientXXX() methods in wxOSX wxComboBox.
[wxWidgets.git] / interface / wx / wizard.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: wizard.h
f41d6c8c 3// Purpose: interface of wxWizardPage, wxWizardEvent,
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxWizardPage
7c913512 11
f41d6c8c
FM
12 wxWizardPage is one of the screens in wxWizard: it must know what are the
13 following and preceding pages (which may be @NULL for the first/last page).
14 Except for this extra knowledge, wxWizardPage is just a
23324ae1 15 panel, so the controls may be placed directly on it in the usual way.
7c913512 16
23324ae1 17 This class allows the programmer to decide the order of pages in the wizard
f41d6c8c
FM
18 dynamically (during run-time) and so provides maximal flexibility.
19 Usually, however, the order of pages is known in advance in which case
20 wxWizardPageSimple class is enough and it is simpler to use.
21
22
23 @section wizardpage_virtuals Virtual functions to override
24
25 To use this class, you must override wxWizardPage::GetPrev() and
26 wxWizardPage::GetNext() pure virtual functions (or you may use
27 wxWizardPageSimple instead).
28 wxWizardPage::GetBitmap() can also be overridden, but this should be very
29 rarely needed.
7c913512 30
23324ae1
FM
31 @library{wxadv}
32 @category{miscwnd}
7c913512 33
f41d6c8c 34 @see wxWizard, @ref page_samples_wizard
23324ae1
FM
35*/
36class wxWizardPage : public wxPanel
37{
38public:
39 /**
40 Constructor accepts an optional bitmap which will be used for this page
41 instead of the default one for this wizard (note that all bitmaps used should
42 be of the same size). Notice that no other parameters are needed because the
43 wizard will resize and reposition the page anyhow.
3c4f71cc 44
7c913512 45 @param parent
4cc4bfaf 46 The parent wizard
7c913512 47 @param bitmap
4cc4bfaf 48 The page-specific bitmap if different from the global one
23324ae1
FM
49 */
50 wxWizardPage(wxWizard* parent,
51 const wxBitmap& bitmap = wxNullBitmap);
52
53 /**
f41d6c8c
FM
54 This method is called by wxWizard to get the bitmap to display alongside the page.
55 By default, @c m_bitmap member variable which was set in the
56 @ref wxWizardPage() constructor.
57
58 If the bitmap was not explicitly set (i.e. if ::wxNullBitmap is returned),
23324ae1 59 the default bitmap for the wizard should be used.
f41d6c8c 60
23324ae1
FM
61 The only cases when you would want to override this function is if the page
62 bitmap depends dynamically on the user choices, i.e. almost never.
63 */
adaaa686 64 virtual wxBitmap GetBitmap() const;
23324ae1
FM
65
66 /**
67 Get the page which should be shown when the user chooses the @c "Next"
f41d6c8c
FM
68 button: if @NULL is returned, this button will be disabled.
69 The last page of the wizard will usually return @NULL from here, but
70 the others will not.
3c4f71cc 71
4cc4bfaf 72 @see GetPrev()
23324ae1 73 */
95b4a59e 74 virtual wxWizardPage* GetNext() const = 0;
23324ae1
FM
75
76 /**
77 Get the page which should be shown when the user chooses the @c "Back"
f41d6c8c
FM
78 button: if @NULL is returned, this button will be disabled.
79 The first page of the wizard will usually return @NULL from here, but
80 the others will not.
3c4f71cc 81
4cc4bfaf 82 @see GetNext()
23324ae1 83 */
95b4a59e 84 virtual wxWizardPage* GetPrev() const = 0;
23324ae1
FM
85};
86
87
e54c96f1 88
23324ae1
FM
89/**
90 @class wxWizardEvent
7c913512 91
f41d6c8c
FM
92 wxWizardEvent class represents an event generated by the wxWizard: this event
93 is first sent to the page itself and, if not processed there, goes up the
94 window hierarchy as usual.
95
96 @beginEventTable{wxWizardEvent}
97 @event{EVT_WIZARD_PAGE_CHANGED(id, func)}
4c51a665 98 The page has been just changed (this event cannot be vetoed).
f41d6c8c
FM
99 @event{EVT_WIZARD_PAGE_CHANGING(id, func)}
100 The page is being changed (this event can be vetoed).
deeb0a89
JS
101 @event{EVT_WIZARD_PAGE_SHOWN(id, func)}
102 The page was shown and laid out (this event cannot be vetoed).
f41d6c8c
FM
103 @event{EVT_WIZARD_CANCEL(id, func)}
104 The user attempted to cancel the wizard (this event may also be vetoed).
105 @event{EVT_WIZARD_HELP(id, func)}
106 The wizard help button was pressed.
107 @event{EVT_WIZARD_FINISHED(id, func)}
108 The wizard finished button was pressed.
109 @endEventTable
7c913512 110
23324ae1
FM
111 @library{wxadv}
112 @category{events}
7c913512 113
f41d6c8c 114 @see wxWizard, @ref page_samples_wizard
23324ae1
FM
115*/
116class wxWizardEvent : public wxNotifyEvent
117{
118public:
119 /**
f41d6c8c
FM
120 Constructor.
121
122 It is not normally used by the user code as the objects of this
23324ae1
FM
123 type are constructed by wxWizard.
124 */
95b4a59e
FM
125 wxWizardEvent(wxEventType type = wxEVT_NULL, int id = wxID_ANY,
126 bool direction = true, wxWizardPage* page = 0);
23324ae1
FM
127
128 /**
f41d6c8c
FM
129 Return the direction in which the page is changing: for
130 @c EVT_WIZARD_PAGE_CHANGING, return @true if we're going forward or
131 @false otherwise and for @c EVT_WIZARD_PAGE_CHANGED return @true if we
132 came from the previous page and @false if we returned from the next one.
23324ae1 133 */
328f5751 134 bool GetDirection() const;
23324ae1
FM
135
136 /**
f41d6c8c 137 Returns the wxWizardPage which was active when this event was generated.
23324ae1 138 */
328f5751 139 wxWizardPage* GetPage() const;
23324ae1
FM
140};
141
142
e54c96f1 143
23324ae1
FM
144/**
145 @class wxWizardPageSimple
7c913512 146
f41d6c8c
FM
147 wxWizardPageSimple is the simplest possible wxWizardPage implementation:
148 it just returns the pointers given to its constructor from wxWizardPage::GetNext()
149 and wxWizardPage::GetPrev() functions.
7c913512 150
23324ae1
FM
151 This makes it very easy to use the objects of this class in the wizards where
152 the pages order is known statically - on the other hand, if this is not the
f41d6c8c 153 case you must derive your own class from wxWizardPage instead.
7c913512 154
23324ae1
FM
155 @library{wxadv}
156 @category{miscwnd}
7c913512 157
f41d6c8c 158 @see wxWizard, @ref page_samples_wizard
23324ae1
FM
159*/
160class wxWizardPageSimple : public wxWizardPage
161{
162public:
163 /**
f41d6c8c
FM
164 Constructor takes the previous and next pages.
165 They may be modified later by SetPrev() or SetNext().
23324ae1 166 */
95b4a59e 167 wxWizardPageSimple(wxWizard* parent,
4cc4bfaf
FM
168 wxWizardPage* prev = NULL,
169 wxWizardPage* next = NULL,
23324ae1
FM
170 const wxBitmap& bitmap = wxNullBitmap);
171
172 /**
173 A convenience function to make the pages follow each other.
23324ae1 174 Example:
f41d6c8c
FM
175
176 @code
177 wxRadioboxPage *page3 = new wxRadioboxPage(wizard);
178 wxValidationPage *page4 = new wxValidationPage(wizard);
179
180 wxWizardPageSimple::Chain(page3, page4);
181 @endcode
23324ae1
FM
182 */
183 static void Chain(wxWizardPageSimple* first,
184 wxWizardPageSimple* second);
185
186 /**
187 Sets the next page.
188 */
189 void SetNext(wxWizardPage* next);
190
191 /**
192 Sets the previous page.
193 */
194 void SetPrev(wxWizardPage* prev);
195};
196
197
e54c96f1 198
23324ae1
FM
199/**
200 @class wxWizard
7c913512 201
f41d6c8c
FM
202 wxWizard is the central class for implementing 'wizard-like' dialogs.
203 These dialogs are mostly familiar to Windows users and are nothing other than a
204 sequence of 'pages', each displayed inside a dialog which has the buttons to
205 navigate to the next (and previous) pages.
7c913512 206
23324ae1
FM
207 The wizards are typically used to decompose a complex dialog into several
208 simple steps and are mainly useful to the novice users, hence it is important
209 to keep them as simple as possible.
7c913512 210
23324ae1 211 To show a wizard dialog, you must first create an instance of the wxWizard class
f41d6c8c
FM
212 using either the non-default constructor or a default one followed by call to the
213 wxWizard::Create function. Then you should add all pages you want the wizard to
214 show and call wxWizard::RunWizard().
215 Finally, don't forget to call @c "wizard->Destroy()", otherwise your application
23324ae1 216 will hang on exit due to an undestroyed window.
7c913512 217
f41d6c8c 218 You can supply a bitmap to display on the left of the wizard, either for all pages
23324ae1 219 or for individual pages. If you need to have the bitmap resize to the height of
f41d6c8c
FM
220 the wizard, call wxWizard::SetBitmapPlacement() and if necessary,
221 wxWizard::SetBitmapBackgroundColour() and wxWizard::SetMinimumBitmapWidth().
7c913512 222
23324ae1 223 To make wizard pages scroll when the display is too small to fit the whole
f41d6c8c
FM
224 dialog, you can switch layout adaptation on globally with
225 wxDialog::EnableLayoutAdaptation() or per dialog with wxDialog::SetLayoutAdaptationMode().
226 For more about layout adaptation, see @ref overview_dialog_autoscrolling.
227
3051a44a 228 @beginEventEmissionTable{wxWizardEvent}
f41d6c8c
FM
229 For some events, Veto() can be called to prevent the event from happening.
230 @event{EVT_WIZARD_PAGE_CHANGED(id, func)}
231 The page has just been changed (this event cannot be vetoed).
232 @event{EVT_WIZARD_PAGE_CHANGING(id, func)}
233 The page is being changed (this event can be vetoed).
deeb0a89
JS
234 @event{EVT_WIZARD_PAGE_SHOWN(id, func)}
235 The page was shown and laid out (this event cannot be vetoed).
f41d6c8c
FM
236 @event{EVT_WIZARD_CANCEL(id, func)}
237 The user attempted to cancel the wizard (this event may also be vetoed).
238 @event{EVT_WIZARD_HELP(id, func)}
239 The wizard help button was pressed.
240 @event{EVT_WIZARD_FINISHED(id, func)}
241 The wizard finished button was pressed.
242 @endEventTable
243
244
245 @section wizard_extstyles Extended styles
246
247 Use the wxWindow::SetExtraStyle() function to set the following style.
248 You will need to use two-step construction (use the default constructor,
249 call SetExtraStyle(), then call Create).
250
251 @beginExtraStyleTable
252 @style{wxWIZARD_EX_HELPBUTTON}
253 Shows a Help button using wxID_HELP.
254 @endExtraStyleTable
255
256 See also wxDialog for other extended styles.
7c913512 257
23324ae1
FM
258 @library{wxadv}
259 @category{cmndlg}
7c913512 260
f41d6c8c 261 @see wxWizardEvent, wxWizardPage, @ref page_samples_wizard
23324ae1
FM
262*/
263class wxWizard : public wxDialog
264{
265public:
f41d6c8c
FM
266 /**
267 Default constructor.
268
269 Use this if you wish to derive from wxWizard and then call Create(),
270 for example if you wish to set an extra style with wxWindow::SetExtraStyle()
271 between the two calls.
272 */
273 wxWizard();
274
23324ae1
FM
275 /**
276 Constructor which really creates the wizard -- if you use this constructor, you
277 shouldn't call Create().
f41d6c8c 278
7c913512 279 Notice that unlike almost all other wxWidgets classes, there is no @e size
23324ae1 280 parameter in the wxWizard constructor because the wizard will have a predefined
f41d6c8c
FM
281 default size by default.
282 If you want to change this, you should use the GetPageAreaSizer() function.
3c4f71cc 283
7c913512 284 @param parent
4cc4bfaf 285 The parent window, may be @NULL.
7c913512 286 @param id
95b4a59e 287 The id of the dialog, will usually be just wxID_ANY.
7c913512 288 @param title
4cc4bfaf 289 The title of the dialog.
7c913512 290 @param bitmap
f41d6c8c 291 The default bitmap used in the left side of the wizard. See also GetBitmap().
7c913512 292 @param pos
f41d6c8c 293 The position of the dialog, it will be centered on the screen by default.
7c913512 294 @param style
4cc4bfaf 295 Window style is passed to wxDialog.
23324ae1 296 */
95b4a59e 297 wxWizard(wxWindow* parent, int id = wxID_ANY,
7c913512
FM
298 const wxString& title = wxEmptyString,
299 const wxBitmap& bitmap = wxNullBitmap,
300 const wxPoint& pos = wxDefaultPosition,
301 long style = wxDEFAULT_DIALOG_STYLE);
23324ae1
FM
302
303 /**
f41d6c8c
FM
304 Creates the wizard dialog.
305 Must be called if the default constructor had been used to create the object.
306
7c913512 307 Notice that unlike almost all other wxWidgets classes, there is no @e size
23324ae1 308 parameter in the wxWizard constructor because the wizard will have a predefined
f41d6c8c
FM
309 default size by default.
310 If you want to change this, you should use the GetPageAreaSizer() function.
3c4f71cc 311
7c913512 312 @param parent
4cc4bfaf 313 The parent window, may be @NULL.
7c913512 314 @param id
4cc4bfaf 315 The id of the dialog, will usually be just -1.
7c913512 316 @param title
4cc4bfaf 317 The title of the dialog.
7c913512 318 @param bitmap
f41d6c8c 319 The default bitmap used in the left side of the wizard. See also GetBitmap().
7c913512 320 @param pos
f41d6c8c 321 The position of the dialog, it will be centered on the screen by default.
7c913512 322 @param style
4cc4bfaf 323 Window style is passed to wxDialog.
23324ae1 324 */
95b4a59e 325 bool Create(wxWindow* parent, int id = wxID_ANY,
23324ae1
FM
326 const wxString& title = wxEmptyString,
327 const wxBitmap& bitmap = wxNullBitmap,
95b4a59e 328 const wxPoint& pos = wxDefaultPosition, long style = 536877056);
23324ae1
FM
329
330 /**
f41d6c8c
FM
331 This method is obsolete, use GetPageAreaSizer() instead.
332
23324ae1
FM
333 Sets the page size to be big enough for all the pages accessible via the
334 given @e firstPage, i.e. this page, its next page and so on.
f41d6c8c 335
23324ae1
FM
336 This method may be called more than once and it will only change the page size
337 if the size required by the new page is bigger than the previously set one.
338 This is useful if the decision about which pages to show is taken during
339 run-time, as in this case, the wizard won't be able to get to all pages starting
340 from a single one and you should call @e Fit separately for the others.
341 */
adaaa686 342 virtual void FitToPage(const wxWizardPage* firstPage);
23324ae1
FM
343
344 /**
345 Returns the bitmap used for the wizard.
346 */
f41d6c8c 347 const wxBitmap& GetBitmap() const;
23324ae1
FM
348
349 /**
350 Returns the colour that should be used to fill the area not taken up by the
f41d6c8c
FM
351 wizard or page bitmap, if a non-zero bitmap placement flag has been set.
352
23324ae1
FM
353 See also SetBitmapPlacement().
354 */
f41d6c8c 355 const wxColour& GetBitmapBackgroundColour() const;
23324ae1
FM
356
357 /**
358 Returns the flags indicating how the wizard or page bitmap should be expanded
f41d6c8c
FM
359 and positioned to fit the page height. By default, placement is 0 (no expansion is done).
360
23324ae1
FM
361 See also SetBitmapPlacement() for the possible values.
362 */
adaaa686 363 int GetBitmapPlacement() const;
23324ae1
FM
364
365 /**
f41d6c8c
FM
366 Get the current page while the wizard is running.
367 @NULL is returned if RunWizard() is not being executed now.
23324ae1 368 */
adaaa686 369 virtual wxWizardPage* GetCurrentPage() const;
23324ae1
FM
370
371 /**
372 Returns the minimum width for the bitmap that will be constructed to contain
f41d6c8c
FM
373 the actual wizard or page bitmap if a non-zero bitmap placement flag has been set.
374
23324ae1
FM
375 See also SetBitmapPlacement().
376 */
328f5751 377 int GetMinimumBitmapWidth() const;
23324ae1
FM
378
379 /**
380 Returns pointer to page area sizer. The wizard is laid out using sizers and
381 the page area sizer is the place-holder for the pages. All pages are resized
f41d6c8c
FM
382 before being shown to match the wizard page area.
383
384 Page area sizer has a minimal size that is the maximum of several values.
385 First, all pages (or other objects) added to the sizer. Second, all pages reachable
386 by repeatedly applying wxWizardPage::GetNext() to any page inserted into the sizer.
387
388 Third, the minimal size specified using SetPageSize() and FitToPage().
389 Fourth, the total wizard height may be increased to accommodate the bitmap height.
390 Fifth and finally, wizards are never smaller than some built-in minimal size to
391 avoid wizards that are too small.
392
393 The caller can use wxSizer::SetMinSize to enlarge it beyond the minimal size.
394 If @c wxRESIZE_BORDER was passed to constructor, user can resize wizard and
395 consequently the page area (but not make it smaller than the minimal size).
396
397 It is recommended to add the first page to the page area sizer.
398 For simple wizards, this will enlarge the wizard to fit the biggest page.
399
400 For non-linear wizards, the first page of every separate chain should be added.
401 Caller-specified size can be accomplished using wxSizer::SetMinSize().
23324ae1
FM
402 Adding pages to the page area sizer affects the default border width around page
403 area that can be altered with SetBorder().
404 */
328f5751 405 virtual wxSizer* GetPageAreaSizer() const;
23324ae1
FM
406
407 /**
408 Returns the size available for the pages.
409 */
adaaa686 410 virtual wxSize GetPageSize() const;
23324ae1
FM
411
412 /**
f41d6c8c
FM
413 Return @true if this page is not the last one in the wizard.
414 The base class version implements this by calling
415 @ref wxWizardPage::GetNext "page->GetNext" but this could be
416 undesirable if, for example, the pages are created on demand only.
3c4f71cc 417
4cc4bfaf 418 @see HasPrevPage()
23324ae1 419 */
4cc4bfaf 420 virtual bool HasNextPage(wxWizardPage* page);
23324ae1
FM
421
422 /**
f41d6c8c
FM
423 Returns @true if this page is not the last one in the wizard.
424 The base class version implements this by calling
425 @ref wxWizardPage::GetPrev "page->GetPrev" but this could be
426 undesirable if, for example, the pages are created on demand only.
3c4f71cc 427
4cc4bfaf 428 @see HasNextPage()
23324ae1 429 */
4cc4bfaf 430 virtual bool HasPrevPage(wxWizardPage* page);
23324ae1
FM
431
432 /**
433 Executes the wizard starting from the given page, returning @true if it was
f41d6c8c 434 successfully finished or @false if user cancelled it.
4c51a665 435 The @a firstPage cannot be @NULL.
23324ae1 436 */
adaaa686 437 virtual bool RunWizard(wxWizardPage* firstPage);
23324ae1
FM
438
439 /**
440 Sets the bitmap used for the wizard.
441 */
442 void SetBitmap(const wxBitmap& bitmap);
443
444 /**
445 Sets the colour that should be used to fill the area not taken up by the wizard
f41d6c8c
FM
446 or page bitmap, if a non-zero bitmap placement flag has been set.
447
23324ae1
FM
448 See also SetBitmapPlacement().
449 */
450 void SetBitmapBackgroundColour(const wxColour& colour);
451
452 /**
453 Sets the flags indicating how the wizard or page bitmap should be expanded and
f41d6c8c 454 positioned to fit the page height.
3c4f71cc 455
f41d6c8c
FM
456 By default, placement is 0 (no expansion is done). @a placement is a bitlist with the
457 following possible values:
3c4f71cc 458
f41d6c8c
FM
459 - @b wxWIZARD_VALIGN_TOP: Aligns the bitmap at the top.
460 - @b wxWIZARD_VALIGN_CENTRE: Centres the bitmap vertically.
461 - @b wxWIZARD_VALIGN_BOTTOM: Aligns the bitmap at the bottom.
462 - @b wxWIZARD_HALIGN_LEFT: Left-aligns the bitmap.
463 - @b wxWIZARD_HALIGN_CENTRE: Centres the bitmap horizontally.
464 - @b wxWIZARD_HALIGN_RIGHT: Right-aligns the bitmap.
465 - @b wxWIZARD_TILE: @todo describe this
3c4f71cc 466
23324ae1
FM
467 See also SetMinimumBitmapWidth().
468 */
469 void SetBitmapPlacement(int placement);
470
471 /**
f41d6c8c
FM
472 Sets width of border around page area. Default is zero.
473 For backward compatibility, if there are no pages in GetPageAreaSizer(),
474 the default is 5 pixels.
475
23324ae1 476 If there is a five point border around all controls in a page and the border
f41d6c8c 477 around page area is left as zero, a five point white space along all dialog borders
23324ae1 478 will be added to the control border in order to space page controls ten points
f41d6c8c 479 from the dialog border and non-page controls.
23324ae1 480 */
adaaa686 481 virtual void SetBorder(int border);
23324ae1
FM
482
483 /**
484 Sets the minimum width for the bitmap that will be constructed to contain the
f41d6c8c
FM
485 actual wizard or page bitmap if a non-zero bitmap placement flag has been set.
486 If this is not set when using bitmap placement, the initial layout may be incorrect.
487
23324ae1
FM
488 See also SetBitmapPlacement().
489 */
490 void SetMinimumBitmapWidth(int width);
491
492 /**
f41d6c8c
FM
493 Sets the minimal size to be made available for the wizard pages.
494 The wizard will take into account the size of the bitmap (if any) itself.
495 Also, the wizard will never be smaller than the default size.
496
497 The recommended way to use this function is to lay out all wizard pages
d13b34d3 498 using the sizers (even though the wizard is not resizable) and then use
f41d6c8c
FM
499 wxSizer::CalcMin() in a loop to calculate the maximum of minimal sizes of
500 the pages and pass it to SetPageSize().
23324ae1 501 */
adaaa686 502 virtual void SetPageSize(const wxSize& sizePage);
23324ae1 503};
e54c96f1 504