Contents Up Previous Next

wxWizard

wxWizard is the central class for implementing 'wizard-like' dialogs. These dialogs are mostly familiar to Windows users and are nothing else but a sequence of 'pages' each of them displayed inside a dialog which has the buttons to pass 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 object of wxWizard class using either the non default constructor or a default one followed by call to Create function. Then you should add all pages you want the wizard to show and call RunWizard. Finally, don't forget to call wizard->Destroy().

Derived from

wxDialog
wxPanel
wxWindow
wxEvtHandler
wxObject

Include files

<wx/wizard.h>

Event table macros

To process input from a wizard dialog, use these event handler macros to direct input to member functions that take a wxWizardEvent argument. For some events, Veto() can be called to prevent the event from happening.

EVT_WIZARD_PAGE_CHANGED(id, func) The page has been just changed (this event can not be vetoed).
EVT_WIZARD_PAGE_CHANGING(id, func) The page is being changed (this event can 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).

wxWIZARD_EX_HELPBUTTON Shows a Help button using wxID_HELP.

See also wxDialog for other extended styles.

See also

wxWizardEvent, wxWizardPage, wxWizard sample

Members

wxWizard::wxWizard
wxWizard::Create
wxWizard::FitToPage
wxWizard::GetCurrentPage
wxWizard::GetPageAreaSizer
wxWizard::GetPageSize
wxWizard::HasNextPage
wxWizard::HasPrevPage
wxWizard::RunWizard
wxWizard::SetPageSize
wxWizard::SetBorder


wxWizard::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(wxWindow* parent, int id = -1, 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 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

id

title

bitmap

pos

style


wxWizard::Create

bool Create(wxWindow* parent, int id = -1, const wxString& title = wxEmptyString, const wxBitmap& bitmap = wxNullBitmap, const wxPoint& pos = wxDefaultPosition, long style = wxDEFAULT_DIALOG_STYLE)

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 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

id

title

bitmap

pos

style


wxWizard::FitToPage

void FitToPage(const wxWizardPage* firstPage)

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 the 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.


wxWizard::GetCurrentPage

wxWizardPage* GetCurrentPage() const

Get the current page while the wizard is running. NULL is returned if RunWizard() is not being executed now.


wxWizard::GetPageAreaSizer

virtual wxSizer* GetPageAreaSizer() const

Returns pointer to page area sizer. Wizard is laid out using sizers and 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 minimal size that is 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, minimal size specified using SetPageSize and FitToPage. Fourth, the total wizard height may be increased to accomodate the bitmap height. Fifth and finally, wizards are never smaller some built-in minimal size to avoid too small wizards.

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

It is recommended to add first page to page area sizer. For simple wizards, this will enlarge the wizard to fit biggest page. For non-linear wizards, first page of every separate chain should be added. Caller-specified size can be accomplished using wxSizer::SetMinSize.

Adding pages to page area sizer affects default border width around page area that can be altered with SetBorder.


wxWizard::GetPageSize

wxSize GetPageSize() const

Returns the size available for the pages.


wxWizard::HasNextPage

virtual bool HasNextPage(wxWizardPage *page)

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


wxWizard::HasPrevPage

virtual bool HasPrevPage(wxWizardPage *page)

Return 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


wxWizard::RunWizard

bool RunWizard(wxWizardPage* firstPage)

Executes the wizard starting from the given page, returns true if it was successfully finished or false if user cancelled it. The firstPage can not be NULL.


wxWizard::SetPageSize

void SetPageSize(const wxSize& sizePage)

This method is obsolete, use GetPageAreaSizer instead.

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 layout all wizard pages using the sizers (even though the wizard is not resizeable) and then use wxSizer::CalcMin in a loop to calculate the maximum of minimal sizes of the pages and pass it to SetPageSize().


wxWizard::SetBorder

void SetBorder(int border)

Sets width of border around page area. Default is zero. For backward compatibility, if there are no pages in GetPageAreaSizer, default is 5 pixels.

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