From 16744532da3c371a8567b7d782c776d8deeb591b Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 24 Apr 2005 07:57:10 +0000 Subject: [PATCH] Implement DrawEllipticArc for GNOME print. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33858 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/gnome/gprint.cpp | 49 ++++++++++++++++++++++++++++++++++++++- src/gtk1/gnome/gprint.cpp | 49 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index c1eb690ea2..765df86c4e 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -76,6 +76,8 @@ public: (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_lineto, (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) + wxDL_METHOD_DEFINE( gint, gnome_print_arcto, + (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction ), (pc, x, y, radius, angle1, angle2, direction), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_curveto, (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_closepath, @@ -102,6 +104,8 @@ public: (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_rotate, (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 ) + wxDL_METHOD_DEFINE( gint, gnome_print_translate, + (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_gsave, (GnomePrintContext *pc), (pc), 0 ) @@ -205,6 +209,7 @@ void wxGnomePrintLibrary::InitializeMethods() wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_moveto, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_lineto, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_curveto, success ) + wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_arcto, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_closepath, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_stroke, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_fill, success ) @@ -218,6 +223,7 @@ void wxGnomePrintLibrary::InitializeMethods() wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_concat, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_scale, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rotate, success ) + wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_translate, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_gsave, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_grestore, success ) @@ -876,6 +882,47 @@ void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoo void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { + x += w/2; + y += h/2; + + int xx = XLOG2DEV(x); + int yy = YLOG2DEV(y); + + gs_lgp->gnome_print_gsave( m_gpc ); + + gs_lgp->gnome_print_translate( m_gpc, xx, yy ); + double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w); + gs_lgp->gnome_print_scale( m_gpc, 1.0, scale ); + + xx = 0; + yy = 0; + + if (m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush( m_brush ); + + gs_lgp->gnome_print_moveto ( m_gpc, xx, yy ); + gs_lgp->gnome_print_arcto( m_gpc, xx, yy, + XLOG2DEVREL(w)/2, sa, ea, 0 ); + gs_lgp->gnome_print_moveto ( m_gpc, xx, yy ); + + gs_lgp->gnome_print_fill( m_gpc ); + } + + if (m_pen.GetStyle () != wxTRANSPARENT) + { + SetPen (m_pen); + + gs_lgp->gnome_print_arcto( m_gpc, xx, yy, + XLOG2DEVREL(w)/2, sa, ea, 0 ); + + gs_lgp->gnome_print_stroke( m_gpc ); + } + + gs_lgp->gnome_print_grestore( m_gpc ); + + CalcBoundingBox( x, y ); + CalcBoundingBox( x+w, y+h ); } void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y) @@ -892,7 +939,7 @@ void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoo int i; for ( i =0; ignome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) ); diff --git a/src/gtk1/gnome/gprint.cpp b/src/gtk1/gnome/gprint.cpp index c1eb690ea2..765df86c4e 100644 --- a/src/gtk1/gnome/gprint.cpp +++ b/src/gtk1/gnome/gprint.cpp @@ -76,6 +76,8 @@ public: (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_lineto, (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) + wxDL_METHOD_DEFINE( gint, gnome_print_arcto, + (GnomePrintContext *pc, gdouble x, gdouble y, gdouble radius, gdouble angle1, gdouble angle2, gint direction ), (pc, x, y, radius, angle1, angle2, direction), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_curveto, (GnomePrintContext *pc, gdouble x1, gdouble y1, gdouble x2, gdouble y2, gdouble x3, gdouble y3), (pc, x1, y1, x2, y2, x3, y3), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_closepath, @@ -102,6 +104,8 @@ public: (GnomePrintContext *pc, gdouble sx, gdouble sy), (pc, sx, sy), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_rotate, (GnomePrintContext *pc, gdouble theta), (pc, theta), 0 ) + wxDL_METHOD_DEFINE( gint, gnome_print_translate, + (GnomePrintContext *pc, gdouble x, gdouble y), (pc, x, y), 0 ) wxDL_METHOD_DEFINE( gint, gnome_print_gsave, (GnomePrintContext *pc), (pc), 0 ) @@ -205,6 +209,7 @@ void wxGnomePrintLibrary::InitializeMethods() wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_moveto, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_lineto, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_curveto, success ) + wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_arcto, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_closepath, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_stroke, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_fill, success ) @@ -218,6 +223,7 @@ void wxGnomePrintLibrary::InitializeMethods() wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_concat, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_scale, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_rotate, success ) + wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_translate, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_gsave, success ) wxDL_METHOD_LOAD( m_gnome_print_lib, gnome_print_grestore, success ) @@ -876,6 +882,47 @@ void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoo void wxGnomePrintDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { + x += w/2; + y += h/2; + + int xx = XLOG2DEV(x); + int yy = YLOG2DEV(y); + + gs_lgp->gnome_print_gsave( m_gpc ); + + gs_lgp->gnome_print_translate( m_gpc, xx, yy ); + double scale = (double)YLOG2DEVREL(h) / (double) XLOG2DEVREL(w); + gs_lgp->gnome_print_scale( m_gpc, 1.0, scale ); + + xx = 0; + yy = 0; + + if (m_brush.GetStyle () != wxTRANSPARENT) + { + SetBrush( m_brush ); + + gs_lgp->gnome_print_moveto ( m_gpc, xx, yy ); + gs_lgp->gnome_print_arcto( m_gpc, xx, yy, + XLOG2DEVREL(w)/2, sa, ea, 0 ); + gs_lgp->gnome_print_moveto ( m_gpc, xx, yy ); + + gs_lgp->gnome_print_fill( m_gpc ); + } + + if (m_pen.GetStyle () != wxTRANSPARENT) + { + SetPen (m_pen); + + gs_lgp->gnome_print_arcto( m_gpc, xx, yy, + XLOG2DEVREL(w)/2, sa, ea, 0 ); + + gs_lgp->gnome_print_stroke( m_gpc ); + } + + gs_lgp->gnome_print_grestore( m_gpc ); + + CalcBoundingBox( x, y ); + CalcBoundingBox( x+w, y+h ); } void wxGnomePrintDC::DoDrawPoint(wxCoord x, wxCoord y) @@ -892,7 +939,7 @@ void wxGnomePrintDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoo int i; for ( i =0; ignome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) ); -- 2.45.2