added test of focusing/selecting another item

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2008-03-16 00:04:51 +00:00
parent 8f5b44d805
commit 6ef2b23056
2 changed files with 16 additions and 0 deletions

View File

@ -75,6 +75,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(LIST_VIRTUAL_VIEW, MyFrame::OnVirtualView)
EVT_MENU(LIST_SMALL_VIRTUAL_VIEW, MyFrame::OnSmallVirtualView)
EVT_MENU(LIST_GOTO, MyFrame::OnGoTo)
EVT_MENU(LIST_FOCUS_LAST, MyFrame::OnFocusLast)
EVT_MENU(LIST_TOGGLE_FIRST, MyFrame::OnToggleFirstSel)
EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll)
@ -225,6 +226,7 @@ MyFrame::MyFrame(const wxChar *title)
#endif
wxMenu *menuList = new wxMenu;
menuList->Append(LIST_GOTO, _T("&Go to item #3\tCtrl-3"));
menuList->Append(LIST_FOCUS_LAST, _T("&Make last item current\tCtrl-L"));
menuList->Append(LIST_TOGGLE_FIRST, _T("To&ggle first item\tCtrl-G"));
menuList->Append(LIST_DESELECT_ALL, _T("&Deselect All\tCtrl-D"));
@ -346,6 +348,18 @@ void MyFrame::OnToggleMacUseGeneric(wxCommandEvent& event)
wxSystemOptions::SetOption(wxT("mac.listctrl.always_use_generic"), event.IsChecked());
}
void MyFrame::OnGoTo(wxCommandEvent& WXUNUSED(event))
{
long index = 3;
m_listCtrl->SetItemState(index, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
long sel = m_listCtrl->GetNextItem(-1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED);
if ( sel != -1 )
m_listCtrl->SetItemState(sel, 0, wxLIST_STATE_SELECTED);
m_listCtrl->SetItemState(index, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
}
void MyFrame::OnFocusLast(wxCommandEvent& WXUNUSED(event))
{
long index = m_listCtrl->GetItemCount() - 1;

View File

@ -120,6 +120,7 @@ protected:
void OnVirtualView(wxCommandEvent& event);
void OnSmallVirtualView(wxCommandEvent& event);
void OnGoTo(wxCommandEvent& event);
void OnFocusLast(wxCommandEvent& event);
void OnToggleFirstSel(wxCommandEvent& event);
void OnDeselectAll(wxCommandEvent& event);
@ -201,6 +202,7 @@ enum
LIST_TOGGLE_FIRST,
LIST_SHOW_COL_INFO,
LIST_SHOW_SEL_INFO,
LIST_GOTO,
LIST_FOCUS_LAST,
LIST_FREEZE,
LIST_THAW,