# wxWizard Class Reference
[Common Dialogs]

`#include </home/work/projects/wx/2.9/wx/interface/wx/wizard.h>`

Inheritance diagram for wxWizard:
[legend]

## Detailed Description

wxWizard is the central class for implementing 'wizard-like' dialogs.

These dialogs are mostly familiar to Windows users and are nothing other than a sequence of 'pages', each displayed inside a dialog which has the buttons to navigate to the next (and previous) pages.

The wizards are typically used to decompose a complex dialog into several simple steps and are mainly useful to the novice users, hence it is important to keep them as simple as possible.

To show a wizard dialog, you must first create an instance of the wxWizard class using either the non-default constructor or a default one followed by call to the wxWizard::Create function. Then you should add all pages you want the wizard to show and call wxWizard::RunWizard(). Finally, don't forget to call `"wizard->Destroy()"`, otherwise your application will hang on exit due to an undestroyed window.

You can supply a bitmap to display on the left of the wizard, either for all pages or for individual pages. If you need to have the bitmap resize to the height of the wizard, call wxWizard::SetBitmapPlacement() and if necessary, wxWizard::SetBitmapBackgroundColour() and wxWizard::SetMinimumBitmapWidth().

To make wizard pages scroll when the display is too small to fit the whole dialog, you can switch layout adaptation on globally with wxDialog::EnableLayoutAdaptation() or per dialog with wxDialog::SetLayoutAdaptationMode(). For more about layout adaptation, see Automatic scrolling dialogs.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxWizardEvent& event)

Event macros for events emitted by this class:

For some events, Veto() can be called to prevent the event from happening.

- EVT_WIZARD_PAGE_CHANGED(id, func):
  The page has just been changed (this event cannot be vetoed).
- EVT_WIZARD_PAGE_CHANGING(id, func):
  The page is being changed (this event can be vetoed).
- EVT_WIZARD_PAGE_SHOWN(id, func):
  The page was shown and laid out (this event cannot be vetoed).
- EVT_WIZARD_CANCEL(id, func):
  The user attempted to cancel the wizard (this event may also be vetoed).
- EVT_WIZARD_HELP(id, func):
  The wizard help button was pressed.
- EVT_WIZARD_FINISHED(id, func):
  The wizard finished button was pressed.

## Extended styles

Use the wxWindow::SetExtraStyle() function to set the following style. You will need to use two-step construction (use the default constructor, call SetExtraStyle(), then call Create).

## Extra styles

This class supports the following extra styles:

- wxWIZARD_EX_HELPBUTTON:
  Shows a Help button using wxID_HELP.

See also wxDialog for other extended styles.

##

Library: wxAdvanced
Category: Common Dialogs

See also:
  wxWizardEvent, wxWizardPage, Wizard Sample

## Public Member Functions

| wxWizard ()
| Default constructor.
| wxWizard (wxWindow *parent, int id=wxID_ANY, const wxString &title=wxEmptyString, const wxBitmap &bitmap=wxNullBitmap, const wxPoint &pos=wxDefaultPosition, long style=wxDEFAULT_DIALOG_STYLE)
| Constructor which really creates the wizard -- if you use this constructor, you shouldn't call Create().
bool | Create (wxWindow *parent, int id=wxID_ANY, const wxString &title=wxEmptyString, const wxBitmap &bitmap=wxNullBitmap, const wxPoint &pos=wxDefaultPosition, long style=536877056)
| Creates the wizard dialog.
virtual void | FitToPage (const wxWizardPage *firstPage)
| This method is obsolete, use GetPageAreaSizer() instead.
const wxBitmap & | GetBitmap () const
| Returns the bitmap used for the wizard.
const wxColour & | GetBitmapBackgroundColour () const
| Returns the colour that should be used to fill the area not taken up by the wizard or page bitmap, if a non-zero bitmap placement flag has been set.
int | GetBitmapPlacement () const
| Returns the flags indicating how the wizard or page bitmap should be expanded and positioned to fit the page height.
virtual wxWizardPage * | GetCurrentPage () const
| Get the current page while the wizard is running.
int | GetMinimumBitmapWidth () const
| Returns the minimum width for the bitmap that will be constructed to contain the actual wizard or page bitmap if a non-zero bitmap placement flag has been set.
virtual wxSizer * | GetPageAreaSizer () const
| Returns pointer to page area sizer.
virtual wxSize | GetPageSize () const
| Returns the size available for the pages.
virtual bool | HasNextPage (wxWizardPage *page)
| Return true if this page is not the last one in the wizard.
virtual bool | HasPrevPage (wxWizardPage *page)
| Returns true if this page is not the last one in the wizard.
virtual bool | RunWizard (wxWizardPage *firstPage)
| Executes the wizard starting from the given page, returning true if it was successfully finished or false if user cancelled it.
void | SetBitmap (const wxBitmap &bitmap)
| Sets the bitmap used for the wizard.
void | SetBitmapBackgroundColour (const wxColour &colour)
| Sets the colour that should be used to fill the area not taken up by the wizard or page bitmap, if a non-zero bitmap placement flag has been set.
void | SetBitmapPlacement (int placement)
| Sets the flags indicating how the wizard or page bitmap should be expanded and positioned to fit the page height.
virtual void | SetBorder (int border)
| Sets width of border around page area.
void | SetMinimumBitmapWidth (int width)
| Sets the minimum width for the bitmap that will be constructed to contain the actual wizard or page bitmap if a non-zero bitmap placement flag has been set.
virtual void | SetPageSize (const wxSize &sizePage)
| Sets the minimal size to be made available for the wizard pages.

