X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0975a8a065f2cb516cec8a39fae8f00e61644908..f1d6804f7c1a398dd0616ccf15cb0f96ea07f5e0:/src/generic/vlbox.cpp diff --git a/src/generic/vlbox.cpp b/src/generic/vlbox.cpp index 1c1f33174e..2a3ca54d1c 100644 --- a/src/generic/vlbox.cpp +++ b/src/generic/vlbox.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: generic/vlbox.cpp +// Name: src/generic/vlbox.cpp // Purpose: implementation of wxVListBox // Author: Vadim Zeitlin // Modified by: @@ -26,12 +26,14 @@ #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,24 +358,15 @@ 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(); - // Fill it with background colour - dc.SetBrush(GetBackgroundColour()); + // fill it with background colour + dc.SetBackground(GetBackgroundColour()); dc.Clear(); // the bounding rectangle of the current line @@ -380,8 +374,8 @@ void wxVListBox::OnPaint(wxPaintEvent& WXUNUSED(event)) rectLine.width = clientSize.x; // iterate over all visible lines - const size_t lineMax = GetLastVisibleLine(); - for ( size_t line = GetFirstVisibleLine(); line <= lineMax; line++ ) + const size_t lineMax = GetVisibleEnd(); + for ( size_t line = GetFirstVisibleLine(); line < lineMax; line++ ) { const wxCoord hLine = OnGetLineHeight(line); @@ -538,13 +532,11 @@ void wxVListBox::OnKeyDown(wxKeyEvent& event) break; case WXK_PAGEDOWN: - case WXK_NEXT: PageDown(); current = GetFirstVisibleLine(); break; case WXK_PAGEUP: - case WXK_PRIOR: if ( m_current == (int)GetFirstVisibleLine() ) { PageUp(); @@ -638,7 +630,7 @@ void wxVListBox::OnLeftDClick(wxMouseEvent& eventMouse) { OnLeftDown(eventMouse); } - + } } @@ -647,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)