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