# wxBookCtrlBase Class Reference
[Book Controls]

`#include </home/work/projects/wx/2.9/wx/interface/wx/bookctrl.h>`

Inheritance diagram for wxBookCtrlBase:
[legend]

## Detailed Description

A book control is a convenient way of displaying multiple pages of information, displayed one page at a time.

wxWidgets has five variants of this control:

- wxChoicebook: controlled by a wxChoice
- wxListbook: controlled by a wxListCtrl
- wxNotebook: uses a row of tabs
- wxTreebook: controlled by a wxTreeCtrl
- wxToolbook: controlled by a wxToolBar

This abstract class is the parent of all these book controls, and provides their basic interface. This is a pure virtual class so you cannot allocate it directly.

##

Library: wxCore
Category: Book Controls

See also:
  wxBookCtrl Overview

## Public Member Functions

| wxBookCtrlBase ()
| Default ctor.
| wxBookCtrlBase (wxWindow *parent, wxWindowID winid, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxEmptyString)
| Constructs the book control with the given parameters.
bool | Create (wxWindow *parent, wxWindowID winid, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxEmptyString)
| Constructs the book control with the given parameters.
virtual void | SetPageSize (const wxSize &size)
| Sets the width and height of the pages.
virtual int | HitTest (const wxPoint &pt, long *flags=NULL) const
| Returns the index of the tab at the specified position or `wxNOT_FOUND` if none.
Image list functions
Each page may have an attached image. The functions of this group manipulate that image.
void | AssignImageList (wxImageList *imageList)
| Sets the image list for the page control and takes ownership of the list.
wxImageList * | GetImageList () const
| Returns the associated image list.
virtual int | GetPageImage (size_t nPage) const =0
| Returns the image index for the given page.
virtual void | SetImageList (wxImageList *imageList)
| Sets the image list for the page control.
virtual bool | SetPageImage (size_t page, int image)=0
| Sets the image index for the given page.
Page text functions
Each page has a text string attached. The functions of this group manipulate that text.
virtual wxString | GetPageText (size_t nPage) const =0
| Returns the string for the given page.
virtual bool | SetPageText (size_t page, const wxString &text)=0
| Sets the text for the given page.
Selection functions
The functions of this group manipulate the selection.
virtual int | GetSelection () const =0
| Returns the currently selected page, or `wxNOT_FOUND` if none was selected.
wxWindow * | GetCurrentPage () const
| Returns the currently selected page or NULL.
virtual int | SetSelection (size_t page)=0
| Sets the selection for the given page, returning the previous selection.
void | AdvanceSelection (bool forward=true)
| Cycles through the tabs.
virtual int | ChangeSelection (size_t page)=0
| Changes the selection for the given page, returning the previous selection.
Page management functions
Functions for adding/removing pages from this control.
virtual bool | AddPage (wxWindow *page, const wxString &text, bool select=false, int imageId=wxNOT_FOUND)
| Adds a new page.
virtual bool | DeleteAllPages ()
| Deletes all pages.
virtual bool | DeletePage (size_t page)
| Deletes the specified page, and the associated window.
virtual bool | InsertPage (size_t index, wxWindow *page, const wxString &text, bool select=false, int imageId=wxNOT_FOUND)=0
| Inserts a new page at the specified position.
virtual bool | RemovePage (size_t page)
| Deletes the specified page, without deleting the associated window.
virtual size_t | GetPageCount () const
| Returns the number of pages in the control.
wxWindow * | GetPage (size_t page) const
| Returns the window at the given page position.

List of all members.

## Constructor & Destructor Documentation

wxBookCtrlBase::wxBookCtrlBase | ( |  | ) |

Default ctor.

wxBookCtrlBase::wxBookCtrlBase | ( | wxWindow * | parent,
|  | wxWindowID | winid,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `0`,
|  | const wxString & | name = `wxEmptyString` |
| ) |  |  |

Constructs the book control with the given parameters.

See Create() for two-step construction.

## Member Function Documentation

virtual bool wxBookCtrlBase::AddPage | ( | wxWindow * | page,
|  | const wxString & | text,
|  | bool | select = `false`,
|  | int | imageId = `wxNOT_FOUND` |
| ) |  |  | `[virtual]`

Adds a new page.

The call to this function may generate the page changing events.

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.

Returns:
  true if successful, false otherwise.

Remarks:
  Do not delete the page, it will be deleted by the book control.

See also:
  InsertPage()

Reimplemented in wxTreebook.

void wxBookCtrlBase::AdvanceSelection | ( | bool | forward = `true` | ) |

Cycles through the tabs.

The call to this function generates the page changing events.

void wxBookCtrlBase::AssignImageList | ( | wxImageList * | imageList | ) |

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

See also:
  wxImageList, SetImageList()

