h1(#wxnotebook). Wx::Notebook
This class represents a notebook control, which manages multiple windows with associated tabs.
To use the class, create a Notebook object and call "add_page":#Notebook_addpage or "insert_page":#Notebook_insertpage,
passing a window to be used as the page. Do not explicitly delete the window for a page that is currently
managed by Notebook.
*NotebookPage* is a typedef for Window.
h2. Derived from
"Control":control.html
"Window":window.html
"EvtHandler":evthandler.html
"Object":object.html
h2. Window styles
|@NB_TOP@|Place tabs on the top side.|
|@NB_LEFT@|Place tabs on the left side.|
|@NB_RIGHT@|Place tabs on the right side.|
|@NB_BOTTOM@|Place tabs under instead of above the notebook pages.|
|@NB_FIXEDWIDTH@|(Windows only) All tabs will have same width.|
|@NB_MULTILINE@|(Windows only) There can be several rows of tabs.|
|@NB_NOPAGETHEME@|(Windows only) Display a solid colour on notebook pages, and not a gradient, which can reduce performance.|
|@NB_FLAT@|(Windows CE only) Show tabs in a flat style.|
The styles @NB_LEFT@, @RIGHT@ and @BOTTOM@ are not
supported under Microsoft Windows XP when using visual themes.
See also "window styles overview":windowstyles.html.
noteevt.inc
h2. Page backgrounds
On Windows XP, the default theme paints a gradient on the notebook's pages.
If you wish to suppress this theme, for aesthetic or performance reasons,
there are three ways of doing it. You can use NB_NOPAGETHEME to disable
themed drawing for a particular notebook, you can call @SystemOptions::SetOption@
to disable it for the whole application, or you can disable it for individual
pages by using @SetBackgroundColour@.
To disable themed pages globally:
SystemOptions::SetOption(T("msw.notebook.themed-background"), 0);
Set the value to 1 to enable it again.
To give a single page a solid background that more or less fits in with the
overall theme, use:
Colour col = notebook->GetThemeBackgroundColour();
if (col.Ok())
{
page->SetBackgroundColour(col);
}
On platforms other than Windows, or if the application is not using Windows
themes, @GetThemeBackgroundColour@ will return an uninitialised colour object,
and the above code will therefore work on all platforms.
h2. See also
"BookCtrl":bookctrloverview.html, "NotebookEvent":notebookevent.html, "ImageList":imagelist.html, "notebook sample":samplenotebook.html
h2. Methods
* "Notebook.new":#Notebook_new
* "Notebook#add_page":#Notebook_addpage
* "Notebook#advance_selection":#Notebook_advanceselection
* "Notebook#create":#Notebook_create
* "Notebook#delete_all_pages":#Notebook_deleteallpages
* "Notebook#delete_page":#Notebook_deletepage
* "Notebook#get_current_page":#Notebook_getcurrentpage
* "Notebook#get_image_list":#Notebook_getimagelist
* "Notebook#get_page":#Notebook_getpage
* "Notebook#get_page_count":#Notebook_getpagecount
* "Notebook#get_page_image":#Notebook_getpageimage
* "Notebook#get_page_text":#Notebook_getpagetext
* "Notebook#get_row_count":#Notebook_getrowcount
* "Notebook#get_selection":#Notebook_getselection
* "Notebook#get_theme_background_colour":#Notebook_getthemebackgroundcolour
* "Notebook#hit_test":#Notebook_hittest
* "Notebook#insert_page":#Notebook_insertpage
* "Notebook#on_sel_change":#Notebook_onselchange
* "Notebook#remove_page":#Notebook_removepage
* "Notebook#set_image_list":#Notebook_setimagelist
* "Notebook#set_padding":#Notebook_setpadding
* "Notebook#set_page_size":#Notebook_setpagesize
* "Notebook#set_page_image":#Notebook_setpageimage
* "Notebook#set_page_text":#Notebook_setpagetext
* "Notebook#set_selection":#Notebook_setselection
h3(#Notebook_new). Notebook.new
*Notebook.new*(%(arg-type)"Window":window.html% parent, %(arg-type)Integer% id,
%(arg-type)"Point":point.html% pos = DEFAULT_POSITION,
%(arg-type)"Size":size.html% size = DEFAULT_SIZE, %(arg-type)Integer% style = 0,
%(arg-type)String% name = NotebookNameStr)
Constructs a notebook control.
Note that sometimes you can reduce flicker by passing the CLIP_CHILDREN window style.
h4. Parameters
* _parent_ The parent window. Must be non-NULL.
* _id_ The window identifier.
* _pos_ The window position.
* _size_ The window size.
* _style_ The window style. See "Notebook":notebook.html.
* _name_ The name of the control (used only under Motif).
*destructor*()
Destroys the Notebook object.
h3(#Notebook_addpage). Notebook#add_page
Boolean *add_page*(%(arg-type)"NotebookPage":notebookpage.html% page, %(arg-type)String% text,
%(arg-type)Boolean% select = false,
%(arg-type)Integer% imageId = -1)
Adds a new page.
The call to this function may generate the page changing events.
h4. Parameters
* _page_ Specifies the new page.
* _text_ Specifies the text for the new page.
* _select_ Specifies whether the page should be selected.
* _imageId_ Specifies the optional image index for the new page.
h4. Return value
true if successful, false otherwise.
h4. Remarks
Do not delete the page, it will be deleted by the notebook.
h4. See also
"Notebook#insert_page":notebook.html#Notebook_insertpage
h3(#Notebook_advanceselection). Notebook#advance_selection
*advance_selection*(%(arg-type)Boolean% forward = true)
Cycles through the tabs.
The call to this function generates the page changing events.
h3(#Notebook_create). Notebook#create
Boolean *create*(%(arg-type)"Window":window.html% parent, %(arg-type)Integer% id,
%(arg-type)"Point":point.html% pos = DEFAULT_POSITION, %(arg-type)"Size":size.html% size, %(arg-type)Integer% style = 0,
%(arg-type)String% name = NotebookNameStr)
Creates a notebook control. See "Notebook.new":notebook.html#Notebook_new for a description
of the parameters.
h3(#Notebook_deleteallpages). Notebook#delete_all_pages
Boolean *delete_all_pages*()
Deletes all pages.
h3(#Notebook_deletepage). Notebook#delete_page
Boolean *delete_page*(%(arg-type)Integer% page)
Deletes the specified page, and the associated window.
The call to this function generates the page changing events.
h3(#Notebook_getcurrentpage). Notebook#get_current_page
"Window":window.html *get_current_page*()
Returns the currently selected notebook age or @NULL@.
h3(#Notebook_getimagelist). Notebook#get_image_list
"ImageList":imagelist.html *get_image_list*()
Returns the associated image list.
h4. See also
"ImageList":imagelist.html, "Notebook#set_image_list":notebook.html#Notebook_setimagelist
h3(#Notebook_getpage). Notebook#get_page
"NotebookPage":notebookpage.html *get_page*(%(arg-type)Integer% page)
Returns the window at the given page position.
h3(#Notebook_getpagecount). Notebook#get_page_count
Integer *get_page_count*()
Returns the number of pages in the notebook control.
h3(#Notebook_getpageimage). Notebook#get_page_image
Integer *get_page_image*(%(arg-type)Integer% nPage)
Returns the image index for the given page.
h3(#Notebook_getpagetext). Notebook#get_page_text
String *get_page_text*(%(arg-type)Integer% nPage)
Returns the string for the given page.
h3(#Notebook_getrowcount). Notebook#get_row_count
Integer *get_row_count*()
Returns the number of rows in the notebook control.
h3(#Notebook_getselection). Notebook#get_selection
Integer *get_selection*()
Returns the currently selected page, or $-1$ if none was selected.
Note that this method may return either the previously or newly selected page
when called from the @EVT_NOTEBOOK_PAGE_CHANGED@ handler depending on
the platform and so "NotebookEvent#get_selection":notebookevent.html#NotebookEvent_getselection should be
used instead in this case.
h3(#Notebook_getthemebackgroundcolour). Notebook#get_theme_background_colour
"Colour":colour.html *get_theme_background_colour*()
If running under Windows and themes are enabled for the application, this function
returns a suitable colour for painting the background of a notebook page, and can be passed
to @SetBackgroundColour@. Otherwise, an uninitialised colour will be returned.
h3(#Notebook_hittest). Notebook#hit_test
Integer *hit_test*(%(arg-type)"Point":point.html% pt, %(arg-type)Integer% flags = @NULL@)
Returns the index of the tab at the specified position or @NOT_FOUND@
if none. If _flags_ parameter is non @NULL@, the position of the point
inside the tab is returned as well.
*NB: * This method is currently only implemented under MSW and Univ.
h4. Parameters
* _pt_ Specifies the point for the hit test.
* _flags_ Return value for detailed information. One of the following values:
|*NB_HITTEST_NOWHERE*|There was no tab under this point.|
|*NB_HITTEST_ONICON*|The point was over an icon (currently MSW only).|
|*NB_HITTEST_ONLABEL*|The point was over a label (currently MSW only).|
|*NB_HITTEST_ONITEM*|The point was over an item, but not on the label or icon.|
h4. Return value
Returns the zero-based tab index or @NOT_FOUND@ if there is no tab is at
the specified position.
h3(#Notebook_insertpage). Notebook#insert_page
Boolean *insert_page*(%(arg-type)Integer% index, %(arg-type)"NotebookPage":notebookpage.html% page,
%(arg-type)String% text,
%(arg-type)Boolean% select = false,
%(arg-type)Integer% imageId = -1)
Inserts a new page at the specified position.
h4. Parameters
* _index_ Specifies the position for the new page.
* _page_ Specifies the new page.
* _text_ Specifies the text for the new page.
* _select_ Specifies whether the page should be selected.
* _imageId_ Specifies the optional image index for the new page.
h4. Return value
true if successful, false otherwise.
h4. Remarks
Do not delete the page, it will be deleted by the notebook.
h4. See also
"Notebook#add_page":notebook.html#Notebook_addpage
h3(#Notebook_onselchange). Notebook#on_sel_change
*on_sel_change*(%(arg-type)"NotebookEvent":notebookevent.html% event)
An event handler function, called when the page selection is changed.
h4. See also
"NotebookEvent":notebookevent.html
h3(#Notebook_removepage). Notebook#remove_page
Boolean *remove_page*(%(arg-type)Integer% page)
Deletes the specified page, without deleting the associated window.
h3(#Notebook_setimagelist). Notebook#set_image_list
*set_image_list*(%(arg-type)"ImageList":imagelist.html% imageList)
Sets the "image list":imagelist.html which can be used to supply icons
for each tab within the notebook.
Once an image list has been assigned to a Notebook, it "belongs" to the
Notebook, and should not be set as the image list for another Notebook
or other control.
h3(#Notebook_setpadding). Notebook#set_padding
*set_padding*(%(arg-type)"Size":size.html% padding)
Sets the amount of space around each page's icon and label, in pixels.
*NB:* The vertical padding cannot be changed in GTK.
h3(#Notebook_setpagesize). Notebook#set_page_size
*set_page_size*(%(arg-type)"Size":size.html% size)
Sets the width and height of the pages.
*NB:* This method is currently not implemented for GTK.
h3(#Notebook_setpageimage). Notebook#set_page_image
Boolean *set_page_image*(%(arg-type)Integer% page, %(arg-type)Integer% image)
Sets the image index for the given page. _image_ is an index into
the image list which was set with "Notebook#set_image_list":notebook.html#Notebook_setimagelist.
h3(#Notebook_setpagetext). Notebook#set_page_text
Boolean *set_page_text*(%(arg-type)Integer% page, %(arg-type)String% text)
Sets the text for the given page.
h3(#Notebook_setselection). Notebook#set_selection
Integer *set_selection*(%(arg-type)Integer% page)
Sets the selection for the given page, returning the previous selection.
The call to this function generates the page changing events.
h4. See also
"Notebook#get_selection":notebook.html#Notebook_getselection