Add a helper function to get the last tree item to the sample.
This makes the behaviour of different menu commands working with the "last item" consistent as some of them used the last root child while others used the really last item (i.e. the last child of the last child). This should have been part of r75987. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76013 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -431,7 +431,7 @@ void MyFrame::OnIdle(wxIdleEvent& event)
|
||||
wxString status;
|
||||
if (idRoot.IsOk())
|
||||
{
|
||||
wxTreeItemId idLast = m_treeCtrl->GetLastChild(idRoot);
|
||||
wxTreeItemId idLast = m_treeCtrl->GetLastTreeITem();
|
||||
status = wxString::Format(
|
||||
wxT("Root/last item is %svisible/%svisible"),
|
||||
m_treeCtrl->IsVisible(idRoot) ? wxT("") : wxT("not "),
|
||||
@@ -759,7 +759,7 @@ void MyFrame::OnCollapseAndReset(wxCommandEvent& WXUNUSED(event))
|
||||
void MyFrame::OnEnsureVisible(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
const wxTreeItemId
|
||||
idLast = m_treeCtrl->GetLastChild(m_treeCtrl->GetRootItem());
|
||||
idLast = m_treeCtrl->GetLastTreeITem();
|
||||
if ( idLast.IsOk() )
|
||||
m_treeCtrl->EnsureVisible(idLast);
|
||||
else
|
||||
@@ -907,16 +907,7 @@ void MyFrame::OnScrollTo(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnSelectLast(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
// select the very last item of the tree
|
||||
wxTreeItemId item = m_treeCtrl->GetRootItem();
|
||||
for ( ;; )
|
||||
{
|
||||
wxTreeItemId itemChild = m_treeCtrl->GetLastChild(item);
|
||||
if ( !itemChild.IsOk() )
|
||||
break;
|
||||
|
||||
item = itemChild;
|
||||
}
|
||||
wxTreeItemId item = m_treeCtrl->GetLastTreeITem();
|
||||
|
||||
CHECK_ITEM( item );
|
||||
|
||||
@@ -1210,6 +1201,21 @@ void MyTreeCtrl::AddTestItemsToTree(size_t numChildren,
|
||||
}
|
||||
}
|
||||
|
||||
wxTreeItemId MyTreeCtrl::GetLastTreeITem() const
|
||||
{
|
||||
wxTreeItemId item = GetRootItem();
|
||||
for ( ;; )
|
||||
{
|
||||
wxTreeItemId itemChild = GetLastChild(item);
|
||||
if ( !itemChild.IsOk() )
|
||||
break;
|
||||
|
||||
item = itemChild;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void MyTreeCtrl::GetItemsRecursively(const wxTreeItemId& idParent,
|
||||
wxTreeItemIdValue cookie)
|
||||
{
|
||||
|
Reference in New Issue
Block a user