#include <libgnomeprintui/gnome-print-job-preview.h>
#include <libgnomeprintui/gnome-print-paper-selector.h>
+static const double RAD2DEG = 180.0 / M_PI;
#include "wx/html/forcelnk.h"
FORCE_LINK_ME(gnome_print)
(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,
(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 )
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 )
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 )
void wxGnomePrintDC::DoDrawArc(wxCoord x1,wxCoord y1,wxCoord x2,wxCoord y2,wxCoord xc,wxCoord yc)
{
+ double dx = x1 - xc;
+ double dy = y1 - yc;
+ double radius = sqrt((double)(dx*dx+dy*dy));
+ double alpha1, alpha2;
+ if (x1 == x2 && y1 == y2)
+ {
+ alpha1 = 0.0;
+ alpha2 = 360.0;
+ }
+ else
+ if (radius == 0.0)
+ {
+ alpha1 = alpha2 = 0.0;
+ }
+ else
+ {
+ alpha1 = (x1 - xc == 0) ?
+ (y1 - yc < 0) ? 90.0 : -90.0 :
+ -atan2(double(y1-yc), double(x1-xc)) * RAD2DEG;
+ alpha2 = (x2 - xc == 0) ?
+ (y2 - yc < 0) ? 90.0 : -90.0 :
+ -atan2(double(y2-yc), double(x2-xc)) * RAD2DEG;
+
+ while (alpha1 <= 0) alpha1 += 360;
+ while (alpha2 <= 0) alpha2 += 360; // adjust angles to be between
+ while (alpha1 > 360) alpha1 -= 360; // 0 and 360 degree
+ while (alpha2 > 360) alpha2 -= 360;
+ }
+
+ if (m_brush.GetStyle() != wxTRANSPARENT)
+ {
+ SetBrush( m_brush );
+ gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) );
+ gs_lgp->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 );
+
+ gs_lgp->gnome_print_fill( m_gpc );
+ }
+
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ {
+ SetPen (m_pen);
+ gs_lgp->gnome_print_newpath( m_gpc );
+ gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc) );
+ gs_lgp->gnome_print_arcto( m_gpc, XLOG2DEV(xc), YLOG2DEV(yc), XLOG2DEVREL((int)radius), alpha1, alpha2, 0 );
+ gs_lgp->gnome_print_closepath( m_gpc );
+
+ gs_lgp->gnome_print_stroke( m_gpc );
+ }
+
+ CalcBoundingBox (x1, y1);
+ CalcBoundingBox (x2, y2);
+ CalcBoundingBox (xc, yc);
}
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)
int i;
for ( i =0; i<n ; i++ )
- CalcBoundingBox( XLOG2DEV(points[i].x+xoffset), YLOG2DEV(points[i].y+yoffset));
+ CalcBoundingBox( points[i].x+xoffset, points[i].y+yoffset);
gs_lgp->gnome_print_moveto ( m_gpc, XLOG2DEV(points[0].x+xoffset), YLOG2DEV(points[0].y+yoffset) );
void wxGnomePrintDC::DoDrawSpline(wxList *points)
{
+ SetPen (m_pen);
+
+ double c, d, x1, y1, x2, y2, x3, y3;
+ wxPoint *p, *q;
+
+ wxList::compatibility_iterator node = points->GetFirst();
+ p = (wxPoint *)node->GetData();
+ x1 = p->x;
+ y1 = p->y;
+
+ node = node->GetNext();
+ p = (wxPoint *)node->GetData();
+ c = p->x;
+ d = p->y;
+ x3 =
+ (double)(x1 + c) / 2;
+ y3 =
+ (double)(y1 + d) / 2;
+
+ gs_lgp->gnome_print_newpath( m_gpc );
+ gs_lgp->gnome_print_moveto( m_gpc, XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1) );
+ gs_lgp->gnome_print_lineto( m_gpc, XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) );
+
+ CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
+ CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
+
+ node = node->GetNext();
+ while (node)
+ {
+ q = (wxPoint *)node->GetData();
+
+ x1 = x3;
+ y1 = y3;
+ x2 = c;
+ y2 = d;
+ c = q->x;
+ d = q->y;
+ x3 = (double)(x2 + c) / 2;
+ y3 = (double)(y2 + d) / 2;
+
+ gs_lgp->gnome_print_curveto(m_gpc,
+ XLOG2DEV((wxCoord)x1), YLOG2DEV((wxCoord)y1),
+ XLOG2DEV((wxCoord)x2), YLOG2DEV((wxCoord)y2),
+ XLOG2DEV((wxCoord)x3), YLOG2DEV((wxCoord)y3) );
+
+ CalcBoundingBox( (wxCoord)x1, (wxCoord)y1 );
+ CalcBoundingBox( (wxCoord)x3, (wxCoord)y3 );
+
+ node = node->GetNext();
+ }
+
+ gs_lgp->gnome_print_lineto ( m_gpc, XLOG2DEV((wxCoord)c), YLOG2DEV((wxCoord)d) );
+
+ gs_lgp->gnome_print_stroke( m_gpc );
}
bool wxGnomePrintDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask,
wxCoord xsrcMask, wxCoord ysrcMask)
{
- return false;
+ wxCHECK_MSG( source, false, wxT("invalid source dc") );
+
+ // blit into a bitmap
+ wxBitmap bitmap( width, height );
+ wxMemoryDC memDC;
+ memDC.SelectObject(bitmap);
+ memDC.Blit(0, 0, width, height, source, xsrc, ysrc, rop); /* TODO: Blit transparently? */
+ memDC.SelectObject(wxNullBitmap);
+
+ // draw bitmap. scaling and positioning is done there
+ DrawBitmap( bitmap, xdest, ydest );
+
+ return true;
}
void wxGnomePrintDC::DoDrawIcon( const wxIcon& icon, wxCoord x, wxCoord y )