## wxNotebook

This class represents a notebook control, which manages multiple windows with associated tabs.

To use the class, create a wxNotebook object and call AddPage or InsertPage, passing a window to be used as the page. Do not explicitly delete the window for a page that is currently managed by wxNotebook.

wxNotebookPage is a typedef for wxWindow.

Derived from

wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/notebook.h>

Window styles

wxNB_LEFT | Place tabs on the left side.
wxNB_RIGHT | Place tabs on the right side.
wxNB_BOTTOM | Place tabs under instead of above the notebook pages.
wxNB_FIXEDWIDTH | (Windows only) All tabs will have same width.
wxNB_MULTILINE | (Windows only) There can be several rows of tabs.

See also window styles overview.

Event handling

To process input from a notebook control, use the following event handler macros to direct input to member functions that take a wxNotebookEvent argument.

EVT_NOTEBOOK_PAGE_CHANGED(id, func) | The page selection was changed. Processes a wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED event.
EVT_NOTEBOOK_PAGE_CHANGING(id, func) | The page selection is about to be changed. Processes a wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING event. This event can be vetoed.

See also

wxNotebookEvent, wxImageList, wxTabCtrl

Members

wxNotebook::wxNotebook
wxNotebook::~wxNotebook
wxNotebook::AddPage
wxNotebook::AdvanceSelection
wxNotebook::AssignImageList
wxNotebook::Create
wxNotebook::DeleteAllPages
wxNotebook::DeletePage
wxNotebook::GetImageList
wxNotebook::GetPage
wxNotebook::GetPageCount
wxNotebook::GetPageImage
wxNotebook::GetPageText
wxNotebook::GetRowCount
wxNotebook::GetSelection
wxNotebook::InsertPage
wxNotebook::OnSelChange
wxNotebook::RemovePage
wxNotebook::SetImageList
wxNotebook::SetPadding
wxNotebook::SetPageSize
wxNotebook::SetPageImage
wxNotebook::SetPageText
wxNotebook::SetSelection

### wxNotebook::wxNotebook

wxNotebook()

Default constructor.

wxNotebook(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "notebook")

Constructs a notebook control.

Note that sometimes you can reduce flicker by passing the wxCLIP_CHILDREN window style.

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 wxNotebook.

name

The name of the control (used only under Motif).

### wxNotebook::~wxNotebook

~wxNotebook()

Destroys the wxNotebook object.

### wxNotebook::AddPage

bool AddPage(wxNotebookPage* page, const wxString& text, bool select = FALSE, int imageId = -1)

Adds a new page.

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.

Return value

TRUE if successful, FALSE otherwise.

Remarks

Do not delete the page, it will be deleted by the notebook.

See also

wxNotebook::InsertPage

### wxNotebook::AdvanceSelection

void AdvanceSelection(bool forward = TRUE)

Cycles through the tabs.

### wxNotebook::AssignImageList

void AssignImageList(wxImageList* imageList)

Sets the image list for the page control and takes ownership of the list.

See also

wxImageList, SetImageList

### wxNotebook::Create

bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size, long style = 0, const wxString& name = "notebook")

Creates a notebook control. See wxNotebook::wxNotebook for a description of the parameters.

### wxNotebook::DeleteAllPages

bool DeleteAllPages()

Deletes all pages.

### wxNotebook::DeletePage

bool DeletePage(int page)

Deletes the specified page, and the associated window.

### wxNotebook::GetImageList

wxImageList* GetImageList() const

Returns the associated image list.

See also

wxImageList, wxNotebook::SetImageList

### wxNotebook::GetPage

wxNotebookPage* GetPage(int page)

Returns the window at the given page position.

### wxNotebook::GetPageCount

int GetPageCount() const

Returns the number of pages in the notebook control.

### wxNotebook::GetPageImage

int GetPageImage(int nPage) const

Returns the image index for the given page.

### wxNotebook::GetPageText

wxString GetPageText(int nPage) const

Returns the string for the given page.

### wxNotebook::GetRowCount

int GetRowCount() const

Returns the number of rows in the notebook control.

### wxNotebook::GetSelection

int GetSelection() const

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 wxNotebookEvent::GetSelection should be used instead in this case.

### wxNotebook::InsertPage

bool InsertPage(int index, wxNotebookPage* page, const wxString& text, bool select = FALSE, int imageId = -1)

Inserts a new page at the specified position.

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.

Return value

TRUE if successful, FALSE otherwise.

Remarks

Do not delete the page, it will be deleted by the notebook.

See also

wxNotebook::AddPage

### wxNotebook::OnSelChange

void OnSelChange(wxNotebookEvent& event)

An event handler function, called when the page selection is changed.

See also

wxNotebookEvent

### wxNotebook::RemovePage

bool RemovePage(int page)

Deletes the specified page, without deleting the associated window.

### wxNotebook::SetImageList

void SetImageList(wxImageList* imageList)

Sets the image list for the page control. It does not take ownership of the image list, you must delete it yourself.

See also

wxImageList, AssignImageList

### wxNotebook::SetPadding

void SetPadding(const wxSize& padding)

Sets the amount of space around each page's icon and label, in pixels.

NB: The vertical padding cannot be changed in wxGTK.

### wxNotebook::SetPageSize

void SetPageSize(const wxSize& size)

Sets the width and height of the pages.

NB: This method is currently not implemented for wxGTK.

### wxNotebook::SetPageImage

bool SetPageImage(int page, int image)

Sets the image index for the given page. image is an index into the image list which was set with wxNotebook::SetImageList.

### wxNotebook::SetPageText

bool SetPageText(int page, const wxString& text)

Sets the text for the given page.

### wxNotebook::SetSelection

int SetSelection(int page)

Sets the selection for the given page, returning the previous selection.

See also

wxNotebook::GetSelection