2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: treebook.h
|
2008-08-01 13:46:46 +00:00
|
|
|
// Purpose: interface of wxTreebook
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxTreebook
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-05-20 07:48:30 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
To use the class simply create it and populate with pages using
|
2008-05-20 07:48:30 +00:00
|
|
|
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.
|
|
|
|
|
2008-08-01 13:46:46 +00:00
|
|
|
@beginEventTable{wxBookCtrlEvent}
|
2008-05-20 07:48:30 +00:00
|
|
|
@event{EVT_TREEBOOK_PAGE_CHANGED(id, func)}
|
|
|
|
The page selection was changed. Processes a @c
|
|
|
|
wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED event.
|
|
|
|
@event{EVT_TREEBOOK_PAGE_CHANGING(id, func)}
|
|
|
|
The page selection is about to be changed. Processes a @c
|
|
|
|
wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING event. This event can be @ref
|
|
|
|
wxNotifyEvent::Veto() "vetoed".
|
|
|
|
@event{EVT_TREEBOOK_NODE_COLLAPSED(id, func)}
|
|
|
|
The page node is going to be collapsed. Processes a @c
|
|
|
|
wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED event.
|
|
|
|
@event{EVT_TREEBOOK_NODE_EXPANDED(id, func)}
|
|
|
|
The page node is going to be expanded. Processes a @c
|
|
|
|
wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED event.
|
|
|
|
@endEventTable
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{miscwnd}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-08-01 13:46:46 +00:00
|
|
|
@see wxBookCtrl, wxBookCtrlEvent, wxNotebook, wxTreeCtrl, wxImageList,
|
2008-05-20 07:48:30 +00:00
|
|
|
@ref overview_bookctrl, @ref page_samples_notebook
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-05-20 07:48:30 +00:00
|
|
|
class wxTreebook : public wxBookCtrlBase
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxTreebook();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates an empty wxTreebook.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param parent
|
2008-03-09 12:33:59 +00:00
|
|
|
The parent window. Must be non-@NULL.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
The window identifier.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param pos
|
2008-03-09 12:33:59 +00:00
|
|
|
The window position.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param size
|
2008-03-09 12:33:59 +00:00
|
|
|
The window size.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param style
|
2008-03-09 12:33:59 +00:00
|
|
|
The window style. See wxNotebook.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param name
|
2008-03-09 12:33:59 +00:00
|
|
|
The name of the control (used only under Motif).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
wxTreebook(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-04-19 21:56:10 +00:00
|
|
|
long style = wxBK_DEFAULT,
|
2008-03-08 14:43:31 +00:00
|
|
|
const wxString& name = wxEmptyString);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Destroys the wxTreebook object. Also deletes all the pages owned by the
|
|
|
|
control (inserted previously into it).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
~wxTreebook();
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
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.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool AddPage(wxWindow* page, const wxString& text,
|
2008-03-09 12:33:59 +00:00
|
|
|
bool bSelect = false,
|
2008-03-08 13:52:38 +00:00
|
|
|
int imageId = wxNOT_FOUND);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Adds a new child-page to the last top-level page. @NULL could be
|
|
|
|
specified for page to create an empty page.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool AddSubPage(wxWindow* page, const wxString& text,
|
2008-03-09 12:33:59 +00:00
|
|
|
bool bSelect = false,
|
2008-03-08 13:52:38 +00:00
|
|
|
int imageId = wxNOT_FOUND);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Sets the image list for the page control and takes ownership of the
|
|
|
|
list.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxImageList, SetImageList()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void AssignImageList(wxImageList* imageList);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Changes the selection for the given page, returning the previous
|
|
|
|
selection.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The call to this function does not generate the page changing events.
|
2008-05-20 07:48:30 +00:00
|
|
|
This is the only difference with SetSelection(). See
|
|
|
|
@ref overview_eventhandling_prog for more info.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
int ChangeSelection(size_t page);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Shortcut for @ref wxTreebook::ExpandNode() "ExpandNode"( @a pageId,
|
|
|
|
@false ).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool CollapseNode(size_t pageId);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Creates a treebook control. See wxTreebook::wxTreebook() for the
|
|
|
|
description of the parameters.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-04-19 21:56:10 +00:00
|
|
|
long style = wxBK_DEFAULT,
|
2008-03-08 13:52:38 +00:00
|
|
|
const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes all pages inserted into the treebook. No event is generated.
|
|
|
|
*/
|
|
|
|
bool DeleteAllPages();
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
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).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool DeletePage(size_t pagePos);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Expands (collapses) the @a pageId node. Returns the previous state. May
|
|
|
|
generate page changing events (if selected page is under the collapsed
|
|
|
|
branch, then its parent is autoselected).
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
bool ExpandNode(size_t pageId, bool expand = true);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the image index for the given page.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetPageImage(size_t n) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the parent page of the given one or @c wxNOT_FOUND if this is a
|
|
|
|
top-level page.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetPageParent(size_t page) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the string for the given page.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetPageText(size_t n) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Returns the currently selected page, or @c 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
|
2008-08-01 13:46:46 +00:00
|
|
|
depending on the platform and so wxBookCtrlEvent::GetSelection()
|
2008-05-20 07:48:30 +00:00
|
|
|
should be used instead in this case.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetSelection() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Inserts a new page just before the page indicated by @a pagePos. The new
|
|
|
|
page is placed before @a pagePos page and on the same level. @NULL could
|
|
|
|
be specified for page to create an empty page.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool InsertPage(size_t pagePos, wxWindow* page,
|
|
|
|
const wxString& text,
|
2008-03-09 12:33:59 +00:00
|
|
|
bool bSelect = false,
|
2008-03-08 13:52:38 +00:00
|
|
|
int imageId = wxNOT_FOUND);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Inserts a sub page under the specified page.
|
2008-05-20 07:48:30 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@NULL could be specified for page to create an empty page.
|
|
|
|
*/
|
|
|
|
bool InsertSubPage(size_t pagePos, wxWindow* page,
|
|
|
|
const wxString& text,
|
2008-03-09 12:33:59 +00:00
|
|
|
bool bSelect = false,
|
2008-03-08 13:52:38 +00:00
|
|
|
int imageId = wxNOT_FOUND);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Returns @true if the page represented by @a pageId is expanded.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool IsNodeExpanded(size_t pageId) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Sets the image list for the page control. It does not take ownership of
|
|
|
|
the image list, you must delete it yourself.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxImageList, AssignImageList()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetImageList(wxImageList* imageList);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Sets the image index for the given @a page. @a imageId is an index into
|
|
|
|
the image list which was set with SetImageList().
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool SetPageImage(size_t page, int imageId);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
Sets the @a text for the given @a page.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
bool SetPageText(size_t page, const wxString& text);
|
|
|
|
|
|
|
|
/**
|
2008-05-20 07:48:30 +00:00
|
|
|
@deprecated Please use ChangeSelection() instead.
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Sets the selection for the given page, returning the previous selection.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-05-20 07:48:30 +00:00
|
|
|
The call to this function generates page changing events.
|
|
|
|
|
|
|
|
@see GetSelection(), ChangeSelection()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
int SetSelection(size_t n);
|
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|