Iterate over wxPointList with STL syntax in wxGCDC::DoDrawSpline

STL syntax is more readable than notation with legacy API.
This commit is contained in:
Artur Wieczorek
2021-07-04 20:47:46 +02:00
parent 07f54869cf
commit fb21a9096e

View File

@@ -847,22 +847,19 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
{ {
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") ); wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
wxCHECK_RET(points, "NULL pointer to spline points?"); wxCHECK_RET(points, "NULL pointer to spline points?");
wxCHECK_RET(points->GetCount() >= 2, "incomplete list of spline points?"); wxCHECK_RET(points->size() >= 2, "incomplete list of spline points?");
if ( !m_logicalFunctionSupported ) if ( !m_logicalFunctionSupported )
return; return;
wxGraphicsPath path = m_graphicContext->CreatePath(); wxGraphicsPath path = m_graphicContext->CreatePath();
wxPointList::compatibility_iterator node = points->GetFirst(); wxPointList::const_iterator itPt = points->begin();
const wxPoint *p = node->GetData(); const wxPoint* p = *itPt; ++itPt;
wxCoord x1 = p->x; wxCoord x1 = p->x;
wxCoord y1 = p->y; wxCoord y1 = p->y;
node = node->GetNext(); p = *itPt; ++itPt;
p = node->GetData();
wxCoord x2 = p->x; wxCoord x2 = p->x;
wxCoord y2 = p->y; wxCoord y2 = p->y;
wxCoord cx1 = ( x1 + x2 ) / 2; wxCoord cx1 = ( x1 + x2 ) / 2;
@@ -870,16 +867,9 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
path.MoveToPoint( x1 , y1 ); path.MoveToPoint( x1 , y1 );
path.AddLineToPoint( cx1 , cy1 ); path.AddLineToPoint( cx1 , cy1 );
#if !wxUSE_STD_CONTAINERS while ( itPt != points->end() )
while ((node = node->GetNext()) != NULL)
#else
while ((node = node->GetNext()))
#endif // !wxUSE_STD_CONTAINERS
{ {
p = node->GetData(); p = *itPt; ++itPt;
x1 = x2; x1 = x2;
y1 = y2; y1 = y2;
x2 = p->x; x2 = p->x;