1 \section{\class{wxNotebook
}}\label{wxnotebook
}
3 This class represents a notebook control, which manages multiple windows with associated tabs.
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
9 {\bf wxNotebookPage
} is a typedef for wxWindow.
11 \wxheading{Derived from
}
13 wxBookCtrlBase (see
\helpref{wxBookCtrl overview
}{wxbookctrloverview
})\\
14 \helpref{wxControl
}{wxcontrol
}\\
15 \helpref{wxWindow
}{wxwindow
}\\
16 \helpref{wxEvtHandler
}{wxevthandler
}\\
17 \helpref{wxObject
}{wxobject
}
19 \wxheading{Include files
}
25 \helpref{wxCore
}{librarieslist
}
27 \wxheading{Window styles
}
30 \begin{twocollist
}\itemsep=
0pt
31 \twocolitem{\windowstyle{wxNB
\_TOP}}{Place tabs on the top side.
}
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.
}
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.
}
37 \twocolitem{\windowstyle{wxNB
\_NOPAGETHEME}}{(Windows only) Display a solid colour on notebook pages, and not a gradient, which can reduce performance.
}
38 \twocolitem{\windowstyle{wxNB
\_FLAT}}{(Windows CE only) Show tabs in a flat style.
}
42 The styles
\texttt{wxNB
\_LEFT},
\texttt{RIGHT
} and
\texttt{BOTTOM
} are not
43 supported under Microsoft Windows XP when using visual themes.
45 See also
\helpref{window styles overview
}{windowstyles
}.
49 \wxheading{Page backgrounds
}
51 On Windows XP, the default theme paints a gradient on the notebook's pages.
52 If you wish to suppress this theme, for aesthetic or performance reasons,
53 there are three ways of doing it. You can use wxNB
\_NOPAGETHEME to disable
54 themed drawing for a particular notebook, you can call
{\tt wxSystemOptions::SetOption
}
55 to disable it for the whole application, or you can disable it for individual
56 pages by using
{\tt SetBackgroundColour
}.
58 To disable themed pages globally:
61 wxSystemOptions::SetOption(wxT("msw.notebook.themed-background"),
0);
64 Set the value to
1 to enable it again.
66 To give a single page a solid background that more or less fits in with the
70 wxColour col = notebook->GetThemeBackgroundColour();
73 page->SetBackgroundColour(col);
77 On platforms other than Windows, or if the application is not using Windows
78 themes,
{\tt GetThemeBackgroundColour
} will return an uninitialised colour object,
79 and the above code will therefore work on all platforms.
83 \helpref{wxBookCtrl
}{wxbookctrloverview
},
\helpref{wxNotebookEvent
}{wxnotebookevent
},
\helpref{wxImageList
}{wximagelist
},
\helpref{notebook sample
}{samplenotebook
}\rtfsp
85 \latexignore{\rtfignore{\wxheading{Members
}}}
87 \membersection{wxNotebook::wxNotebook
}\label{wxnotebookctor
}
89 \func{}{wxNotebook
}{\void}
93 \func{}{wxNotebook
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
94 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style =
0},
\param{const wxString\&
}{name = wxNotebookNameStr
}}
96 Constructs a notebook control.
98 Note that sometimes you can reduce flicker by passing the wxCLIP
\_CHILDREN window style.
100 \wxheading{Parameters
}
102 \docparam{parent
}{The parent window. Must be non-NULL.
}
104 \docparam{id
}{The window identifier.
}
106 \docparam{pos
}{The window position.
}
108 \docparam{size
}{The window size.
}
110 \docparam{style
}{The window style. See
\helpref{wxNotebook
}{wxnotebook
}.
}
112 \docparam{name
}{The name of the control (used only under Motif).
}
115 \membersection{wxNotebook::
\destruct{wxNotebook
}}\label{wxnotebookdtor
}
117 \func{}{\destruct{wxNotebook
}}{\void}
119 Destroys the wxNotebook object.
122 \membersection{wxNotebook::AddPage
}\label{wxnotebookaddpage
}
124 \func{bool
}{AddPage
}{\param{wxNotebookPage*
}{ page
},
125 \param{const wxString\&
}{ text
},
126 \param{bool
}{ select = false
},
127 \param{int
}{ imageId = -
1}}
131 The call to this function may generate the page changing events.
133 \wxheading{Parameters
}
135 \docparam{page
}{Specifies the new page.
}
137 \docparam{text
}{Specifies the text for the new page.
}
139 \docparam{select
}{Specifies whether the page should be selected.
}
141 \docparam{imageId
}{Specifies the optional image index for the new page.
}
143 \wxheading{Return value
}
145 true if successful, false otherwise.
149 Do not delete the page, it will be deleted by the notebook.
153 \helpref{wxNotebook::InsertPage
}{wxnotebookinsertpage
}
156 \membersection{wxNotebook::AdvanceSelection
}\label{wxnotebookadvanceselection
}
158 \func{void
}{AdvanceSelection
}{\param{bool
}{ forward = true
}}
160 Cycles through the tabs.
162 The call to this function generates the page changing events.
165 \membersection{wxNotebook::AssignImageList
}\label{wxnotebookassignimagelist
}
167 \func{void
}{AssignImageList
}{\param{wxImageList*
}{ imageList
}}
169 Sets the image list for the page control and takes ownership of
174 \helpref{wxImageList
}{wximagelist
},
175 \helpref{SetImageList
}{wxnotebooksetimagelist
}
178 \membersection{wxNotebook::Create
}\label{wxnotebookcreate
}
180 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
181 \param{const wxSize\&
}{ size
},
\param{long
}{ style =
0},
\param{const wxString\&
}{name = wxNotebookNameStr
}}
183 Creates a notebook control. See
\helpref{wxNotebook::wxNotebook
}{wxnotebookctor
} for a description
187 \membersection{wxNotebook::DeleteAllPages
}\label{wxnotebookdeleteallpages
}
189 \func{bool
}{DeleteAllPages
}{\void}
194 \membersection{wxNotebook::DeletePage
}\label{wxnotebookdeletepage
}
196 \func{bool
}{DeletePage
}{\param{size
\_t}{ page
}}
198 Deletes the specified page, and the associated window.
200 The call to this function generates the page changing events.
203 \membersection{wxNotebook::GetCurrentPage
}\label{wxnotebookgetcurrentpage
}
205 \constfunc{wxWindow *
}{GetCurrentPage
}{\void}
207 Returns the currently selected notebook page or
\NULL.
210 \membersection{wxNotebook::GetImageList
}\label{wxnotebookgetimagelist
}
212 \constfunc{wxImageList*
}{GetImageList
}{\void}
214 Returns the associated image list.
218 \helpref{wxImageList
}{wximagelist
},
\helpref{wxNotebook::SetImageList
}{wxnotebooksetimagelist
}
221 \membersection{wxNotebook::GetPage
}\label{wxnotebookgetpage
}
223 \func{wxNotebookPage*
}{GetPage
}{\param{size
\_t}{ page
}}
225 Returns the window at the given page position.
228 \membersection{wxNotebook::GetPageCount
}\label{wxnotebookgetpagecount
}
230 \constfunc{size
\_t}{GetPageCount
}{\void}
232 Returns the number of pages in the notebook control.
235 \membersection{wxNotebook::GetPageImage
}\label{wxnotebookgetpageimage
}
237 \constfunc{int
}{GetPageImage
}{\param{size
\_t }{nPage
}}
239 Returns the image index for the given page.
242 \membersection{wxNotebook::GetPageText
}\label{wxnotebookgetpagetext
}
244 \constfunc{wxString
}{GetPageText
}{\param{size
\_t }{nPage
}}
246 Returns the string for the given page.
249 \membersection{wxNotebook::GetRowCount
}\label{wxnotebookgetrowcount
}
251 \constfunc{int
}{GetRowCount
}{\void}
253 Returns the number of rows in the notebook control.
256 \membersection{wxNotebook::GetSelection
}\label{wxnotebookgetselection
}
258 \constfunc{int
}{GetSelection
}{\void}
260 Returns the currently selected page, or $-
1$ if none was selected.
262 Note that this method may return either the previously or newly selected page
263 when called from the
{\tt EVT
\_NOTEBOOK\_PAGE\_CHANGED} handler depending on
264 the platform and so
\rtfsp
265 \helpref{wxNotebookEvent::GetSelection
}{wxnotebookeventgetselection
} should be
266 used instead in this case.
268 \membersection{wxNotebook::GetThemeBackgroundColour
}\label{wxnotebookgetthemebackgroundcolour
}
270 \constfunc{wxColour
}{GetThemeBackgroundColour
}{\void}
272 If running under Windows and themes are enabled for the application, this function
273 returns a suitable colour for painting the background of a notebook page, and can be passed
274 to
{\tt SetBackgroundColour
}. Otherwise, an uninitialised colour will be returned.
276 \membersection{wxNotebook::HitTest
}\label{wxnotebookhittest
}
278 \func{int
}{HitTest
}{\param{const wxPoint\&
}{ pt
},
\param{long
}{ *flags =
{\tt NULL
}}}
280 Returns the index of the tab at the specified position or
{\tt wxNOT
\_FOUND}
281 if none. If
{\it flags
} parameter is non-
{\tt NULL
}, the position of the point
282 inside the tab is returned as well.
284 \wxheading{Parameters
}
286 \docparam{pt
}{Specifies the point for the hit test.
}
288 \docparam{flags
}{Return value for detailed information. One of the following values:
290 \begin{twocollist
}\itemsep=
0pt
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.
}
299 \wxheading{Return value
}
301 Returns the zero-based tab index or
{\tt wxNOT
\_FOUND} if there is no tab is at
302 the specified position.
306 \membersection{wxNotebook::InsertPage
}\label{wxnotebookinsertpage
}
308 \func{bool
}{InsertPage
}{\param{size
\_t}{ index
},
\param{wxNotebookPage*
}{ page
},
309 \param{const wxString\&
}{ text
},
310 \param{bool
}{ select = false
},
311 \param{int
}{ imageId = -
1}}
313 Inserts a new page at the specified position.
315 \wxheading{Parameters
}
317 \docparam{index
}{Specifies the position for the new page.
}
319 \docparam{page
}{Specifies the new page.
}
321 \docparam{text
}{Specifies the text for the new page.
}
323 \docparam{select
}{Specifies whether the page should be selected.
}
325 \docparam{imageId
}{Specifies the optional image index for the new page.
}
327 \wxheading{Return value
}
329 true if successful, false otherwise.
333 Do not delete the page, it will be deleted by the notebook.
337 \helpref{wxNotebook::AddPage
}{wxnotebookaddpage
}
340 \membersection{wxNotebook::OnSelChange
}\label{wxnotebookonselchange
}
342 \func{void
}{OnSelChange
}{\param{wxNotebookEvent\&
}{ event
}}
344 An event handler function, called when the page selection is changed.
348 \helpref{wxNotebookEvent
}{wxnotebookevent
}
351 \membersection{wxNotebook::RemovePage
}\label{wxnotebookremovepage
}
353 \func{bool
}{RemovePage
}{\param{size
\_t}{ page
}}
355 Deletes the specified page, without deleting the associated window.
358 \membersection{wxNotebook::SetImageList
}\label{wxnotebooksetimagelist
}
360 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
}}
362 Sets the image list for the page control. It does not take
363 ownership of the image list, you must delete it yourself.
367 \helpref{wxImageList
}{wximagelist
},
368 \helpref{AssignImageList
}{wxnotebookassignimagelist
}
371 \membersection{wxNotebook::SetPadding
}\label{wxnotebooksetpadding
}
373 \func{void
}{SetPadding
}{\param{const wxSize\&
}{ padding
}}
375 Sets the amount of space around each page's icon and label, in pixels.
377 {\bf NB:
} The vertical padding cannot be changed in wxGTK.
380 \membersection{wxNotebook::SetPageSize
}\label{wxnotebooksetpagesize
}
382 \func{void
}{SetPageSize
}{\param{const wxSize\&
}{ size
}}
384 Sets the width and height of the pages.
386 {\bf NB:
} This method is currently not implemented for wxGTK.
389 \membersection{wxNotebook::SetPageImage
}\label{wxnotebooksetpageimage
}
391 \func{bool
}{SetPageImage
}{\param{size
\_t}{ page
},
\param{int
}{image
}}
393 Sets the image index for the given page.
{\it image
} is an index into
394 the image list which was set with
\helpref{wxNotebook::SetImageList
}{wxnotebooksetimagelist
}.
397 \membersection{wxNotebook::SetPageText
}\label{wxnotebooksetpagetext
}
399 \func{bool
}{SetPageText
}{\param{size
\_t}{ page
},
\param{const wxString\&
}{text
}}
401 Sets the text for the given page.
404 \membersection{wxNotebook::SetSelection
}\label{wxnotebooksetselection
}
406 \func{int
}{SetSelection
}{\param{size
\_t}{ page
}}
408 Sets the selection for the given page, returning the previous selection.
410 The call to this function generates the page changing events.
412 This function is deprecated and should not be used in new code. Please use the
413 \helpref{ChangeSelection
}{wxnotebookchangeselection
} function instead.
417 \helpref{wxNotebook::GetSelection
}{wxnotebookgetselection
}
420 \membersection{wxNotebook::ChangeSelection
}\label{wxnotebookchangeselection
}
422 \func{int
}{ChangeSelection
}{\param{size
\_t}{ page
}}
424 Changes the selection for the given page, returning the previous selection.
426 The call to this function
\emph{does not
} generate the page changing events.
427 This is the only difference with
\helpref{SetSelection
}{wxnotebooksetselection
}.
428 See
\helpref{this topic
}{progevent
} for more info.