2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "gdiplus_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus
);
30 static DWORD
gdip_to_gdi_dash(GpDashStyle dash
)
39 case DashStyleDashDot
:
41 case DashStyleDashDotDot
:
44 FIXME("DashStyleCustom not implemented\n");
47 ERR("Not a member of GpDashStyle enumeration\n");
52 static DWORD
gdip_to_gdi_join(GpLineJoin join
)
60 case LineJoinMiterClipped
:
63 ERR("Not a member of GpLineJoin enumeration\n");
68 GpStatus WINGDIPAPI
GdipClonePen(GpPen
*pen
, GpPen
**clonepen
)
73 return InvalidParameter
;
75 *clonepen
= GdipAlloc(sizeof(GpPen
));
76 if(!*clonepen
) return OutOfMemory
;
78 memcpy(*clonepen
, pen
, sizeof(GpPen
));
80 lb
.lbStyle
= BS_SOLID
;
81 lb
.lbColor
= (*clonepen
)->color
;
84 (*clonepen
)->gdipen
= ExtCreatePen((*clonepen
)->style
,
85 roundr((*clonepen
)->width
), &lb
, 0, NULL
);
90 GpStatus WINGDIPAPI
GdipCreatePen1(ARGB color
, FLOAT width
, GpUnit unit
,
96 return InvalidParameter
;
98 gp_pen
= GdipAlloc(sizeof(GpPen
));
99 if(!gp_pen
) return OutOfMemory
;
101 gp_pen
->style
= GP_DEFAULT_PENSTYLE
;
102 gp_pen
->color
= ARGB2COLORREF(color
);
103 gp_pen
->width
= width
;
105 gp_pen
->endcap
= LineCapFlat
;
106 gp_pen
->join
= LineJoinMiter
;
107 gp_pen
->miterlimit
= 10.0;
108 gp_pen
->dash
= DashStyleSolid
;
109 GdipCreateSolidFill(color
, (GpSolidFill
**)(&gp_pen
->brush
));
111 if((gp_pen
->unit
== UnitWorld
) || (gp_pen
->unit
== UnitPixel
)) {
112 gp_pen
->gdipen
= ExtCreatePen(gp_pen
->style
, (INT
) gp_pen
->width
,
113 &gp_pen
->brush
->lb
, 0, NULL
);
115 FIXME("UnitWorld, UnitPixel only supported units\n");
117 return NotImplemented
;
125 GpStatus WINGDIPAPI
GdipDeletePen(GpPen
*pen
)
127 if(!pen
) return InvalidParameter
;
128 DeleteObject(pen
->gdipen
);
130 GdipDeleteBrush(pen
->brush
);
131 GdipDeleteCustomLineCap(pen
->customstart
);
132 GdipDeleteCustomLineCap(pen
->customend
);
138 GpStatus WINGDIPAPI
GdipGetPenDashStyle(GpPen
*pen
, GpDashStyle
*dash
)
141 return InvalidParameter
;
148 GpStatus WINGDIPAPI
GdipSetPenCustomEndCap(GpPen
*pen
, GpCustomLineCap
* customCap
)
150 GpCustomLineCap
* cap
;
153 if(!pen
|| !customCap
) return InvalidParameter
;
155 if((ret
= GdipCloneCustomLineCap(customCap
, &cap
)) == Ok
){
156 GdipDeleteCustomLineCap(pen
->customend
);
157 pen
->endcap
= LineCapCustom
;
158 pen
->customend
= cap
;
164 GpStatus WINGDIPAPI
GdipSetPenCustomStartCap(GpPen
*pen
, GpCustomLineCap
* customCap
)
166 GpCustomLineCap
* cap
;
169 if(!pen
|| !customCap
) return InvalidParameter
;
171 if((ret
= GdipCloneCustomLineCap(customCap
, &cap
)) == Ok
){
172 GdipDeleteCustomLineCap(pen
->customstart
);
173 pen
->startcap
= LineCapCustom
;
174 pen
->customstart
= cap
;
180 GpStatus WINGDIPAPI
GdipSetPenDashStyle(GpPen
*pen
, GpDashStyle dash
)
183 return InvalidParameter
;
185 DeleteObject(pen
->gdipen
);
187 pen
->style
&= ~(PS_ALTERNATE
| PS_SOLID
| PS_DASH
| PS_DOT
| PS_DASHDOT
|
188 PS_DASHDOTDOT
| PS_NULL
| PS_USERSTYLE
| PS_INSIDEFRAME
);
189 pen
->style
|= gdip_to_gdi_dash(dash
);
191 pen
->gdipen
= ExtCreatePen(pen
->style
, (INT
) pen
->width
, &pen
->brush
->lb
, 0, NULL
);
196 GpStatus WINGDIPAPI
GdipSetPenEndCap(GpPen
*pen
, GpLineCap cap
)
198 if(!pen
) return InvalidParameter
;
200 /* The old custom cap gets deleted even if the new style is LineCapCustom. */
201 GdipDeleteCustomLineCap(pen
->customend
);
202 pen
->customend
= NULL
;
208 /* FIXME: startcap, dashcap not used. */
209 GpStatus WINGDIPAPI
GdipSetPenLineCap197819(GpPen
*pen
, GpLineCap start
,
210 GpLineCap end
, GpDashCap dash
)
213 return InvalidParameter
;
215 GdipDeleteCustomLineCap(pen
->customend
);
216 GdipDeleteCustomLineCap(pen
->customstart
);
217 pen
->customend
= NULL
;
218 pen
->customstart
= NULL
;
220 pen
->startcap
= start
;
227 /* FIXME: Miter line joins behave a bit differently than they do in windows.
228 * Both kinds of miter joins clip if the angle is less than 11 degrees. */
229 GpStatus WINGDIPAPI
GdipSetPenLineJoin(GpPen
*pen
, GpLineJoin join
)
231 if(!pen
) return InvalidParameter
;
233 DeleteObject(pen
->gdipen
);
235 pen
->style
&= ~(PS_JOIN_ROUND
| PS_JOIN_BEVEL
| PS_JOIN_MITER
);
236 pen
->style
|= gdip_to_gdi_join(join
);
238 pen
->gdipen
= ExtCreatePen(pen
->style
, (INT
) pen
->width
, &pen
->brush
->lb
, 0, NULL
);
243 GpStatus WINGDIPAPI
GdipSetPenMiterLimit(GpPen
*pen
, REAL limit
)
246 return InvalidParameter
;
248 pen
->miterlimit
= limit
;