Contents Up Previous Next

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_FIXEDWIDTH (Windows only)All tabs will have same width.
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.

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.
EVT_NOTEBOOK_PAGE_CHANGING(id, func) The page selection is about to be changed. This can be prevented by calling Veto().
See also

wxNotebookEvent, wxImageList, wxTabCtrl

Members

wxNotebook::wxNotebook
wxNotebook::~wxNotebook
wxNotebook::AddPage
wxNotebook::AdvanceSelection
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, 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

id

pos

size

style

name


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

text

select

imageId

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


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

page

text

select

imageId

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.

See also

wxImageList


wxNotebook::SetPadding

void SetPadding(const wxSize& padding)

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


wxNotebook::SetPageSize

void SetPageSize(const wxSize& size)

Sets the width and height of the pages.


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