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
28 #include "gdiplus_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
33 static DWORD gdip_to_gdi_dash(GpDashStyle dash)
42 case DashStyleDashDot:
44 case DashStyleDashDotDot:
49 ERR("Not a member of GpDashStyle enumeration\n");
54 static DWORD gdip_to_gdi_join(GpLineJoin join)
62 case LineJoinMiterClipped:
65 ERR("Not a member of GpLineJoin enumeration\n");
70 GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
73 return InvalidParameter;
75 *clonepen = GdipAlloc(sizeof(GpPen));
76 if(!*clonepen) return OutOfMemory;
80 GdipCloneCustomLineCap(pen->customstart, &(*clonepen)->customstart);
81 GdipCloneCustomLineCap(pen->customend, &(*clonepen)->customend);
82 GdipCloneBrush(pen->brush, &(*clonepen)->brush);
87 GpStatus WINGDIPAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit,
91 GdipCreateSolidFill(color, (GpSolidFill **)(&brush));
92 return GdipCreatePen2(brush, width, unit, pen);
95 GpStatus WINGDIPAPI GdipCreatePen2(GpBrush *brush, REAL width, GpUnit unit,
101 return InvalidParameter;
103 gp_pen = GdipAlloc(sizeof(GpPen));
104 if(!gp_pen) return OutOfMemory;
106 gp_pen->style = GP_DEFAULT_PENSTYLE;
107 gp_pen->width = width;
109 gp_pen->endcap = LineCapFlat;
110 gp_pen->join = LineJoinMiter;
111 gp_pen->miterlimit = 10.0;
112 gp_pen->dash = DashStyleSolid;
113 gp_pen->offset = 0.0;
114 gp_pen->brush = brush;
116 if(!((gp_pen->unit == UnitWorld) || (gp_pen->unit == UnitPixel))) {
117 FIXME("UnitWorld, UnitPixel only supported units\n");
119 return NotImplemented;
127 GpStatus WINGDIPAPI GdipDeletePen(GpPen *pen)
129 if(!pen) return InvalidParameter;
131 GdipDeleteBrush(pen->brush);
132 GdipDeleteCustomLineCap(pen->customstart);
133 GdipDeleteCustomLineCap(pen->customend);
134 GdipFree(pen->dashes);
140 GpStatus WINGDIPAPI GdipGetPenBrushFill(GpPen *pen, GpBrush **brush)
143 return InvalidParameter;
145 return GdipCloneBrush(pen->brush, brush);
148 GpStatus WINGDIPAPI GdipGetPenColor(GpPen *pen, ARGB *argb)
151 return InvalidParameter;
153 if(pen->brush->bt != BrushTypeSolidColor)
154 return NotImplemented;
156 return GdipGetSolidFillColor(((GpSolidFill*)pen->brush), argb);
159 GpStatus WINGDIPAPI GdipGetPenDashArray(GpPen *pen, REAL *dash, INT count)
161 if(!pen || !dash || count > pen->numdashes)
162 return InvalidParameter;
164 /* note: if you pass a negative value for count, it crashes native gdiplus. */
168 memcpy(dash, pen->dashes, count * sizeof(REAL));
173 GpStatus WINGDIPAPI GdipGetPenDashOffset(GpPen *pen, REAL *offset)
176 return InvalidParameter;
178 *offset = pen->offset;
183 GpStatus WINGDIPAPI GdipGetPenDashStyle(GpPen *pen, GpDashStyle *dash)
186 return InvalidParameter;
193 GpStatus WINGDIPAPI GdipSetPenBrushFill(GpPen *pen, GpBrush *brush)
196 return InvalidParameter;
198 GdipDeleteBrush(pen->brush);
199 return GdipCloneBrush(brush, &pen->brush);
202 GpStatus WINGDIPAPI GdipSetPenColor(GpPen *pen, ARGB argb)
205 return InvalidParameter;
207 if(pen->brush->bt != BrushTypeSolidColor)
208 return NotImplemented;
210 return GdipSetSolidFillColor(((GpSolidFill*)pen->brush), argb);
213 GpStatus WINGDIPAPI GdipSetPenCustomEndCap(GpPen *pen, GpCustomLineCap* customCap)
215 GpCustomLineCap * cap;
218 if(!pen || !customCap) return InvalidParameter;
220 if((ret = GdipCloneCustomLineCap(customCap, &cap)) == Ok){
221 GdipDeleteCustomLineCap(pen->customend);
222 pen->endcap = LineCapCustom;
223 pen->customend = cap;
229 GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap* customCap)
231 GpCustomLineCap * cap;
234 if(!pen || !customCap) return InvalidParameter;
236 if((ret = GdipCloneCustomLineCap(customCap, &cap)) == Ok){
237 GdipDeleteCustomLineCap(pen->customstart);
238 pen->startcap = LineCapCustom;
239 pen->customstart = cap;
245 GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
252 return InvalidParameter;
254 for(i = 0; i < count; i++){
257 return InvalidParameter;
260 if(sum == 0.0 && count)
261 return InvalidParameter;
263 GdipFree(pen->dashes);
267 pen->dashes = GdipAlloc(count * sizeof(REAL));
273 GdipSetPenDashStyle(pen, DashStyleCustom);
274 memcpy(pen->dashes, dash, count * sizeof(REAL));
275 pen->numdashes = count;
280 /* FIXME: dash offset not used */
281 GpStatus WINGDIPAPI GdipSetPenDashOffset(GpPen *pen, REAL offset)
284 return InvalidParameter;
286 pen->offset = offset;
291 GpStatus WINGDIPAPI GdipSetPenDashStyle(GpPen *pen, GpDashStyle dash)
294 return InvalidParameter;
296 if(dash != DashStyleCustom){
297 GdipFree(pen->dashes);
303 pen->style &= ~(PS_ALTERNATE | PS_SOLID | PS_DASH | PS_DOT | PS_DASHDOT |
304 PS_DASHDOTDOT | PS_NULL | PS_USERSTYLE | PS_INSIDEFRAME);
305 pen->style |= gdip_to_gdi_dash(dash);
310 GpStatus WINGDIPAPI GdipSetPenEndCap(GpPen *pen, GpLineCap cap)
312 if(!pen) return InvalidParameter;
314 /* The old custom cap gets deleted even if the new style is LineCapCustom. */
315 GdipDeleteCustomLineCap(pen->customend);
316 pen->customend = NULL;
322 /* FIXME: startcap, dashcap not used. */
323 GpStatus WINGDIPAPI GdipSetPenLineCap197819(GpPen *pen, GpLineCap start,
324 GpLineCap end, GpDashCap dash)
327 return InvalidParameter;
329 GdipDeleteCustomLineCap(pen->customend);
330 GdipDeleteCustomLineCap(pen->customstart);
331 pen->customend = NULL;
332 pen->customstart = NULL;
334 pen->startcap = start;
341 /* FIXME: Miter line joins behave a bit differently than they do in windows.
342 * Both kinds of miter joins clip if the angle is less than 11 degrees. */
343 GpStatus WINGDIPAPI GdipSetPenLineJoin(GpPen *pen, GpLineJoin join)
345 if(!pen) return InvalidParameter;
348 pen->style &= ~(PS_JOIN_ROUND | PS_JOIN_BEVEL | PS_JOIN_MITER);
349 pen->style |= gdip_to_gdi_join(join);
354 GpStatus WINGDIPAPI GdipSetPenMiterLimit(GpPen *pen, REAL limit)
357 return InvalidParameter;
359 pen->miterlimit = limit;
364 GpStatus WINGDIPAPI GdipSetPenStartCap(GpPen *pen, GpLineCap cap)
366 if(!pen) return InvalidParameter;
368 GdipDeleteCustomLineCap(pen->customstart);
369 pen->customstart = NULL;
375 GpStatus WINGDIPAPI GdipSetPenWidth(GpPen *pen, REAL width)
377 if(!pen) return InvalidParameter;
385 GpStatus WINGDIPAPI GdipSetPenMode(GpPen *pen, GpPenAlignment penAlignment)
387 if(!pen) return InvalidParameter;
389 FIXME("stub (%d)\n", penAlignment);