gdiplus: Draw custom dashes.
This commit is contained in:
parent
4e4c150bed
commit
1f61f4821f
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
|
#define GP_DEFAULT_PENSTYLE (PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_FLAT | PS_JOIN_MITER)
|
||||||
#define MAX_ARC_PTS (13)
|
#define MAX_ARC_PTS (13)
|
||||||
|
#define MAX_DASHLEN (16) /* this is a limitation of gdi */
|
||||||
|
|
||||||
COLORREF ARGB2COLORREF(ARGB color);
|
COLORREF ARGB2COLORREF(ARGB color);
|
||||||
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
|
extern INT arc2polybezier(GpPointF * points, REAL x1, REAL y1, REAL x2, REAL y2,
|
||||||
|
|
|
@ -98,8 +98,9 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
|
||||||
{
|
{
|
||||||
HPEN gdipen;
|
HPEN gdipen;
|
||||||
REAL width;
|
REAL width;
|
||||||
INT save_state = SaveDC(graphics->hdc);
|
INT save_state = SaveDC(graphics->hdc), i, numdashes;
|
||||||
GpPointF pt[2];
|
GpPointF pt[2];
|
||||||
|
DWORD dash_array[MAX_DASHLEN];
|
||||||
|
|
||||||
EndPath(graphics->hdc);
|
EndPath(graphics->hdc);
|
||||||
|
|
||||||
|
@ -116,7 +117,22 @@ static INT prepare_dc(GpGraphics *graphics, GpPen *pen)
|
||||||
width *= pen->width * convert_unit(graphics->hdc,
|
width *= pen->width * convert_unit(graphics->hdc,
|
||||||
pen->unit == UnitWorld ? graphics->unit : pen->unit);
|
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);
|
SelectObject(graphics->hdc, gdipen);
|
||||||
|
|
||||||
return save_state;
|
return save_state;
|
||||||
|
|
|
@ -29,8 +29,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
||||||
|
|
||||||
static DWORD gdip_to_gdi_dash(GpDashStyle dash)
|
static DWORD gdip_to_gdi_dash(GpDashStyle dash)
|
||||||
{
|
{
|
||||||
static int calls;
|
|
||||||
|
|
||||||
switch(dash){
|
switch(dash){
|
||||||
case DashStyleSolid:
|
case DashStyleSolid:
|
||||||
return PS_SOLID;
|
return PS_SOLID;
|
||||||
|
@ -43,9 +41,7 @@ static DWORD gdip_to_gdi_dash(GpDashStyle dash)
|
||||||
case DashStyleDashDotDot:
|
case DashStyleDashDotDot:
|
||||||
return PS_DASHDOTDOT;
|
return PS_DASHDOTDOT;
|
||||||
case DashStyleCustom:
|
case DashStyleCustom:
|
||||||
if(!(calls++))
|
return PS_USERSTYLE;
|
||||||
FIXME("DashStyleCustom not implemented\n");
|
|
||||||
return PS_SOLID;
|
|
||||||
default:
|
default:
|
||||||
ERR("Not a member of GpDashStyle enumeration\n");
|
ERR("Not a member of GpDashStyle enumeration\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -240,7 +236,7 @@ GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
|
||||||
return OutOfMemory;
|
return OutOfMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
pen->dash = DashStyleCustom;
|
GdipSetPenDashStyle(pen, DashStyleCustom);
|
||||||
memcpy(pen->dashes, dash, count * sizeof(REAL));
|
memcpy(pen->dashes, dash, count * sizeof(REAL));
|
||||||
pen->numdashes = count;
|
pen->numdashes = count;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue