1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxNotebook
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 This class represents a notebook control, which manages multiple windows with
15 To use the class, create a wxNotebook object and call wxNotebook::AddPage
16 or wxNotebook::InsertPage, passing a window to be used as the page. Do not
17 explicitly delete the window for a page that is currently managed by
20 @b wxNotebookPage is a typedef for wxWindow.
24 Place tabs on the top side.
26 Place tabs on the left side.
28 Place tabs on the right side.
30 Place tabs under instead of above the notebook pages.
31 @style{wxNB_FIXEDWIDTH}
32 (Windows only) All tabs will have same width.
33 @style{wxNB_MULTILINE}
34 (Windows only) There can be several rows of tabs.
35 @style{wxNB_NOPAGETHEME}
36 (Windows only) Display a solid colour on notebook pages, and not a
37 gradient, which can reduce performance.
39 (Windows CE only) Show tabs in a flat style.
45 @see wxBookCtrl, wxBookCtrlEvent, wxImageList, @ref page_samples_notebook
47 class wxNotebook
: public wxBookCtrl
52 Constructs a notebook control.
57 Constructs a notebook control.
58 Note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN
62 The parent window. Must be non-@NULL.
64 The window identifier.
70 The window style. See wxNotebook.
72 The name of the control.
74 wxNotebook(wxWindow
* parent
, wxWindowID id
,
75 const wxPoint
& pos
= wxDefaultPosition
,
76 const wxSize
& size
= wxDefaultSize
,
78 const wxString
& name
= wxNotebookNameStr
);
81 Destroys the wxNotebook object.
83 virtual ~wxNotebook();
87 The call to this function may generate the page changing events.
90 Specifies the new page.
92 Specifies the text for the new page.
94 Specifies whether the page should be selected.
96 Specifies the optional image index for the new page.
98 @return @true if successful, @false otherwise.
100 @remarks Do not delete the page, it will be deleted by the notebook.
104 bool AddPage(wxNotebookPage
* page
, const wxString
& text
,
109 Cycles through the tabs.
110 The call to this function generates the page changing events.
112 void AdvanceSelection(bool forward
= true);
115 Sets the image list for the page control and takes ownership of the list.
117 @see wxImageList, SetImageList()
119 void AssignImageList(wxImageList
* imageList
);
122 Changes the selection for the given page, returning the previous selection.
124 The call to this function does NOT generate the page changing events.
125 This is the only difference with SetSelection().
126 See @ref overview_eventhandling_prog for more infomation.
128 virtual int ChangeSelection(size_t page
);
131 Creates a notebook control.
132 See wxNotebook() for a description of the parameters.
134 bool Create(wxWindow
* parent
, wxWindowID id
,
135 const wxPoint
& pos
= wxDefaultPosition
,
136 const wxSize
& size
= wxDefaultSize
,
138 const wxString
& name
= wxNotebookNameStr
);
143 virtual bool DeleteAllPages();
146 Deletes the specified page, and the associated window.
147 The call to this function generates the page changing events.
149 bool DeletePage(size_t page
);
152 Returns the currently selected notebook page or @NULL.
154 wxWindow
* GetCurrentPage() const;
157 Returns the associated image list.
159 @see wxImageList, SetImageList()
161 wxImageList
* GetImageList() const;
164 Returns the window at the given page position.
166 wxNotebookPage
* GetPage(size_t page
);
169 Returns the number of pages in the notebook control.
171 size_t GetPageCount() const;
174 Returns the image index for the given page.
176 virtual int GetPageImage(size_t nPage
) const;
179 Returns the string for the given page.
181 virtual wxString
GetPageText(size_t nPage
) const;
184 Returns the number of rows in the notebook control.
186 virtual int GetRowCount() const;
189 Returns the currently selected page, or -1 if none was selected.
191 Note that this method may return either the previously or newly
192 selected page when called from the @c EVT_NOTEBOOK_PAGE_CHANGED handler
193 depending on the platform and so wxBookCtrlEvent::GetSelection should be
194 used instead in this case.
196 virtual int GetSelection() const;
199 If running under Windows and themes are enabled for the application, this
200 function returns a suitable colour for painting the background of a notebook
201 page, and can be passed to SetBackgroundColour().
203 Otherwise, an uninitialised colour will be returned.
205 virtual wxColour
GetThemeBackgroundColour() const;
208 Returns the index of the tab at the specified position or @c wxNOT_FOUND
209 if none. If @a flags parameter is non-@NULL, the position of the point
210 inside the tab is returned as well.
213 Specifies the point for the hit test.
215 Return value for detailed information. One of the following values:
216 <TABLE><TR><TD>wxBK_HITTEST_NOWHERE</TD>
217 <TD>There was no tab under this point.</TD></TR>
218 <TR><TD>wxBK_HITTEST_ONICON</TD>
219 <TD>The point was over an icon (currently wxMSW only).</TD></TR>
220 <TR><TD>wxBK_HITTEST_ONLABEL</TD>
221 <TD>The point was over a label (currently wxMSW only).</TD></TR>
222 <TR><TD>wxBK_HITTEST_ONITEM</TD>
223 <TD>The point was over an item, but not on the label or icon.</TD></TR>
224 <TR><TD>wxBK_HITTEST_ONPAGE</TD>
225 <TD>The point was over a currently selected page, not over any tab.
226 Note that this flag is present only if wxNOT_FOUND is returned.</TD></TR>
229 @return Returns the zero-based tab index or @c wxNOT_FOUND if there is no
230 tab at the specified position.
232 virtual int HitTest(const wxPoint
& pt
, long* flags
= NULL
) const;
235 Inserts a new page at the specified position.
238 Specifies the position for the new page.
240 Specifies the new page.
242 Specifies the text for the new page.
244 Specifies whether the page should be selected.
246 Specifies the optional image index for the new page.
248 @return @true if successful, @false otherwise.
250 @remarks Do not delete the page, it will be deleted by the notebook.
254 virtual bool InsertPage(size_t index
, wxNotebookPage
* page
,
255 const wxString
& text
, bool select
= false,
259 An event handler function, called when the page selection is changed.
263 void OnSelChange(wxBookCtrlEvent
& event
);
266 Deletes the specified page, without deleting the associated window.
268 bool RemovePage(size_t page
);
271 Sets the image list for the page control.
272 It does not take ownership of the image list, you must delete it yourself.
274 @see wxImageList, AssignImageList()
276 void SetImageList(wxImageList
* imageList
);
279 Sets the amount of space around each page's icon and label, in pixels.
281 @note The vertical padding cannot be changed in wxGTK.
283 virtual void SetPadding(const wxSize
& padding
);
286 Sets the image index for the given page. @a image is an index into
287 the image list which was set with SetImageList().
289 virtual bool SetPageImage(size_t page
, int image
);
292 Sets the width and height of the pages.
294 @note This method is currently not implemented for wxGTK.
296 virtual void SetPageSize(const wxSize
& size
);
299 Sets the text for the given page.
301 virtual bool SetPageText(size_t page
, const wxString
& text
);
304 Sets the selection for the given page, returning the previous selection.
305 The call to this function generates the page changing events.
308 This function is deprecated and should not be used in new code.
309 Please use the ChangeSelection() function instead.
313 virtual int SetSelection(size_t page
);