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