Add a test for selecting the last item in the tree control sample.
This allows to test whether an item is brought into view by selecting it, see #11154. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64650 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -142,6 +142,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
MENU_LINK(ShowPrevSibling)
|
MENU_LINK(ShowPrevSibling)
|
||||||
MENU_LINK(ShowNextSibling)
|
MENU_LINK(ShowNextSibling)
|
||||||
MENU_LINK(ScrollTo)
|
MENU_LINK(ScrollTo)
|
||||||
|
MENU_LINK(SelectLast)
|
||||||
#undef MENU_LINK
|
#undef MENU_LINK
|
||||||
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -308,6 +309,8 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
|||||||
item_menu->AppendSeparator();
|
item_menu->AppendSeparator();
|
||||||
item_menu->Append(TreeTest_ScrollTo, "Scroll &to item",
|
item_menu->Append(TreeTest_ScrollTo, "Scroll &to item",
|
||||||
"Scroll to the last by one top level child");
|
"Scroll to the last by one top level child");
|
||||||
|
item_menu->Append(TreeTest_SelectLast, "Select &last item",
|
||||||
|
"Select the last item");
|
||||||
|
|
||||||
#ifndef NO_MULTIPLE_SELECTION
|
#ifndef NO_MULTIPLE_SELECTION
|
||||||
item_menu->AppendSeparator();
|
item_menu->AppendSeparator();
|
||||||
@@ -878,6 +881,24 @@ void MyFrame::OnScrollTo(wxCommandEvent& WXUNUSED(event))
|
|||||||
m_treeCtrl->ScrollTo(item);
|
m_treeCtrl->ScrollTo(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
CHECK_ITEM( item );
|
||||||
|
|
||||||
|
m_treeCtrl->SelectItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnSetFgColour(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxColour col = wxGetColourFromUser(this, m_treeCtrl->GetForegroundColour());
|
wxColour col = wxGetColourFromUser(this, m_treeCtrl->GetForegroundColour());
|
||||||
|
@@ -272,6 +272,7 @@ public:
|
|||||||
{ DoShowRelativeItem(&wxTreeCtrl::GetNextSibling, "next sibling"); }
|
{ DoShowRelativeItem(&wxTreeCtrl::GetNextSibling, "next sibling"); }
|
||||||
|
|
||||||
void OnScrollTo(wxCommandEvent& event);
|
void OnScrollTo(wxCommandEvent& event);
|
||||||
|
void OnSelectLast(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnIdle(wxIdleEvent& event);
|
void OnIdle(wxIdleEvent& event);
|
||||||
void OnSize(wxSizeEvent& event);
|
void OnSize(wxSizeEvent& event);
|
||||||
@@ -368,5 +369,6 @@ enum
|
|||||||
TreeTest_ShowPrevSibling,
|
TreeTest_ShowPrevSibling,
|
||||||
TreeTest_ShowNextSibling,
|
TreeTest_ShowNextSibling,
|
||||||
TreeTest_ScrollTo,
|
TreeTest_ScrollTo,
|
||||||
|
TreeTest_SelectLast,
|
||||||
TreeTest_Ctrl = 1000
|
TreeTest_Ctrl = 1000
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user