]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/wizard.tex
better documentation for wxWindow::SetSizerAndFit()
[wxWidgets.git] / docs / latex / wx / wizard.tex
CommitLineData
f6bcfd97
BP
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: wizard.tex
3%% Purpose: wxWizard class documentation
4%% Author: Vadim Zeitlin
07f20d9a 5%% Modified by: Robert Vazan (sizers)
f6bcfd97
BP
6%% Created: 02.04.00
7%% RCS-ID: $Id$
8%% Copyright: (c) Vadim Zeitlin
8795498c 9%% License: wxWindows license
f6bcfd97
BP
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxWizard}}\label{wxwizard}
13
14wxWizard is the central class for implementing `wizard-like' dialogs. These
027aa6fa
JS
15dialogs are mostly familiar to Windows users and are nothing other than a
16sequence of `pages', each displayed inside a dialog which has the
17buttons to navigate to the next (and previous) pages.
f6bcfd97
BP
18
19The wizards are typically used to decompose a complex dialog into several
20simple steps and are mainly useful to the novice users, hence it is important
21to keep them as simple as possible.
22
027aa6fa
JS
23To show a wizard dialog, you must first create an instance of the wxWizard class
24using either the non-default constructor or a default one followed by call to the
750cefbc
VZ
25\helpref{Create}{wxwizardcreate} function. Then you should add all pages you
26want the wizard to show and call \helpref{RunWizard}{wxwizardrunwizard}.
b18f44e2 27Finally, don't forget to call {\tt wizard->Destroy()}, otherwise your application will hang on exit due to an undestroyed window.
f6bcfd97 28
3aa8e4ea
JS
29You can supply a bitmap to display on the left of the wizard, either for all pages
30or for individual pages. If you need to have the bitmap resize to the height of the wizard,
31call \helpref{wxWizard::SetBitmapPlacement}{wxwizardsetbitmapplacement} and if necessary,\rtfsp
81d2719d 32\helpref{wxWizard::SetBitmapBackgroundColour}{wxwizardsetbitmapbackgroundcolour} and \helpref{wxWizard::SetMinimumBitmapWidth}{wxwizardsetminimumbitmapwidth}.
3aa8e4ea
JS
33
34To make wizard pages scroll when the display is too small to fit the whole dialog, you can switch
35layout adaptation on globally with \helpref{wxDialog::EnableLayoutAdaptation}{wxdialogenablelayoutadaptation} or
36per dialog with \helpref{wxDialog::SetLayoutAdaptationMode}{wxdialogsetlayoutadaptationmode}. For more
37about layout adaptation, see \helpref{Automatic scrolling dialogs}{autoscrollingdialogs}.
38
f6bcfd97
BP
39\wxheading{Derived from}
40
41\helpref{wxDialog}{wxdialog}\\
7376079d 42\helpref{wxTopLevelWindow}{wxtoplevelwindow}\\
f6bcfd97
BP
43\helpref{wxWindow}{wxwindow}\\
44\helpref{wxEvtHandler}{wxevthandler}\\
45\helpref{wxObject}{wxobject}
46
47\wxheading{Include files}
48
49<wx/wizard.h>
50
a7af285d
VZ
51\wxheading{Library}
52
53\helpref{wxAdv}{librarieslist}
54
f6bcfd97
BP
55\wxheading{Event table macros}
56
57To process input from a wizard dialog, use these event handler macros to
58direct input to member functions that take a
59\helpref{wxWizardEvent}{wxwizardevent} argument. For some events,
60\helpref{Veto()}{wxnotifyeventveto} can be called to prevent the event from
61happening.
62
63\twocolwidtha{7cm}
64\begin{twocollist}\itemsep=2pt
027aa6fa
JS
65\twocolitem{{\bf EVT\_WIZARD\_PAGE\_CHANGED(id, func)}}{The page has just been
66changed (this event cannot be vetoed).}
f6bcfd97
BP
67\twocolitem{{\bf EVT\_WIZARD\_PAGE\_CHANGING(id, func)}}{The page is being
68changed (this event can be vetoed).}
69\twocolitem{{\bf EVT\_WIZARD\_CANCEL(id, func)}}{The user attempted to cancel
70the wizard (this event may also be vetoed).}
f80bf901 71\twocolitem{{\bf EVT\_WIZARD\_HELP(id, func)}}{The wizard help button was pressed.}
1d30a0a1 72\twocolitem{{\bf EVT\_WIZARD\_FINISHED(id, func)}}{The wizard finished button was pressed.}
d2c2afc9 73\end{twocollist}
f6bcfd97 74
213ba43b
JS
75\wxheading{Extended styles}
76
77Use the \helpref{wxWindow::SetExtraStyle}{wxwindowsetextrastyle} function to set the following
78style. You will need to use two-step construction (use the default constructor, call {\bf SetExtraStyle}, then call {\bf Create}).
79
80\twocolwidtha{5cm}%
81\begin{twocollist}\itemsep=0pt
82\twocolitem{\windowstyle{wxWIZARD\_EX\_HELPBUTTON}}{Shows a Help button using wxID\_HELP.}
83\end{twocollist}
84
85See also \helpref{wxDialog}{wxdialog} for other extended styles.
86
f6bcfd97
BP
87\wxheading{See also}
88
89\helpref{wxWizardEvent}{wxwizardevent}, \helpref{wxWizardPage}{wxwizardpage}, \helpref{wxWizard sample}{samplewizard}
90
91\latexignore{\rtfignore{\wxheading{Members}}}
92
213ba43b
JS
93\membersection{wxWizard::wxWizard}\label{wxwizardctor}
94
95\func{}{wxWizard}{\void}
96
750cefbc
VZ
97Default constructor. Use this if you wish to derive from wxWizard and then call
98\helpref{Create}{wxwizardcreate}, for example if you wish to set an extra style
99with \helpref{wxWindow::SetExtraStyle}{wxwindowsetextrastyle} between the two
100calls.
213ba43b 101
c0d26c0f 102\func{}{wxWizard}{\param{wxWindow* }{parent}, \param{int }{id = -1}, \param{const wxString\& }{title = wxEmptyString}, \param{const wxBitmap\& }{bitmap = wxNullBitmap}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{long }{style = wxDEFAULT\_DIALOG\_STYLE}}
213ba43b 103
750cefbc
VZ
104Constructor which really creates the wizard -- if you use this constructor, you
105shouldn't call \helpref{Create}{wxwizardcreate}.
213ba43b 106
fc2171bd 107Notice that unlike almost all other wxWidgets classes, there is no {\it size}
027aa6fa 108parameter in the wxWizard constructor because the wizard will have a predefined
213ba43b 109default size by default. If you want to change this, you should use the
07f20d9a 110\helpref{GetPageAreaSizer}{wxwizardgetpageareasizer} function.
213ba43b
JS
111
112\wxheading{Parameters}
113
114\docparam{parent}{The parent window, may be NULL.}
115
116\docparam{id}{The id of the dialog, will usually be just $-1$.}
117
118\docparam{title}{The title of the dialog.}
119
120\docparam{bitmap}{The default bitmap used in the left side of the wizard. See
121also \helpref{GetBitmap}{wxwizardpagegetbitmap}.}
122
123\docparam{pos}{The position of the dialog, it will be centered on the screen
124by default.}
125
07f20d9a
VZ
126\docparam{style}{Window style is passed to wxDialog.}
127
128
f6bcfd97
BP
129\membersection{wxWizard::Create}\label{wxwizardcreate}
130
c0d26c0f 131\func{bool}{Create}{\param{wxWindow* }{parent}, \param{int }{id = -1}, \param{const wxString\& }{title = wxEmptyString}, \param{const wxBitmap\& }{bitmap = wxNullBitmap}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{long }{style = wxDEFAULT\_DIALOG\_STYLE}}
f6bcfd97 132
750cefbc
VZ
133Creates the wizard dialog. Must be called if the default constructor had been
134used to create the object.
f6bcfd97 135
fc2171bd 136Notice that unlike almost all other wxWidgets classes, there is no {\it size}
027aa6fa 137parameter in the wxWizard constructor because the wizard will have a predefined
f6bcfd97 138default size by default. If you want to change this, you should use the
07f20d9a 139\helpref{GetPageAreaSizer}{wxwizardgetpageareasizer} function.
f6bcfd97
BP
140
141\wxheading{Parameters}
142
143\docparam{parent}{The parent window, may be NULL.}
144
145\docparam{id}{The id of the dialog, will usually be just $-1$.}
146
147\docparam{title}{The title of the dialog.}
148
149\docparam{bitmap}{The default bitmap used in the left side of the wizard. See
150also \helpref{GetBitmap}{wxwizardpagegetbitmap}.}
151
152\docparam{pos}{The position of the dialog, it will be centered on the screen
153by default.}
154
07f20d9a
VZ
155\docparam{style}{Window style is passed to wxDialog.}
156
157
2b5f62a0 158\membersection{wxWizard::FitToPage}\label{wxwizardfittopage}
f6bcfd97 159
384c9653 160\func{void}{FitToPage}{\param{const wxWizardPage* }{firstPage}}
f6bcfd97 161
07f20d9a
VZ
162This method is obsolete, use
163\helpref{GetPageAreaSizer}{wxwizardgetpageareasizer} instead.
164
c73b439f
VZ
165Sets the page size to be big enough for all the pages accessible via the
166given {\it firstPage}, i.e. this page, its next page and so on.
167
168This method may be called more than once and it will only change the page size
169if the size required by the new page is bigger than the previously set one.
027aa6fa
JS
170This is useful if the decision about which pages to show is taken during
171run-time, as in this case, the wizard won't be able to get to all pages starting
c73b439f 172from a single one and you should call {\it Fit} separately for the others.
f6bcfd97 173
f49fd6d0
JS
174\membersection{wxWizard::GetBitmap}\label{wxwizardgetbitmap}
175
176\constfunc{const wxBitmap\&}{GetBitmap}{\void}
177
178Returns the bitmap used for the wizard.
07f20d9a 179
3aa8e4ea
JS
180
181\membersection{wxWizard::GetBitmapBackgroundColour}\label{wxwizardgetbitmapbackgroundcolour}
182
183\constfunc{const wxColour\&}{GetBitmapBackgroundColour}{\void}
184
185Returns the colour that should be used to fill the area not taken up by the wizard or page bitmap,
186if a non-zero bitmap placement flag has been set.
187
188See also \helpref{wxWizard::SetBitmapPlacement}{wxwizardsetbitmapplacement}.
189
190
191
192\membersection{wxWizard::GetBitmapPlacement}\label{wxwizardgetbitmapplacement}
193
194\func{int}{GetBitmapPlacement}{\void}
195
196Returns the flags indicating how the wizard or page bitmap should be expanded and positioned to fit the
197page height. By default, placement is 0 (no expansion is done).
198
199See also \helpref{wxWizard::SetBitmapPlacement}{wxwizardsetbitmapplacement} for the possible values.
200
201
f6bcfd97
BP
202\membersection{wxWizard::GetCurrentPage}\label{wxwizardgetcurrentpage}
203
204\constfunc{wxWizardPage*}{GetCurrentPage}{\void}
205
206Get the current page while the wizard is running. {\tt NULL} is returned if
207\helpref{RunWizard()}{wxwizardrunwizard} is not being executed now.
208
07f20d9a 209
3aa8e4ea
JS
210\membersection{wxWizard::GetMinimumBitmapWidth}\label{wxwizardgetminimumbitmapwidth}
211
212\constfunc{int}{GetMinimumBitmapWidth}{\void}
213
214Returns the minimum width for the bitmap that will be constructed to contain the actual wizard or page bitmap
215if a non-zero bitmap placement flag has been set.
216
217See also \helpref{wxWizard::SetBitmapPlacement}{wxwizardsetbitmapplacement}.
218
219
07f20d9a
VZ
220\membersection{wxWizard::GetPageAreaSizer}\label{wxwizardgetpageareasizer}
221
222\constfunc{virtual wxSizer*}{GetPageAreaSizer}{\void}
223
027aa6fa
JS
224Returns pointer to page area sizer. The wizard is laid out using sizers and
225the page area sizer is the place-holder for the pages. All pages are resized before
07f20d9a
VZ
226being shown to match the wizard page area.
227
027aa6fa 228Page area sizer has a minimal size that is the maximum of several values. First,
07f20d9a
VZ
229all pages (or other objects) added to the sizer. Second, all pages reachable
230by repeatedly applying
231\helpref{wxWizardPage::GetNext}{wxwizardpagegetnext} to
232any page inserted into the sizer. Third,
027aa6fa 233the minimal size specified using \helpref{SetPageSize}{wxwizardsetpagesize} and
07f20d9a 234\helpref{FitToPage}{wxwizardfittopage}. Fourth, the total wizard height may
dbd94b75 235be increased to accommodate the bitmap height. Fifth and finally, wizards are
027aa6fa 236never smaller than some built-in minimal size to avoid wizards that are too small.
07f20d9a 237
027aa6fa
JS
238The caller can use \helpref{wxSizer::SetMinSize}{wxsizersetminsize} to enlarge it
239beyond the minimal size. If {\tt wxRESIZE\_BORDER} was passed to constructor, user
240can resize wizard and consequently the page area (but not make it smaller than the
07f20d9a
VZ
241minimal size).
242
027aa6fa
JS
243It is recommended to add the first page to the page area sizer. For simple wizards,
244this will enlarge the wizard to fit the biggest page. For non-linear wizards,
245the first page of every separate chain should be added. Caller-specified size
07f20d9a
VZ
246can be accomplished using \helpref{wxSizer::SetMinSize}{wxsizersetminsize}.
247
027aa6fa 248Adding pages to the page area sizer affects the default border width around page
07f20d9a
VZ
249area that can be altered with \helpref{SetBorder}{wxwizardsetborder}.
250
251
f6bcfd97
BP
252\membersection{wxWizard::GetPageSize}\label{wxwizardgetpagesize}
253
254\constfunc{wxSize}{GetPageSize}{\void}
255
256Returns the size available for the pages.
257
07f20d9a 258
2b5f62a0
VZ
259\membersection{wxWizard::HasNextPage}\label{wxwizardhasnextpage}
260
261\func{virtual bool}{HasNextPage}{\param{wxWizardPage *}{page}}
262
cc81d32f 263Return {\tt true} if this page is not the last one in the wizard. The base
2b5f62a0
VZ
264class version implements this by calling
265\helpref{page->GetNext}{wxwizardpagegetnext} but this could be undesirable if,
266for example, the pages are created on demand only.
267
268\wxheading{See also}
269
270\helpref{HasPrevPage}{wxwizardhasprevpage}
271
07f20d9a 272
2b5f62a0
VZ
273\membersection{wxWizard::HasPrevPage}\label{wxwizardhasprevpage}
274
275\func{virtual bool}{HasPrevPage}{\param{wxWizardPage *}{page}}
276
027aa6fa 277Returns {\tt true} if this page is not the last one in the wizard. The base
2b5f62a0
VZ
278class version implements this by calling
279\helpref{page->GetPrev}{wxwizardpagegetprev} but this could be undesirable if,
280for example, the pages are created on demand only.
281
282\wxheading{See also}
283
284\helpref{HasNextPage}{wxwizardhasnextpage}
285
07f20d9a 286
c73b439f
VZ
287\membersection{wxWizard::RunWizard}\label{wxwizardrunwizard}
288
289\func{bool}{RunWizard}{\param{wxWizardPage* }{firstPage}}
290
027aa6fa 291Executes the wizard starting from the given page, returning {\tt true} if it was
cc81d32f 292successfully finished or {\tt false} if user cancelled it. The {\it firstPage}
c73b439f
VZ
293can not be {\tt NULL}.
294
f49fd6d0
JS
295\membersection{wxWizard::SetBitmap}\label{wxwizardsetbitmap}
296
297\func{void}{SetBitmap}{\param{const wxBitmap\& }{bitmap}}
298
299Sets the bitmap used for the wizard.
07f20d9a 300
3aa8e4ea
JS
301
302\membersection{wxWizard::SetBitmapBackgroundColour}\label{wxwizardsetbitmapbackgroundcolour}
303
304\func{void}{SetBitmapBackgroundColour}{\param{const wxColour\&}{ colour}}
305
306Sets the colour that should be used to fill the area not taken up by the wizard or page bitmap,
307if a non-zero bitmap placement flag has been set.
308
309See also \helpref{wxWizard::SetBitmapPlacement}{wxwizardsetbitmapplacement}.
310
311
312\membersection{wxWizard::SetBitmapPlacement}\label{wxwizardsetbitmapplacement}
313
314\func{void}{SetBitmapPlacement}{\param{int}{ placement}}
315
316Sets the flags indicating how the wizard or page bitmap should be expanded and positioned to fit the
317page height. By default, placement is 0 (no expansion is done). {\it placement} is a bitlist with the
318following possible values:
319
320\begin{twocollist}\itemsep=0pt
321\twocolitem{\windowstyle{wxWIZARD\_VALIGN\_TOP}}{Aligns the bitmap at the top.}
322\twocolitem{\windowstyle{wxWIZARD\_VALIGN\_CENTRE}}{Centres the bitmap vertically.}
323\twocolitem{\windowstyle{wxWIZARD\_VALIGN\_BOTTOM}}{Aligns the bitmap at the bottom.}
324\twocolitem{\windowstyle{wxWIZARD\_HALIGN\_LEFT}}{Left-aligns the bitmap.}
325\twocolitem{\windowstyle{wxWIZARD\_HALIGN\_CENTRE}}{Centres the bitmap horizontally.}
326\twocolitem{\windowstyle{wxWIZARD\_HALIGN\_RIGHT}}{Right-aligns the bitmap.}
327\twocolitem{\windowstyle{wxWIZARD\_TILE}}{}
328\end{twocollist}
329
330See also \helpref{wxWizard::SetMinimumBitmapWidth}{wxwizardsetminimumbitmapwidth}.
331
332
333\membersection{wxWizard::SetMinimumBitmapWidth}\label{wxwizardsetminimumbitmapwidth}
334
335\func{void}{SetMinimumBitmapWidth}{\param{int}{ width}}
336
337Sets the minimum width for the bitmap that will be constructed to contain the actual wizard or page bitmap
338if a non-zero bitmap placement flag has been set. If this is not set when using bitmap placement, the initial
339layout may be incorrect.
340
341See also \helpref{wxWizard::SetBitmapPlacement}{wxwizardsetbitmapplacement}.
342
343
344
f6bcfd97
BP
345\membersection{wxWizard::SetPageSize}\label{wxwizardsetpagesize}
346
347\func{void}{SetPageSize}{\param{const wxSize\& }{sizePage}}
348
07f20d9a
VZ
349This method is obsolete, use
350\helpref{GetPageAreaSizer}{wxwizardgetpageareasizer} instead.
351
f6bcfd97
BP
352Sets the minimal size to be made available for the wizard pages. The wizard
353will take into account the size of the bitmap (if any) itself. Also, the
354wizard will never be smaller than the default size.
355
027aa6fa 356The recommended way to use this function is to lay out all wizard pages using
f6bcfd97
BP
357the sizers (even though the wizard is not resizeable) and then use
358\helpref{wxSizer::CalcMin}{wxsizercalcmin} in a loop to calculate the maximum
359of minimal sizes of the pages and pass it to SetPageSize().
360
07f20d9a
VZ
361
362\membersection{wxWizard::SetBorder}\label{wxwizardsetborder}
363
364\func{void}{SetBorder}{\param{int }{border}}
365
366Sets width of border around page area. Default is zero. For backward
367compatibility, if there are no pages in
027aa6fa 368\helpref{GetPageAreaSizer}{wxwizardgetpageareasizer}, the default is $5$ pixels.
07f20d9a 369
027aa6fa
JS
370If there is a five point border around all controls in a page and the border around
371page area is left as zero, a five point white space along all dialog borders
372will be added to the control border in order to space page controls ten points from the dialog
07f20d9a
VZ
373border and non-page controls.
374