X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1d6fcbcc7088e9c104b3dc5b4704a07f728d55ae..75595b9750de618c1ccc6356159aad0918bc4786:/src/generic/treebkg.cpp?ds=inline diff --git a/src/generic/treebkg.cpp b/src/generic/treebkg.cpp index 8f34b7ef4d..5cb6d44cc8 100644 --- a/src/generic/treebkg.cpp +++ b/src/generic/treebkg.cpp @@ -46,38 +46,28 @@ // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxTreebook, wxBookCtrlBase) -IMPLEMENT_DYNAMIC_CLASS(wxTreebookEvent, wxNotifyEvent) -#if !WXWIN_COMPATIBILITY_EVENT_TYPES -const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING = wxNewEventType(); -const wxEventType wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED = wxNewEventType(); -const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED = wxNewEventType(); -const wxEventType wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED = wxNewEventType(); -#endif -const int wxID_TREEBOOKTREEVIEW = wxNewId(); +wxDEFINE_EVENT( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, wxBookCtrlEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_TREEBOOK_PAGE_CHANGED, wxBookCtrlEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, wxBookCtrlEvent ); +wxDEFINE_EVENT( wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED, wxBookCtrlEvent ); BEGIN_EVENT_TABLE(wxTreebook, wxBookCtrlBase) - EVT_TREE_SEL_CHANGED (wxID_TREEBOOKTREEVIEW, wxTreebook::OnTreeSelectionChange) - EVT_TREE_ITEM_EXPANDED (wxID_TREEBOOKTREEVIEW, wxTreebook::OnTreeNodeExpandedCollapsed) - EVT_TREE_ITEM_COLLAPSED(wxID_TREEBOOKTREEVIEW, wxTreebook::OnTreeNodeExpandedCollapsed) - - WX_EVENT_TABLE_CONTROL_CONTAINER(wxTreebook) + EVT_TREE_SEL_CHANGED (wxID_ANY, wxTreebook::OnTreeSelectionChange) + EVT_TREE_ITEM_EXPANDED (wxID_ANY, wxTreebook::OnTreeNodeExpandedCollapsed) + EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxTreebook::OnTreeNodeExpandedCollapsed) END_EVENT_TABLE() // ============================================================================ // wxTreebook implementation // ============================================================================ -WX_DELEGATE_TO_CONTROL_CONTAINER(wxTreebook, wxControl) - // ---------------------------------------------------------------------------- // wxTreebook creation // ---------------------------------------------------------------------------- void wxTreebook::Init() { - m_container.SetContainerWindow(this); - m_selection = m_actualSelection = wxNOT_FOUND; } @@ -108,12 +98,10 @@ wxTreebook::Create(wxWindow *parent, m_bookctrl = new wxTreeCtrl ( this, - wxID_TREEBOOKTREEVIEW, + wxID_ANY, wxDefaultPosition, wxDefaultSize, -#ifndef __WXMSW__ - wxBORDER_SIMPLE | // On wxMSW this produces a black border which is wrong -#endif + wxBORDER_THEME | wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT | wxTR_SINGLE @@ -229,7 +217,7 @@ bool wxTreebook::DoAddSubPage(wxWindow *page, const wxString& text, bool bSelect wxTreeItemId lastNodeId = tree->GetLastChild(rootId); wxCHECK_MSG( lastNodeId.IsOk(), false, - _T("Can't insert sub page when there are no pages") ); + wxT("Can't insert sub page when there are no pages") ); // now calculate its position (should we save/update it too?) size_t newPos = tree->GetCount() - @@ -258,8 +246,6 @@ bool wxTreebook::DoInsertSubPage(size_t pagePos, wxTreeItemId newId = tree->AppendItem(parentId, text, imageId); - tree->InvalidateBestSize(); - if ( !newId.IsOk() ) { (void)wxBookCtrlBase::DoRemovePage(newPos); @@ -570,16 +556,6 @@ bool wxTreebook::SetPageImage(size_t n, int imageId) return true; } -wxSize wxTreebook::CalcSizeFromPage(const wxSize& sizePage) const -{ - const wxSize sizeTree = GetControllerSize(); - - wxSize size = sizePage; - size.x += sizeTree.x; - - return size; -} - int wxTreebook::GetSelection() const { return m_selection; @@ -592,7 +568,7 @@ int wxTreebook::DoSetSelection(size_t pagePos, int flags) wxASSERT_MSG( GetPageCount() == DoInternalGetPageCount(), wxT("wxTreebook logic error: m_treeIds and m_pages not in sync!")); - wxTreebookEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId); + wxBookCtrlEvent event(wxEVT_COMMAND_TREEBOOK_PAGE_CHANGING, m_windowId); const int oldSel = m_selection; wxTreeCtrl *tree = GetTreeCtrl(); bool allowed = false; @@ -693,6 +669,12 @@ void wxTreebook::AssignImageList(wxImageList *imageList) void wxTreebook::OnTreeSelectionChange(wxTreeEvent& event) { + if ( event.GetEventObject() != m_bookctrl ) + { + event.Skip(); + return; + } + wxTreeItemId newId = event.GetItem(); if ( (m_selection == wxNOT_FOUND && @@ -712,13 +694,19 @@ void wxTreebook::OnTreeSelectionChange(wxTreeEvent& event) void wxTreebook::OnTreeNodeExpandedCollapsed(wxTreeEvent & event) { + if ( event.GetEventObject() != m_bookctrl ) + { + event.Skip(); + return; + } + wxTreeItemId nodeId = event.GetItem(); if ( !nodeId.IsOk() || nodeId == GetTreeCtrl()->GetRootItem() ) return; int pagePos = DoInternalFindPageById(nodeId); wxCHECK_RET( pagePos != wxNOT_FOUND, wxT("Internal problem in wxTreebook!..") ); - wxTreebookEvent ev(GetTreeCtrl()->IsExpanded(nodeId) + wxBookCtrlEvent ev(GetTreeCtrl()->IsExpanded(nodeId) ? wxEVT_COMMAND_TREEBOOK_NODE_EXPANDED : wxEVT_COMMAND_TREEBOOK_NODE_COLLAPSED, m_windowId);