]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/choicdgg.cpp
Border corrections
[wxWidgets.git] / src / generic / choicdgg.cpp
index 0b3ec8c65229145b6e405de76d9ba20a458e9a59..fa3c19415bd479884041a577aa1afad3f2e54114 100644 (file)
@@ -40,6 +40,7 @@
 #endif
 
 #include "wx/statline.h"
+#include "wx/settings.h"
 #include "wx/generic/choicdgg.h"
 
 // ----------------------------------------------------------------------------
@@ -263,7 +264,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
         m_listbox->SetSelection(0);
 
     topsizer->
-        Add(m_listbox, wxSizerFlags().Expand().TripleBorder(wxLEFT | wxRIGHT));
+        Add(m_listbox, wxSizerFlags().Expand().Proportion(1).TripleBorder(wxLEFT | wxRIGHT));
 
     // 3) buttons if any
     wxSizer *
@@ -435,10 +436,17 @@ bool wxMultiChoiceDialog::Create( wxWindow *parent,
                                   long style,
                                   const wxPoint& pos )
 {
+    long styleLbox;
+#if wxUSE_CHECKLISTBOX
+    styleLbox = wxLB_ALWAYS_SB;
+#else
+    styleLbox = wxLB_ALWAYS_SB | wxLB_EXTENDED;
+#endif
+
     if ( !wxAnyChoiceDialog::Create(parent, message, caption,
                                     n, choices,
                                     style, pos,
-                                    wxLB_ALWAYS_SB | wxLB_EXTENDED) )
+                                    styleLbox) )
         return false;
 
     return true;
@@ -458,6 +466,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 +509,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++ )
     {