]> git.saurik.com Git - wxWidgets.git/commitdiff
Corrected wxMultiChoiceDialog if wxCheckListBox is used
authorJulian Smart <julian@anthemion.co.uk>
Mon, 13 Nov 2006 17:08:23 +0000 (17:08 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 13 Nov 2006 17:08:23 +0000 (17:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43397 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/choicdgg.cpp

index 0b3ec8c65229145b6e405de76d9ba20a458e9a59..058ef02ac2450e8f221498a29b5df7a900e79b84 100644 (file)
@@ -458,6 +458,30 @@ bool wxMultiChoiceDialog::Create( wxWindow *parent,
 
 void wxMultiChoiceDialog::SetSelections(const wxArrayInt& selections)
 {
+#if wxUSE_CHECKLISTBOX
+    wxCheckListBox* checkListBox = wxDynamicCast(m_listbox, wxCheckListBox);
+    if (checkListBox)
+    {
+        // first clear all currently selected items
+        size_t n,
+            count = checkListBox->GetCount();
+        for ( n = 0; n < count; ++n )
+        {
+            if (checkListBox->IsChecked(n))
+                checkListBox->Check(n, false);
+        }
+
+        // now select the ones which should be selected
+        count = selections.GetCount();
+        for ( n = 0; n < count; n++ )
+        {
+            checkListBox->Check(selections[n]);
+        }
+        
+        return;
+    }
+#endif
+    
     // first clear all currently selected items
     size_t n,
            count = m_listbox->GetCount();
@@ -477,6 +501,21 @@ void wxMultiChoiceDialog::SetSelections(const wxArrayInt& selections)
 bool wxMultiChoiceDialog::TransferDataFromWindow()
 {
     m_selections.Empty();
+
+#if wxUSE_CHECKLISTBOX
+    wxCheckListBox* checkListBox = wxDynamicCast(m_listbox, wxCheckListBox);
+    if (checkListBox)
+    {
+        size_t count = checkListBox->GetCount();
+        for ( size_t n = 0; n < count; n++ )
+        {
+            if ( checkListBox->IsChecked(n) )
+                m_selections.Add(n);
+        }
+        return true;
+    }
+#endif
+
     size_t count = m_listbox->GetCount();
     for ( size_t n = 0; n < count; n++ )
     {