From 761f05c6494562f9941cdd84614cd587709ad338 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Wed, 4 May 2016 02:47:56 +0400 Subject: [PATCH] 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 6443de026310552cacd68a6d0318e73d14929680) and drawing the last one in the list (should have been bottom visible item). --- src/msw/listctrl.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index b590ebce93..4355256ce2 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -3071,22 +3071,13 @@ void wxListCtrl::OnPaint(wxPaintEvent& event) if (drawHRules) { 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)) { - int cy = itemRect.GetTop(); - if (i != 0) // Don't draw the first one - { - 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; - } + const int cy = itemRect.GetBottom(); + dc.DrawLine(0, cy, clientSize.x, cy); } } }