]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/vlbox.cpp
Override GetPixelSize on OS X as the base impl creates a wxScreenDC each time, which...
[wxWidgets.git] / src / generic / vlbox.cpp
index 4aaf8fa0af0e88d8d6b4586c40757e7c50a2f7fc..2a3ca54d1cbce461ab5a6664f0dd6fb3af239648 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        generic/vlbox.cpp
+// Name:        src/generic/vlbox.cpp
 // Purpose:     implementation of wxVListBox
 // Author:      Vadim Zeitlin
 // Modified by:
 
 #if wxUSE_LISTBOX
 
+#include "wx/vlbox.h"
+
 #ifndef WX_PRECOMP
     #include "wx/settings.h"
     #include "wx/dcclient.h"
+    #include "wx/listbox.h"
 #endif //WX_PRECOMP
 
-#include "wx/vlbox.h"
 #include "wx/dcbuffer.h"
 #include "wx/selstore.h"
 
@@ -62,7 +64,6 @@ void wxVListBox::Init()
     m_current =
     m_anchor = wxNOT_FOUND;
     m_selStore = NULL;
-    m_doubleBuffer = NULL;
 }
 
 bool wxVListBox::Create(wxWindow *parent,
@@ -92,7 +93,6 @@ bool wxVListBox::Create(wxWindow *parent,
 
 wxVListBox::~wxVListBox()
 {
-    delete m_doubleBuffer;    
     delete m_selStore;
 }
 
@@ -231,7 +231,7 @@ bool wxVListBox::DoSetCurrent(int current)
             // it is, indeed, only partly visible, so scroll it into view to
             // make it entirely visible
             while ( (size_t)m_current == GetLastVisibleLine() &&
-                    ScrollToLine(GetVisibleBegin()+1) );
+                    ScrollToLine(GetVisibleBegin()+1) ) ;
 
             // but in any case refresh it as even if it was only partly visible
             // before we need to redraw it entirely as its background changed
@@ -262,7 +262,10 @@ void wxVListBox::SetSelection(int selection)
 
     if ( HasMultipleSelection() )
     {
-        Select(selection);
+        if (selection != wxNOT_FOUND)
+            Select(selection);
+        else
+            DeselectAll();
         m_anchor = selection;
     }
 
@@ -355,18 +358,9 @@ void wxVListBox::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const
 
 void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event))
 {
-    // If size is larger, recalculate double buffer bitmap
     wxSize clientSize = GetClientSize();
 
-    if ( !m_doubleBuffer ||
-         clientSize.x > m_doubleBuffer->GetWidth() ||
-         clientSize.y > m_doubleBuffer->GetHeight() )
-    {
-        delete m_doubleBuffer;
-        m_doubleBuffer = new wxBitmap(clientSize.x+25,clientSize.y+25);
-    }
-
-    wxBufferedPaintDC dc(this,*m_doubleBuffer);
+    wxAutoBufferedPaintDC dc(this);
 
     // the update rectangle
     wxRect rectUpdate = GetUpdateClientRect();
@@ -636,7 +630,7 @@ void wxVListBox::OnLeftDClick(wxMouseEvent& eventMouse)
         {
             OnLeftDown(eventMouse);
         }
-    
+
     }
 }
 
@@ -645,8 +639,6 @@ void wxVListBox::OnLeftDClick(wxMouseEvent& eventMouse)
 // use the same default attributes as wxListBox
 // ----------------------------------------------------------------------------
 
-#include "wx/listbox.h"
-
 //static
 wxVisualAttributes
 wxVListBox::GetClassDefaultAttributes(wxWindowVariant variant)