]> git.saurik.com Git - wxWidgets.git/blame - include/wx/wizard.h
extracted platform/compiler detection macros from wx/defs,h into wx/platform.h
[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)
7// Modified by:
8// Created: 15.08.99
9// RCS-ID: $Id$
10// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
11// Licence: wxWindows license
12///////////////////////////////////////////////////////////////////////////////
13
14#ifndef _WX_WIZARD_H_
15#define _WX_WIZARD_H_
16
1e6feb95
VZ
17#if wxUSE_WIZARDDLG
18
b87654f3 19// ----------------------------------------------------------------------------
74b31181 20// headers and other simple declarations
b87654f3
VZ
21// ----------------------------------------------------------------------------
22
23#ifndef WX_PRECOMP
24 #include "wx/dialog.h" // the base class
210e3a3a 25 #include "wx/panel.h" // ditto
b87654f3
VZ
26
27 #include "wx/event.h" // wxEVT_XXX constants
28#endif // WX_PRECOMP
29
77436c4c
JS
30// Extended style to specify a help button
31#define wxWIZARD_EX_HELPBUTTON 0x00000010
32
74b31181
VZ
33// forward declarations
34class WXDLLEXPORT wxWizard;
35
36// ----------------------------------------------------------------------------
37// wxWizardPage is one of the wizards screen: it must know what are the
38// following and preceding pages (which may be NULL for the first/last page).
39//
40// Other than GetNext/Prev() functions, wxWizardPage is just a panel and may be
41// used as such (i.e. controls may be placed directly on it &c).
42// ----------------------------------------------------------------------------
43
44class WXDLLEXPORT wxWizardPage : public wxPanel
45{
46public:
f1df0927
VZ
47 // ctor accepts an optional bitmap which will be used for this page instead
48 // of the default one for this wizard (should be of the same size). Notice
49 // that no other parameters are needed because the wizard will resize and
74b31181 50 // reposition the page anyhow
f1df0927 51 wxWizardPage(wxWizard *parent, const wxBitmap& bitmap = wxNullBitmap);
74b31181
VZ
52
53 // these functions are used by the wizard to show another page when the
54 // user chooses "Back" or "Next" button
55 virtual wxWizardPage *GetPrev() const = 0;
56 virtual wxWizardPage *GetNext() const = 0;
57
f1df0927
VZ
58 // default GetBitmap() will just return m_bitmap which is ok in 99% of
59 // cases - override this method if you want to create the bitmap to be used
60 // dynamically or to do something even more fancy. It's ok to return
61 // wxNullBitmap from here - the default one will be used then.
62 virtual wxBitmap GetBitmap() const { return m_bitmap; }
63
64protected:
65 wxBitmap m_bitmap;
66
74b31181
VZ
67private:
68 DECLARE_ABSTRACT_CLASS(wxWizardPage)
69};
70
71// ----------------------------------------------------------------------------
72// wxWizardPageSimple just returns the pointers given to the ctor and is useful
73// to create a simple wizard where the order of pages never changes.
74//
75// OTOH, it is also possible to dynamicly decide which page to return (i.e.
76// depending on the user's choices) as the wizard sample shows - in order to do
77// this, you must derive from wxWizardPage directly.
78// ----------------------------------------------------------------------------
79
80class WXDLLEXPORT wxWizardPageSimple : public wxWizardPage
81{
82public:
83 // ctor takes the previous and next pages
84 wxWizardPageSimple(wxWizard *parent = NULL, // let it be default ctor too
85 wxWizardPage *prev = (wxWizardPage *)NULL,
86 wxWizardPage *next = (wxWizardPage *)NULL)
87 : wxWizardPage(parent)
88 {
89 m_prev = prev;
90 m_next = next;
91 }
92
93 // the pointers may be also set later - but before starting the wizard
94 void SetPrev(wxWizardPage *prev) { m_prev = prev; }
95 void SetNext(wxWizardPage *next) { m_next = next; }
96
97 // a convenience function to make the pages follow each other
98 static void Chain(wxWizardPageSimple *first, wxWizardPageSimple *second)
99 {
100 wxCHECK_RET( first && second,
223d09f6 101 wxT("NULL passed to wxWizardPageSimple::Chain") );
74b31181
VZ
102
103 first->SetNext(second);
104 second->SetPrev(first);
105 }
106
107 // base class pure virtuals
108 virtual wxWizardPage *GetPrev() const;
109 virtual wxWizardPage *GetNext() const;
110
111private:
112 // pointers are private, the derived classes shouldn't mess with them -
113 // just derive from wxWizardPage directly to implement different behaviour
114 wxWizardPage *m_prev,
115 *m_next;
116
117 DECLARE_DYNAMIC_CLASS(wxWizardPageSimple)
118};
119
66cd017c
VZ
120// ----------------------------------------------------------------------------
121// wxWizard
122// ----------------------------------------------------------------------------
123
74b31181 124class WXDLLEXPORT wxWizardBase : public wxDialog
66cd017c
VZ
125{
126public:
127 // create the wizard control
128 static wxWizard *Create(wxWindow *parent,
129 int id = -1,
130 const wxString& title = wxEmptyString,
131 const wxBitmap& bitmap = wxNullBitmap,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize);
134
74b31181
VZ
135 // executes the wizard starting from the given page, returns TRUE if it was
136 // successfully finished, FALSE if user cancelled it
137 virtual bool RunWizard(wxWizardPage *firstPage) = 0;
66cd017c
VZ
138
139 // get the current page (NULL if RunWizard() isn't running)
74b31181 140 virtual wxWizardPage *GetCurrentPage() const = 0;
4fe5383d 141
f6bcfd97
BP
142 // set the min size which should be available for the pages: a
143 // wizard will take into account the size of the bitmap (if any)
144 // itself and will never be less than some predefined fixed size
145 virtual void SetPageSize(const wxSize& size) = 0;
146
4fe5383d
VZ
147 // get the size available for the page: the wizards are not resizeable, so
148 // this size doesn't change
149 virtual wxSize GetPageSize() const = 0;
66cd017c
VZ
150};
151
74b31181
VZ
152// include the real class declaration
153#include "wx/generic/wizard.h"
154
66cd017c 155// ----------------------------------------------------------------------------
74b31181
VZ
156// wxWizardEvent class represents an event generated by the wizard: this event
157// is first sent to the page itself and, if not processed there, goes up the
158// window hierarchy as usual
66cd017c
VZ
159// ----------------------------------------------------------------------------
160
161class WXDLLEXPORT wxWizardEvent : public wxNotifyEvent
162{
163public:
74b31181
VZ
164 wxWizardEvent(wxEventType type = wxEVT_NULL,
165 int id = -1,
166 bool direction = TRUE);
66cd017c 167
74b31181
VZ
168 // for EVT_WIZARD_PAGE_CHANGING, return TRUE if we're going forward or
169 // FALSE otherwise and for EVT_WIZARD_PAGE_CHANGED return TRUE if we came
170 // from the previous page and FALSE if we returned from the next one
171 // (this function doesn't make sense for CANCEL events)
172 bool GetDirection() const { return m_direction; }
66cd017c
VZ
173
174private:
74b31181 175 bool m_direction;
66cd017c
VZ
176
177 DECLARE_DYNAMIC_CLASS(wxWizardEvent)
178};
179
180// ----------------------------------------------------------------------------
181// macros for handling wxWizardEvents
182// ----------------------------------------------------------------------------
183
2e4df4bf
VZ
184BEGIN_DECLARE_EVENT_TYPES()
185 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGED, 900)
186 DECLARE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGING, 901)
187 DECLARE_EVENT_TYPE(wxEVT_WIZARD_CANCEL, 902)
188END_DECLARE_EVENT_TYPES()
189
66cd017c
VZ
190typedef void (wxEvtHandler::*wxWizardEventFunction)(wxWizardEvent&);
191
74b31181 192// notifies that the page has just been changed (can't be vetoed)
2e4df4bf 193#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
194
195// the user pressed "<Back" or "Next>" button and the page is going to be
196// changed - unless the event handler vetoes the event
2e4df4bf 197#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
198
199// the user pressed "Cancel" button and the wizard is going to be dismissed -
200// unless the event handler vetoes the event
2e4df4bf 201#define EVT_WIZARD_CANCEL(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_WIZARD_CANCEL, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxWizardEventFunction) & fn, (wxObject *)NULL),
66cd017c 202
1e6feb95
VZ
203#endif // wxUSE_WIZARDDLG
204
66cd017c 205#endif // _WX_WIZARD_H_