Public Member Functions

# wxTreebook Class Reference
[Book Controls]

`#include <wx/treebook.h>`

Inheritance diagram for wxTreebook:
[legend]

## Detailed Description

This class is an extension of the wxNotebook class that allows a tree structured set of pages to be shown in a control.

A classic example is a netscape preferences dialog that shows a tree of preference sections on the left and select section page on the right.

To use the class simply create it and populate with pages using InsertPage(), InsertSubPage(), AddPage(), AddSubPage().

If your tree is no more than 1 level in depth then you could simply use AddPage() and AddSubPage() to sequentially populate your tree by adding at every step a page or a subpage to the end of the tree.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxBookCtrlEvent& event)

Event macros for events emitted by this class:

- EVT_TREEBOOK_PAGE_CHANGED(id, func):
  The page selection was changed. Processes a `wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED` event.
- EVT_TREEBOOK_PAGE_CHANGING(id, func):
  The page selection is about to be changed. Processes a `wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING` event. This event can be vetoed.
- EVT_TREEBOOK_NODE_COLLAPSED(id, func):
  The page node is going to be collapsed. Processes a `wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED` event.
- EVT_TREEBOOK_NODE_EXPANDED(id, func):
  The page node is going to be expanded. Processes a `wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED` event.

##

Library: wxCore
Category: Book Controls

See also:
  wxBookCtrl, wxBookCtrlEvent, wxNotebook, wxTreeCtrl, wxImageList, wxBookCtrl Overview, Notebook Sample

## Public Member Functions
| wxTreebook ()
| Default constructor.
| wxTreebook (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxBK_DEFAULT, const wxString &name=wxEmptyString)
| Creates an empty wxTreebook.
virtual | ~wxTreebook ()
| Destroys the wxTreebook object.
virtual bool | AddPage (wxWindow *page, const wxString &text, bool bSelect=false, int imageId=wxNOT_FOUND)
| Adds a new page.
virtual bool | AddSubPage (wxWindow *page, const wxString &text, bool bSelect=false, int imageId=wxNOT_FOUND)
| Adds a new child-page to the last top-level page.
bool | CollapseNode (size_t pageId)
| Shortcut for ExpandNode( pageId, false ).
bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxBK_DEFAULT, const wxString &name=wxEmptyString)
| Creates a treebook control.
virtual bool | DeletePage (size_t pagePos)
| Deletes the page at the specified position and all its children.
virtual bool | ExpandNode (size_t pageId, bool expand=true)
| Expands (collapses) the pageId node.
int | GetPageParent (size_t page) const
| Returns the parent page of the given one or `wxNOT_FOUND` if this is a top-level page.
virtual int | GetSelection () const
| Returns the currently selected page, or `wxNOT_FOUND` if none was selected.
virtual bool | InsertPage (size_t pagePos, wxWindow *page, const wxString &text, bool bSelect=false, int imageId=wxNOT_FOUND)
| Inserts a new page just before the page indicated by pagePos.
virtual bool | InsertSubPage (size_t pagePos, wxWindow *page, const wxString &text, bool bSelect=false, int imageId=wxNOT_FOUND)
| Inserts a sub page under the specified page.
virtual bool | IsNodeExpanded (size_t pageId) const
| Returns true if the page represented by pageId is expanded.

List of all members.

## Constructor & Destructor Documentation

wxTreebook::wxTreebook | ( |  | ) |

Default constructor.

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

Creates an empty wxTreebook.

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

virtual wxTreebook::~wxTreebook | ( |  | ) | `[virtual]`

Destroys the wxTreebook object.

Also deletes all the pages owned by the control (inserted previously into it).

## Member Function Documentation

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

Adds a new page.

The page is placed at the topmost level after all other pages. NULL could be specified for page to create an empty page.

Reimplemented from wxBookCtrlBase.

virtual bool wxTreebook::AddSubPage | ( | wxWindow * | page,
|  | const wxString & | text,
|  | bool | bSelect = `false`,
|  | int | imageId = `wxNOT_FOUND` |
| ) |  |  | `[virtual]`

Adds a new child-page to the last top-level page.

NULL could be specified for page to create an empty page.

bool wxTreebook::CollapseNode | ( | size_t | pageId | ) |

Shortcut for ExpandNode( pageId, false ).

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

Creates a treebook control.

See wxTreebook::wxTreebook() for the description of the parameters.

Reimplemented from wxBookCtrlBase.

virtual bool wxTreebook::DeletePage | ( | size_t | pagePos | ) | `[virtual]`

Deletes the page at the specified position and all its children.

Could trigger page selection change in a case when selected page is removed. In that case its parent is selected (or the next page if no parent).

Reimplemented from wxBookCtrlBase.

virtual bool wxTreebook::ExpandNode | ( | size_t | pageId,
|  | bool | expand = `true` |
| ) |  |  | `[virtual]`

Expands (collapses) the pageId node.

Returns the previous state. May generate page changing events (if selected page is under the collapsed branch, then its parent is autoselected).

int wxTreebook::GetPageParent | ( | size_t | page | ) | const

Returns the parent page of the given one or `wxNOT_FOUND` if this is a top-level page.

virtual int wxTreebook::GetSelection | ( |  | ) | const`[virtual]`

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

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

Implements wxBookCtrlBase.

virtual bool wxTreebook::InsertPage | ( | size_t | pagePos,
|  | wxWindow * | page,
|  | const wxString & | text,
|  | bool | bSelect = `false`,
|  | int | imageId = `wxNOT_FOUND` |
| ) |  |  | `[virtual]`

Inserts a new page just before the page indicated by pagePos.

The new page is placed before pagePos page and on the same level. NULL could be specified for page to create an empty page.

Implements wxBookCtrlBase.

virtual bool wxTreebook::InsertSubPage | ( | size_t | pagePos,
|  | wxWindow * | page,
|  | const wxString & | text,
|  | bool | bSelect = `false`,
|  | int | imageId = `wxNOT_FOUND` |
| ) |  |  | `[virtual]`

Inserts a sub page under the specified page.

NULL could be specified for page to create an empty page.

virtual bool wxTreebook::IsNodeExpanded | ( | size_t | pageId | ) | const`[virtual]`

Returns true if the page represented by pageId is expanded.

|  | [ top ]