From 1f61f4821fb7cd1004b04355306d341a4fc7f216 Mon Sep 17 00:00:00 2001 From: Evan Stade Date: Fri, 27 Jul 2007 16:07:39 -0700 Subject: [PATCH] gdiplus: Draw custom dashes. --- dlls/gdiplus/gdiplus_private.h | 1 + dlls/gdiplus/graphics.c | 20 ++++++++++++++++++-- dlls/gdiplus/pen.c | 8 ++------ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index f20ea3d36b..b9420a398d 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -26,6 +26,7 @@ #define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER) #define MAX_ARC_PTS (13) +#define MAX_DASHLEN (16) /* this is a limitation of gdi */ COLORREF ARGB2COLORREF(ARGB color); extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2, diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 38364764c6..cb56c7323c 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -98,8 +98,9 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen) { HPEN gdipen; REAL width; - INT save_state = SaveDC(graphics->hdc); + INT save_state = SaveDC(graphics->hdc), i, numdashes; GpPointF pt[2]; + DWORD dash_array[MAX_DASHLEN]; EndPath(graphics->hdc); @@ -116,7 +117,22 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen) width *= pen->width * convert_unit(graphics->hdc, pen->unit == UnitWorld ? graphics->unit : pen->unit); - gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, 0, NULL); + if(pen->dash == DashStyleCustom){ + numdashes = min(pen->numdashes, MAX_DASHLEN); + + TRACE("dashes are: "); + for(i = 0; i < numdashes; i++){ + dash_array[i] = roundr(width * pen->dashes[i]); + TRACE("%d, ", dash_array[i]); + } + TRACE("\n and the pen style is %x\n", pen->style); + + gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, + numdashes, dash_array); + } + else + gdipen = ExtCreatePen(pen->style, roundr(width), &pen->brush->lb, 0, NULL); + SelectObject(graphics->hdc, gdipen); return save_state; diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c index e582f7644c..7d7237b4ac 100644 --- a/dlls/gdiplus/pen.c +++ b/dlls/gdiplus/pen.c @@ -29,8 +29,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus); static DWORD gdip_to_gdi_dash(GpDashStyle dash) { - static int calls; - switch(dash){ case DashStyleSolid: return PS_SOLID; @@ -43,9 +41,7 @@ static DWORD gdip_to_gdi_dash(GpDashStyle dash) case DashStyleDashDotDot: return PS_DASHDOTDOT; case DashStyleCustom: - if(!(calls++)) - FIXME("DashStyleCustom not implemented\n"); - return PS_SOLID; + return PS_USERSTYLE; default: ERR("Not a member of GpDashStyle enumeration\n"); return 0; @@ -240,7 +236,7 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash, return OutOfMemory; } - pen->dash = DashStyleCustom; + GdipSetPenDashStyle(pen, DashStyleCustom); memcpy(pen->dashes, dash, count * sizeof(REAL)); pen->numdashes = count;