]> git.saurik.com Git - wxWidgets.git/commitdiff
add SetSelection(-1) test (part of patch 1506943)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Jun 2006 00:47:47 +0000 (00:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Jun 2006 00:47:47 +0000 (00:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39837 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/listbox/lboxtest.cpp

index 7917dabf4c50ae6c05b89ba695592e930f0bab38..8e67ca7083ca8a0c5bd7d60a68ee308ce2f7f9fc 100644 (file)
@@ -77,6 +77,7 @@ enum
     LboxTest_Delete,
     LboxTest_DeleteText,
     LboxTest_DeleteSel,
+    LboxTest_DeselectAll,
     LboxTest_Listbox,
     LboxTest_Quit
 };
@@ -113,7 +114,9 @@ protected:
     void OnButtonChange(wxCommandEvent& event);
     void OnButtonDelete(wxCommandEvent& event);
     void OnButtonDeleteSel(wxCommandEvent& event);
+    void OnButtonDeselectAll(wxCommandEvent& event);
     void OnButtonClear(wxCommandEvent& event);
+
 #if wxUSE_LOG
     void OnButtonClearLog(wxCommandEvent& event);
 #endif // wxUSE_LOG
@@ -133,6 +136,7 @@ protected:
     void OnUpdateUIClearButton(wxUpdateUIEvent& event);
     void OnUpdateUIDeleteButton(wxUpdateUIEvent& event);
     void OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event);
+    void OnUpdateUIDeselectAllButton(wxUpdateUIEvent& event);
 
     // reset the listbox parameters
     void Reset();
@@ -277,6 +281,7 @@ BEGIN_EVENT_TABLE(LboxTestFrame, wxFrame)
     EVT_BUTTON(LboxTest_Change, LboxTestFrame::OnButtonChange)
     EVT_BUTTON(LboxTest_Delete, LboxTestFrame::OnButtonDelete)
     EVT_BUTTON(LboxTest_DeleteSel, LboxTestFrame::OnButtonDeleteSel)
+    EVT_BUTTON(LboxTest_DeselectAll, LboxTestFrame::OnButtonDeselectAll)
     EVT_BUTTON(LboxTest_Clear, LboxTestFrame::OnButtonClear)
 #if wxUSE_LOG
     EVT_BUTTON(LboxTest_ClearLog, LboxTestFrame::OnButtonClearLog)
@@ -299,6 +304,7 @@ BEGIN_EVENT_TABLE(LboxTestFrame, wxFrame)
     EVT_UPDATE_UI(LboxTest_Change, LboxTestFrame::OnUpdateUIDeleteSelButton)
     EVT_UPDATE_UI(LboxTest_ChangeText, LboxTestFrame::OnUpdateUIDeleteSelButton)
     EVT_UPDATE_UI(LboxTest_DeleteSel, LboxTestFrame::OnUpdateUIDeleteSelButton)
+    EVT_UPDATE_UI(LboxTest_DeselectAll, LboxTestFrame::OnUpdateUIDeselectAllButton)
 
     EVT_LISTBOX(LboxTest_Listbox, LboxTestFrame::OnListbox)
     EVT_LISTBOX_DCLICK(wxID_ANY, LboxTestFrame::OnListboxDClick)
@@ -432,6 +438,9 @@ LboxTestFrame::LboxTestFrame(const wxString& title)
     btn = new wxButton(m_panel, LboxTest_DeleteSel, _T("Delete &selection"));
     sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
 
+    btn = new wxButton(m_panel, LboxTest_DeselectAll, _T("Deselect All"));
+    sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
+
     btn = new wxButton(m_panel, LboxTest_Clear, _T("&Clear"));
     sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
 
@@ -619,6 +628,11 @@ void LboxTestFrame::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
     }
 }
 
+void LboxTestFrame::OnButtonDeselectAll(wxCommandEvent& WXUNUSED(event))
+{
+    m_lbox->SetSelection(-1); 
+}
+
 void LboxTestFrame::OnButtonClear(wxCommandEvent& WXUNUSED(event))
 {
     m_lbox->Clear();
@@ -681,6 +695,12 @@ void LboxTestFrame::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
     event.Enable(m_lbox->GetSelections(selections) != 0);
 }
 
+void LboxTestFrame::OnUpdateUIDeselectAllButton(wxUpdateUIEvent& event)
+{
+    wxArrayInt selections;
+    event.Enable(m_lbox->GetSelections(selections) != 0);
+}
+
 void LboxTestFrame::OnUpdateUIClearButton(wxUpdateUIEvent& event)
 {
     event.Enable(m_lbox->GetCount() != 0);