From 07f54869cf913c6f76023b55421bc64d50de3657 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 4 Jul 2021 20:43:02 +0200 Subject: [PATCH] Iterate over wxPointList with STL syntax in wxMSWDC::DoDrawSpline STL syntax is more readable than notation with legacy API. --- src/msw/dc.cpp | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index de310cf35e..ea27b75a01 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1160,7 +1160,7 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) wxCHECK_RET( points, "NULL pointer to spline points?" ); - const size_t n_points = points->GetCount(); + const size_t n_points = points->size(); wxCHECK_RET( n_points >= 2 , "incomplete list of spline points?" ); const size_t n_bezier_points = n_points * 3 + 1; @@ -1168,8 +1168,8 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) size_t bezier_pos = 0; wxCoord x1, y1, x2, y2, cx1, cy1; - wxPointList::compatibility_iterator node = points->GetFirst(); - wxPoint *p = node->GetData(); + wxPointList::const_iterator itPt = points->begin(); + wxPoint* p = *itPt; ++itPt; lppt[ bezier_pos ].x = x1 = p->x; lppt[ bezier_pos ].y = y1 = p->y; bezier_pos++; @@ -1177,9 +1177,7 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) bezier_pos++; CalcBoundingBox(x1, y1); - node = node->GetNext(); - p = node->GetData(); - + p = *itPt; ++itPt; x2 = p->x; y2 = p->y; cx1 = ( x1 + x2 ) / 2; @@ -1191,20 +1189,15 @@ void wxMSWDCImpl::DoDrawSpline(const wxPointList *points) bezier_pos++; CalcBoundingBox(x2, y2); -#if !wxUSE_STD_CONTAINERS - while ((node = node->GetNext()) != NULL) -#else - while ((node = node->GetNext())) -#endif // !wxUSE_STD_CONTAINERS + while ( itPt != points->end() ) { - int cx4, cy4; - p = (wxPoint *)node->GetData(); + p = *itPt; ++itPt; x1 = x2; y1 = y2; x2 = p->x; y2 = p->y; - cx4 = (x1 + x2) / 2; - cy4 = (y1 + y2) / 2; + int cx4 = (x1 + x2) / 2; + int cy4 = (y1 + y2) / 2; // B0 is B3 of previous segment // B1: lppt[ bezier_pos ].x = XLOG2DEV((x1*2+cx1)/3);