List of all members.

## Constructor & Destructor Documentation

wxWizard::wxWizard | ( |  | ) |

Default constructor.

Use this if you wish to derive from wxWizard and then call Create(), for example if you wish to set an extra style with wxWindow::SetExtraStyle() between the two calls.

wxWizard::wxWizard | ( | wxWindow * | parent,
|  | int | id = `wxID_ANY`,
|  | const wxString & | title = `wxEmptyString`,
|  | const wxBitmap & | bitmap = `wxNullBitmap`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | long | style = `wxDEFAULT_DIALOG_STYLE` |
| ) |  |  |

Constructor which really creates the wizard -- if you use this constructor, you shouldn't call Create().

Notice that unlike almost all other wxWidgets classes, there is no size parameter in the wxWizard constructor because the wizard will have a predefined default size by default. If you want to change this, you should use the GetPageAreaSizer() function.

Parameters:

  | parent | The parent window, may be NULL.
  | id | The id of the dialog, will usually be just wxID_ANY.
  | title | The title of the dialog.
  | bitmap | The default bitmap used in the left side of the wizard. See also GetBitmap().
  | pos | The position of the dialog, it will be centered on the screen by default.
  | style | Window style is passed to wxDialog.

## Member Function Documentation

bool wxWizard::Create | ( | wxWindow * | parent,
|  | int | id = `wxID_ANY`,
|  | const wxString & | title = `wxEmptyString`,
|  | const wxBitmap & | bitmap = `wxNullBitmap`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | long | style = `536877056` |
| ) |  |  |

Creates the wizard dialog.

Must be called if the default constructor had been used to create the object.

Notice that unlike almost all other wxWidgets classes, there is no size parameter in the wxWizard constructor because the wizard will have a predefined default size by default. If you want to change this, you should use the GetPageAreaSizer() function.

Parameters:

  | parent | The parent window, may be NULL.
  | id | The id of the dialog, will usually be just -1.
  | title | The title of the dialog.
  | bitmap | The default bitmap used in the left side of the wizard. See also GetBitmap().
  | pos | The position of the dialog, it will be centered on the screen by default.
  | style | Window style is passed to wxDialog.

virtual void wxWizard::FitToPage | ( | const wxWizardPage * | firstPage | ) | `[virtual]`

This method is obsolete, use GetPageAreaSizer() instead.

Sets the page size to be big enough for all the pages accessible via the given firstPage, i.e. this page, its next page and so on.

This method may be called more than once and it will only change the page size if the size required by the new page is bigger than the previously set one. This is useful if the decision about which pages to show is taken during run-time, as in this case, the wizard won't be able to get to all pages starting from a single one and you should call Fit separately for the others.

const wxBitmap& wxWizard::GetBitmap | ( |  | ) | const

Returns the bitmap used for the wizard.

const wxColour& wxWizard::GetBitmapBackgroundColour | ( |  | ) | const

Returns the colour that should be used to fill the area not taken up by the wizard or page bitmap, if a non-zero bitmap placement flag has been set.

See also SetBitmapPlacement().

int wxWizard::GetBitmapPlacement | ( |  | ) | const

Returns the flags indicating how the wizard or page bitmap should be expanded and positioned to fit the page height.

By default, placement is 0 (no expansion is done).

See also SetBitmapPlacement() for the possible values.

virtual wxWizardPage* wxWizard::GetCurrentPage | ( |  | ) | const`[virtual]`

Get the current page while the wizard is running.

NULL is returned if RunWizard() is not being executed now.

int wxWizard::GetMinimumBitmapWidth | ( |  | ) | const

Returns the minimum width for the bitmap that will be constructed to contain the actual wizard or page bitmap if a non-zero bitmap placement flag has been set.

See also SetBitmapPlacement().

