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 \helpref{wxControl
}{wxcontrol
}\\
14 \helpref{wxWindow
}{wxwindow
}\\
15 \helpref{wxEvtHandler
}{wxevthandler
}\\
16 \helpref{wxObject
}{wxobject
}
18 \wxheading{Include files
}
22 \wxheading{Window styles
}
25 \begin{twocollist
}\itemsep=
0pt
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.
}
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.
}
32 \twocolitem{\windowstyle{wxNB
\_NOPAGETHEME}}{(Windows only) Display a solid colour on notebook pages, and not a gradient, which can reduce performance.
}
36 The styles
\texttt{wxNB
\_LEFT},
\texttt{RIGHT
} and
\texttt{BOTTOM
} are not
37 supported under Microsoft Windows XP when using visual themes.
39 See also
\helpref{window styles overview
}{windowstyles
}.
43 \wxheading{Page backgrounds
}
45 On Windows XP, the default theme paints a gradient on the notebook's pages.
46 If you wish to suppress this theme, for aesthetic or performance reasons,
47 there are three ways of doing it. You can use wxNB
\_NOPAGETHEME to disable
48 themed drawing for a particular notebook, you can call
{\tt wxSystemOptions::SetOption
}
49 to disable it for the whole application, or you can disable it for individual
50 pages by using
{\tt SetBackgroundColour
}.
52 To disable themed pages globally:
55 wxSystemOptions::SetOption(wxT("msw.notebook.themed-background"),
0);
58 Set the value to
1 to enable it again.
60 To give a single page a solid background that more or less fits in with the
64 wxColour col = notebook->GetThemeBackgroundColour();
67 page->SetBackgroundColour(col);
71 On platforms other than Windows, or if the application is not using Windows
72 themes,
{\tt GetThemeBackgroundColour
} will return an uninitialised colour object,
73 and the above code will therefore work on all platforms.
77 \helpref{wxBookCtrl
}{wxbookctrloverview
},
\helpref{wxNotebookEvent
}{wxnotebookevent
},
\helpref{wxImageList
}{wximagelist
},
\helpref{notebook sample
}{samplenotebook
}\rtfsp
79 \latexignore{\rtfignore{\wxheading{Members
}}}
81 \membersection{wxNotebook::wxNotebook
}\label{wxnotebookctor
}
83 \func{}{wxNotebook
}{\void}
87 \func{}{wxNotebook
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
88 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style =
0},
\param{const wxString\&
}{name = wxNotebookNameStr
}}
90 Constructs a notebook control.
92 Note that sometimes you can reduce flicker by passing the wxCLIP
\_CHILDREN window style.
94 \wxheading{Parameters
}
96 \docparam{parent
}{The parent window. Must be non-NULL.
}
98 \docparam{id
}{The window identifier.
}
100 \docparam{pos
}{The window position.
}
102 \docparam{size
}{The window size.
}
104 \docparam{style
}{The window style. See
\helpref{wxNotebook
}{wxnotebook
}.
}
106 \docparam{name
}{The name of the control (used only under Motif).
}
109 \membersection{wxNotebook::
\destruct{wxNotebook
}}\label{wxnotebookdtor
}
111 \func{}{\destruct{wxNotebook
}}{\void}
113 Destroys the wxNotebook object.
116 \membersection{wxNotebook::AddPage
}\label{wxnotebookaddpage
}
118 \func{bool
}{AddPage
}{\param{wxNotebookPage*
}{ page
},
119 \param{const wxString\&
}{ text
},
120 \param{bool
}{ select = false
},
121 \param{int
}{ imageId = -
1}}
125 The call to this function may generate the page changing events.
127 \wxheading{Parameters
}
129 \docparam{page
}{Specifies the new page.
}
131 \docparam{text
}{Specifies the text for the new page.
}
133 \docparam{select
}{Specifies whether the page should be selected.
}
135 \docparam{imageId
}{Specifies the optional image index for the new page.
}
137 \wxheading{Return value
}
139 true if successful, false otherwise.
143 Do not delete the page, it will be deleted by the notebook.
147 \helpref{wxNotebook::InsertPage
}{wxnotebookinsertpage
}
150 \membersection{wxNotebook::AdvanceSelection
}\label{wxnotebookadvanceselection
}
152 \func{void
}{AdvanceSelection
}{\param{bool
}{ forward = true
}}
154 Cycles through the tabs.
156 The call to this function generates the page changing events.
159 \membersection{wxNotebook::AssignImageList
}\label{wxnotebookassignimagelist
}
161 \func{void
}{AssignImageList
}{\param{wxImageList*
}{ imageList
}}
163 Sets the image list for the page control and takes ownership of
168 \helpref{wxImageList
}{wximagelist
},
169 \helpref{SetImageList
}{wxnotebooksetimagelist
}
172 \membersection{wxNotebook::Create
}\label{wxnotebookcreate
}
174 \func{bool
}{Create
}{\param{wxWindow*
}{ parent
},
\param{wxWindowID
}{id
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
175 \param{const wxSize\&
}{ size
},
\param{long
}{ style =
0},
\param{const wxString\&
}{name = wxNotebookNameStr
}}
177 Creates a notebook control. See
\helpref{wxNotebook::wxNotebook
}{wxnotebookctor
} for a description
181 \membersection{wxNotebook::DeleteAllPages
}\label{wxnotebookdeleteallpages
}
183 \func{bool
}{DeleteAllPages
}{\void}
188 \membersection{wxNotebook::DeletePage
}\label{wxnotebookdeletepage
}
190 \func{bool
}{DeletePage
}{\param{size
\_t}{ page
}}
192 Deletes the specified page, and the associated window.
194 The call to this function generates the page changing events.
197 \membersection{wxNotebook::GetCurrentPage
}\label{wxnotebookgetcurrentpage
}
199 \constfunc{wxWindow *
}{GetCurrentPage
}{\void}
201 Returns the currently selected notebook age or
\texttt{NULL
}.
204 \membersection{wxNotebook::GetImageList
}\label{wxnotebookgetimagelist
}
206 \constfunc{wxImageList*
}{GetImageList
}{\void}
208 Returns the associated image list.
212 \helpref{wxImageList
}{wximagelist
},
\helpref{wxNotebook::SetImageList
}{wxnotebooksetimagelist
}
215 \membersection{wxNotebook::GetPage
}\label{wxnotebookgetpage
}
217 \func{wxNotebookPage*
}{GetPage
}{\param{size
\_t}{ page
}}
219 Returns the window at the given page position.
222 \membersection{wxNotebook::GetPageCount
}\label{wxnotebookgetpagecount
}
224 \constfunc{size
\_t}{GetPageCount
}{\void}
226 Returns the number of pages in the notebook control.
229 \membersection{wxNotebook::GetPageImage
}\label{wxnotebookgetpageimage
}
231 \constfunc{int
}{GetPageImage
}{\param{size
\_t }{nPage
}}
233 Returns the image index for the given page.
236 \membersection{wxNotebook::GetPageText
}\label{wxnotebookgetpagetext
}
238 \constfunc{wxString
}{GetPageText
}{\param{size
\_t }{nPage
}}
240 Returns the string for the given page.
243 \membersection{wxNotebook::GetRowCount
}\label{wxnotebookgetrowcount
}
245 \constfunc{int
}{GetRowCount
}{\void}
247 Returns the number of rows in the notebook control.
250 \membersection{wxNotebook::GetSelection
}\label{wxnotebookgetselection
}
252 \constfunc{int
}{GetSelection
}{\void}
254 Returns the currently selected page, or $-
1$ if none was selected.
256 Note that this method may return either the previously or newly selected page
257 when called from the
{\tt EVT
\_NOTEBOOK\_PAGE\_CHANGED} handler depending on
258 the platform and so
\rtfsp
259 \helpref{wxNotebookEvent::GetSelection
}{wxnotebookeventgetselection
} should be
260 used instead in this case.
262 \membersection{wxNotebook::GetThemeBackgroundColour
}\label{wxnotebookgetthemebackgroundcolour
}
264 \constfunc{wxColour
}{GetThemeBackgroundColour
}{\void}
266 If running under Windows and themes are enabled for the application, this function
267 returns a suitable colour for painting the background of a notebook page, and can be passed
268 to
{\tt SetBackgroundColour
}. Otherwise, an uninitialised colour will be returned.
270 \membersection{wxNotebook::HitTest
}\label{wxnotebookhittest
}
272 \func{int
}{HitTest
}{\param{const wxPoint\&
}{ pt
},
\param{long
}{ *flags =
{\tt NULL
}}}
274 Returns the index of the tab at the specified position or
{\tt wxNOT
\_FOUND}
275 if none. If
{\it flags
} parameter is non
{\tt NULL
}, the position of the point
276 inside the tab is returned as well.
278 {\bf NB:
} This method is currently only implemented under wxMSW and wxUniv.
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 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.
}
294 \wxheading{Return value
}
296 Returns the zero-based tab index or
{\tt wxNOT
\_FOUND} if there is no tab is at
297 the specified position.
301 \membersection{wxNotebook::InsertPage
}\label{wxnotebookinsertpage
}
303 \func{bool
}{InsertPage
}{\param{size
\_t}{ index
},
\param{wxNotebookPage*
}{ page
},
304 \param{const wxString\&
}{ text
},
305 \param{bool
}{ select = false
},
306 \param{int
}{ imageId = -
1}}
308 Inserts a new page at the specified position.
310 \wxheading{Parameters
}
312 \docparam{index
}{Specifies the position for the new page.
}
314 \docparam{page
}{Specifies the new page.
}
316 \docparam{text
}{Specifies the text for the new page.
}
318 \docparam{select
}{Specifies whether the page should be selected.
}
320 \docparam{imageId
}{Specifies the optional image index for the new page.
}
322 \wxheading{Return value
}
324 true if successful, false otherwise.
328 Do not delete the page, it will be deleted by the notebook.
332 \helpref{wxNotebook::AddPage
}{wxnotebookaddpage
}
335 \membersection{wxNotebook::OnSelChange
}\label{wxnotebookonselchange
}
337 \func{void
}{OnSelChange
}{\param{wxNotebookEvent\&
}{ event
}}
339 An event handler function, called when the page selection is changed.
343 \helpref{wxNotebookEvent
}{wxnotebookevent
}
346 \membersection{wxNotebook::RemovePage
}\label{wxnotebookremovepage
}
348 \func{bool
}{RemovePage
}{\param{size
\_t}{ page
}}
350 Deletes the specified page, without deleting the associated window.
353 \membersection{wxNotebook::SetImageList
}\label{wxnotebooksetimagelist
}
355 \func{void
}{SetImageList
}{\param{wxImageList*
}{ imageList
}}
357 Sets the image list for the page control. It does not take
358 ownership of the image list, you must delete it yourself.
362 \helpref{wxImageList
}{wximagelist
},
363 \helpref{AssignImageList
}{wxnotebookassignimagelist
}
366 \membersection{wxNotebook::SetPadding
}\label{wxnotebooksetpadding
}
368 \func{void
}{SetPadding
}{\param{const wxSize\&
}{ padding
}}
370 Sets the amount of space around each page's icon and label, in pixels.
372 {\bf NB:
} The vertical padding cannot be changed in wxGTK.
375 \membersection{wxNotebook::SetPageSize
}\label{wxnotebooksetpagesize
}
377 \func{void
}{SetPageSize
}{\param{const wxSize\&
}{ size
}}
379 Sets the width and height of the pages.
381 {\bf NB:
} This method is currently not implemented for wxGTK.
384 \membersection{wxNotebook::SetPageImage
}\label{wxnotebooksetpageimage
}
386 \func{bool
}{SetPageImage
}{\param{size
\_t}{ page
},
\param{int
}{image
}}
388 Sets the image index for the given page.
{\it image
} is an index into
389 the image list which was set with
\helpref{wxNotebook::SetImageList
}{wxnotebooksetimagelist
}.
392 \membersection{wxNotebook::SetPageText
}\label{wxnotebooksetpagetext
}
394 \func{bool
}{SetPageText
}{\param{size
\_t}{ page
},
\param{const wxString\&
}{text
}}
396 Sets the text for the given page.
399 \membersection{wxNotebook::SetSelection
}\label{wxnotebooksetselection
}
401 \func{int
}{SetSelection
}{\param{size
\_t}{ page
}}
403 Sets the selection for the given page, returning the previous selection.
405 The call to this function generates the page changing events.
409 \helpref{wxNotebook::GetSelection
}{wxnotebookgetselection
}