2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: treebook.h
|
|
|
|
// Purpose: documentation for wxTreebookEvent class
|
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxTreebookEvent
|
|
|
|
@wxheader{treebook.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
This class represents the events generated by a treebook control: currently,
|
|
|
|
there are four of them. The PAGE_CHANGING and PAGE_CHANGED - have exactly the
|
|
|
|
same
|
|
|
|
behaviour as wxNotebookEvent.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
The other two NODE_COLLAPSED and NODE_EXPANDED are triggered when page node in
|
|
|
|
the tree control
|
|
|
|
is collapsed/expanded. The page index could be retreived by calling
|
|
|
|
wxTreebookEvent::GetSelection.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
|
|
|
@category{events}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@seealso
|
|
|
|
wxNotebookEvent, wxTreebook
|
|
|
|
*/
|
|
|
|
class wxTreebookEvent : public wxNotifyEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxNotebookEvent
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
|
2008-03-08 13:52:38 +00:00
|
|
|
int nSel = wxNOT_FOUND,
|
|
|
|
int nOldSel = wxNOT_FOUND);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the page that was selected before the change, wxNOT_FOUND if none was
|
|
|
|
selected.
|
|
|
|
*/
|
|
|
|
int GetOldSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the currently selected page, or wxNOT_FOUND if none was selected.
|
|
|
|
*/
|
|
|
|
int GetSelection();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxTreebook
|
|
|
|
@wxheader{treebook.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
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
|
|
|
|
wxTreebook::InsertPage,
|
|
|
|
wxTreebook::InsertSubPage,
|
|
|
|
wxTreebook::AddPage,
|
|
|
|
wxTreebook::AddSubPage.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
If your tree is no more than 1 level in depth then you could
|
2008-03-08 14:43:31 +00:00
|
|
|
simply use wxTreebook::AddPage and
|
2008-03-08 13:52:38 +00:00
|
|
|
wxTreebook::AddSubPage to sequentially populate your tree
|
|
|
|
by adding at every step a page or a subpage to the end of the tree.
|
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-03-08 13:52:38 +00:00
|
|
|
@seealso
|
|
|
|
wxNotebook, wxTreebookEvent, wxImageList, @ref overview_samplenotebook
|
|
|
|
"notebook sample"
|
|
|
|
*/
|
|
|
|
class wxTreebook : public wxBookCtrl overview
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Creates an empty TreeBook control.
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
wxTreebook();
|
2008-03-08 14:43:31 +00:00
|
|
|
wxTreebook(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxTBK_DEFAULT,
|
|
|
|
const wxString& name = wxEmptyString);
|
2008-03-08 13:52:38 +00:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroys the wxTreebook object.
|
|
|
|
Also deletes all the pages owned by the control (inserted previously into it).
|
|
|
|
*/
|
|
|
|
~wxTreebook();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a new child-page to the last top-level page.
|
|
|
|
@NULL could be specified for page to create an empty page.
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the image list for the page control and takes ownership of the list.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxImageList, SetImageList()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void AssignImageList(wxImageList* imageList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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 @ref overview_progevent "this topic" for more info.
|
|
|
|
*/
|
|
|
|
int ChangeSelection(size_t page);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Shortcut for wxTreebook::ExpandNode(pageId, @false).
|
|
|
|
*/
|
|
|
|
bool CollapseNode(size_t pageId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a treebook control. See wxTreebook() for the description of the
|
|
|
|
parameters.
|
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxTBK_DEFAULT,
|
|
|
|
const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes all pages inserted into the treebook. No event is generated.
|
|
|
|
*/
|
|
|
|
bool DeleteAllPages();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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).
|
|
|
|
*/
|
|
|
|
bool DeletePage(size_t pagePos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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).
|
|
|
|
*/
|
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.
|
|
|
|
*/
|
|
|
|
int GetPageImage(size_t n);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the parent page of the given one or @c wxNOT_FOUND if this is a
|
|
|
|
top-level page.
|
|
|
|
*/
|
|
|
|
int GetPageParent(size_t page);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the string for the given page.
|
|
|
|
*/
|
|
|
|
wxString GetPageText(size_t n);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
int GetSelection();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
@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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the pagePos page state -- whether it is expanded or collapsed
|
|
|
|
*/
|
|
|
|
bool IsNodeExpanded(size_t pageId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the image list for the page control. It does not take ownership of the
|
|
|
|
image list, you must delete it yourself.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see wxImageList, AssignImageList()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void SetImageList(wxImageList* imageList);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the image index for the given page. ImageId is an index into the image list
|
|
|
|
which was set with SetImageList().
|
|
|
|
*/
|
|
|
|
bool SetPageImage(size_t page, int imageId);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the text for the given page.
|
|
|
|
*/
|
|
|
|
bool SetPageText(size_t page, const wxString& text);
|
|
|
|
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see GetSelection()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
int SetSelection(size_t n);
|
|
|
|
};
|