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;
|
wxString status;
|
||||||
if (idRoot.IsOk())
|
if (idRoot.IsOk())
|
||||||
{
|
{
|
||||||
wxTreeItemId idLast = m_treeCtrl->GetLastChild(idRoot);
|
wxTreeItemId idLast = m_treeCtrl->GetLastTreeITem();
|
||||||
status = wxString::Format(
|
status = wxString::Format(
|
||||||
wxT("Root/last item is %svisible/%svisible"),
|
wxT("Root/last item is %svisible/%svisible"),
|
||||||
m_treeCtrl->IsVisible(idRoot) ? wxT("") : wxT("not "),
|
m_treeCtrl->IsVisible(idRoot) ? wxT("") : wxT("not "),
|
||||||
@@ -759,7 +759,7 @@ void MyFrame::OnCollapseAndReset(wxCommandEvent& WXUNUSED(event))
|
|||||||
void MyFrame::OnEnsureVisible(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnEnsureVisible(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
const wxTreeItemId
|
const wxTreeItemId
|
||||||
idLast = m_treeCtrl->GetLastChild(m_treeCtrl->GetRootItem());
|
idLast = m_treeCtrl->GetLastTreeITem();
|
||||||
if ( idLast.IsOk() )
|
if ( idLast.IsOk() )
|
||||||
m_treeCtrl->EnsureVisible(idLast);
|
m_treeCtrl->EnsureVisible(idLast);
|
||||||
else
|
else
|
||||||
@@ -907,16 +907,7 @@ void MyFrame::OnScrollTo(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void MyFrame::OnSelectLast(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnSelectLast(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
// select the very last item of the tree
|
wxTreeItemId item = m_treeCtrl->GetLastTreeITem();
|
||||||
wxTreeItemId item = m_treeCtrl->GetRootItem();
|
|
||||||
for ( ;; )
|
|
||||||
{
|
|
||||||
wxTreeItemId itemChild = m_treeCtrl->GetLastChild(item);
|
|
||||||
if ( !itemChild.IsOk() )
|
|
||||||
break;
|
|
||||||
|
|
||||||
item = itemChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK_ITEM( item );
|
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,
|
void MyTreeCtrl::GetItemsRecursively(const wxTreeItemId& idParent,
|
||||||
wxTreeItemIdValue cookie)
|
wxTreeItemIdValue cookie)
|
||||||
{
|
{
|
||||||
|
@@ -94,6 +94,7 @@ public:
|
|||||||
void OnRMouseUp(wxMouseEvent& event);
|
void OnRMouseUp(wxMouseEvent& event);
|
||||||
void OnRMouseDClick(wxMouseEvent& event);
|
void OnRMouseDClick(wxMouseEvent& event);
|
||||||
|
|
||||||
|
wxTreeItemId GetLastTreeITem() const;
|
||||||
void GetItemsRecursively(const wxTreeItemId& idParent,
|
void GetItemsRecursively(const wxTreeItemId& idParent,
|
||||||
wxTreeItemIdValue cookie = 0);
|
wxTreeItemIdValue cookie = 0);
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Find the very last item in the tree.
|
||||||
void AddItemsRecursively(const wxTreeItemId& idParent,
|
void AddItemsRecursively(const wxTreeItemId& idParent,
|
||||||
size_t nChildren,
|
size_t nChildren,
|
||||||
size_t depth,
|
size_t depth,
|
||||||
|
Reference in New Issue
Block a user