diff --git a/docs/changes.txt b/docs/changes.txt index cf47256cd3..d880ff3f80 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -58,6 +58,7 @@ All (GUI): - Allow requesting modern (3.x+) OpenGL version in wxGLCanvas (Fabio Arnold). - Allow customizing window shown by wxBusyInfo. +- Make results of wxDC::DrawEllipticArc() consistent across all platforms. - XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart). - Add wxFD_NO_FOLLOW style for wxFileDialog (Luca Bacci). - Add support for embedding bitmaps in generated SVG in wxSVGFileDC (iwbnwif). diff --git a/interface/wx/dc.h b/interface/wx/dc.h index 13d6350c97..8ff5c64ce9 100644 --- a/interface/wx/dc.h +++ b/interface/wx/dc.h @@ -356,12 +356,14 @@ public: @a width and @a height specify the width and height of the rectangle 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 specified in degrees with 0 degree angle corresponding to the positive - horizontal axis (3 o'clock) direction. Positive values mean - counter-clockwise motion. If @a start is equal to @e end, a complete - ellipse will be drawn. + horizontal axis (3 o'clock) direction. + + 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 the arc ends, even when using non-transparent brush. diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index ffd15f061e..f40b2ff2d4 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -646,22 +646,27 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, m_graphicContext->Scale(factor, 1.0); 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 // get clockwise angles if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT ) { 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 ); m_graphicContext->FillPath( path ); 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 ); } 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 ); } diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 45a28be344..d7a799613e 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -663,6 +663,16 @@ void wxWindowDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxC { wxCoord start = wxCoord(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() ) { diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index c6822f1bb1..c18f0edbc6 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1290,17 +1290,6 @@ void wxMSWDCImpl::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub rx2 += (int)(100.0 * abs(w) * cos(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 // drawn from the start and end points to the centre HPEN hpenOld = (HPEN) ::SelectObject(GetHdc(), (HPEN) ::GetStockObject(NULL_PEN));