From 64797a78ea419b24cf82fe43faf9760c51de95f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 15 Feb 2015 22:54:50 +0000 Subject: [PATCH] Fix wxDV_ROW_LINES drawing when horizontally scrolled in generic version. Use the correct, i.e. logical, as wxDC does the translation to physical internally, coordinates for drawing the highlighted rows. Closes #16815. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/datavgen.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index 283dc5799c..092f265dc2 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -1807,9 +1807,11 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) wxDataViewModel *model = GetModel(); wxAutoBufferedPaintDC dc( this ); + const wxSize size = GetClientSize(); + dc.SetBrush(GetOwner()->GetBackgroundColour()); dc.SetPen( *wxTRANSPARENT_PEN ); - dc.DrawRectangle(GetClientSize()); + dc.DrawRectangle(size); if ( IsEmpty() ) { @@ -1895,13 +1897,16 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(altRowColour)); + // We only need to draw the visible part, so limit the rectangle to it. + const int xRect = m_owner->CalcUnscrolledPosition(wxPoint(0, 0)).x; + const int widthRect = size.x; for (unsigned int item = item_start; item < item_last; item++) { if ( item % 2 ) { - dc.DrawRectangle(x_start, + dc.DrawRectangle(xRect, GetLineStart(item), - GetClientSize().GetWidth(), + widthRect, GetLineHeight(item)); } }