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
}
23 \wxheading{Window styles
}
26 \begin{twocollist
}\itemsep=
0pt
27 \twocolitem{\windowstyle{wxNB
\_TOP}}{Place tabs on the top side.
}
28 \twocolitem{\windowstyle{wxNB
\_LEFT}}{Place tabs on the left side.
}
29 \twocolitem{\windowstyle{wxNB
\_RIGHT}}{Place tabs on the right side.
}
30 \twocolitem{\windowstyle{wxNB
\_BOTTOM}}{Place tabs under instead of above the notebook pages.
}
31 \twocolitem{\windowstyle{wxNB
\_FIXEDWIDTH}}{(Windows only) All tabs will have same width.
}
32 \twocolitem{\windowstyle{wxNB
\_MULTILINE}}{(Windows only) There can be several rows of tabs.
}
33 \twocolitem{\windowstyle{wxNB
\_NOPAGETHEME}}{(Windows only) Display a solid colour on notebook pages, and not a gradient, which can reduce performance.
}
34 \twocolitem{\windowstyle{wxNB
\_FLAT}}{(Windows CE only) Show tabs in a flat style.
}
38 The styles
\texttt{wxNB
\_LEFT},
\texttt{RIGHT
} and
\texttt{BOTTOM
} are not
39 supported under Microsoft Windows XP when using visual themes.
41 See also
\helpref{window styles overview
}{windowstyles
}.
45 \wxheading{Page backgrounds
}
47 On Windows XP, the default theme paints a gradient on the notebook's pages.
48 If you wish to suppress this theme, for aesthetic or performance reasons,
49 there are three ways of doing it. You can use wxNB
\_NOPAGETHEME to disable
50 themed drawing for a particular notebook, you can call
{\tt wxSystemOptions::SetOption
}
51 to disable it for the whole application, or you can disable it for individual
52 pages by using
{\tt SetBackgroundColour
}.
54 To disable themed pages globally:
57 wxSystemOptions::SetOption(wxT("msw.notebook.themed-background"),
0);
60 Set the value to
1 to enable it again.
62 To give a single page a solid background that more or less fits in with the
66 wxColour col = notebook->GetThemeBackgroundColour();
69 page->SetBackgroundColour(col);
73 On platforms other than Windows, or if the application is not using Windows
74 themes,
{\tt GetThemeBackgroundColour
} will return an uninitialised colour object,
75 and the above code will therefore work on all platforms.
79 \helpref{wxBookCtrl
}{wxbookctrloverview
},
\helpref{wxNotebookEvent
}{wxnotebookevent
},
\helpref{wxImageList
}{wximagelist
},
\helpref{notebook sample
}{samplenotebook
}\rtfsp
81 \latexignore{\rtfignore{\wxheading{Members
}}}
83 \membersection{wxNotebook::wxNotebook
}\label{wxnotebookctor
}
85 \func{}{wxNotebook
}{\void}
89 \func{}{wxNotebook
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
90 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style =
0},
\param{const wxString\&
}{name = wxNotebookNameStr
}}
92 Constructs a notebook control.
94 Note that sometimes you can reduce flicker by passing the wxCLIP
\_CHILDREN window style.
96 \wxheading{Parameters
}
98 \docparam{parent
}{The parent window. Must be non-NULL.
}
100 \docparam{id
}{The window identifier.
}
102 \docparam{pos
}{The window position.
}
104 \docparam{size
}{The window size.
}
106 \docparam{style
}{The window style. See
\helpref{wxNotebook
}{wxnotebook
}.
}
108 \docparam{name
}{The name of the control (used only under Motif).
}
111 \membersection{wxNotebook::
\destruct{wxNotebook
}}\label{wxnotebookdtor
}
113 \func{}{\destruct{wxNotebook
}}{\void}
115 Destroys the wxNotebook object.
118 \membersection{wxNotebook::AddPage
}\label{wxnotebookaddpage
}
120 \func{bool
}{AddPage
}{\param{wxNotebookPage*
}{ page
},
121 \param{const wxString\&
}{ text
},
122 \param{bool
}{ select = false
},
123 \param{int
}{ imageId = -
1}}
127 The call to this function may generate the page changing events.
129 \wxheading{Parameters
}
131 \docparam{page
}{Specifies the new page.
}
133 \docparam{text
}{Specifies the text for the new page.
}
135 \docparam{select
}{Specifies whether the page should be selected.
}
137 \docparam{imageId
}{Specifies the optional image index for the new page.
}
139 \wxheading{Return value
}
141 true if successful, false otherwise.
145 Do not delete the page, it will be deleted by the notebook.
149 \helpref{wxNotebook::InsertPage
}{wxnotebookinsertpage
}
152 \membersection{wxNotebook::AdvanceSelection
}\label{wxnotebookadvanceselection
}
154 \func{void
}{AdvanceSelection
}{\param{bool
}{ forward = true
}}
156 Cycles through the tabs.
158 The call to this function generates the page changing events.
161 \membersection{wxNotebook::AssignImageList
}\label{wxnotebookassignimagelist
}
163 \func{void
}{AssignImageList
}{\param{wxImageList*
}{ imageList
}}
165 Sets the image list for the page control and takes ownership of
170 \helpref{wxImageList
}{wximagelist
},
171 \helpref{SetImageList
}{wxnotebooksetimagelist
}
174 \membersection{wxNotebook::Create
}\label{wxnotebookcreate
}
176 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
177 \param{const wxSize\&
}{ size
},
\param{long
}{ style =
0},
\param{const wxString\&
}{name = wxNotebookNameStr
}}
179 Creates a notebook control. See
\helpref{wxNotebook::wxNotebook
}{wxnotebookctor
} for a description
183 \membersection{wxNotebook::DeleteAllPages
}\label{wxnotebookdeleteallpages
}
185 \func{bool
}{DeleteAllPages
}{\void}
190 \membersection{wxNotebook::DeletePage
}\label{wxnotebookdeletepage
}
192 \func{bool
}{DeletePage
}{\param{size
\_t}{ page
}}
194 Deletes the specified page, and the associated window.
196 The call to this function generates the page changing events.
199 \membersection{wxNotebook::GetCurrentPage
}\label{wxnotebookgetcurrentpage
}
201 \constfunc{wxWindow *
}{GetCurrentPage
}{\void}
203 Returns the currently selected notebook page or
\NULL.
206 \membersection{wxNotebook::GetImageList
}\label{wxnotebookgetimagelist
}
208 \constfunc{wxImageList*
}{GetImageList
}{\void}
210 Returns the associated image list.
214 \helpref{wxImageList
}{wximagelist
},
\helpref{wxNotebook::SetImageList
}{wxnotebooksetimagelist
}
217 \membersection{wxNotebook::GetPage
}\label{wxnotebookgetpage
}
219 \func{wxNotebookPage*
}{GetPage
}{\param{size
\_t}{ page
}}
221 Returns the window at the given page position.
224 \membersection{wxNotebook::GetPageCount
}\label{wxnotebookgetpagecount
}
226 \constfunc{size
\_t}{GetPageCount
}{\void}
228 Returns the number of pages in the notebook control.
231 \membersection{wxNotebook::GetPageImage
}\label{wxnotebookgetpageimage
}
233 \constfunc{int
}{GetPageImage
}{\param{size
\_t }{nPage
}}
235 Returns the image index for the given page.
238 \membersection{wxNotebook::GetPageText
}\label{wxnotebookgetpagetext
}
240 \constfunc{wxString
}{GetPageText
}{\param{size
\_t }{nPage
}}
242 Returns the string for the given page.
245 \membersection{wxNotebook::GetRowCount
}\label{wxnotebookgetrowcount
}
247 \constfunc{int
}{GetRowCount
}{\void}
249 Returns the number of rows in the notebook control.
252 \membersection{wxNotebook::GetSelection
}\label{wxnotebookgetselection
}
254 \constfunc{int
}{GetSelection
}{\void}
256 Returns the currently selected page, or $-
1$ if none was selected.
258 Note that this method may return either the previously or newly selected page
259 when called from the
{\tt EVT
\_NOTEBOOK\_PAGE\_CHANGED} handler depending on
260 the platform and so
\rtfsp
261 \helpref{wxNotebookEvent::GetSelection
}{wxnotebookeventgetselection
} should be
262 used instead in this case.
264 \membersection{wxNotebook::GetThemeBackgroundColour
}\label{wxnotebookgetthemebackgroundcolour
}
266 \constfunc{wxColour
}{GetThemeBackgroundColour
}{\void}
268 If running under Windows and themes are enabled for the application, this function
269 returns a suitable colour for painting the background of a notebook page, and can be passed
270 to
{\tt SetBackgroundColour
}. Otherwise, an uninitialised colour will be returned.
272 \membersection{wxNotebook::HitTest
}\label{wxnotebookhittest
}
274 \func{int
}{HitTest
}{\param{const wxPoint\&
}{ pt
},
\param{long
}{ *flags =
{\tt NULL
}}}
276 Returns the index of the tab at the specified position or
{\tt wxNOT
\_FOUND}
277 if none. If
{\it flags
} parameter is non-
{\tt NULL
}, the position of the point
278 inside the tab is returned as well.
280 \wxheading{Parameters
}
282 \docparam{pt
}{Specifies the point for the hit test.
}
284 \docparam{flags
}{Return value for detailed information. One of the following values:
286 \begin{twocollist
}\itemsep=
0pt
287 \twocolitem{{\bf wxBK
\_HITTEST\_NOWHERE}}{There was no tab under this point.
}
288 \twocolitem{{\bf wxBK
\_HITTEST\_ONICON}}{The point was over an icon (currently wxMSW only).
}
289 \twocolitem{{\bf wxBK
\_HITTEST\_ONLABEL}}{The point was over a label (currently wxMSW only).
}
290 \twocolitem{{\bf wxBK
\_HITTEST\_ONITEM}}{The point was over an item, but not on the label or icon.
}
291 \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.
}
295 \wxheading{Return value
}
297 Returns the zero-based tab index or
{\tt wxNOT
\_FOUND} if there is no tab is at
298 the specified position.
302 \membersection{wxNotebook::InsertPage
}\label{wxnotebookinsertpage
}
304 \func{bool
}{InsertPage
}{\param{size
\_t}{ index
},
\param{wxNotebookPage*
}{ page
},
305 \param{const wxString\&
}{ text
},
306 \param{bool
}{ select = false
},
307 \param{int
}{ imageId = -
1}}
309 Inserts a new page at the specified position.
311 \wxheading{Parameters
}
313 \docparam{index
}{Specifies the position for the new page.
}
315 \docparam{page
}{Specifies the new page.
}
317 \docparam{text
}{Specifies the text for the new page.
}
319 \docparam{select
}{Specifies whether the page should be selected.
}
321 \docparam{imageId
}{Specifies the optional image index for the new page.
}
323 \wxheading{Return value
}
325 true if successful, false otherwise.
329 Do not delete the page, it will be deleted by the notebook.
333 \helpref{wxNotebook::AddPage
}{wxnotebookaddpage
}
336 \membersection{wxNotebook::OnSelChange
}\label{wxnotebookonselchange
}
338 \func{void
}{OnSelChange
}{\param{wxNotebookEvent\&
}{ event
}}
340 An event handler function, called when the page selection is changed.
344 \helpref{wxNotebookEvent
}{wxnotebookevent
}
347 \membersection{wxNotebook::RemovePage
}\label{wxnotebookremovepage
}
349 \func{bool
}{RemovePage
}{\param{size
\_t}{ page
}}
351 Deletes the specified page, without deleting the associated window.
354 \membersection{wxNotebook::SetImageList
}\label{wxnotebooksetimagelist
}
356 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
}}
358 Sets the image list for the page control. It does not take
359 ownership of the image list, you must delete it yourself.
363 \helpref{wxImageList
}{wximagelist
},
364 \helpref{AssignImageList
}{wxnotebookassignimagelist
}
367 \membersection{wxNotebook::SetPadding
}\label{wxnotebooksetpadding
}
369 \func{void
}{SetPadding
}{\param{const wxSize\&
}{ padding
}}
371 Sets the amount of space around each page's icon and label, in pixels.
373 {\bf NB:
} The vertical padding cannot be changed in wxGTK.
376 \membersection{wxNotebook::SetPageSize
}\label{wxnotebooksetpagesize
}
378 \func{void
}{SetPageSize
}{\param{const wxSize\&
}{ size
}}
380 Sets the width and height of the pages.
382 {\bf NB:
} This method is currently not implemented for wxGTK.
385 \membersection{wxNotebook::SetPageImage
}\label{wxnotebooksetpageimage
}
387 \func{bool
}{SetPageImage
}{\param{size
\_t}{ page
},
\param{int
}{image
}}
389 Sets the image index for the given page.
{\it image
} is an index into
390 the image list which was set with
\helpref{wxNotebook::SetImageList
}{wxnotebooksetimagelist
}.
393 \membersection{wxNotebook::SetPageText
}\label{wxnotebooksetpagetext
}
395 \func{bool
}{SetPageText
}{\param{size
\_t}{ page
},
\param{const wxString\&
}{text
}}
397 Sets the text for the given page.
400 \membersection{wxNotebook::SetSelection
}\label{wxnotebooksetselection
}
402 \func{int
}{SetSelection
}{\param{size
\_t}{ page
}}
404 Sets the selection for the given page, returning the previous selection.
406 The call to this function generates the page changing events.
408 This function is deprecated and should not be used in new code. Please use the
409 \helpref{ChangeSelection
}{wxnotebookchangeselection
} function instead.
413 \helpref{wxNotebook::GetSelection
}{wxnotebookgetselection
}
416 \membersection{wxNotebook::ChangeSelection
}\label{wxnotebookchangeselection
}
418 \func{int
}{ChangeSelection
}{\param{size
\_t}{ page
}}
420 Changes the selection for the given page, returning the previous selection.
422 The call to this function
\emph{does not
} generate the page changing events.
423 This is the only difference with
\helpref{SetSelection
}{wxnotebooksetselection
}.
424 See
\helpref{this topic
}{progevent
} for more info.