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