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