#if wxUSE_TREEBOOK
#include "wx/bookctrl.h"
+#include "wx/containr.h"
#include "wx/treectrl.h" // for wxArrayTreeItemIds
typedef wxWindow wxTreebookPage;
-class WXDLLEXPORT wxTreeEvent;
-
-// ----------------------------------------------------------------------------
-// style flags
-// ----------------------------------------------------------------------------
-
-// This is a set of synonyms of wxNB_XXX, which still could be used directly
-// for styling the control. Defined for consistency with wxListbook and
-// wxChoicebook only.
-#define wxTBK_LEFT wxNB_LEFT
-#define wxTBK_RIGHT wxNB_RIGHT
-
-// we don't support TOP/BOTTOM orientations but still define the flags (again,
-// for consistency with others)
-#define wxTBK_TOP wxTBK_LEFT
-#define wxTBK_BOTTOM wxTBK_RIGHT
-
-#define wxTBK_ALIGN_MASK (wxTBK_LEFT | wxTBK_RIGHT)
-#define wxTBK_DEFAULT wxTBK_LEFT
+class WXDLLIMPEXP_FWD_CORE wxTreeEvent;
// ----------------------------------------------------------------------------
// wxTreebook
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTreebook : public wxBookCtrlBase
+class WXDLLIMPEXP_CORE wxTreebook : public wxNavigationEnabled<wxBookCtrlBase>
{
public:
// Constructors and such
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxTBK_DEFAULT,
+ long style = wxBK_DEFAULT,
const wxString& name = wxEmptyString)
{
Init();
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxTBK_DEFAULT,
+ long style = wxBK_DEFAULT,
const wxString& name = wxEmptyString);
wxWindow *page,
const wxString& text,
bool bSelect = false,
- int imageId = wxNOT_FOUND);
+ int imageId = NO_IMAGE);
// Inserts a new sub-page to the end of children of the page at given pos.
- virtual bool AddSubPage(size_t pos,
- wxWindow *page,
- const wxString& text,
- bool bSelect = false,
- int imageId = wxNOT_FOUND);
+ virtual bool InsertSubPage(size_t pos,
+ wxWindow *page,
+ const wxString& text,
+ bool bSelect = false,
+ int imageId = NO_IMAGE);
// Adds a new page at top level after all other pages.
virtual bool AddPage(wxWindow *page,
const wxString& text,
bool bSelect = false,
- int imageId = wxNOT_FOUND);
+ int imageId = NO_IMAGE);
// Adds a new child-page to the last top-level page inserted.
// Useful when constructing 1 level tree structure.
virtual bool AddSubPage(wxWindow *page,
const wxString& text,
bool bSelect = false,
- int imageId = wxNOT_FOUND);
+ int imageId = NO_IMAGE);
// Deletes the page and ALL its children. Could trigger page selection
// change in a case when selected page is removed. In that case its parent
// get the parent page or wxNOT_FOUND if this is a top level page
int GetPageParent(size_t pos) const;
+ // the tree control we use for showing the pages index tree
+ wxTreeCtrl* GetTreeCtrl() const { return (wxTreeCtrl*)m_bookctrl; }
+
// Standard operations inherited from wxBookCtrlBase
// -------------------------------------------------
- virtual int GetSelection() const;
virtual bool SetPageText(size_t n, const wxString& strText);
virtual wxString GetPageText(size_t n) const;
virtual int GetPageImage(size_t n) const;
virtual bool SetPageImage(size_t n, int imageId);
- virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
- virtual int SetSelection(size_t n);
+ virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
+ virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
+ virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
virtual void SetImageList(wxImageList *imageList);
virtual void AssignImageList(wxImageList *imageList);
virtual bool DeleteAllPages();
protected:
+ // Implementation of a page removal. See DeletPage for comments.
+ wxTreebookPage *DoRemovePage(size_t pos);
+
// This subclass of wxBookCtrlBase accepts NULL page pointers (empty pages)
virtual bool AllowNullPage() const { return true; }
- // get the size which the tree control should have
- wxSize GetTreeSize() const;
-
- // get the page area
- wxRect GetPageRect() const;
-
// event handlers
- void OnSize(wxSizeEvent& event);
void OnTreeSelectionChange(wxTreeEvent& event);
void OnTreeNodeExpandedCollapsed(wxTreeEvent& event);
-
- // the tree control we use for showing the pages index tree
- wxTreeCtrl *m_tree;
-
// array of page ids and page windows
wxArrayTreeItemIds m_treeIds;
- // the currently selected page or wxNOT_FOUND if none
- int m_selection;
-
// in the situation when m_selection page is not wxNOT_FOUND but page is
// NULL this is the first (sub)child that has a non-NULL page
int m_actualSelection;
wxWindow *page,
const wxString& text,
bool bSelect = false,
- int imageId = wxNOT_FOUND);
+ int imageId = NO_IMAGE);
bool DoInsertSubPage(size_t pos,
wxWindow *page,
const wxString& text,
bool bSelect = false,
- int imageId = wxNOT_FOUND);
+ int imageId = NO_IMAGE);
bool DoAddSubPage(wxWindow *page,
const wxString& text,
bool bSelect = false,
- int imageId = wxNOT_FOUND);
-
- // Implementation of a page removal. See DeletPage for comments.
- wxTreebookPage *DoRemovePage(size_t pos);
+ int imageId = NO_IMAGE);
// Sets selection in the tree control and updates the page being shown.
- int DoSetSelection(size_t pos);
+ int DoSetSelection(size_t pos, int flags = 0);
// Returns currently shown page. In a case when selected the node
// has empty (NULL) page finds first (sub)child with not-empty page.
// Returns internal number of pages which can be different from
// GetPageCount() while performing a page insertion or removal.
- size_t DoInternalGetPageCount() const { return m_treeIds.Count(); }
+ size_t DoInternalGetPageCount() const { return m_treeIds.GetCount(); }
DECLARE_EVENT_TABLE()
// treebook event class and related stuff
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTreebookEvent : public wxBookCtrlBaseEvent
-{
-public:
- wxTreebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0,
- int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
- : wxBookCtrlBaseEvent(commandType, id, nSel, nOldSel)
- {
- }
-
-private:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxTreebookEvent)
-};
-
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED;
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING;
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED;
-extern WXDLLIMPEXP_CORE const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED;
+// wxTreebookEvent is obsolete and defined for compatibility only
+#define wxTreebookEvent wxBookCtrlEvent
+typedef wxBookCtrlEventFunction wxTreebookEventFunction;
+#define wxTreebookEventHandler(func) wxBookCtrlEventHandler(func)
-typedef void (wxEvtHandler::*wxTreebookEventFunction)(wxTreebookEvent&);
-#define wxTreebookEventHandler(func) \
- (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTreebookEventFunction, &func)
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, wxBookCtrlEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, wxBookCtrlEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, wxBookCtrlEvent );
+wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, wxBookCtrlEvent );
#define EVT_TREEBOOK_PAGE_CHANGED(winid, fn) \
- wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, winid, wxTreebookEventHandler(fn))
+ wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, winid, wxBookCtrlEventHandler(fn))
#define EVT_TREEBOOK_PAGE_CHANGING(winid, fn) \
- wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, winid, wxTreebookEventHandler(fn))
+ wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, winid, wxBookCtrlEventHandler(fn))
#define EVT_TREEBOOK_NODE_COLLAPSED(winid, fn) \
- wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, winid, wxTreebookEventHandler(fn))
+ wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, winid, wxBookCtrlEventHandler(fn))
#define EVT_TREEBOOK_NODE_EXPANDED(winid, fn) \
- wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, winid, wxTreebookEventHandler(fn))
+ wx__DECLARE_EVT1(wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, winid, wxBookCtrlEventHandler(fn))
#endif // wxUSE_TREEBOOK