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