Make results of wxDC::DrawEllipticArc() consistent across all platforms.

And also consistent with wxGraphicsContext method with the same name.

Document the rules determining what is drawn.

Closes #4437.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78125 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-11-11 01:02:14 +00:00
parent f9637c9626
commit 8b72652a28
5 changed files with 25 additions and 18 deletions

View File

@@ -58,6 +58,7 @@ All (GUI):
- Allow requesting modern (3.x+) OpenGL version in wxGLCanvas (Fabio Arnold). - Allow requesting modern (3.x+) OpenGL version in wxGLCanvas (Fabio Arnold).
- Allow customizing window shown by wxBusyInfo. - Allow customizing window shown by wxBusyInfo.
- Make results of wxDC::DrawEllipticArc() consistent across all platforms.
- XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart). - XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart).
- Add wxFD_NO_FOLLOW style for wxFileDialog (Luca Bacci). - Add wxFD_NO_FOLLOW style for wxFileDialog (Luca Bacci).
- Add support for embedding bitmaps in generated SVG in wxSVGFileDC (iwbnwif). - Add support for embedding bitmaps in generated SVG in wxSVGFileDC (iwbnwif).

View File

@@ -356,12 +356,14 @@ public:
@a width and @a height specify the width and height of the rectangle @a width and @a height specify the width and height of the rectangle
that contains the ellipse. that contains the ellipse.
@a start and @a end specify the start and end of the arc relative to @a start and @a end specify the end points of the arc relative to
the three-o'clock position from the center of the rectangle. Angles are the three-o'clock position from the center of the rectangle. Angles are
specified in degrees with 0 degree angle corresponding to the positive specified in degrees with 0 degree angle corresponding to the positive
horizontal axis (3 o'clock) direction. Positive values mean horizontal axis (3 o'clock) direction.
counter-clockwise motion. If @a start is equal to @e end, a complete
ellipse will be drawn. Independently of whether @a start is greater than or less than @a end,
the arc is drawn in the counter-clockwise direction. Also, if @a start
is equal to @e end, a complete ellipse is drawn.
Notice that unlike DrawArc(), this function does not draw the lines to Notice that unlike DrawArc(), this function does not draw the lines to
the arc ends, even when using non-transparent brush. the arc ends, even when using non-transparent brush.

View File

@@ -646,22 +646,27 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
m_graphicContext->Scale(factor, 1.0); m_graphicContext->Scale(factor, 1.0);
wxGraphicsPath path = m_graphicContext->CreatePath(); wxGraphicsPath path = m_graphicContext->CreatePath();
// If end angle equals start angle we want draw a full ellipse.
if (ea == sa)
{
ea += 360.0;
}
// since these angles (ea,sa) are measured counter-clockwise, we invert them to // since these angles (ea,sa) are measured counter-clockwise, we invert them to
// get clockwise angles // get clockwise angles
if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT ) if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT )
{ {
path.MoveToPoint( 0, 0 ); path.MoveToPoint( 0, 0 );
path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), sa > ea ); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false );
path.AddLineToPoint( 0, 0 ); path.AddLineToPoint( 0, 0 );
m_graphicContext->FillPath( path ); m_graphicContext->FillPath( path );
path = m_graphicContext->CreatePath(); path = m_graphicContext->CreatePath();
path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), sa > ea ); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false );
m_graphicContext->StrokePath( path ); m_graphicContext->StrokePath( path );
} }
else else
{ {
path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), sa > ea ); path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), false );
m_graphicContext->DrawPath( path ); m_graphicContext->DrawPath( path );
} }

View File

@@ -663,6 +663,16 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC
{ {
wxCoord start = wxCoord(sa * 64.0); wxCoord start = wxCoord(sa * 64.0);
wxCoord end = wxCoord((ea-sa) * 64.0); wxCoord end = wxCoord((ea-sa) * 64.0);
// We want to draw always in the counter-clokwise direction.
if (end < 0)
{
end = end % (360*64) + 360*64;
}
// If end angle equals start engle we want to draw a full ellipse.
if (end == 0)
{
end = 360*64;
}
if ( m_brush.IsNonTransparent() ) if ( m_brush.IsNonTransparent() )
{ {

View File

@@ -1290,17 +1290,6 @@ void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub
rx2 += (int)(100.0 * abs(w) * cos(ea)); rx2 += (int)(100.0 * abs(w) * cos(ea));
ry2 -= (int)(100.0 * abs(h) * m_signY * sin(ea)); ry2 -= (int)(100.0 * abs(h) * m_signY * sin(ea));
// Swap start and end positions if the end angle is less than the start angle.
if (ea < sa) {
int temp;
temp = rx2;
rx2 = rx1;
rx1 = temp;
temp = ry2;
ry2 = ry1;
ry1 = temp;
}
// draw pie with NULL_PEN first and then outline otherwise a line is // draw pie with NULL_PEN first and then outline otherwise a line is
// drawn from the start and end points to the centre // drawn from the start and end points to the centre
HPEN hpenOld = (HPEN) ::SelectObject(GetHdc(), (HPEN) ::GetStockObject(NULL_PEN)); HPEN hpenOld = (HPEN) ::SelectObject(GetHdc(), (HPEN) ::GetStockObject(NULL_PEN));