예제 #1
0
static void
draw_ellipse(DiaRenderer *self, 
	     Point *center,
	     real width, real height,
	     Color *fill, Color *stroke)
{
    WmfRenderer *renderer = WMF_RENDERER (self);
    W32::HPEN hPen;
    W32::HGDIOBJ hBrush, hBrOld;

    DIAG_NOTE(renderer, "draw_ellipse %fx%f @ %f,%f\n", 
              width, height, center->x, center->y);

    if (fill) {
	W32::COLORREF rgb = W32COLOR(fill);
	hBrush = W32::CreateSolidBrush(rgb);
	hBrOld = W32::SelectObject(renderer->hFileDC, hBrush);
    }
    if (stroke)
	hPen = UsePen(renderer, stroke);

    W32::Ellipse(renderer->hFileDC,
                 SCX(center->x - width / 2), /* bbox corners */
                 SCY(center->y - height / 2),
                 SCX(center->x + width / 2), 
                 SCY(center->y + height / 2));

    if (stroke)
	DonePen(renderer, hPen);
    if (fill) {
	W32::SelectObject(renderer->hFileDC, 
			  W32::GetStockObject (HOLLOW_BRUSH) );
	W32::DeleteObject(hBrush);
    }
}
예제 #2
0
파일: wmf.cpp 프로젝트: montsuqi/monpe
static void
draw_arc(DiaRenderer *self, 
	 Point *center,
	 real width, real height,
	 real angle1, real angle2,
	 Color *colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);
    W32::HPEN  hPen;
    W32::POINT ptStart, ptEnd;

    DIAG_NOTE(renderer, "draw_arc %fx%f <%f,<%f @%f,%f\n", 
              width, height, angle1, angle2, center->x, center->y);

    hPen = UsePen(renderer, colour);

    /* calculate start and end points of arc */
    ptStart.x = SCX(center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle1));
    ptStart.y = SCY(center->y - (height / 2.0) * sin((M_PI / 180.0) * angle1));
    ptEnd.x = SCX(center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle2));
    ptEnd.y = SCY(center->y - (height / 2.0) * sin((M_PI / 180.0) * angle2));

    W32::MoveToEx(renderer->hFileDC, ptStart.x, ptStart.y, NULL);
    W32::Arc(renderer->hFileDC,
             SCX(center->x - width / 2), /* bbox corners */
             SCY(center->y - height / 2),
             SCX(center->x + width / 2), 
             SCY(center->y + height / 2),
             ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); 

    DonePen(renderer, hPen);
}
예제 #3
0
static void
draw_rect(DiaRenderer *self, 
	  Point *ul_corner, Point *lr_corner,
	  Color *fill, Color *stroke)
{
    WmfRenderer *renderer = WMF_RENDERER (self);

    W32::HPEN hPen;

    DIAG_NOTE(renderer, "draw_rect %f,%f -> %f,%f\n", 
              ul_corner->x, ul_corner->y, lr_corner->x, lr_corner->y);

    if (fill) {
	W32::HGDIOBJ hBrush, hBrOld;
	W32::COLORREF rgb = W32COLOR(fill);
	hBrush = W32::CreateSolidBrush(rgb);
	hBrOld = W32::SelectObject(renderer->hFileDC, hBrush);
	W32::Rectangle (renderer->hFileDC,
			SCX(ul_corner->x), SCY(ul_corner->y),
			SCX(lr_corner->x), SCY(lr_corner->y));
	W32::SelectObject (renderer->hFileDC, 
			   W32::GetStockObject (HOLLOW_BRUSH) );
	W32::DeleteObject(hBrush);
    }
    if (stroke) {
	hPen = UsePen(renderer, stroke);

	W32::Rectangle (renderer->hFileDC,
			SCX(ul_corner->x), SCY(ul_corner->y),
			SCX(lr_corner->x), SCY(lr_corner->y));

	DonePen(renderer, hPen);
    }
}
예제 #4
0
static void
draw_polyline(DiaRenderer *self, 
	      Point *points, int num_points, 
	      Color *line_colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);

    W32::HPEN hPen;
    W32::POINT*  pts;
    int	    i;

    DIAG_NOTE(renderer, "draw_polyline n:%d %f,%f ...\n", 
              num_points, points->x, points->y);

    if (num_points < 2)
	return;
    pts = g_new (W32::POINT, num_points+1);
    for (i = 0; i < num_points; i++)
    {
	pts[i].x = SCX(points[i].x);
	pts[i].y = SCY(points[i].y);
    }

    hPen = UsePen(renderer, line_colour);
    W32::Polyline(renderer->hFileDC, pts, num_points);
    DonePen(renderer, hPen);

    g_free(pts);
}
예제 #5
0
static void
_bezier (DiaRenderer *self,
	 BezPoint *points,
	 int       numpoints,
	 Color    *colour,
	 gboolean  fill,
	 gboolean  closed)
{
    WmfRenderer *renderer = WMF_RENDERER (self);
    W32::HGDIOBJ hBrush, hBrOld;
    W32::HPEN hPen;
    W32::COLORREF rgb = W32COLOR(colour);

    DIAG_NOTE(renderer, "_bezier n:%d %fx%f ...\n", 
              numpoints, points->p1.x, points->p1.y);

    if (fill) {
      hBrush = W32::CreateSolidBrush(rgb);
      hBrOld = W32::SelectObject(renderer->hFileDC, hBrush);
    } else {
      hPen = UsePen(renderer, colour);
    }

    W32::BeginPath (renderer->hFileDC);
    
    for (int i = 0; i < numpoints; ++i) {
        switch (points[i].type) {
	case BezPoint::BEZ_MOVE_TO :
	    W32::MoveToEx (renderer->hFileDC, SCX(points[i].p1.x), SCY(points[i].p1.y), NULL);
	    break;
	case BezPoint::BEZ_LINE_TO :
	    W32::LineTo (renderer->hFileDC, SCX(points[i].p1.x), SCY(points[i].p1.y));
	    break;
	case BezPoint::BEZ_CURVE_TO :
	  {
	    W32::POINT pts[3] = {
	      {SCX(points[i].p1.x), SCY(points[i].p1.y)},
	      {SCX(points[i].p2.x), SCY(points[i].p2.y)},
	      {SCX(points[i].p3.x), SCY(points[i].p3.y)}
	    };
	    W32::PolyBezierTo (renderer->hFileDC, pts, 3);
	  }
	  break;
	}
    }
    if (closed)
        W32::CloseFigure (renderer->hFileDC);
    W32::EndPath (renderer->hFileDC);
    if (fill) {
        W32::FillPath (renderer->hFileDC);
        W32::SelectObject(renderer->hFileDC, 
                          W32::GetStockObject (HOLLOW_BRUSH) );
        W32::DeleteObject(hBrush);
    } else {
        W32::StrokePath (renderer->hFileDC);
        DonePen(renderer, hPen);
    }
}
예제 #6
0
파일: wmf.cpp 프로젝트: montsuqi/monpe
static void
draw_bezier(DiaRenderer *self, 
	    BezPoint *points,
	    int numpoints,
	    Color *colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);
    W32::HPEN    hPen;
    W32::POINT * pts;
    int i;

    DIAG_NOTE(renderer, "draw_bezier n:%d %fx%f ...\n", 
              numpoints, points->p1.x, points->p1.y);

    pts = g_new(W32::POINT, (numpoints-1) * 3 + 1);

    pts[0].x = SCX(points[0].p1.x);
    pts[0].y = SCY(points[0].p1.y);

    for (i = 1; i < numpoints; i++)
    {
        switch(points[i].type)
        {
        case _BezPoint::BEZ_MOVE_TO:
            g_warning("only first BezPoint can be a BEZ_MOVE_TO");
	      break;
        case _BezPoint::BEZ_LINE_TO:
            /* everyhing the same ?*/
            pts[i*3-2].x = pts[i*3-1].x = 
            pts[i*3  ].x = SCX(points[i].p1.x);
            pts[i*3-2].y = pts[i*3-1].y = 
            pts[i*3  ].y = SCY(points[i].p1.y);
        break;
        case _BezPoint::BEZ_CURVE_TO:
            /* control points */
            pts[i*3-2].x = SCX(points[i].p1.x);
            pts[i*3-2].y = SCY(points[i].p1.y);
            pts[i*3-1].x = SCX(points[i].p2.x);
            pts[i*3-1].y = SCY(points[i].p2.y);
            /* end point */
            pts[i*3  ].x = SCX(points[i].p3.x);
            pts[i*3  ].y = SCY(points[i].p3.y);
	  break;
        default:
        break;
        }
    }

    hPen = UsePen(renderer, colour);

    W32::PolyBezier(renderer->hFileDC,
		    pts, (numpoints-1)*3+1);

    DonePen(renderer, hPen);

    g_free(pts);
}
예제 #7
0
파일: wmf.cpp 프로젝트: mpuels/dia
static void
fill_arc(DiaRenderer *self, 
	 Point *center,
	 real width, real height,
	 real angle1, real angle2,
	 Color *colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);
    W32::HPEN    hPen;
    W32::HGDIOBJ hBrush;
    W32::POINT ptStart, ptEnd;
    W32::COLORREF rgb = W32COLOR(colour);

    DIAG_NOTE(renderer, "fill_arc %fx%f <%f,<%f @%f,%f\n", 
              width, height, angle1, angle2, center->x, center->y);

    if (angle1 > angle2) {
	/* make it counter-clockwise by swapping start/end */
	real tmp = angle1;
	angle1 = angle2;
	angle2 = tmp;
    }
    /* calculate start and end points of arc */
    ptStart.x = SCX(center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle1));
    ptStart.y = SCY(center->y - (height / 2.0) * sin((M_PI / 180.0) * angle1));
    ptEnd.x = SCX(center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle2));
    ptEnd.y = SCY(center->y - (height / 2.0) * sin((M_PI / 180.0) * angle2));

    hPen = UsePen(renderer, NULL); /* no border */
    hBrush = W32::CreateSolidBrush(rgb);

    W32::SelectObject(renderer->hFileDC, hBrush);

    W32::Pie(renderer->hFileDC,
             SCX(center->x - width / 2), /* bbox corners */
             SCY(center->y - height / 2),
             SCX(center->x + width / 2), 
             SCY(center->y + height / 2),
             ptStart.x, ptStart.y, ptEnd.x, ptEnd.y); 

    W32::SelectObject(renderer->hFileDC, 
                    W32::GetStockObject (HOLLOW_BRUSH) );
    W32::DeleteObject(hBrush);
    DonePen(renderer, hPen);
}
예제 #8
0
static void
draw_polygon(DiaRenderer *self, 
	     Point *points, int num_points, 
	     Color *fill, Color *stroke)
{
    WmfRenderer *renderer = WMF_RENDERER (self);

    W32::HPEN    hPen;
    W32::POINT*  pts;
    int          i;
    W32::HBRUSH  hBrush, hBrOld;
    W32::COLORREF rgb = fill ? W32COLOR(fill) : 0;

    DIAG_NOTE(renderer, "draw_polygon n:%d %f,%f ...\n", 
              num_points, points->x, points->y);

    if (num_points < 2)
	  return;
    pts = g_new (W32::POINT, num_points+1);
    for (i = 0; i < num_points; i++)
    {
	pts[i].x = SCX(points[i].x);
	pts[i].y = SCY(points[i].y);
    }

    if (stroke)
      hPen = UsePen(renderer, stroke);
    if (fill) {
      hBrush = W32::CreateSolidBrush(rgb);
      hBrOld = (W32::HBRUSH)W32::SelectObject(renderer->hFileDC, hBrush);
    }

    W32::Polygon(renderer->hFileDC, pts, num_points);

    if (stroke)
      DonePen(renderer, hPen);
    if (fill) {
      W32::SelectObject(renderer->hFileDC, 
                        W32::GetStockObject(HOLLOW_BRUSH) );
      W32::DeleteObject(hBrush);
    }
    g_free(pts);
}
예제 #9
0
static void
draw_line(DiaRenderer *self, 
	  Point *start, Point *end, 
	  Color *line_colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);

    W32::HPEN hPen;

    DIAG_NOTE(renderer, "draw_line %f,%f -> %f, %f\n", 
              start->x, start->y, end->x, end->y);

    hPen = UsePen(renderer, line_colour);

    W32::MoveToEx(renderer->hFileDC, SCX(start->x), SCY(start->y), NULL);
    W32::LineTo(renderer->hFileDC, SCX(end->x), SCY(end->y));

    DonePen(renderer, hPen);
}
예제 #10
0
파일: wmf.cpp 프로젝트: montsuqi/monpe
static void
draw_rect(DiaRenderer *self, 
	  Point *ul_corner, Point *lr_corner,
	  Color *colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);

    W32::HPEN hPen;

    DIAG_NOTE(renderer, "draw_rect %f,%f -> %f,%f\n", 
              ul_corner->x, ul_corner->y, lr_corner->x, lr_corner->y);

    hPen = UsePen(renderer, colour);

    W32::Rectangle(renderer->hFileDC,
                   SCX(ul_corner->x), SCY(ul_corner->y),
                   SCX(lr_corner->x), SCY(lr_corner->y));

    DonePen(renderer, hPen);
}
예제 #11
0
파일: wmf.cpp 프로젝트: montsuqi/monpe
static void
draw_ellipse(DiaRenderer *self, 
	     Point *center,
	     real width, real height,
	     Color *colour)
{
    WmfRenderer *renderer = WMF_RENDERER (self);
    W32::HPEN hPen;

    DIAG_NOTE(renderer, "draw_ellipse %fx%f @ %f,%f\n", 
              width, height, center->x, center->y);

    hPen = UsePen(renderer, colour);

    W32::Ellipse(renderer->hFileDC,
                 SCX(center->x - width / 2), /* bbox corners */
                 SCY(center->y - height / 2),
                 SCX(center->x + width / 2), 
                 SCY(center->y + height / 2));

    DonePen(renderer, hPen);
}