]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/notebook.tex
Consistent wxWindow::Enable with wxRadioBox::Enable for control and its items. wxRadi...
[wxWidgets.git] / docs / latex / wx / notebook.tex
CommitLineData
3972fb49
JS
1\section{\class{wxNotebook}}\label{wxnotebook}
2
3This class represents a notebook control, which manages multiple windows with associated tabs.
4
5To use the class, create a wxNotebook object and call \helpref{AddPage}{wxnotebookaddpage} or \helpref{InsertPage}{wxnotebookinsertpage},
6passing a window to be used as the page. Do not explicitly delete the window for a page that is currently
7managed by wxNotebook.
8
9{\bf wxNotebookPage} is a typedef for wxWindow.
10
11\wxheading{Derived from}
12
13\helpref{wxControl}{wxcontrol}\\
14\helpref{wxWindow}{wxwindow}\\
15\helpref{wxEvtHandler}{wxevthandler}\\
16\helpref{wxObject}{wxobject}
17
954b8ae6
JS
18\wxheading{Include files}
19
20<wx/notebook.h>
21
da27bd0b
VZ
22\wxheading{Window styles}
23
24\twocolwidtha{5cm}
25\begin{twocollist}\itemsep=0pt
f6bcfd97 26
df10208f
VZ
27\twocolitem{\windowstyle{wxNB\_LEFT}}{Place tabs on the left side.}
28\twocolitem{\windowstyle{wxNB\_RIGHT}}{Place tabs on the right side.}
29\twocolitem{\windowstyle{wxNB\_BOTTOM}}{Place tabs under instead of above the notebook pages.}
2b5f62a0
VZ
30\twocolitem{\windowstyle{wxNB\_FIXEDWIDTH}}{(Windows only) All tabs will have same width.}
31\twocolitem{\windowstyle{wxNB\_MULTILINE}}{(Windows only) There can be several rows of tabs.}
25057aba 32\twocolitem{\windowstyle{wxNB\_NOPAGETHEME}}{(Windows only) Display a solid colour on notebook pages, and not a gradient, which can reduce performance.}
f6bcfd97 33
da27bd0b
VZ
34\end{twocollist}
35
df10208f
VZ
36The styles \texttt{wxNB\_LEFT}, \texttt{RIGHT} and \texttt{BOTTOM} are not
37supported under Microsoft Windows XP when using visual themes.
38
f6bcfd97
BP
39See also \helpref{window styles overview}{windowstyles}.
40
1d2bd847 41\input noteevt.inc
3972fb49 42
25057aba
JS
43\wxheading{Page backgrounds}
44
45On Windows XP, the default theme paints a gradient on the notebook's pages.
46If you wish to suppress this theme, for aesthetic or performance reasons,
47there are three ways of doing it. You can use wxNB\_NOPAGETHEME to disable
48themed drawing for a particular notebook, you can call {\tt wxSystemOptions::SetOption}
49to disable it for the whole application, or you can disable it for individual
50pages by using {\tt SetBackgroundColour}.
51
52To disable themed pages globally:
53
54\begin{verbatim}
55 wxSystemOptions::SetOption(wxT("msw.notebook.themed-background"), 0);
56\end{verbatim}
57
58Set the value to 1 to enable it again.
59
60To give a single page a solid background that more or less fits in with the
61overall theme, use:
62
63\begin{verbatim}
64 wxColour col = notebook->GetThemeBackgroundColour();
65 if (col.Ok())
66 {
67 page->SetBackgroundColour(col);
68 }
69\end{verbatim}
70
71On platforms other than Windows, or if the application is not using Windows
72themes, {\tt GetThemeBackgroundColour} will return an uninitialised colour object,
73and the above code will therefore work on all platforms.
74
3972fb49
JS
75\wxheading{See also}
76
b742a43b 77\helpref{wxBookCtrl}{wxbookctrloverview}, \helpref{wxNotebookEvent}{wxnotebookevent}, \helpref{wxImageList}{wximagelist}, \helpref{notebook sample}{samplenotebook}\rtfsp
3972fb49
JS
78
79\latexignore{\rtfignore{\wxheading{Members}}}
80
dcbd177f 81\membersection{wxNotebook::wxNotebook}\label{wxnotebookctor}
3972fb49
JS
82
83\func{}{wxNotebook}{\void}
84
85Default constructor.
86
87\func{}{wxNotebook}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id}, \param{const wxPoint\&}{ pos = wxDefaultPosition},
630ad6c6 88 \param{const wxSize\&}{ size = wxDefaultSize}, \param{long}{ style = 0}, \param{const wxString\& }{name = wxNotebookNameStr}}
3972fb49
JS
89
90Constructs a notebook control.
91
5fa399c9
JS
92Note that sometimes you can reduce flicker by passing the wxCLIP\_CHILDREN window style.
93
3972fb49
JS
94\wxheading{Parameters}
95
96\docparam{parent}{The parent window. Must be non-NULL.}
97
98\docparam{id}{The window identifier.}
99
100\docparam{pos}{The window position.}
101
102\docparam{size}{The window size.}
103
f6bcfd97 104\docparam{style}{The window style. See \helpref{wxNotebook}{wxnotebook}.}
3972fb49 105
8c517ddd
VZ
106\docparam{name}{The name of the control (used only under Motif).}
107
21db32c1 108
dcbd177f 109\membersection{wxNotebook::\destruct{wxNotebook}}\label{wxnotebookdtor}
3972fb49
JS
110
111\func{}{\destruct{wxNotebook}}{\void}
112
113Destroys the wxNotebook object.
114
21db32c1 115
3972fb49
JS
116\membersection{wxNotebook::AddPage}\label{wxnotebookaddpage}
117
118\func{bool}{AddPage}{\param{wxNotebookPage*}{ page},
119 \param{const wxString\&}{ text},
cc81d32f 120 \param{bool}{ select = false},
3972fb49
JS
121 \param{int}{ imageId = -1}}
122
123Adds a new page.
124
f65a450a
VZ
125The call to this function may generate the page changing events.
126
3972fb49
JS
127\wxheading{Parameters}
128
129\docparam{page}{Specifies the new page.}
130
131\docparam{text}{Specifies the text for the new page.}
132
133\docparam{select}{Specifies whether the page should be selected.}
134
135\docparam{imageId}{Specifies the optional image index for the new page.}
136
137\wxheading{Return value}
138
cc81d32f 139true if successful, false otherwise.
3972fb49
JS
140
141\wxheading{Remarks}
142
143Do not delete the page, it will be deleted by the notebook.
144
145\wxheading{See also}
146
147\helpref{wxNotebook::InsertPage}{wxnotebookinsertpage}
148
21db32c1 149
3972fb49
JS
150\membersection{wxNotebook::AdvanceSelection}\label{wxnotebookadvanceselection}
151
cc81d32f 152\func{void}{AdvanceSelection}{\param{bool}{ forward = true}}
3972fb49
JS
153
154Cycles through the tabs.
155
f65a450a
VZ
156The call to this function generates the page changing events.
157
21db32c1 158
b656febd
VS
159\membersection{wxNotebook::AssignImageList}\label{wxnotebookassignimagelist}
160
161\func{void}{AssignImageList}{\param{wxImageList*}{ imageList}}
162
163Sets the image list for the page control and takes ownership of
164the list.
165
166\wxheading{See also}
167
168\helpref{wxImageList}{wximagelist},
169\helpref{SetImageList}{wxnotebooksetimagelist}
170
21db32c1 171
3972fb49
JS
172\membersection{wxNotebook::Create}\label{wxnotebookcreate}
173
174\func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id}, \param{const wxPoint\&}{ pos = wxDefaultPosition},
630ad6c6 175 \param{const wxSize\&}{ size}, \param{long}{ style = 0}, \param{const wxString\& }{name = wxNotebookNameStr}}
3972fb49 176
dcbd177f 177Creates a notebook control. See \helpref{wxNotebook::wxNotebook}{wxnotebookctor} for a description
3972fb49
JS
178of the parameters.
179
21db32c1 180
3972fb49
JS
181\membersection{wxNotebook::DeleteAllPages}\label{wxnotebookdeleteallpages}
182
183\func{bool}{DeleteAllPages}{\void}
184
185Deletes all pages.
186
21db32c1 187
3972fb49
JS
188\membersection{wxNotebook::DeletePage}\label{wxnotebookdeletepage}
189
74f8518b 190\func{bool}{DeletePage}{\param{size\_t}{ page}}
3972fb49 191
621793f4 192Deletes the specified page, and the associated window.
3972fb49 193
f65a450a
VZ
194The call to this function generates the page changing events.
195
21db32c1
VZ
196
197\membersection{wxNotebook::GetCurrentPage}\label{wxnotebookgetcurrentpage}
198
199\constfunc{wxWindow *}{GetCurrentPage}{\void}
200
201Returns the currently selected notebook age or \texttt{NULL}.
202
203
3972fb49
JS
204\membersection{wxNotebook::GetImageList}\label{wxnotebookgetimagelist}
205
206\constfunc{wxImageList*}{GetImageList}{\void}
207
208Returns the associated image list.
209
210\wxheading{See also}
211
212\helpref{wxImageList}{wximagelist}, \helpref{wxNotebook::SetImageList}{wxnotebooksetimagelist}
213
21db32c1 214
3972fb49
JS
215\membersection{wxNotebook::GetPage}\label{wxnotebookgetpage}
216
74f8518b 217\func{wxNotebookPage*}{GetPage}{\param{size\_t}{ page}}
3972fb49
JS
218
219Returns the window at the given page position.
220
21db32c1 221
3972fb49
JS
222\membersection{wxNotebook::GetPageCount}\label{wxnotebookgetpagecount}
223
74f8518b 224\constfunc{size\_t}{GetPageCount}{\void}
3972fb49
JS
225
226Returns the number of pages in the notebook control.
227
21db32c1 228
3972fb49
JS
229\membersection{wxNotebook::GetPageImage}\label{wxnotebookgetpageimage}
230
74f8518b 231\constfunc{int}{GetPageImage}{\param{size\_t }{nPage}}
3972fb49
JS
232
233Returns the image index for the given page.
234
21db32c1 235
3972fb49
JS
236\membersection{wxNotebook::GetPageText}\label{wxnotebookgetpagetext}
237
74f8518b 238\constfunc{wxString}{GetPageText}{\param{size\_t }{nPage}}
3972fb49
JS
239
240Returns the string for the given page.
241
21db32c1 242
3972fb49
JS
243\membersection{wxNotebook::GetRowCount}\label{wxnotebookgetrowcount}
244
245\constfunc{int}{GetRowCount}{\void}
246
247Returns the number of rows in the notebook control.
248
21db32c1 249
3972fb49
JS
250\membersection{wxNotebook::GetSelection}\label{wxnotebookgetselection}
251
252\constfunc{int}{GetSelection}{\void}
253
f0125ede
VZ
254Returns the currently selected page, or $-1$ if none was selected.
255
256Note that this method may return either the previously or newly selected page
257when called from the {\tt EVT\_NOTEBOOK\_PAGE\_CHANGED} handler depending on
258the platform and so\rtfsp
259\helpref{wxNotebookEvent::GetSelection}{wxnotebookeventgetselection} should be
260used instead in this case.
3972fb49 261
25057aba
JS
262\membersection{wxNotebook::GetThemeBackgroundColour}\label{wxnotebookgetthemebackgroundcolour}
263
264\constfunc{wxColour}{GetThemeBackgroundColour}{\void}
265
266If running under Windows and themes are enabled for the application, this function
267returns a suitable colour for painting the background of a notebook page, and can be passed
268to {\tt SetBackgroundColour}. Otherwise, an uninitialised colour will be returned.
21db32c1 269
e450aa69
VZ
270\membersection{wxNotebook::HitTest}\label{wxnotebookhittest}
271
272\func{int}{HitTest}{\param{const wxPoint\&}{ pt}, \param{long}{ *flags = {\tt NULL}}}
273
630ad6c6 274Returns the index of the tab at the specified position or {\tt wxNOT\_FOUND}
e450aa69
VZ
275if none. If {\it flags} parameter is non {\tt NULL}, the position of the point
276inside the tab is returned as well.
277
278{\bf NB: } This method is currently only implemented under wxMSW and wxUniv.
279
280\wxheading{Parameters}
281
282\docparam{pt}{Specifies the point for the hit test.}
283
284\docparam{flags}{Return value for detailed information. One of the following values:
285\twocolwidtha{7cm}
286\begin{twocollist}\itemsep=0pt
287\twocolitem{{\bf wxNB\_HITTEST\_NOWHERE}}{There was no tab under this point.}
288\twocolitem{{\bf wxNB\_HITTEST\_ONICON}}{The point was over an icon (currently wxMSW only).}
289\twocolitem{{\bf wxNB\_HITTEST\_ONLABEL}}{The point was over a label (currently wxMSW only).}
290\twocolitem{{\bf wxNB\_HITTEST\_ONITEM}}{The point was over an item, but not on the label or icon.}
291\end{twocollist}
292}
293
294\wxheading{Return value}
295
296Returns the zero-based tab index or {\tt wxNOT\_FOUND} if there is no tab is at
297the specified position.
298
299
21db32c1 300
3972fb49
JS
301\membersection{wxNotebook::InsertPage}\label{wxnotebookinsertpage}
302
74f8518b 303\func{bool}{InsertPage}{\param{size\_t}{ index}, \param{wxNotebookPage*}{ page},
3972fb49 304 \param{const wxString\&}{ text},
cc81d32f 305 \param{bool}{ select = false},
3972fb49
JS
306 \param{int}{ imageId = -1}}
307
308Inserts a new page at the specified position.
309
310\wxheading{Parameters}
311
312\docparam{index}{Specifies the position for the new page.}
313
314\docparam{page}{Specifies the new page.}
315
316\docparam{text}{Specifies the text for the new page.}
317
318\docparam{select}{Specifies whether the page should be selected.}
319
320\docparam{imageId}{Specifies the optional image index for the new page.}
321
322\wxheading{Return value}
323
cc81d32f 324true if successful, false otherwise.
3972fb49
JS
325
326\wxheading{Remarks}
327
328Do not delete the page, it will be deleted by the notebook.
329
330\wxheading{See also}
331
332\helpref{wxNotebook::AddPage}{wxnotebookaddpage}
333
21db32c1 334
3972fb49
JS
335\membersection{wxNotebook::OnSelChange}\label{wxnotebookonselchange}
336
337\func{void}{OnSelChange}{\param{wxNotebookEvent\&}{ event}}
338
339An event handler function, called when the page selection is changed.
340
341\wxheading{See also}
342
343\helpref{wxNotebookEvent}{wxnotebookevent}
344
21db32c1 345
621793f4
JS
346\membersection{wxNotebook::RemovePage}\label{wxnotebookremovepage}
347
74f8518b 348\func{bool}{RemovePage}{\param{size\_t}{ page}}
621793f4
JS
349
350Deletes the specified page, without deleting the associated window.
351
21db32c1 352
3972fb49
JS
353\membersection{wxNotebook::SetImageList}\label{wxnotebooksetimagelist}
354
355\func{void}{SetImageList}{\param{wxImageList*}{ imageList}}
356
b656febd
VS
357Sets the image list for the page control. It does not take
358ownership of the image list, you must delete it yourself.
3972fb49
JS
359
360\wxheading{See also}
361
b656febd
VS
362\helpref{wxImageList}{wximagelist},
363\helpref{AssignImageList}{wxnotebookassignimagelist}
3972fb49 364
21db32c1 365
3972fb49
JS
366\membersection{wxNotebook::SetPadding}\label{wxnotebooksetpadding}
367
368\func{void}{SetPadding}{\param{const wxSize\&}{ padding}}
369
370Sets the amount of space around each page's icon and label, in pixels.
371
b318dc42
JS
372{\bf NB:} The vertical padding cannot be changed in wxGTK.
373
21db32c1 374
3972fb49
JS
375\membersection{wxNotebook::SetPageSize}\label{wxnotebooksetpagesize}
376
377\func{void}{SetPageSize}{\param{const wxSize\&}{ size}}
378
379Sets the width and height of the pages.
380
b318dc42
JS
381{\bf NB:} This method is currently not implemented for wxGTK.
382
21db32c1 383
3972fb49
JS
384\membersection{wxNotebook::SetPageImage}\label{wxnotebooksetpageimage}
385
74f8518b 386\func{bool}{SetPageImage}{\param{size\_t}{ page}, \param{int }{image}}
3972fb49
JS
387
388Sets the image index for the given page. {\it image} is an index into
389the image list which was set with \helpref{wxNotebook::SetImageList}{wxnotebooksetimagelist}.
390
21db32c1 391
3972fb49
JS
392\membersection{wxNotebook::SetPageText}\label{wxnotebooksetpagetext}
393
74f8518b 394\func{bool}{SetPageText}{\param{size\_t}{ page}, \param{const wxString\& }{text}}
3972fb49
JS
395
396Sets the text for the given page.
397
21db32c1 398
3972fb49
JS
399\membersection{wxNotebook::SetSelection}\label{wxnotebooksetselection}
400
74f8518b 401\func{int}{SetSelection}{\param{size\_t}{ page}}
3972fb49
JS
402
403Sets the selection for the given page, returning the previous selection.
404
f65a450a
VZ
405The call to this function generates the page changing events.
406
3972fb49
JS
407\wxheading{See also}
408
409\helpref{wxNotebook::GetSelection}{wxnotebookgetselection}
410
411