From 90860e9444e29236439c93d72183acd3c05fde8c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Feb 2014 22:39:53 +0000 Subject: [PATCH] Remove code maintaining last item from the treectrl sample. The code was buggy (e.g. it didn't update the last item correctly after executing "Append many items" menu command) and seems to be unnecessary. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75987 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/treectrl/treetest.cpp | 14 ++++++-------- samples/treectrl/treetest.h | 6 +----- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 9de78d1081..5a18e39a9a 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -758,7 +758,12 @@ void MyFrame::OnCollapseAndReset(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEnsureVisible(wxCommandEvent& WXUNUSED(event)) { - m_treeCtrl->DoEnsureVisible(); + const wxTreeItemId + idLast = m_treeCtrl->GetLastChild(m_treeCtrl->GetRootItem()); + if ( idLast.IsOk() ) + m_treeCtrl->EnsureVisible(idLast); + else + wxLogMessage("No last item"); } void MyFrame::OnSetFocus(wxCommandEvent& WXUNUSED(event)) @@ -1167,12 +1172,6 @@ void MyTreeCtrl::AddItemsRecursively(const wxTreeItemId& idParent, wxTreeItemIcon_Expanded); } - // remember the last child for OnEnsureVisible() - if ( !hasChildren && n == numChildren - 1 ) - { - m_lastItem = id; - } - AddItemsRecursively(id, numChildren, depth - 1, n + 1); } } @@ -1307,7 +1306,6 @@ void MyTreeCtrl::LogEvent(const wxChar *name, const wxTreeEvent& event) void MyTreeCtrl::name(wxTreeEvent& event) \ { \ LogEvent(wxT(#name), event); \ - SetLastItem(wxTreeItemId()); \ event.Skip(); \ } diff --git a/samples/treectrl/treetest.h b/samples/treectrl/treetest.h index 239e2a6768..325a82c54a 100644 --- a/samples/treectrl/treetest.h +++ b/samples/treectrl/treetest.h @@ -105,7 +105,6 @@ public: void DoSortChildren(const wxTreeItemId& item, bool reverse = false) { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); } - void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); } void DoToggleIcon(const wxTreeItemId& item); void DoToggleState(const wxTreeItemId& item); @@ -114,8 +113,6 @@ public: int ImageSize(void) const { return m_imageSize; } - void SetLastItem(wxTreeItemId id) { m_lastItem = id; } - void SetAlternateImages(bool show) { m_alternateImages = show; } bool AlternateImages() const { return m_alternateImages; } @@ -152,8 +149,7 @@ private: int m_imageSize; // current size of images bool m_reverseSort; // flag for OnCompareItems - wxTreeItemId m_lastItem, // for OnEnsureVisible() - m_draggedItem; // item being dragged right now + wxTreeItemId m_draggedItem; // item being dragged right now bool m_alternateImages; bool m_alternateStates;