]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/vlbox.cpp
Improvements to OnIdle processing
[wxWidgets.git] / src / generic / vlbox.cpp
index bc846054a238b49dceae8b7b79ea47752fe1b91f..938b9d331c76d8780cd5e28d81b18bdbf8f920f3 100644 (file)
@@ -69,11 +69,12 @@ bool wxVListBox::Create(wxWindow *parent,
     if ( !wxVScrolledWindow::Create(parent, id, pos, size, style, name) )
         return false;
 
-    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX));
-
     if ( style & wxLB_MULTIPLE )
         m_selStore = new wxSelectionStore;
 
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX));
+    m_colBgSel = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
+
     return true;
 }
 
@@ -248,8 +249,11 @@ void wxVListBox::SetSelection(int selection)
                   (selection >= 0 && (size_t)selection < GetItemCount()),
                   _T("wxVListBox::SetSelection(): invalid item index") );
 
-    wxASSERT_MSG( !HasMultipleSelection(),
-                  _T("SetSelection() is invalid with multiselection listbox") );
+    if ( HasMultipleSelection() )
+    {
+        Select(selection);
+        m_anchor = selection;
+    }
 
     DoSetCurrent(selection);
 }
@@ -282,7 +286,7 @@ int wxVListBox::GetNextSelected(unsigned long& cookie) const
 }
 
 // ----------------------------------------------------------------------------
-// wxVListBox painting
+// wxVListBox appearance parameters
 // ----------------------------------------------------------------------------
 
 void wxVListBox::SetMargins(const wxPoint& pt)
@@ -295,6 +299,15 @@ void wxVListBox::SetMargins(const wxPoint& pt)
     }
 }
 
+void wxVListBox::SetSelectionBackground(const wxColour& col)
+{
+    m_colBgSel = col;
+}
+
+// ----------------------------------------------------------------------------
+// wxVListBox painting
+// ----------------------------------------------------------------------------
+
 wxCoord wxVListBox::OnGetLineHeight(size_t line) const
 {
     return OnMeasureItem(line) + 2*m_ptMargins.y;
@@ -337,10 +350,7 @@ void wxVListBox::OnPaint(wxPaintEvent& event)
             {
                 if ( isSelected )
                 {
-                    wxBrush brush(wxSystemSettings::
-                                    GetColour(wxSYS_COLOUR_HIGHLIGHT),
-                                    wxSOLID);
-                    dc.SetBrush(brush);
+                    dc.SetBrush(wxBrush(m_colBgSel, wxSOLID));
                 }
                 else // !selected
                 {