From d81fb0be63757e04aec3ed9ec37207ef1f2cf639 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Tue, 31 May 2016 21:02:34 +0200 Subject: [PATCH] Use native methods to draw some geometric figures using GDI+ renderer Use native methods provided by GDI+ renderer to draw circles and ellipses. Closes #17554 --- src/msw/graphics.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 807d6818d5..be6c7bce1b 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -155,15 +155,18 @@ public : // // appends a rectangle as a new closed subpath - virtual void AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDouble h ) ; + virtual void AddRectangle(wxDouble x, wxDouble y, wxDouble w, wxDouble h) wxOVERRIDE; + + // appends a circle as a new closed subpath + virtual void AddCircle(wxDouble x, wxDouble y, wxDouble r) wxOVERRIDE; + + // appends an ellipse as a new closed subpath fitting the passed rectangle + virtual void AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h) wxOVERRIDE; + /* - - // appends an ellipsis as a new closed subpath fitting the passed rectangle - virtual void AddEllipsis( wxDouble x, wxDouble y, wxDouble w , wxDouble h ) ; - // draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1) virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r ) ; -*/ + */ // returns the native path virtual void * GetNativePath() const { return m_path; } @@ -1324,6 +1327,16 @@ void wxGDIPlusPathData::AddRectangle( wxDouble x, wxDouble y, wxDouble w, wxDoub MoveToPoint(x, y); } +void wxGDIPlusPathData::AddCircle(wxDouble x, wxDouble y, wxDouble r) +{ + m_path->AddEllipse((REAL)(x-r), (REAL)(y-r), (REAL)(2.0*r), (REAL)(2.0*r)); +} + +void wxGDIPlusPathData::AddEllipse(wxDouble x, wxDouble y, wxDouble w, wxDouble h) +{ + m_path->AddEllipse((REAL)x, (REAL)y, (REAL)w, (REAL)h); +} + void wxGDIPlusPathData::AddPath( const wxGraphicsPathData* path ) { const wxGDIPlusPathData* pathData = static_cast(path);