]> git.saurik.com Git - wxWidgets.git/commitdiff
added test of focusing/selecting another item
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 16 Mar 2008 00:04:51 +0000 (00:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 16 Mar 2008 00:04:51 +0000 (00:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/listctrl/listtest.cpp
samples/listctrl/listtest.h

index ebfa7accb6c4fd723be820803ddebab81e82f701..23ee183e1e8689863f34e753341254f2c677ba5a 100644 (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;
index 2126c4b4b7b0252e86d1f6af855b24fbfcb47e20..18066ea9925309eb0ae66995db56399d8ed7f93a 100644 (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,