virtual int wxBookCtrlBase::ChangeSelection | ( | size_t | page | ) | `[pure virtual]`

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

This function behaves as SetSelection() but does not generate the page changing events.

See User Generated Events vs Programmatically Generated Events for more information.

bool wxBookCtrlBase::Create | ( | wxWindow * | parent,
|  | wxWindowID | winid,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `0`,
|  | const wxString & | name = `wxEmptyString` |
| ) |  |  |

Constructs the book control with the given parameters.

Reimplemented from wxWindow.

Reimplemented in wxNotebook, and wxTreebook.

virtual bool wxBookCtrlBase::DeleteAllPages | ( |  | ) | `[virtual]`

Deletes all pages.

virtual bool wxBookCtrlBase::DeletePage | ( | size_t | page | ) | `[virtual]`

Deletes the specified page, and the associated window.

The call to this function generates the page changing events.

Reimplemented in wxTreebook.

wxWindow* wxBookCtrlBase::GetCurrentPage | ( |  | ) | const

Returns the currently selected page or NULL.

wxImageList* wxBookCtrlBase::GetImageList | ( |  | ) | const

Returns the associated image list.

See also:
  wxImageList, SetImageList()

wxWindow* wxBookCtrlBase::GetPage | ( | size_t | page | ) | const

Returns the window at the given page position.

virtual size_t wxBookCtrlBase::GetPageCount | ( |  | ) | const`[virtual]`

Returns the number of pages in the control.

virtual int wxBookCtrlBase::GetPageImage | ( | size_t | nPage | ) | const`[pure virtual]`

Returns the image index for the given page.

virtual wxString wxBookCtrlBase::GetPageText | ( | size_t | nPage | ) | const`[pure virtual]`

Returns the string for the given page.

virtual int wxBookCtrlBase::GetSelection | ( |  | ) | const`[pure virtual]`

Returns the currently selected page, or `wxNOT_FOUND` if none was selected.

Note that this method may return either the previously or newly selected page when called from the `EVT_BOOKCTRL_PAGE_CHANGED` handler depending on the platform and so wxBookCtrlEvent::GetSelection should be used instead in this case.

Implemented in wxTreebook.

virtual int wxBookCtrlBase::HitTest | ( | const wxPoint & | pt,
|  | long * | flags = `NULL` |
| ) |  |  | const`[virtual]`

Returns the index of the tab at the specified position or `wxNOT_FOUND` if none.

If flags parameter is non-NULL, the position of the point inside the tab is returned as well.

Parameters:

  | pt | Specifies the point for the hit test.

  flags

  Return value for detailed information. One of the following values:

  wxBK_HITTEST_NOWHERE | There was no tab under this point.
  wxBK_HITTEST_ONICON | The point was over an icon (currently wxMSW only).
  wxBK_HITTEST_ONLABEL | The point was over a label (currently wxMSW only).
  wxBK_HITTEST_ONITEM | The point was over an item, but not on the label or icon.
  wxBK_HITTEST_ONPAGE | The point was over a currently selected page, not over any tab. Note that this flag is present only if wxNOT_FOUND is returned.

Returns:
  Returns the zero-based tab index or `wxNOT_FOUND` if there is no tab at the specified position.

virtual bool wxBookCtrlBase::InsertPage | ( | size_t | index,
|  | wxWindow * | page,
|  | const wxString & | text,
|  | bool | select = `false`,
|  | int | imageId = `wxNOT_FOUND` |
| ) |  |  | `[pure virtual]`

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.

Returns:
  true if successful, false otherwise.

Remarks:
  Do not delete the page, it will be deleted by the book control.

See also:
  AddPage()

Implemented in wxTreebook.

virtual bool wxBookCtrlBase::RemovePage | ( | size_t | page | ) | `[virtual]`

Deletes the specified page, without deleting the associated window.

virtual void wxBookCtrlBase::SetImageList | ( | wxImageList * | imageList | ) | `[virtual]`

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()

virtual bool wxBookCtrlBase::SetPageImage | ( | size_t | page,
|  | int | image |
| ) |  |  | `[pure virtual]`

Sets the image index for the given page.

image is an index into the image list which was set with SetImageList().

virtual void wxBookCtrlBase::SetPageSize | ( | const wxSize & | size | ) | `[virtual]`

Sets the width and height of the pages.

Note:
  This method is currently not implemented for wxGTK.

virtual bool wxBookCtrlBase::SetPageText | ( | size_t | page,
|  | const wxString & | text |
| ) |  |  | `[pure virtual]`

Sets the text for the given page.

virtual int wxBookCtrlBase::SetSelection | ( | size_t | page | ) | `[pure virtual]`

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

Notice that the call to this function generates the page changing events, use the ChangeSelection() function if you don't want these events to be generated.

See also:
  GetSelection()

|  | [ top ]