Improve wxMSW ListCtrl drawing of horizontal rules

Appending an item in the listctrl sample results in two horizontal lines
drawn next to each other while they should be overlapping. Fix by drawing
only the bottom line of each item instead of skipping the first one
(should have been the top visible item since
6443de0263) and drawing the last one in the
list (should have been bottom visible item).
This commit is contained in:
Dimitri Schoolwerth
2016-05-04 02:47:56 +04:00
parent 8d661b6bf8
commit 761f05c649

View File

@@ -3071,22 +3071,13 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
if (drawHRules) if (drawHRules)
{ {
const long top = GetTopItem(); const long top = GetTopItem();
for ( int i = top; i < top + GetCountPerPage() + 1; i++ ) const long bottom = wxMin(top + GetCountPerPage(), itemCount - 1);
for ( long i = top; i <= bottom; i++ )
{ {
if (GetItemRect(i, itemRect)) if (GetItemRect(i, itemRect))
{ {
int cy = itemRect.GetTop(); const int cy = itemRect.GetBottom();
if (i != 0) // Don't draw the first one dc.DrawLine(0, cy, clientSize.x, cy);
{
dc.DrawLine(0, cy, clientSize.x, cy);
}
// Draw last line
if (i == itemCount - 1)
{
cy = itemRect.GetBottom();
dc.DrawLine(0, cy, clientSize.x, cy);
break;
}
} }
} }
} }