Fix wxMSW ListCtrl drawing of horizontal rules for new items

When adding a new item to a wxMSW ListCtrl that uses horizontal rules the
painting is horizontally clipped to the left of the control and the
rightmost column and the rule doesn't extend beyond that as it does when
doing a full repaint. Fix by refreshing the part to the right of the
rightmost column.

This also reverts 02c8973a57 which became
unnecessary now.

Also see #17158.
This commit is contained in:
Dimitri Schoolwerth 2016-05-04 11:19:21 +04:00
parent d382107ea2
commit 374db28747

View File

@ -709,15 +709,7 @@ bool wxListCtrl::SetColumnWidth(int col, int width)
else if ( width == wxLIST_AUTOSIZE_USEHEADER)
width = LVSCW_AUTOSIZE_USEHEADER;
if ( !ListView_SetColumnWidth(GetHwnd(), col, width) )
return false;
// Failure to explicitly refresh the control with horizontal rules results
// in corrupted rules display.
if ( HasFlag(wxLC_HRULES) )
Refresh();
return true;
return ListView_SetColumnWidth(GetHwnd(), col, width) != 0;
}
// ----------------------------------------------------------------------------
@ -3077,6 +3069,9 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
const long top = GetTopItem();
const long bottom = wxMin(top + countPerPage, itemCount - 1);
wxRect clipRect;
dc.GetClippingBox(clipRect);
if (drawHRules)
{
wxRect itemRect;
@ -3085,9 +3080,24 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
if (GetItemRect(i, itemRect))
{
const int cy = itemRect.GetBottom();
dc.DrawLine(0, cy, clientSize.x, cy);
dc.DrawLine(clipRect.x, cy, clipRect.GetRight() + 1, cy);
}
}
/*
The drawing can be clipped horizontally to the rightmost column. This
happens when an item is added (and visible) and results in a
horizontal rule being clipped instead of drawn across the entire list
control. In that case we request for the part to the right of the
rightmost column to be drawn as well.
*/
if ( clipRect.GetRight() != clientSize.GetWidth() - 1
&& clipRect.width)
{
RefreshRect(wxRect(clipRect.GetRight(), clipRect.y,
clientSize.x - clipRect.width, clipRect.height),
false /* erase background? */);
}
}
if (drawVRules)