Slightly improve wxMSW ListCtrl drawing of vertical rules
Draw the vertical rules with Y coordinates related to the top and bottom visible item which makes more sense than using the first and last item.
This commit is contained in:
@@ -3066,12 +3066,20 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
|
|||||||
dc.SetBrush(* wxTRANSPARENT_BRUSH);
|
dc.SetBrush(* wxTRANSPARENT_BRUSH);
|
||||||
|
|
||||||
wxSize clientSize = GetClientSize();
|
wxSize clientSize = GetClientSize();
|
||||||
wxRect itemRect;
|
|
||||||
|
const int countPerPage = GetCountPerPage();
|
||||||
|
if (countPerPage < 0)
|
||||||
|
{
|
||||||
|
// Can be -1 in which case it's useless to try to draw rules.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const long top = GetTopItem();
|
||||||
|
const long bottom = wxMin(top + countPerPage, itemCount - 1);
|
||||||
|
|
||||||
if (drawHRules)
|
if (drawHRules)
|
||||||
{
|
{
|
||||||
const long top = GetTopItem();
|
wxRect itemRect;
|
||||||
const long bottom = wxMin(top + GetCountPerPage(), itemCount - 1);
|
|
||||||
for ( long i = top; i <= bottom; i++ )
|
for ( long i = top; i <= bottom; i++ )
|
||||||
{
|
{
|
||||||
if (GetItemRect(i, itemRect))
|
if (GetItemRect(i, itemRect))
|
||||||
@@ -3084,10 +3092,10 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
|
|||||||
|
|
||||||
if (drawVRules)
|
if (drawVRules)
|
||||||
{
|
{
|
||||||
wxRect firstItemRect;
|
wxRect topItemRect, bottomItemRect;
|
||||||
GetItemRect(0, firstItemRect);
|
GetItemRect(top, topItemRect);
|
||||||
|
|
||||||
if (GetItemRect(itemCount - 1, itemRect))
|
if (GetItemRect(bottom, bottomItemRect))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
This is a fix for ticket #747: erase the pixels which we would
|
This is a fix for ticket #747: erase the pixels which we would
|
||||||
@@ -3119,7 +3127,7 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
|
|||||||
{
|
{
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
dc.SetBrush(wxBrush(GetBackgroundColour()));
|
dc.SetBrush(wxBrush(GetBackgroundColour()));
|
||||||
dc.DrawRectangle(0, firstItemRect.GetY() - gap,
|
dc.DrawRectangle(0, topItemRect.GetY() - gap,
|
||||||
clientSize.GetWidth(), gap);
|
clientSize.GetWidth(), gap);
|
||||||
|
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
@@ -3136,13 +3144,13 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x = itemRect.GetX();
|
int x = bottomItemRect.GetX();
|
||||||
for (int col = 0; col < numCols; col++)
|
for (int col = 0; col < numCols; col++)
|
||||||
{
|
{
|
||||||
int colWidth = GetColumnWidth(indexArray[col]);
|
int colWidth = GetColumnWidth(indexArray[col]);
|
||||||
x += colWidth ;
|
x += colWidth ;
|
||||||
dc.DrawLine(x-1, firstItemRect.GetY() - gap,
|
dc.DrawLine(x-1, topItemRect.GetY() - gap,
|
||||||
x-1, itemRect.GetBottom());
|
x-1, bottomItemRect.GetBottom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user