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 ///////////////////////////////////////////////////////////////////////////////
19 // ----------------------------------------------------------------------------
20 // headers and other simple declarations
21 // ----------------------------------------------------------------------------
24 #include "wx/dialog.h" // the base class
26 #include "wx/event.h" // wxEVT_XXX constants
29 // Extended style to specify a help button
30 #define wxWIZARD_EX_HELPBUTTON 0x00000010
32 // forward declarations
33 class WXDLLEXPORT wxWizard
;
35 // ----------------------------------------------------------------------------
36 // wxWizardPage is one of the wizards screen: it must know what are the
37 // following and preceding pages (which may be NULL for the first/last page).
39 // Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
40 // used as such (i.e. controls may be placed directly on it &c).
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxWizardPage
: public wxPanel
46 // ctor accepts an optional bitmap which will be used for this page instead
47 // of the default one for this wizard (should be of the same size). Notice
48 // that no other parameters are needed because the wizard will resize and
49 // reposition the page anyhow
50 wxWizardPage(wxWizard
*parent
, const wxBitmap
& bitmap
= wxNullBitmap
);
52 // these functions are used by the wizard to show another page when the
53 // user chooses "Back" or "Next" button
54 virtual wxWizardPage
*GetPrev() const = 0;
55 virtual wxWizardPage
*GetNext() const = 0;
57 // default GetBitmap() will just return m_bitmap which is ok in 99% of
58 // cases - override this method if you want to create the bitmap to be used
59 // dynamically or to do something even more fancy. It's ok to return
60 // wxNullBitmap from here - the default one will be used then.
61 virtual wxBitmap
GetBitmap() const { return m_bitmap
; }
67 DECLARE_ABSTRACT_CLASS(wxWizardPage
)
70 // ----------------------------------------------------------------------------
71 // wxWizardPageSimple just returns the pointers given to the ctor and is useful
72 // to create a simple wizard where the order of pages never changes.
74 // OTOH, it is also possible to dynamicly decide which page to return (i.e.
75 // depending on the user's choices) as the wizard sample shows - in order to do
76 // this, you must derive from wxWizardPage directly.
77 // ----------------------------------------------------------------------------
79 class WXDLLEXPORT wxWizardPageSimple
: public wxWizardPage
82 // ctor takes the previous and next pages
83 wxWizardPageSimple(wxWizard
*parent
= NULL
, // let it be default ctor too
84 wxWizardPage
*prev
= (wxWizardPage
*)NULL
,
85 wxWizardPage
*next
= (wxWizardPage
*)NULL
)
86 : wxWizardPage(parent
)
92 // the pointers may be also set later - but before starting the wizard
93 void SetPrev(wxWizardPage
*prev
) { m_prev
= prev
; }
94 void SetNext(wxWizardPage
*next
) { m_next
= next
; }
96 // a convenience function to make the pages follow each other
97 static void Chain(wxWizardPageSimple
*first
, wxWizardPageSimple
*second
)
99 wxCHECK_RET( first
&& second
,
100 wxT("NULL passed to wxWizardPageSimple::Chain") );
102 first
->SetNext(second
);
103 second
->SetPrev(first
);
106 // base class pure virtuals
107 virtual wxWizardPage
*GetPrev() const;
108 virtual wxWizardPage
*GetNext() const;
111 // pointers are private, the derived classes shouldn't mess with them -
112 // just derive from wxWizardPage directly to implement different behaviour
113 wxWizardPage
*m_prev
,
116 DECLARE_DYNAMIC_CLASS(wxWizardPageSimple
)
119 // ----------------------------------------------------------------------------
121 // ----------------------------------------------------------------------------
123 class WXDLLEXPORT wxWizardBase
: public wxDialog
126 // create the wizard control
127 static wxWizard
*Create(wxWindow
*parent
,
129 const wxString
& title
= wxEmptyString
,
130 const wxBitmap
& bitmap
= wxNullBitmap
,
131 const wxPoint
& pos
= wxDefaultPosition
,
132 const wxSize
& size
= wxDefaultSize
);
134 // executes the wizard starting from the given page, returns TRUE if it was
135 // successfully finished, FALSE if user cancelled it
136 virtual bool RunWizard(wxWizardPage
*firstPage
) = 0;
138 // get the current page (NULL if RunWizard() isn't running)
139 virtual wxWizardPage
*GetCurrentPage() const = 0;
141 // set the min size which should be available for the pages: a
142 // wizard will take into account the size of the bitmap (if any)
143 // itself and will never be less than some predefined fixed size
144 virtual void SetPageSize(const wxSize
& size
) = 0;
146 // get the size available for the page: the wizards are not resizeable, so
147 // this size doesn't change
148 virtual wxSize
GetPageSize() const = 0;
151 // include the real class declaration
152 #include "wx/generic/wizard.h"
154 // ----------------------------------------------------------------------------
155 // wxWizardEvent class represents an event generated by the wizard: this event
156 // is first sent to the page itself and, if not processed there, goes up the
157 // window hierarchy as usual
158 // ----------------------------------------------------------------------------
160 class WXDLLEXPORT wxWizardEvent
: public wxNotifyEvent
163 wxWizardEvent(wxEventType type
= wxEVT_NULL
,
165 bool direction
= TRUE
);
167 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
168 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
169 // from the previous page and FALSE if we returned from the next one
170 // (this function doesn't make sense for CANCEL events)
171 bool GetDirection() const { return m_direction
; }
176 DECLARE_DYNAMIC_CLASS(wxWizardEvent
)
179 // ----------------------------------------------------------------------------
180 // macros for handling wxWizardEvents
181 // ----------------------------------------------------------------------------
183 BEGIN_DECLARE_EVENT_TYPES()
184 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGED
, 900)
185 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGING
, 901)
186 DECLARE_EVENT_TYPE(wxEVT_WIZARD_CANCEL
, 902)
187 END_DECLARE_EVENT_TYPES()
189 typedef void (wxEvtHandler::*wxWizardEventFunction
)(wxWizardEvent
&);
191 // notifies that the page has just been changed (can't be vetoed)
192 #define EVT_WIZARD_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
194 // the user pressed "<Back" or "Next>" button and the page is going to be
195 // changed - unless the event handler vetoes the event
196 #define EVT_WIZARD_PAGE_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_PAGE_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
198 // the user pressed "Cancel" button and the wizard is going to be dismissed -
199 // unless the event handler vetoes the event
200 #define EVT_WIZARD_CANCEL(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_CANCEL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
202 #endif // wxUSE_WIZARDDLG
204 #endif // _WX_WIZARD_H_