Contents Up Previous Next

wxTreebook

This class is an extension of the Notebook 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.

Derived from

wxBookCtrlBase
wxControl
wxWindow
wxEvtHandler
wxObject

Include files

<wx/treebook.h>

Event handling

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

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.

See also

wxNotebook, wxTreebookEvent, wxImageList, notebook sample

Members

wxTreebook::wxTreebook
wxTreebook::~wxTreebook
wxTreebook::AddPage
wxTreebook::AddSubPage
wxTreebook::AssignImageList
wxTreebook::ChangeSelection
wxTreebook::CollapseNode
wxTreebook::Create
wxTreebook::DeleteAllPages
wxTreebook::DeletePage
wxTreebook::ExpandNode
wxTreebook::GetPageImage
wxTreebook::GetPageParent
wxTreebook::GetPageText
wxTreebook::GetSelection
wxTreebook::InsertPage
wxTreebook::InsertSubPage
wxTreebook::IsNodeExpanded
wxTreebook::SetImageList
wxTreebook::SetPageImage
wxTreebook::SetPageText
wxTreebook::SetSelection


wxTreebook::wxTreebook

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 TreeBook control.

Parameters

parent

id

pos

size

style

name


wxTreebook::~wxTreebook

~wxTreebook()

Destroys the wxTreebook object.

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


wxTreebook::AddPage

bool AddPage( wxWindow* page, const wxString& text, bool bSelect = false, int imageId = wxNOT_FOUND)

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.


wxTreebook::AddSubPage

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. NULL could be specified for page to create an empty page.


wxTreebook::AssignImageList

void AssignImageList(wxImageList* imageList)

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

See also

wxImageList, SetImageList


wxTreebook::ChangeSelection

int ChangeSelection(size_t page)

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

The call to this function does not generate the page changing events. This is the only difference with SetSelection. See this topic for more info.


wxTreebook::CollapseNode

bool CollapseNode(size_t pageId)

Shortcut for ExpandNode(pageId, false).


wxTreebook::Create

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. See wxTreebook::wxTreebook for the description of the parameters.


wxTreebook::DeleteAllPages

bool DeleteAllPages()

Deletes all pages inserted into the treebook. No event is generated.


wxTreebook::DeletePage

bool DeletePage(size_t pagePos)

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


wxTreebook::ExpandNode

bool ExpandNode(size_t pageId, bool expand = true)

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


wxTreebook::GetPageImage

int GetPageImage(size_t n) const

Returns the image index for the given page.


wxTreebook::GetPageParent

int GetPageParent(size_t page) const

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


wxTreebook::GetPageText

wxString GetPageText(size_t n) const

Returns the string for the given page.


wxTreebook::GetSelection

int GetSelection() const

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_TREEBOOK_PAGE_CHANGED handler depending on the platform and so wxTreebookEvent::GetSelection should be used instead in this case.


wxTreebook::InsertPage

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. The new page is placed before pagePos page and on the same level. NULL could be specified for page to create an empty page.


wxTreebook::InsertSubPage

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.

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


wxTreebook::IsNodeExpanded

bool IsNodeExpanded(size_t pageId) const

Gets the pagePos page state -- whether it is expanded or collapsed


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


wxTreebook::SetPageImage

bool SetPageImage(size_t page, int imageId)

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


wxTreebook::SetPageText

bool SetPageText(size_t page, const wxString& text)

Sets the text for the given page.


wxTreebook::SetSelection

int SetSelection(size_t n)

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

The call to this function generates the page changing events.

This function is deprecated and should not be used in new code. Please use the ChangeSelection function instead.

See also

wxTreebook::GetSelection