virtual wxSizer* wxWizard::GetPageAreaSizer | ( |  | ) | const`[virtual]`

Returns pointer to page area sizer.

The wizard is laid out using sizers and the page area sizer is the place-holder for the pages. All pages are resized before being shown to match the wizard page area.

Page area sizer has a minimal size that is the maximum of several values. First, all pages (or other objects) added to the sizer. Second, all pages reachable by repeatedly applying wxWizardPage::GetNext() to any page inserted into the sizer.

Third, the minimal size specified using SetPageSize() and FitToPage(). Fourth, the total wizard height may be increased to accommodate the bitmap height. Fifth and finally, wizards are never smaller than some built-in minimal size to avoid wizards that are too small.

The caller can use wxSizer::SetMinSize to enlarge it beyond the minimal size. If `wxRESIZE_BORDER` was passed to constructor, user can resize wizard and consequently the page area (but not make it smaller than the minimal size).

It is recommended to add the first page to the page area sizer. For simple wizards, this will enlarge the wizard to fit the biggest page.

For non-linear wizards, the first page of every separate chain should be added. Caller-specified size can be accomplished using wxSizer::SetMinSize(). Adding pages to the page area sizer affects the default border width around page area that can be altered with SetBorder().

virtual wxSize wxWizard::GetPageSize | ( |  | ) | const`[virtual]`

Returns the size available for the pages.

virtual bool wxWizard::HasNextPage | ( | wxWizardPage * | page | ) | `[virtual]`

Return true if this page is not the last one in the wizard.

The base class version implements this by calling page->GetNext but this could be undesirable if, for example, the pages are created on demand only.

See also:
  HasPrevPage()

virtual bool wxWizard::HasPrevPage | ( | wxWizardPage * | page | ) | `[virtual]`

Returns true if this page is not the last one in the wizard.

The base class version implements this by calling page->GetPrev but this could be undesirable if, for example, the pages are created on demand only.

See also:
  HasNextPage()

virtual bool wxWizard::RunWizard | ( | wxWizardPage * | firstPage | ) | `[virtual]`

Executes the wizard starting from the given page, returning true if it was successfully finished or false if user cancelled it.

The firstPage cannot be NULL.

void wxWizard::SetBitmap | ( | const wxBitmap & | bitmap | ) |

Sets the bitmap used for the wizard.

void wxWizard::SetBitmapBackgroundColour | ( | const wxColour & | colour | ) |

Sets the colour that should be used to fill the area not taken up by the wizard or page bitmap, if a non-zero bitmap placement flag has been set.

See also SetBitmapPlacement().

void wxWizard::SetBitmapPlacement | ( | int | placement | ) |

Sets the flags indicating how the wizard or page bitmap should be expanded and positioned to fit the page height.

By default, placement is 0 (no expansion is done). placement is a bitlist with the following possible values:

- wxWIZARD_VALIGN_TOP: Aligns the bitmap at the top.
- wxWIZARD_VALIGN_CENTRE: Centres the bitmap vertically.
- wxWIZARD_VALIGN_BOTTOM: Aligns the bitmap at the bottom.
- wxWIZARD_HALIGN_LEFT: Left-aligns the bitmap.
- wxWIZARD_HALIGN_CENTRE: Centres the bitmap horizontally.
- wxWIZARD_HALIGN_RIGHT: Right-aligns the bitmap.
- wxWIZARD_TILE: todo 67.

See also SetMinimumBitmapWidth().

virtual void wxWizard::SetBorder | ( | int | border | ) | `[virtual]`

Sets width of border around page area.

Default is zero. For backward compatibility, if there are no pages in GetPageAreaSizer(), the default is 5 pixels.

If there is a five point border around all controls in a page and the border around page area is left as zero, a five point white space along all dialog borders will be added to the control border in order to space page controls ten points from the dialog border and non-page controls.

void wxWizard::SetMinimumBitmapWidth | ( | int | width | ) |

Sets the minimum width for the bitmap that will be constructed to contain the actual wizard or page bitmap if a non-zero bitmap placement flag has been set.

If this is not set when using bitmap placement, the initial layout may be incorrect.

See also SetBitmapPlacement().

virtual void wxWizard::SetPageSize | ( | const wxSize & | sizePage | ) | `[virtual]`

Sets the minimal size to be made available for the wizard pages.

The wizard will take into account the size of the bitmap (if any) itself. Also, the wizard will never be smaller than the default size.

The recommended way to use this function is to lay out all wizard pages using the sizers (even though the wizard is not resizable) and then use wxSizer::CalcMin() in a loop to calculate the maximum of minimal sizes of the pages and pass it to SetPageSize().

|  | [ top ]