From c47711479ece3eb4bacfdb9a64326a73c313d6f6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Karsten=20Ball=C3=BCder?= Date: Sun, 23 Aug 1998 20:06:24 +0000 Subject: [PATCH] added (de)select all git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/listctrl/listtest.cpp | 20 ++++++++++++++++++++ samples/listctrl/listtest.h | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/samples/listctrl/listtest.cpp b/samples/listctrl/listtest.cpp index b6a9885b5b..fb90214cca 100644 --- a/samples/listctrl/listtest.cpp +++ b/samples/listctrl/listtest.cpp @@ -37,6 +37,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(LIST_ICON_TEXT_VIEW, MyFrame::OnIconTextView) EVT_MENU(LIST_SMALL_ICON_VIEW, MyFrame::OnSmallIconView) EVT_MENU(LIST_SMALL_ICON_TEXT_VIEW, MyFrame::OnSmallIconTextView) + EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnDeselectAll) + EVT_MENU(LIST_DESELECT_ALL, MyFrame::OnSelectAll) END_EVENT_TABLE() BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl) @@ -125,6 +127,8 @@ bool MyApp::OnInit(void) file_menu->Append(LIST_ICON_TEXT_VIEW, "Icon view with &text"); file_menu->Append(LIST_SMALL_ICON_VIEW, "&Small icon view"); file_menu->Append(LIST_SMALL_ICON_TEXT_VIEW, "Small icon &view with text"); + file_menu->Append(LIST_DESELECT_ALL, "&Deselect All"); + file_menu->Append(LIST_SELECT_ALL, "S&elect All"); file_menu->AppendSeparator(); file_menu->Append(LIST_ABOUT, "&About"); file_menu->Append(LIST_QUIT, "E&xit"); @@ -198,6 +202,22 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) dialog.ShowModal(); } +void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event)) +{ + int n = m_listCtrl->GetItemCount(); + int i; + for(i = 0; i < n; i++) + m_listCtrl->SetItemState(i,0,wxLIST_STATE_SELECTED); +} + +void MyFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event)) +{ + int n = m_listCtrl->GetItemCount(); + int i; + for(i = 0; i < n; i++) + m_listCtrl->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); +} + void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event)) { m_logWindow->Clear(); diff --git a/samples/listctrl/listtest.h b/samples/listctrl/listtest.h index 4126bbbab2..b303d90559 100644 --- a/samples/listctrl/listtest.h +++ b/samples/listctrl/listtest.h @@ -59,7 +59,9 @@ class MyFrame: public wxFrame void OnIconTextView(wxCommandEvent& event); void OnSmallIconView(wxCommandEvent& event); void OnSmallIconTextView(wxCommandEvent& event); - bool OnClose(void) { return TRUE; } + bool OnClose(void) { return TRUE; } + void OnDeselectAll(wxCommandEvent& event); + void OnSelectAll(wxCommandEvent& event); DECLARE_EVENT_TABLE() }; @@ -73,6 +75,8 @@ class MyFrame: public wxFrame #define LIST_SMALL_ICON_VIEW 5 #define LIST_SMALL_ICON_TEXT_VIEW 6 #define LIST_REPORT_VIEW 7 +#define LIST_DESELECT_ALL 8 +#define LIST_SELECT_ALL 9 #define LIST_ABOUT 102 #define LIST_CTRL 1000 -- 2.47.2