]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listbox/lboxtest.cpp
wx.aui.AUI_ART_GRADIENT_TYPE --> wx.aui.AUI_DOCKART_GRADIENT_TYPE
[wxWidgets.git] / samples / listbox / lboxtest.cpp
index a5a9117fbafbb18f545026aed5cec23d53d9dc22..d5dd01608f7181a2bcfd963a4b0bd49e42eb657a 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);
 
@@ -486,9 +495,6 @@ LboxTestFrame::LboxTestFrame(const wxString& title)
     m_logTarget = new LboxLogger(m_lboxLog, wxLog::GetActiveTarget());
     wxLog::SetActiveTarget(m_logTarget);
 #endif // wxUSE_LOG
-
-    m_lbox->Connect(wxEVT_RIGHT_DOWN, 
-        wxMouseEventHandler(LboxTestFrame::OnListboxRDown), NULL, this);
 }
 
 LboxTestFrame::~LboxTestFrame()
@@ -622,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();
@@ -636,7 +647,7 @@ void LboxTestFrame::OnButtonClearLog(wxCommandEvent& WXUNUSED(event))
 
 void LboxTestFrame::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
 {
-    static size_t s_item = 0;
+    static unsigned s_item = 0;
 
     wxString s = m_textAdd->GetValue();
     if ( !m_textAdd->IsModified() )
@@ -651,7 +662,7 @@ void LboxTestFrame::OnButtonAdd(wxCommandEvent& WXUNUSED(event))
 void LboxTestFrame::OnButtonAddMany(wxCommandEvent& WXUNUSED(event))
 {
     // "many" means 1000 here
-    for ( size_t n = 0; n < 1000; n++ )
+    for ( unsigned n = 0; n < 1000; n++ )
     {
         m_lbox->Append(wxString::Format(_T("item #%u"), n));
     }
@@ -684,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);