]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wizard.h
another compilation fix for over-optimized #includes
[wxWidgets.git] / include / wx / wizard.h
CommitLineData
66cd017c
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wizard.h
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.
6// Smith)
a0a48a3f
VZ
7// Modified by: Robert Cavanaugh
8// Added capability to use .WXR resource files in Wizard pages
9// Added wxWIZARD_HELP event
66cd017c
VZ
10// Created: 15.08.99
11// RCS-ID: $Id$
12// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
13// Licence: wxWindows license
14///////////////////////////////////////////////////////////////////////////////
15
16#ifndef _WX_WIZARD_H_
17#define _WX_WIZARD_H_
18
1e6feb95
VZ
19#if wxUSE_WIZARDDLG
20
b87654f3 21// ----------------------------------------------------------------------------
74b31181 22// headers and other simple declarations
b87654f3
VZ
23// ----------------------------------------------------------------------------
24
25#ifndef WX_PRECOMP
26 #include "wx/dialog.h" // the base class
210e3a3a 27 #include "wx/panel.h" // ditto
b87654f3
VZ
28
29 #include "wx/event.h" // wxEVT_XXX constants
30#endif // WX_PRECOMP
31
77436c4c
JS
32// Extended style to specify a help button
33#define wxWIZARD_EX_HELPBUTTON 0x00000010
34
74b31181
VZ
35// forward declarations
36class WXDLLEXPORT wxWizard;
37
38// ----------------------------------------------------------------------------
39// wxWizardPage is one of the wizards screen: it must know what are the
40// following and preceding pages (which may be NULL for the first/last page).
41//
42// Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
43// used as such (i.e. controls may be placed directly on it &c).
44// ----------------------------------------------------------------------------
45
46class WXDLLEXPORT wxWizardPage : public wxPanel
47{
48public:
c7de4135 49 wxWizardPage() { Init(); }
c7de4135 50
f1df0927
VZ
51 // ctor accepts an optional bitmap which will be used for this page instead
52 // of the default one for this wizard (should be of the same size). Notice
53 // that no other parameters are needed because the wizard will resize and
74b31181 54 // reposition the page anyhow
a0a48a3f 55 wxWizardPage(wxWizard *parent,
c7de4135
VS
56 const wxBitmap& bitmap = wxNullBitmap,
57 const wxChar* resource = NULL);
58
59 bool Create(wxWizard *parent,
a0a48a3f
VZ
60 const wxBitmap& bitmap = wxNullBitmap,
61 const wxChar* resource = NULL);
74b31181
VZ
62
63 // these functions are used by the wizard to show another page when the
64 // user chooses "Back" or "Next" button
65 virtual wxWizardPage *GetPrev() const = 0;
66 virtual wxWizardPage *GetNext() const = 0;
67
f1df0927
VZ
68 // default GetBitmap() will just return m_bitmap which is ok in 99% of
69 // cases - override this method if you want to create the bitmap to be used
70 // dynamically or to do something even more fancy. It's ok to return
71 // wxNullBitmap from here - the default one will be used then.
636d266b 72 virtual wxBitmap GetBitmap() const { return m_bitmap; }
f1df0927
VZ
73
74protected:
750cefbc
VZ
75 // common part of ctors:
76 void Init();
77
636d266b 78 wxBitmap m_bitmap;
f1df0927 79
74b31181
VZ
80private:
81 DECLARE_ABSTRACT_CLASS(wxWizardPage)
82};
83
84// ----------------------------------------------------------------------------
85// wxWizardPageSimple just returns the pointers given to the ctor and is useful
86// to create a simple wizard where the order of pages never changes.
87//
88// OTOH, it is also possible to dynamicly decide which page to return (i.e.
89// depending on the user's choices) as the wizard sample shows - in order to do
90// this, you must derive from wxWizardPage directly.
91// ----------------------------------------------------------------------------
92
93class WXDLLEXPORT wxWizardPageSimple : public wxWizardPage
94{
95public:
c7de4135 96 wxWizardPageSimple() { Init(); }
c7de4135 97
74b31181 98 // ctor takes the previous and next pages
c7de4135 99 wxWizardPageSimple(wxWizard *parent,
74b31181 100 wxWizardPage *prev = (wxWizardPage *)NULL,
a0a48a3f
VZ
101 wxWizardPage *next = (wxWizardPage *)NULL,
102 const wxBitmap& bitmap = wxNullBitmap,
103 const wxChar* resource = NULL)
c7de4135
VS
104 {
105 Create(parent, prev, next, bitmap, resource);
106 }
107
108 bool Create(wxWizard *parent = NULL, // let it be default ctor too
109 wxWizardPage *prev = (wxWizardPage *)NULL,
110 wxWizardPage *next = (wxWizardPage *)NULL,
111 const wxBitmap& bitmap = wxNullBitmap,
112 const wxChar* resource = NULL)
74b31181
VZ
113 {
114 m_prev = prev;
115 m_next = next;
c7de4135 116 return wxWizardPage::Create(parent, bitmap, resource);
74b31181
VZ
117 }
118
119 // the pointers may be also set later - but before starting the wizard
120 void SetPrev(wxWizardPage *prev) { m_prev = prev; }
121 void SetNext(wxWizardPage *next) { m_next = next; }
122
123 // a convenience function to make the pages follow each other
124 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second)
125 {
126 wxCHECK_RET( first && second,
223d09f6 127 wxT("NULL passed to wxWizardPageSimple::Chain") );
74b31181
VZ
128
129 first->SetNext(second);
130 second->SetPrev(first);
131 }
132
133 // base class pure virtuals
134 virtual wxWizardPage *GetPrev() const;
135 virtual wxWizardPage *GetNext() const;
136
137private:
750cefbc
VZ
138 // common part of ctors:
139 void Init()
140 {
141 m_prev = m_next = NULL;
142 }
143
74b31181
VZ
144 // pointers are private, the derived classes shouldn't mess with them -
145 // just derive from wxWizardPage directly to implement different behaviour
146 wxWizardPage *m_prev,
147 *m_next;
148
149 DECLARE_DYNAMIC_CLASS(wxWizardPageSimple)
22f3361e 150 DECLARE_NO_COPY_CLASS(wxWizardPageSimple)
74b31181
VZ
151};
152
66cd017c
VZ
153// ----------------------------------------------------------------------------
154// wxWizard
155// ----------------------------------------------------------------------------
156
74b31181 157class WXDLLEXPORT wxWizardBase : public wxDialog
66cd017c
VZ
158{
159public:
750cefbc
VZ
160 /*
161 The derived class (i.e. the real wxWizard) has a ctor and Create()
162 function taking the following arguments:
163
164 wxWizard(wxWindow *parent,
165 int id = -1,
166 const wxString& title = wxEmptyString,
167 const wxBitmap& bitmap = wxNullBitmap,
168 const wxPoint& pos = wxDefaultPosition);
169 */
66cd017c 170
74b31181
VZ
171 // executes the wizard starting from the given page, returns TRUE if it was
172 // successfully finished, FALSE if user cancelled it
173 virtual bool RunWizard(wxWizardPage *firstPage) = 0;
66cd017c
VZ
174
175 // get the current page (NULL if RunWizard() isn't running)
74b31181 176 virtual wxWizardPage *GetCurrentPage() const = 0;
4fe5383d 177
f6bcfd97
BP
178 // set the min size which should be available for the pages: a
179 // wizard will take into account the size of the bitmap (if any)
180 // itself and will never be less than some predefined fixed size
181 virtual void SetPageSize(const wxSize& size) = 0;
182
4fe5383d
VZ
183 // get the size available for the page: the wizards are not resizeable, so
184 // this size doesn't change
185 virtual wxSize GetPageSize() const = 0;
c73b439f
VZ
186
187 // set the best size for the wizard, i.e. make it big enough to contain all
188 // of the pages starting from the given one
189 //
190 // this function may be called several times and possible with different
191 // pages in which case it will only increase the page size if needed (this
192 // may be useful if not all pages are accessible from the first one by
193 // default)
3ee58334 194 virtual void FitToPage(const wxWizardPage *firstPage) = 0;
750cefbc
VZ
195
196 // wxWizard should be created using "new wxWizard" now, not with Create()
197#ifdef WXWIN_COMPATIBILITY_2_2
ef669359
VZ
198 static wxWizard *Create(wxWindow *parent,
199 int id = -1,
200 const wxString& title = wxEmptyString,
201 const wxBitmap& bitmap = wxNullBitmap,
202 const wxPoint& pos = wxDefaultPosition,
203 const wxSize& size = wxDefaultSize);
750cefbc 204#endif // WXWIN_COMPATIBILITY_2_2
2b5f62a0
VZ
205
206 // the methods below may be overridden by the derived classes to provide
207 // custom logic for determining the pages order
208
209 virtual bool HasNextPage(wxWizardPage *page)
210 { return page->GetNext() != NULL; }
211
212 virtual bool HasPrevPage(wxWizardPage *page)
213 { return page->GetPrev() != NULL; }
66cd017c
VZ
214};
215
74b31181
VZ
216// include the real class declaration
217#include "wx/generic/wizard.h"
218
66cd017c 219// ----------------------------------------------------------------------------
74b31181
VZ
220// wxWizardEvent class represents an event generated by the wizard: this event
221// is first sent to the page itself and, if not processed there, goes up the
222// window hierarchy as usual
66cd017c
VZ
223// ----------------------------------------------------------------------------
224
225class WXDLLEXPORT wxWizardEvent : public wxNotifyEvent
226{
227public:
74b31181
VZ
228 wxWizardEvent(wxEventType type = wxEVT_NULL,
229 int id = -1,
f80bf901
VZ
230 bool direction = TRUE,
231 wxWizardPage* page = NULL);
66cd017c 232
74b31181
VZ
233 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
234 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
235 // from the previous page and FALSE if we returned from the next one
236 // (this function doesn't make sense for CANCEL events)
237 bool GetDirection() const { return m_direction; }
66cd017c 238
f80bf901
VZ
239 wxWizardPage* GetPage() const { return m_page; }
240
66cd017c 241private:
74b31181 242 bool m_direction;
f80bf901 243 wxWizardPage* m_page;
66cd017c
VZ
244
245 DECLARE_DYNAMIC_CLASS(wxWizardEvent)
22f3361e 246 DECLARE_NO_COPY_CLASS(wxWizardEvent)
66cd017c
VZ
247};
248
249// ----------------------------------------------------------------------------
250// macros for handling wxWizardEvents
251// ----------------------------------------------------------------------------
252
2e4df4bf
VZ
253BEGIN_DECLARE_EVENT_TYPES()
254 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGED, 900)
255 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGING, 901)
256 DECLARE_EVENT_TYPE(wxEVT_WIZARD_CANCEL, 902)
f80bf901 257 DECLARE_EVENT_TYPE(wxEVT_WIZARD_HELP, 903)
1d30a0a1 258 DECLARE_EVENT_TYPE(wxEVT_WIZARD_FINISHED, 903)
2e4df4bf
VZ
259END_DECLARE_EVENT_TYPES()
260
66cd017c
VZ
261typedef void (wxEvtHandler::*wxWizardEventFunction)(wxWizardEvent&);
262
74b31181 263// notifies that the page has just been changed (can't be vetoed)
2e4df4bf 264#define EVT_WIZARD_PAGE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_PAGE_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
66cd017c
VZ
265
266// the user pressed "<Back" or "Next>" button and the page is going to be
267// changed - unless the event handler vetoes the event
2e4df4bf 268#define EVT_WIZARD_PAGE_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_PAGE_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
66cd017c
VZ
269
270// the user pressed "Cancel" button and the wizard is going to be dismissed -
271// unless the event handler vetoes the event
2e4df4bf 272#define EVT_WIZARD_CANCEL(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_CANCEL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
66cd017c 273
1d30a0a1
JS
274// the user pressed "Finish" button and the wizard is going to be dismissed -
275#define EVT_WIZARD_FINISHED(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_FINISHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
276
f80bf901 277// the user pressed "Help" button
fec679a4 278#define EVT_WIZARD_HELP(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_HELP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
f80bf901 279
1e6feb95
VZ
280#endif // wxUSE_WIZARDDLG
281
66cd017c 282#endif // _WX_WIZARD_H_