1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWizard class: a GUI control presenting the user with a
4 // sequence of dialogs which allows to simply perform some task
5 // Author: Vadim Zeitlin (partly based on work by Ron Kuris and Kevin B.
10 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
11 // Licence: wxWindows license
12 ///////////////////////////////////////////////////////////////////////////////
17 // ----------------------------------------------------------------------------
18 // headers and other simple declarations
19 // ----------------------------------------------------------------------------
22 #include "wx/dialog.h" // the base class
24 #include "wx/event.h" // wxEVT_XXX constants
27 // forward declarations
28 class WXDLLEXPORT wxWizard
;
30 // ----------------------------------------------------------------------------
31 // wxWizardPage is one of the wizards screen: it must know what are the
32 // following and preceding pages (which may be NULL for the first/last page).
34 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
35 // used as such (i.e. controls may be placed directly on it &c).
36 // ----------------------------------------------------------------------------
38 class WXDLLEXPORT wxWizardPage
: public wxPanel
41 // ctor: no other parameters are needed because the wizard will resize and
42 // reposition the page anyhow
43 wxWizardPage(wxWizard
*parent
);
45 // these functions are used by the wizard to show another page when the
46 // user chooses "Back" or "Next" button
47 virtual wxWizardPage
*GetPrev() const = 0;
48 virtual wxWizardPage
*GetNext() const = 0;
51 DECLARE_ABSTRACT_CLASS(wxWizardPage
)
54 // ----------------------------------------------------------------------------
55 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
56 // to create a simple wizard where the order of pages never changes.
58 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
59 // depending on the user's choices) as the wizard sample shows - in order to do
60 // this, you must derive from wxWizardPage directly.
61 // ----------------------------------------------------------------------------
63 class WXDLLEXPORT wxWizardPageSimple
: public wxWizardPage
66 // ctor takes the previous and next pages
67 wxWizardPageSimple(wxWizard
*parent
= NULL
, // let it be default ctor too
68 wxWizardPage
*prev
= (wxWizardPage
*)NULL
,
69 wxWizardPage
*next
= (wxWizardPage
*)NULL
)
70 : wxWizardPage(parent
)
76 // the pointers may be also set later - but before starting the wizard
77 void SetPrev(wxWizardPage
*prev
) { m_prev
= prev
; }
78 void SetNext(wxWizardPage
*next
) { m_next
= next
; }
80 // a convenience function to make the pages follow each other
81 static void Chain(wxWizardPageSimple
*first
, wxWizardPageSimple
*second
)
83 wxCHECK_RET( first
&& second
,
84 T("NULL passed to wxWizardPageSimple::Chain") );
86 first
->SetNext(second
);
87 second
->SetPrev(first
);
90 // base class pure virtuals
91 virtual wxWizardPage
*GetPrev() const;
92 virtual wxWizardPage
*GetNext() const;
95 // pointers are private, the derived classes shouldn't mess with them -
96 // just derive from wxWizardPage directly to implement different behaviour
100 DECLARE_DYNAMIC_CLASS(wxWizardPageSimple
)
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 class WXDLLEXPORT wxWizardBase
: public wxDialog
110 // create the wizard control
111 static wxWizard
*Create(wxWindow
*parent
,
113 const wxString
& title
= wxEmptyString
,
114 const wxBitmap
& bitmap
= wxNullBitmap
,
115 const wxPoint
& pos
= wxDefaultPosition
,
116 const wxSize
& size
= wxDefaultSize
);
118 // executes the wizard starting from the given page, returns TRUE if it was
119 // successfully finished, FALSE if user cancelled it
120 virtual bool RunWizard(wxWizardPage
*firstPage
) = 0;
122 // get the current page (NULL if RunWizard() isn't running)
123 virtual wxWizardPage
*GetCurrentPage() const = 0;
126 // include the real class declaration
127 #include "wx/generic/wizard.h"
129 // ----------------------------------------------------------------------------
130 // wxWizardEvent class represents an event generated by the wizard: this event
131 // is first sent to the page itself and, if not processed there, goes up the
132 // window hierarchy as usual
133 // ----------------------------------------------------------------------------
135 class WXDLLEXPORT wxWizardEvent
: public wxNotifyEvent
138 wxWizardEvent(wxEventType type
= wxEVT_NULL
,
140 bool direction
= TRUE
);
142 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
143 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
144 // from the previous page and FALSE if we returned from the next one
145 // (this function doesn't make sense for CANCEL events)
146 bool GetDirection() const { return m_direction
; }
151 DECLARE_DYNAMIC_CLASS(wxWizardEvent
)
154 // ----------------------------------------------------------------------------
155 // macros for handling wxWizardEvents
156 // ----------------------------------------------------------------------------
158 typedef void (wxEvtHandler::*wxWizardEventFunction
)(wxWizardEvent
&);
160 // notifies that the page has just been changed (can't be vetoed)
161 #define EVT_WIZARD_PAGE_CHANGED(id, fn) { wxEVT_WIZARD_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL },
163 // the user pressed "<Back" or "Next>" button and the page is going to be
164 // changed - unless the event handler vetoes the event
165 #define EVT_WIZARD_PAGE_CHANGING(id, fn) { wxEVT_WIZARD_PAGE_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL },
167 // the user pressed "Cancel" button and the wizard is going to be dismissed -
168 // unless the event handler vetoes the event
169 #define EVT_WIZARD_CANCEL(id, fn) { wxEVT_WIZARD_CANCEL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL },
171 #endif // _WX_WIZARD_H_