From 4787c92d397bb4849b1248f5ba1875746434f4e2 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 18 Jan 2013 17:27:51 +0000 Subject: [PATCH] use const arrays for wxDC array parameters, closes #10712 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/dc.h | 4 ++-- include/wx/dc.h | 16 ++++++++-------- include/wx/dcgraph.h | 6 +++--- include/wx/dcmirror.h | 30 +++++++++++++----------------- include/wx/dcsvg.h | 4 ++-- include/wx/dfb/dc.h | 4 ++-- include/wx/generic/dcpsg.h | 6 +++--- include/wx/gtk/dcclient.h | 4 ++-- include/wx/gtk/gnome/gprint.h | 6 +++--- include/wx/gtk/print.h | 6 +++--- include/wx/gtk1/dcclient.h | 4 ++-- include/wx/motif/dcclient.h | 4 ++-- include/wx/msw/dc.h | 6 +++--- include/wx/os2/dc.h | 4 ++-- include/wx/x11/dcclient.h | 4 ++-- interface/wx/dc.h | 8 ++++---- src/cocoa/dc.mm | 4 ++-- src/common/dcbase.cpp | 12 ++++++------ src/common/dcgraph.cpp | 10 +++++----- src/common/dcsvg.cpp | 4 ++-- src/dfb/dc.cpp | 4 ++-- src/generic/dcpsg.cpp | 6 +++--- src/gtk/dcclient.cpp | 34 ++++++++++++++++++++-------------- src/gtk/gnome/gprint.cpp | 6 +++--- src/gtk/print.cpp | 6 +++--- src/gtk1/dcclient.cpp | 4 ++-- src/motif/dcclient.cpp | 4 ++-- src/msw/dc.cpp | 8 ++++---- src/os2/dc.cpp | 4 ++-- src/x11/dcclient.cpp | 4 ++-- 30 files changed, 114 insertions(+), 112 deletions(-) diff --git a/include/wx/cocoa/dc.h b/include/wx/cocoa/dc.h index 65af01c0b2..66b1478abf 100644 --- a/include/wx/cocoa/dc.h +++ b/include/wx/cocoa/dc.h @@ -165,9 +165,9 @@ protected: virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSizeMM(int* width, int* height) const; - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); }; diff --git a/include/wx/dc.h b/include/wx/dc.h index 34f58e2662..a957b28e78 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -604,15 +604,15 @@ public: { return wxNullBitmap; } - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset ) = 0; virtual void DrawLines(const wxPointList *list, wxCoord xoffset, wxCoord yoffset ); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) = 0; - virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle); void DrawPolygon(const wxPointList *list, @@ -624,7 +624,7 @@ public: void DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3); - void DrawSpline(int n, wxPoint points[]); + void DrawSpline(int n, const wxPoint points[]); void DrawSpline(const wxPointList *points) { DoDrawSpline(points); } virtual void DoDrawSpline(const wxPointList *points); @@ -1139,7 +1139,7 @@ public: void DrawPoint(const wxPoint& pt) { m_pimpl->DoDrawPoint(pt.x, pt.y); } - void DrawLines(int n, wxPoint points[], + void DrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0) { m_pimpl->DoDrawLines(n, points, xoffset, yoffset); } void DrawLines(const wxPointList *list, @@ -1150,7 +1150,7 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0) ); #endif // WXWIN_COMPATIBILITY_2_8 - void DrawPolygon(int n, wxPoint points[], + void DrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { m_pimpl->DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); } @@ -1158,7 +1158,7 @@ public: wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { m_pimpl->DrawPolygon( list, xoffset, yoffset, fillStyle ); } - void DrawPolyPolygon(int n, int count[], wxPoint points[], + void DrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { m_pimpl->DoDrawPolyPolygon(n, count, points, xoffset, yoffset, fillStyle); } @@ -1281,7 +1281,7 @@ public: wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) { m_pimpl->DrawSpline(x1,y1,x2,y2,x3,y3); } - void DrawSpline(int n, wxPoint points[]) + void DrawSpline(int n, const wxPoint points[]) { m_pimpl->DrawSpline(n,points); } void DrawSpline(const wxPointList *points) { m_pimpl->DrawSpline(points); } diff --git a/include/wx/dcgraph.h b/include/wx/dcgraph.h index d010b63ae4..95f0732d06 100644 --- a/include/wx/dcgraph.h +++ b/include/wx/dcgraph.h @@ -177,12 +177,12 @@ public: virtual void DoGetSize(int *,int *) const; virtual void DoGetSizeMM(int* width, int* height) const; - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle); diff --git a/include/wx/dcmirror.h b/include/wx/dcmirror.h index ee6d5c1b8a..890667cc88 100644 --- a/include/wx/dcmirror.h +++ b/include/wx/dcmirror.h @@ -82,27 +82,23 @@ protected: wxCoord *GetX(wxCoord *x, wxCoord *y) const { return m_mirror ? y : x; } wxCoord *GetY(wxCoord *x, wxCoord *y) const { return m_mirror ? x : y; } - // exchange x and y unconditionally - static void Swap(wxCoord& x, wxCoord& y) - { - wxCoord t = x; - x = y; - y = t; - } - // exchange x and y components of all points in the array if necessary - void Mirror(int n, wxPoint points[]) const + wxPoint* Mirror(int n, const wxPoint*& points) const { + wxPoint* points_alloc = NULL; if ( m_mirror ) { + points_alloc = new wxPoint[n]; for ( int i = 0; i < n; i++ ) { - Swap(points[i].x, points[i].y); + points_alloc[i].x = points[i].y; + points_alloc[i].y = points[i].x; } + points = points_alloc; } + return points_alloc; } - // wxDCBase functions virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, wxFloodFillStyle style = wxFLOOD_SURFACE) @@ -226,28 +222,28 @@ protected: m_dc.DoGetSizeMM(GetX(w, h), GetY(w, h)); } - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { - Mirror(n, points); + wxPoint* points_alloc = Mirror(n, points); m_dc.DoDrawLines(n, points, GetX(xoffset, yoffset), GetY(xoffset, yoffset)); - Mirror(n, points); + delete[] points_alloc; } - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE) { - Mirror(n, points); + wxPoint* points_alloc = Mirror(n, points); m_dc.DoDrawPolygon(n, points, GetX(xoffset, yoffset), GetY(xoffset, yoffset), fillStyle); - Mirror(n, points); + delete[] points_alloc; } virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region)) diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h index d1b26c1e20..ee99a8e703 100644 --- a/include/wx/dcsvg.h +++ b/include/wx/dcsvg.h @@ -126,12 +126,12 @@ private: virtual void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); virtual void DoDrawPoint(wxCoord, wxCoord); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle); diff --git a/include/wx/dfb/dc.h b/include/wx/dfb/dc.h index d5acf69401..2d64cdb966 100644 --- a/include/wx/dfb/dc.h +++ b/include/wx/dfb/dc.h @@ -132,9 +132,9 @@ protected: virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSizeMM(int* width, int* height) const; - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); diff --git a/include/wx/generic/dcpsg.h b/include/wx/generic/dcpsg.h index 65e36cbce8..57b8500689 100644 --- a/include/wx/generic/dcpsg.h +++ b/include/wx/generic/dcpsg.h @@ -105,11 +105,11 @@ protected: void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); void DoDrawPoint(wxCoord x, wxCoord y); - void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); - void DoDrawPolygon(int n, wxPoint points[], + void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); + void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index b64f995348..4c96d69fc0 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -40,9 +40,9 @@ public: double sa, double ea ); virtual void DoDrawPoint( wxCoord x, wxCoord y ); - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h index 880a528d60..67d4f415c0 100644 --- a/include/wx/gtk/gnome/gprint.h +++ b/include/wx/gtk/gnome/gprint.h @@ -258,9 +258,9 @@ protected: void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); void DoDrawPoint(wxCoord x, wxCoord y); - void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); - void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); - void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); + void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); + void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); + void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0); void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); diff --git a/include/wx/gtk/print.h b/include/wx/gtk/print.h index 16a90f8cb2..180d0c6e88 100644 --- a/include/wx/gtk/print.h +++ b/include/wx/gtk/print.h @@ -266,9 +266,9 @@ protected: void DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc); void DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea); void DoDrawPoint(wxCoord x, wxCoord y); - void DoDrawLines(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); - void DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); - void DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); + void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); + void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); + void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fillStyle=wxODDEVEN_RULE); void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); void DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0); void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h index bc6ade1901..14290f9085 100644 --- a/include/wx/gtk1/dcclient.h +++ b/include/wx/gtk1/dcclient.h @@ -49,9 +49,9 @@ protected: double sa, double ea ); virtual void DoDrawPoint( wxCoord x, wxCoord y ); - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); diff --git a/include/wx/motif/dcclient.h b/include/wx/motif/dcclient.h index b13f196eb4..1d46c91951 100644 --- a/include/wx/motif/dcclient.h +++ b/include/wx/motif/dcclient.h @@ -121,9 +121,9 @@ protected: wxCoord width, wxCoord height); virtual void DoSetDeviceClippingRegion(const wxRegion& region); - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index ddb8797d00..cd08950210 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -249,12 +249,12 @@ public: virtual void DoGetSizeMM(int* width, int* height) const; - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); - virtual void DoDrawPolyPolygon(int n, int count[], wxPoint points[], + virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const diff --git a/include/wx/os2/dc.h b/include/wx/os2/dc.h index dfe7c050a5..98af509457 100644 --- a/include/wx/os2/dc.h +++ b/include/wx/os2/dc.h @@ -336,12 +336,12 @@ public: ) const; virtual void DoDrawLines( int n - ,wxPoint vaPoints[] + ,const wxPoint vaPoints[] ,wxCoord vXoffset ,wxCoord yYoffset ); virtual void DoDrawPolygon( int n - ,wxPoint vaPoints[] + ,const wxPoint vaPoints[] ,wxCoord vXoffset ,wxCoord vYoffset ,wxPolygonFillMode nFillStyle = wxODDEVEN_RULE diff --git a/include/wx/x11/dcclient.h b/include/wx/x11/dcclient.h index 9850e700ca..1110046197 100644 --- a/include/wx/x11/dcclient.h +++ b/include/wx/x11/dcclient.h @@ -77,9 +77,9 @@ protected: wxCoord width, wxCoord height); virtual void DoSetDeviceClippingRegion(const wxRegion& region); - virtual void DoDrawLines(int n, wxPoint points[], + virtual void DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], + virtual void DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle = wxODDEVEN_RULE); diff --git a/interface/wx/dc.h b/interface/wx/dc.h index 0d7e5ab5e6..c723f19e6e 100644 --- a/interface/wx/dc.h +++ b/interface/wx/dc.h @@ -413,7 +413,7 @@ public: Not supported by wxPerl. @endWxPerlOnly */ - void DrawLines(int n, wxPoint points[], wxCoord xoffset = 0, + void DrawLines(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0); /** This method uses a list of wxPoints, adding the optional offset @@ -455,7 +455,7 @@ public: Not supported by wxPerl. @endWxPerlOnly */ - void DrawPolygon(int n, wxPoint points[], wxCoord xoffset = 0, + void DrawPolygon(int n, const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fill_style = wxODDEVEN_RULE); /** @@ -504,7 +504,7 @@ public: the DrawPolygon() member function, the polygons created by this method are not closed automatically. */ - void DrawPolyPolygon(int n, int count[], wxPoint points[], + void DrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset = 0, wxCoord yoffset = 0, wxPolygonFillMode fill_style = wxODDEVEN_RULE); @@ -579,7 +579,7 @@ public: Not supported by wxPerl. @endWxPerlOnly */ - void DrawSpline(int n, wxPoint points[]); + void DrawSpline(int n, const wxPoint points[]); /** @overload diff --git a/src/cocoa/dc.mm b/src/cocoa/dc.mm index 0f24ba758f..dee7258850 100644 --- a/src/cocoa/dc.mm +++ b/src/cocoa/dc.mm @@ -362,11 +362,11 @@ void wxCocoaDCImpl::DoDrawPoint( int x, int y ) { }; -void wxCocoaDCImpl::DoDrawPolygon( int, wxPoint *, int, int, wxPolygonFillMode) +void wxCocoaDCImpl::DoDrawPolygon( int, const wxPoint *, int, int, wxPolygonFillMode) { }; -void wxCocoaDCImpl::DoDrawLines( int, wxPoint *, int, int ) +void wxCocoaDCImpl::DoDrawLines( int, const wxPoint *, int, int ) { } diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 46a163129c..6f4d456002 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -622,8 +622,8 @@ void wxDCImpl::DrawPolygon(const wxPointList *list, void wxDCImpl::DoDrawPolyPolygon(int n, - int count[], - wxPoint points[], + const int count[], + const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { @@ -673,11 +673,11 @@ void wxDCImpl::DrawSpline(wxCoord x1, wxCoord y1, DrawSpline(WXSIZEOF(points), points); } -void wxDCImpl::DrawSpline(int n, wxPoint points[]) +void wxDCImpl::DrawSpline(int n, const wxPoint points[]) { wxPointList list; for ( int i = 0; i < n; i++ ) - list.Append(&points[i]); + list.Append(const_cast(&points[i])); DrawSpline(&list); } @@ -799,7 +799,7 @@ void wxDCImpl::DoDrawSpline( const wxPointList *points ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); - wxPoint *p; + const wxPoint *p; double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4; double x1, y1, x2, y2; @@ -808,7 +808,7 @@ void wxDCImpl::DoDrawSpline( const wxPointList *points ) // empty list return; - p = (wxPoint *)node->GetData(); + p = node->GetData(); x1 = p->x; y1 = p->y; diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 2b9b2913a5..e80d2375b3 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -608,7 +608,7 @@ void wxGCDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) DoDrawLine( x , y , x + 1 , y + 1 ); } -void wxGCDCImpl::DoDrawLines(int n, wxPoint points[], +void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") ); @@ -642,7 +642,7 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points) // empty list return; - wxPoint *p = node->GetData(); + const wxPoint *p = node->GetData(); wxCoord x1 = p->x; wxCoord y1 = p->y; @@ -686,7 +686,7 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points) } #endif // wxUSE_SPLINES -void wxGCDCImpl::DoDrawPolygon( int n, wxPoint points[], +void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle ) { @@ -715,8 +715,8 @@ void wxGCDCImpl::DoDrawPolygon( int n, wxPoint points[], } void wxGCDCImpl::DoDrawPolyPolygon(int n, - int count[], - wxPoint points[], + const int count[], + const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index 85105f91f2..1be3feb2e7 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -209,7 +209,7 @@ void wxSVGFileDCImpl::DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 CalcBoundingBox(x2, y2); } -void wxSVGFileDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset , wxCoord yoffset ) +void wxSVGFileDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset , wxCoord yoffset ) { for ( int i = 1; i < n; i++ ) { @@ -322,7 +322,7 @@ void wxSVGFileDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width CalcBoundingBox(x + width, y + height); } -void wxSVGFileDCImpl::DoDrawPolygon(int n, wxPoint points[], +void wxSVGFileDCImpl::DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp index c4006994df..90191f4692 100644 --- a/src/dfb/dc.cpp +++ b/src/dfb/dc.cpp @@ -239,7 +239,7 @@ void wxDFBDCImpl::DoDrawPoint(wxCoord x, wxCoord y) // FIXME_DFB: implement special cases for common formats (RGB24,RGBA/RGB32) } -void wxDFBDCImpl::DoDrawPolygon(int WXUNUSED(n), wxPoint WXUNUSED(points)[], +void wxDFBDCImpl::DoDrawPolygon(int WXUNUSED(n), const wxPoint WXUNUSED(points)[], wxCoord WXUNUSED(xoffset), wxCoord WXUNUSED(yoffset), wxPolygonFillMode WXUNUSED(fillStyle)) { @@ -248,7 +248,7 @@ void wxDFBDCImpl::DoDrawPolygon(int WXUNUSED(n), wxPoint WXUNUSED(points)[], wxFAIL_MSG( "DrawPolygon not implemented" ); } -void wxDFBDCImpl::DoDrawLines(int WXUNUSED(n), wxPoint WXUNUSED(points)[], +void wxDFBDCImpl::DoDrawLines(int WXUNUSED(n), const wxPoint WXUNUSED(points)[], wxCoord WXUNUSED(xoffset), wxCoord WXUNUSED(yoffset)) { wxCHECK_RET( IsOk(), wxT("invalid dc") ); diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index a490757cb0..61946d5174 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -597,7 +597,7 @@ void wxPostScriptDCImpl::DoDrawPoint (wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxPostScriptDCImpl::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) +void wxPostScriptDCImpl::DoDrawPolygon (int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -667,7 +667,7 @@ void wxPostScriptDCImpl::DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset } } -void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) +void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); @@ -743,7 +743,7 @@ void wxPostScriptDCImpl::DoDrawPolyPolygon (int n, int count[], wxPoint points[] } } -void wxPostScriptDCImpl::DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxPostScriptDCImpl::DoDrawLines (int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { wxCHECK_RET( m_ok, wxT("invalid postscript dc") ); diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 9f5aedbe53..b20b5d71cf 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -697,7 +697,7 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) CalcBoundingBox (x, y); } -void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -711,17 +711,21 @@ void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCo xoffset != 0 || yoffset != 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10; // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other - GdkPoint* gpts = reinterpret_cast(points); + const GdkPoint* gpts = reinterpret_cast(points); + GdkPoint* gpts_alloc = NULL; if (doScale) - gpts = new GdkPoint[n]; + { + gpts_alloc = new GdkPoint[n]; + gpts = gpts_alloc; + } for (int i = 0; i < n; i++) { if (doScale) { - gpts[i].x = XLOG2DEV(points[i].x + xoffset); - gpts[i].y = YLOG2DEV(points[i].y + yoffset); + gpts_alloc[i].x = XLOG2DEV(points[i].x + xoffset); + gpts_alloc[i].y = YLOG2DEV(points[i].y + yoffset); } CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset); } @@ -729,11 +733,10 @@ void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCo if (m_gdkwindow) gdk_draw_lines( m_gdkwindow, m_penGC, gpts, n); - if (doScale) - delete[] gpts; + delete[] gpts_alloc; } -void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], +void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED(fillStyle) ) { @@ -746,18 +749,22 @@ void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], xoffset != 0 || yoffset != 0 || XLOG2DEV(10) != 10 || YLOG2DEV(10) != 10; // GdkPoint and wxPoint have the same memory layout, so we can cast one to the other - GdkPoint* gdkpoints = reinterpret_cast(points); + const GdkPoint* gdkpoints = reinterpret_cast(points); + GdkPoint* gdkpoints_alloc = NULL; if (doScale) - gdkpoints = new GdkPoint[n]; + { + gdkpoints_alloc = new GdkPoint[n]; + gdkpoints = gdkpoints_alloc; + } int i; for (i = 0 ; i < n ; i++) { if (doScale) { - gdkpoints[i].x = XLOG2DEV(points[i].x + xoffset); - gdkpoints[i].y = YLOG2DEV(points[i].y + yoffset); + gdkpoints_alloc[i].x = XLOG2DEV(points[i].x + xoffset); + gdkpoints_alloc[i].y = YLOG2DEV(points[i].y + yoffset); } CalcBoundingBox(points[i].x + xoffset, points[i].y + yoffset); } @@ -793,8 +800,7 @@ void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], } } - if (doScale) - delete[] gdkpoints; + delete[] gdkpoints_alloc; } void wxWindowDCImpl::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index 17888b8a6d..767c3c2f48 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -1189,7 +1189,7 @@ void wxGnomePrinterDCImpl::DoDrawPoint(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) { } -void wxGnomePrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxGnomePrinterDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { if (n <= 0) return; @@ -1210,7 +1210,7 @@ void wxGnomePrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, gs_libGnomePrint->gnome_print_stroke ( m_gpc); } -void wxGnomePrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], +void wxGnomePrinterDCImpl::DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED(fillStyle)) { @@ -1258,7 +1258,7 @@ void wxGnomePrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], } } -void wxGnomePrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) +void wxGnomePrinterDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { #if wxUSE_NEW_DC wxDCImpl::DoDrawPolyPolygon( n, count, points, xoffset, yoffset, fillStyle ); diff --git a/src/gtk/print.cpp b/src/gtk/print.cpp index 637e7ec86e..6076ef552f 100644 --- a/src/gtk/print.cpp +++ b/src/gtk/print.cpp @@ -1457,7 +1457,7 @@ void wxGtkPrinterDCImpl::DoDrawPoint(wxCoord x, wxCoord y) CalcBoundingBox( x, y ); } -void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxGtkPrinterDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { if ( m_pen.IsTransparent() ) return; @@ -1479,7 +1479,7 @@ void wxGtkPrinterDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, w cairo_stroke ( m_cairo); } -void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], +void wxGtkPrinterDCImpl::DoDrawPolygon(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { @@ -1515,7 +1515,7 @@ void wxGtkPrinterDCImpl::DoDrawPolygon(int n, wxPoint points[], cairo_restore(m_cairo); } -void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, int count[], wxPoint points[], +void wxGtkPrinterDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index bff8a142c0..4df6a262f4 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -649,7 +649,7 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) CalcBoundingBox (x, y); } -void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -680,7 +680,7 @@ void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCo delete[] gpts; } -void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED(fillStyle) ) +void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED(fillStyle) ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp index 4622070bb8..1c7b8f4c62 100644 --- a/src/motif/dcclient.cpp +++ b/src/motif/dcclient.cpp @@ -438,7 +438,7 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) CalcBoundingBox (x, y); } -void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { wxCHECK_RET( IsOk(), "invalid dc" ); @@ -470,7 +470,7 @@ void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCo } } -void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], +void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle ) { wxCHECK_RET( IsOk(), "invalid dc" ); diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 74eec510d4..22bf7df908 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -881,7 +881,7 @@ void wxMSWDCImpl::DoDrawPoint(wxCoord x, wxCoord y) } void wxMSWDCImpl::DoDrawPolygon(int n, - wxPoint points[], + const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED_IN_WINCE(fillStyle)) @@ -929,8 +929,8 @@ void wxMSWDCImpl::DoDrawPolygon(int n, void wxMSWDCImpl::DoDrawPolyPolygon(int n, - int count[], - wxPoint points[], + const int count[], + const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) @@ -982,7 +982,7 @@ wxMSWDCImpl::DoDrawPolyPolygon(int n, // __WXWINCE__ } -void wxMSWDCImpl::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) +void wxMSWDCImpl::DoDrawLines(int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset) { WXMICROWIN_CHECK_HDC diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index b13314253a..2f6b70a553 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -836,7 +836,7 @@ void wxPMDCImpl::DoDrawPoint( } // end of wxPMDCImpl::DoDrawPoint void wxPMDCImpl::DoDrawPolygon( int n, - wxPoint vPoints[], + const wxPoint vPoints[], wxCoord vXoffset, wxCoord vYoffset, wxPolygonFillMode nFillStyle ) @@ -903,7 +903,7 @@ void wxPMDCImpl::DoDrawPolygon( int n, void wxPMDCImpl::DoDrawLines( int n -, wxPoint vPoints[] +, const wxPoint vPoints[] , wxCoord vXoffset , wxCoord vYoffset ) diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index 3f127c442b..46a9657a24 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -621,7 +621,7 @@ void wxWindowDCImpl::DoDrawPoint( wxCoord x, wxCoord y ) CalcBoundingBox (x, y); } -void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) +void wxWindowDCImpl::DoDrawLines( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset ) { wxCHECK_RET( IsOk(), wxT("invalid window dc") ); @@ -641,7 +641,7 @@ void wxWindowDCImpl::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCo delete[] xpoints; } -void wxWindowDCImpl::DoDrawPolygon( int n, wxPoint points[], +void wxWindowDCImpl::DoDrawPolygon( int n, const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode WXUNUSED(fillStyle) ) { -- 2.45.2