OSDN Git Service

Avoid an implication that the API is exclusively 32-bit.
[mingw/mingw-org-wsl.git] / wslapi / include / gdiplus / gdipluspath.h
1 /*\r
2  * gdipluspath.h\r
3  *\r
4  * GDI+ GraphicsPath class\r
5  *\r
6  * This file is part of the w32api package.\r
7  *\r
8  * Contributors:\r
9  *   Created by Markus Koenig <markus@stber-koenig.de>\r
10  *\r
11  * THIS SOFTWARE IS NOT COPYRIGHTED\r
12  *\r
13  * This source code is offered for use in the public domain. You may\r
14  * use, modify or distribute it freely.\r
15  *\r
16  * This code is distributed in the hope that it will be useful but\r
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY\r
18  * DISCLAIMED. This includes but is not limited to warranties of\r
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
20  *\r
21  */\r
22 \r
23 #ifndef __GDIPLUS_PATH_H\r
24 #define __GDIPLUS_PATH_H\r
25 #if __GNUC__ >=3\r
26 #pragma GCC system_header\r
27 #endif\r
28 \r
29 #ifndef __cplusplus\r
30 #error "A C++ compiler is required to include gdipluspath.h."\r
31 #endif\r
32 \r
33 // Note that some methods of GraphicsPath are implemented in gdiplusimpl.h.\r
34 // This avoids a cyclic dependency on Graphics and Pen.\r
35 \r
36 class GraphicsPath: public GdiplusBase\r
37 {\r
38         friend class CustomLineCap;\r
39         friend class Graphics;\r
40         friend class GraphicsPathIterator;\r
41         friend class PathGradientBrush;\r
42         friend class Region;\r
43 \r
44 public:\r
45         GraphicsPath(FillMode fillMode = FillModeAlternate):\r
46                         nativePath(NULL), lastStatus(Ok)\r
47         {\r
48                 lastStatus = DllExports::GdipCreatePath(fillMode, &nativePath);\r
49         }\r
50         GraphicsPath(const PointF *points, const BYTE *types, INT count,\r
51                         FillMode fillMode = FillModeAlternate):\r
52                         nativePath(NULL), lastStatus(Ok)\r
53         {\r
54                 lastStatus = DllExports::GdipCreatePath2(\r
55                                 points, types, count, fillMode, &nativePath);\r
56         }\r
57         GraphicsPath(const Point *points, const BYTE *types, INT count,\r
58                         FillMode fillMode = FillModeAlternate):\r
59                         nativePath(NULL), lastStatus(Ok)\r
60         {\r
61                 lastStatus = DllExports::GdipCreatePath2I(\r
62                                 points, types, count, fillMode, &nativePath);\r
63         }\r
64         ~GraphicsPath()\r
65         {\r
66                 DllExports::GdipDeletePath(nativePath);\r
67         }\r
68         GraphicsPath* Clone() const\r
69         {\r
70                 GpPath *clonePath = NULL;\r
71                 Status status = updateStatus(DllExports::GdipClonePath(\r
72                                 nativePath, &clonePath));\r
73                 if (status == Ok) {\r
74                         GraphicsPath *result = new GraphicsPath(clonePath, lastStatus);\r
75                         if (!result) {\r
76                                 DllExports::GdipDeletePath(clonePath);\r
77                                 lastStatus = OutOfMemory;\r
78                         }\r
79                         return result;\r
80                 } else {\r
81                         return NULL;\r
82                 }\r
83         }\r
84 \r
85         Status AddArc(REAL x, REAL y, REAL width, REAL height,\r
86                         REAL startAngle, REAL sweepAngle)\r
87         {\r
88                 return updateStatus(DllExports::GdipAddPathArc(nativePath,\r
89                                 x, y, width, height, startAngle, sweepAngle));\r
90         }\r
91         Status AddArc(INT x, INT y, INT width, INT height,\r
92                         REAL startAngle, REAL sweepAngle)\r
93         {\r
94                 return updateStatus(DllExports::GdipAddPathArcI(nativePath,\r
95                                 x, y, width, height, startAngle, sweepAngle));\r
96         }\r
97         Status AddArc(const RectF& rect, REAL startAngle, REAL sweepAngle)\r
98         {\r
99                 return updateStatus(DllExports::GdipAddPathArc(nativePath,\r
100                                 rect.X, rect.Y, rect.Width, rect.Height,\r
101                                 startAngle, sweepAngle));\r
102         }\r
103         Status AddArc(const Rect& rect, REAL startAngle, REAL sweepAngle)\r
104         {\r
105                 return updateStatus(DllExports::GdipAddPathArcI(nativePath,\r
106                                 rect.X, rect.Y, rect.Width, rect.Height,\r
107                                 startAngle, sweepAngle));\r
108         }\r
109         Status AddBezier(REAL x1, REAL y1, REAL x2, REAL y2,\r
110                         REAL x3, REAL y3, REAL x4, REAL y4)\r
111         {\r
112                 return updateStatus(DllExports::GdipAddPathBezier(nativePath,\r
113                                 x1, y1, x2, y2, x3, y3, x4, y4));\r
114         }\r
115         Status AddBezier(INT x1, INT y1, INT x2, INT y2,\r
116                         INT x3, INT y3, INT x4, INT y4)\r
117         {\r
118                 return updateStatus(DllExports::GdipAddPathBezierI(nativePath,\r
119                                 x1, y1, x2, y2, x3, y3, x4, y4));\r
120         }\r
121         Status AddBezier(const PointF& pt1, const PointF& pt2,\r
122                         const PointF& pt3, const PointF& pt4)\r
123         {\r
124                 return updateStatus(DllExports::GdipAddPathBezier(nativePath,\r
125                                 pt1.X, pt1.Y, pt2.X, pt2.Y,\r
126                                 pt3.X, pt3.Y, pt4.X, pt4.Y));\r
127         }\r
128         Status AddBezier(const Point& pt1, const Point& pt2,\r
129                         const Point& pt3, const Point& pt4)\r
130         {\r
131                 return updateStatus(DllExports::GdipAddPathBezierI(nativePath,\r
132                                 pt1.X, pt1.Y, pt2.X, pt2.Y,\r
133                                 pt3.X, pt3.Y, pt4.X, pt4.Y));\r
134         }\r
135         Status AddBeziers(const PointF *points, INT count)\r
136         {\r
137                 return updateStatus(DllExports::GdipAddPathBeziers(\r
138                                 nativePath, points, count));\r
139         }\r
140         Status AddBeziers(const Point *points, INT count)\r
141         {\r
142                 return updateStatus(DllExports::GdipAddPathBeziersI(\r
143                                 nativePath, points, count));\r
144         }\r
145         Status AddClosedCurve(const PointF *points, INT count)\r
146         {\r
147                 return updateStatus(DllExports::GdipAddPathClosedCurve(\r
148                                 nativePath, points, count));\r
149         }\r
150         Status AddClosedCurve(const Point *points, INT count)\r
151         {\r
152                 return updateStatus(DllExports::GdipAddPathClosedCurveI(\r
153                                 nativePath, points, count));\r
154         }\r
155         Status AddClosedCurve(const PointF *points, INT count, REAL tension)\r
156         {\r
157                 return updateStatus(DllExports::GdipAddPathClosedCurve2(\r
158                                 nativePath, points, count, tension));\r
159         }\r
160         Status AddClosedCurve(const Point *points, INT count, REAL tension)\r
161         {\r
162                 return updateStatus(DllExports::GdipAddPathClosedCurve2I(\r
163                                 nativePath, points, count, tension));\r
164         }\r
165         Status AddCurve(const PointF *points, INT count)\r
166         {\r
167                 return updateStatus(DllExports::GdipAddPathCurve(\r
168                                 nativePath, points, count));\r
169         }\r
170         Status AddCurve(const Point *points, INT count)\r
171         {\r
172                 return updateStatus(DllExports::GdipAddPathCurveI(\r
173                                 nativePath, points, count));\r
174         }\r
175         Status AddCurve(const PointF *points, INT count, REAL tension)\r
176         {\r
177                 return updateStatus(DllExports::GdipAddPathCurve2(\r
178                                 nativePath, points, count, tension));\r
179         }\r
180         Status AddCurve(const Point *points, INT count, REAL tension)\r
181         {\r
182                 return updateStatus(DllExports::GdipAddPathCurve2I(\r
183                                 nativePath, points, count, tension));\r
184         }\r
185         Status AddCurve(const PointF *points, INT count, INT offset,\r
186                         INT numberOfSegments, REAL tension)\r
187         {\r
188                 return updateStatus(DllExports::GdipAddPathCurve3(\r
189                                 nativePath, points, count,\r
190                                 offset, numberOfSegments, tension));\r
191         }\r
192         Status AddCurve(const Point *points, INT count, INT offset,\r
193                         INT numberOfSegments, REAL tension)\r
194         {\r
195                 return updateStatus(DllExports::GdipAddPathCurve3I(\r
196                                 nativePath, points, count,\r
197                                 offset, numberOfSegments, tension));\r
198         }\r
199         Status AddEllipse(REAL x, REAL y, REAL width, REAL height)\r
200         {\r
201                 return updateStatus(DllExports::GdipAddPathEllipse(nativePath,\r
202                                 x, y, width, height));\r
203         }\r
204         Status AddEllipse(INT x, INT y, INT width, INT height)\r
205         {\r
206                 return updateStatus(DllExports::GdipAddPathEllipseI(nativePath,\r
207                                 x, y, width, height));\r
208         }\r
209         Status AddEllipse(const RectF& rect)\r
210         {\r
211                 return updateStatus(DllExports::GdipAddPathEllipse(nativePath,\r
212                                 rect.X, rect.Y, rect.Width, rect.Height));\r
213         }\r
214         Status AddEllipse(const Rect& rect)\r
215         {\r
216                 return updateStatus(DllExports::GdipAddPathEllipseI(nativePath,\r
217                                 rect.X, rect.Y, rect.Width, rect.Height));\r
218         }\r
219         Status AddLine(REAL x1, REAL y1, REAL x2, REAL y2)\r
220         {\r
221                 return updateStatus(DllExports::GdipAddPathLine(nativePath,\r
222                                 x1, y1, x2, y2));\r
223         }\r
224         Status AddLine(INT x1, INT y1, INT x2, INT y2)\r
225         {\r
226                 return updateStatus(DllExports::GdipAddPathLineI(nativePath,\r
227                                 x1, y1, x2, y2));\r
228         }\r
229         Status AddLine(const PointF& pt1, const PointF& pt2)\r
230         {\r
231                 return updateStatus(DllExports::GdipAddPathLine(nativePath,\r
232                                 pt1.X, pt1.Y, pt2.X, pt2.Y));\r
233         }\r
234         Status AddLine(const Point& pt1, const Point& pt2)\r
235         {\r
236                 return updateStatus(DllExports::GdipAddPathLineI(nativePath,\r
237                                 pt1.X, pt1.Y, pt2.X, pt2.Y));\r
238         }\r
239         Status AddLines(const PointF *points, INT count)\r
240         {\r
241                 return updateStatus(DllExports::GdipAddPathLine2(nativePath,\r
242                                 points, count));\r
243         }\r
244         Status AddLines(const Point *points, INT count)\r
245         {\r
246                 return updateStatus(DllExports::GdipAddPathLine2I(nativePath,\r
247                                 points, count));\r
248         }\r
249         Status AddPath(const GraphicsPath *addingPath, BOOL connect)\r
250         {\r
251                 return updateStatus(DllExports::GdipAddPathPath(nativePath,\r
252                                 addingPath ? addingPath->nativePath : NULL,\r
253                                 connect));\r
254         }\r
255         Status AddPie(REAL x, REAL y, REAL width, REAL height,\r
256                         REAL startAngle, REAL sweepAngle)\r
257         {\r
258                 return updateStatus(DllExports::GdipAddPathPie(nativePath,\r
259                                 x, y, width, height, startAngle, sweepAngle));\r
260         }\r
261         Status AddPie(INT x, INT y, INT width, INT height,\r
262                         REAL startAngle, REAL sweepAngle)\r
263         {\r
264                 return updateStatus(DllExports::GdipAddPathPieI(nativePath,\r
265                                 x, y, width, height, startAngle, sweepAngle));\r
266         }\r
267         Status AddPie(const RectF& rect, REAL startAngle, REAL sweepAngle)\r
268         {\r
269                 return updateStatus(DllExports::GdipAddPathPie(nativePath,\r
270                                 rect.X, rect.Y, rect.Width, rect.Height,\r
271                                 startAngle, sweepAngle));\r
272         }\r
273         Status AddPie(const Rect& rect, REAL startAngle, REAL sweepAngle)\r
274         {\r
275                 return updateStatus(DllExports::GdipAddPathPieI(nativePath,\r
276                                 rect.X, rect.Y, rect.Width, rect.Height,\r
277                                 startAngle, sweepAngle));\r
278         }\r
279         Status AddPolygon(const PointF *points, INT count)\r
280         {\r
281                 return updateStatus(DllExports::GdipAddPathPolygon(nativePath,\r
282                                 points, count));\r
283         }\r
284         Status AddPolygon(const Point *points, INT count)\r
285         {\r
286                 return updateStatus(DllExports::GdipAddPathPolygonI(nativePath,\r
287                                 points, count));\r
288         }\r
289         Status AddRectangle(const RectF& rect)\r
290         {\r
291                 return updateStatus(DllExports::GdipAddPathRectangle(nativePath,\r
292                                 rect.X, rect.Y, rect.Width, rect.Height));\r
293         }\r
294         Status AddRectangle(const Rect& rect)\r
295         {\r
296                 return updateStatus(DllExports::GdipAddPathRectangleI(\r
297                                 nativePath,\r
298                                 rect.X, rect.Y, rect.Width, rect.Height));\r
299         }\r
300         Status AddRectangles(const RectF *rects, INT count)\r
301         {\r
302                 return updateStatus(DllExports::GdipAddPathRectangles(\r
303                                 nativePath, rects, count));\r
304         }\r
305         Status AddRectangles(const Rect *rects, INT count)\r
306         {\r
307                 return updateStatus(DllExports::GdipAddPathRectanglesI(\r
308                                 nativePath, rects, count));\r
309         }\r
310         Status AddString(const WCHAR *string, INT length,\r
311                         const FontFamily *family, INT style, REAL emSize,\r
312                         const PointF& origin, const StringFormat *format)\r
313         {\r
314                 RectF layoutRect(origin, SizeF(0.0f, 0.0f));\r
315                 return updateStatus(DllExports::GdipAddPathString(nativePath,\r
316                                 string, length,\r
317                                 family ? family->nativeFontFamily : NULL,\r
318                                 style, emSize, &layoutRect,\r
319                                 format ? format->nativeStringFormat : NULL));\r
320         }\r
321         Status AddString(const WCHAR *string, INT length,\r
322                         const FontFamily *family, INT style, REAL emSize,\r
323                         const Point& origin, const StringFormat *format)\r
324         {\r
325                 Rect layoutRect(origin, Size(0, 0));\r
326                 return updateStatus(DllExports::GdipAddPathStringI(nativePath,\r
327                                 string, length,\r
328                                 family ? family->nativeFontFamily : NULL,\r
329                                 style, emSize, &layoutRect,\r
330                                 format ? format->nativeStringFormat : NULL));\r
331         }\r
332         Status AddString(const WCHAR *string, INT length,\r
333                         const FontFamily *family, INT style, REAL emSize,\r
334                         const RectF& layoutRect, const StringFormat *format)\r
335         {\r
336                 return updateStatus(DllExports::GdipAddPathString(nativePath,\r
337                                 string, length,\r
338                                 family ? family->nativeFontFamily : NULL,\r
339                                 style, emSize, &layoutRect,\r
340                                 format ? format->nativeStringFormat : NULL));\r
341         }\r
342         Status AddString(const WCHAR *string, INT length,\r
343                         const FontFamily *family, INT style, REAL emSize,\r
344                         const Rect& layoutRect, const StringFormat *format)\r
345         {\r
346                 return updateStatus(DllExports::GdipAddPathStringI(nativePath,\r
347                                 string, length,\r
348                                 family ? family->nativeFontFamily : NULL,\r
349                                 style, emSize, &layoutRect,\r
350                                 format ? format->nativeStringFormat : NULL));\r
351         }\r
352         Status ClearMarkers()\r
353         {\r
354                 return updateStatus(DllExports::GdipClearPathMarkers(\r
355                                 nativePath));\r
356         }\r
357         Status CloseAllFigures()\r
358         {\r
359                 return updateStatus(DllExports::GdipClosePathFigures(\r
360                                 nativePath));\r
361         }\r
362         Status CloseFigure()\r
363         {\r
364                 return updateStatus(DllExports::GdipClosePathFigure(\r
365                                 nativePath));\r
366         }\r
367         Status Flatten(const Matrix *matrix = NULL,\r
368                         REAL flatness = FlatnessDefault)\r
369         {\r
370                 return updateStatus(DllExports::GdipFlattenPath(nativePath,\r
371                                 matrix ? matrix->nativeMatrix : NULL,\r
372                                 flatness));\r
373         }\r
374         Status GetBounds(RectF *bounds, const Matrix *matrix = NULL,\r
375                         const Pen *pen = NULL) const\r
376         {\r
377                 return updateStatus(DllExports::GdipGetPathWorldBounds(\r
378                                 nativePath, bounds,\r
379                                 matrix ? matrix->nativeMatrix : NULL,\r
380                                 pen ? pen->nativePen : NULL));\r
381         }\r
382         Status GetBounds(Rect *bounds, const Matrix *matrix = NULL,\r
383                         const Pen *pen = NULL) const\r
384         {\r
385                 return updateStatus(DllExports::GdipGetPathWorldBoundsI(\r
386                                 nativePath, bounds,\r
387                                 matrix ? matrix->nativeMatrix : NULL,\r
388                                 pen ? pen->nativePen : NULL));\r
389         }       \r
390         FillMode GetFillMode() const\r
391         {\r
392                 FillMode result = FillModeAlternate;\r
393                 updateStatus(DllExports::GdipGetPathFillMode(nativePath,\r
394                                 &result));\r
395                 return result;\r
396         }\r
397         Status GetLastPoint(PointF *lastPoint) const\r
398         {\r
399                 return updateStatus(DllExports::GdipGetPathLastPoint(\r
400                                 nativePath, lastPoint));\r
401         }\r
402         Status GetLastStatus() const\r
403         {\r
404                 Status result = lastStatus;\r
405                 lastStatus = Ok;\r
406                 return result;\r
407         }\r
408         Status GetPathData(PathData *pathData) const\r
409         {\r
410                 if (!pathData) return lastStatus = InvalidParameter;\r
411 \r
412                 Status status;\r
413                 INT count;\r
414 \r
415                 status = updateStatus(DllExports::GdipGetPointCount(\r
416                                 nativePath, &count));\r
417                 if (status != Ok) return status;\r
418 \r
419                 status = updateStatus(pathData->AllocateArrays(count));\r
420                 if (status != Ok) return status;\r
421 \r
422                 return updateStatus(DllExports::GdipGetPathData(\r
423                                 nativePath, (GpPathData*) pathData));\r
424         }\r
425         Status GetPathPoints(PointF *points, INT count) const\r
426         {\r
427                 return updateStatus(DllExports::GdipGetPathPoints(nativePath,\r
428                                 points, count));\r
429         }\r
430         Status GetPathPoints(Point *points, INT count) const\r
431         {\r
432                 return updateStatus(DllExports::GdipGetPathPointsI(nativePath,\r
433                                 points, count));\r
434         }\r
435         Status GetPathTypes(BYTE *types, INT count) const\r
436         {\r
437                 return updateStatus(DllExports::GdipGetPathTypes(nativePath,\r
438                                 types, count));\r
439         }\r
440         INT GetPointCount() const\r
441         {\r
442                 INT result = 0;\r
443                 updateStatus(DllExports::GdipGetPointCount(nativePath,\r
444                                 &result));\r
445                 return result;\r
446         }\r
447         BOOL IsOutlineVisible(REAL x, REAL y, const Pen *pen,\r
448                         const Graphics *g = NULL) const;\r
449         BOOL IsOutlineVisible(INT x, INT y, const Pen *pen,\r
450                         const Graphics *g = NULL) const;\r
451         BOOL IsOutlineVisible(const PointF& point, const Pen *pen,\r
452                         const Graphics *g = NULL) const;\r
453         BOOL IsOutlineVisible(const Point& point, const Pen *pen,\r
454                         const Graphics *g = NULL) const;\r
455         BOOL IsVisible(REAL x, REAL y, const Graphics *g = NULL) const;\r
456         BOOL IsVisible(INT x, INT y, const Graphics *g = NULL) const;\r
457         BOOL IsVisible(const PointF& point, const Graphics *g = NULL) const;\r
458         BOOL IsVisible(const Point& point, const Graphics *g = NULL) const;\r
459         Status Outline(const Matrix *matrix = NULL,\r
460                         REAL flatness = FlatnessDefault)\r
461         {\r
462                 return updateStatus(DllExports::GdipWindingModeOutline(\r
463                                 nativePath,\r
464                                 matrix ? matrix->nativeMatrix : NULL,\r
465                                 flatness));\r
466         }\r
467         Status Reset()\r
468         {\r
469                 return updateStatus(DllExports::GdipResetPath(nativePath));\r
470         }\r
471         Status Reverse()\r
472         {\r
473                 return updateStatus(DllExports::GdipReversePath(nativePath));\r
474         }\r
475         Status SetFillMode(FillMode fillMode)\r
476         {\r
477                 return updateStatus(DllExports::GdipSetPathFillMode(\r
478                                 nativePath, fillMode));\r
479         }\r
480         Status SetMarker()\r
481         {\r
482                 return updateStatus(DllExports::GdipSetPathMarker(nativePath));\r
483         }\r
484         Status StartFigure()\r
485         {\r
486                 return updateStatus(DllExports::GdipStartPathFigure(\r
487                                 nativePath));\r
488         }\r
489         Status Transform(const Matrix *matrix)\r
490         {\r
491                 return updateStatus(DllExports::GdipTransformPath(\r
492                                 nativePath,\r
493                                 matrix ? matrix->nativeMatrix : NULL));\r
494         }\r
495         Status Warp(const PointF *destPoints, INT count, const RectF& srcRect,\r
496                         const Matrix *matrix = NULL,\r
497                         WarpMode warpMode = WarpModePerspective,\r
498                         REAL flatness = FlatnessDefault)\r
499         {\r
500                 return updateStatus(DllExports::GdipWarpPath(nativePath,\r
501                                 matrix ? matrix->nativeMatrix : NULL,\r
502                                 destPoints, count,\r
503                                 srcRect.X, srcRect.Y,\r
504                                 srcRect.Width, srcRect.Height,\r
505                                 warpMode, flatness));\r
506         }\r
507         Status Widen(const Pen *pen, const Matrix *matrix = NULL,\r
508                         REAL flatness = FlatnessDefault)\r
509         {\r
510                 return updateStatus(DllExports::GdipWidenPath(nativePath,\r
511                                 pen ? pen->nativePen : NULL,\r
512                                 matrix ? matrix->nativeMatrix : NULL,\r
513                                 flatness));\r
514         }\r
515 \r
516 private:\r
517         GraphicsPath(GpPath *path, Status status):\r
518                 nativePath(path), lastStatus(status) {}\r
519         GraphicsPath(const GraphicsPath&);\r
520         GraphicsPath& operator=(const GraphicsPath&);\r
521 \r
522         Status updateStatus(Status newStatus) const\r
523         {\r
524                 if (newStatus != Ok) lastStatus = newStatus;\r
525                 return newStatus;\r
526         }\r
527 \r
528         GpPath *nativePath;\r
529         mutable Status lastStatus;\r
530 };\r
531 \r
532 class GraphicsPathIterator: public GdiplusBase\r
533 {\r
534 public:\r
535         GraphicsPathIterator(GraphicsPath *path):\r
536                 nativePathIterator(NULL), lastStatus(Ok)\r
537         {\r
538                 lastStatus = DllExports::GdipCreatePathIter(\r
539                                 &nativePathIterator,\r
540                                 path ? path->nativePath : NULL);\r
541         }\r
542         ~GraphicsPathIterator()\r
543         {\r
544                 DllExports::GdipDeletePathIter(nativePathIterator);\r
545         }\r
546 \r
547         INT CopyData(PointF *points, BYTE *types, INT startIndex, INT endIndex)\r
548         {\r
549                 INT result = 0;\r
550                 updateStatus(DllExports::GdipPathIterCopyData(\r
551                                 nativePathIterator, &result,\r
552                                 points, types, startIndex, endIndex));\r
553                 return result;\r
554         }\r
555         INT Enumerate(PointF *points, BYTE *types, INT count)\r
556         {\r
557                 INT result = 0;\r
558                 updateStatus(DllExports::GdipPathIterEnumerate(\r
559                                 nativePathIterator, &result,\r
560                                 points, types, count));\r
561                 return result;\r
562         }\r
563         INT GetCount() const\r
564         {\r
565                 INT result = 0;\r
566                 updateStatus(DllExports::GdipPathIterGetCount(\r
567                                 nativePathIterator, &result));\r
568                 return result;\r
569         }\r
570         Status GetLastStatus() const\r
571         {\r
572                 Status result = lastStatus;\r
573                 lastStatus = Ok;\r
574                 return result;\r
575         }\r
576         INT GetSubpathCount() const\r
577         {\r
578                 INT result = 0;\r
579                 updateStatus(DllExports::GdipPathIterGetSubpathCount(\r
580                                 nativePathIterator, &result));\r
581                 return result;\r
582         }\r
583         BOOL HasCurve() const\r
584         {\r
585                 BOOL result = FALSE;\r
586                 updateStatus(DllExports::GdipPathIterHasCurve(\r
587                                 nativePathIterator, &result));\r
588                 return result;\r
589         }\r
590         INT NextMarker(INT *startIndex, INT *endIndex)\r
591         {\r
592                 INT result = 0;\r
593                 updateStatus(DllExports::GdipPathIterNextMarker(\r
594                                 nativePathIterator, &result,\r
595                                 startIndex, endIndex));\r
596                 return result;\r
597         }\r
598         INT NextMarker(GraphicsPath *path)\r
599         {\r
600                 INT result = 0;\r
601                 updateStatus(DllExports::GdipPathIterNextMarkerPath(\r
602                                 nativePathIterator, &result,\r
603                                 path ? path->nativePath : NULL));\r
604                 return result;\r
605         }\r
606         INT NextPathType(BYTE *pathType, INT *startIndex, INT *endIndex)\r
607         {\r
608                 INT result = 0;\r
609                 updateStatus(DllExports::GdipPathIterNextPathType(\r
610                                 nativePathIterator, &result,\r
611                                 pathType, startIndex, endIndex));\r
612                 return result;\r
613         }\r
614         INT NextSubpath(INT *startIndex, INT *endIndex, BOOL *isClosed)\r
615         {\r
616                 INT result = 0;\r
617                 updateStatus(DllExports::GdipPathIterNextSubpath(\r
618                                 nativePathIterator, &result,\r
619                                 startIndex, endIndex, isClosed));\r
620                 return result;\r
621         }\r
622         INT NextSubpath(GraphicsPath *path, BOOL *isClosed)\r
623         {\r
624                 INT result = 0;\r
625                 updateStatus(DllExports::GdipPathIterNextSubpathPath(\r
626                                 nativePathIterator, &result,\r
627                                 path ? path->nativePath : NULL, isClosed));\r
628                 return result;\r
629         }\r
630         VOID Rewind()\r
631         {\r
632                 updateStatus(DllExports::GdipPathIterRewind(\r
633                                 nativePathIterator));\r
634         }\r
635 \r
636 private:\r
637         GraphicsPathIterator(GpPathIterator *pathIterator, Status status):\r
638                 nativePathIterator(pathIterator), lastStatus(status) {}\r
639         GraphicsPathIterator(const GraphicsPathIterator&);\r
640         GraphicsPathIterator& operator=(const GraphicsPathIterator&);\r
641 \r
642         Status updateStatus(Status newStatus) const\r
643         {\r
644                 if (newStatus != Ok) lastStatus = newStatus;\r
645                 return newStatus;\r
646         }\r
647 \r
648         GpPathIterator *nativePathIterator;\r
649         mutable Status lastStatus;\r
650 };\r
651 \r
652 class PathGradientBrush: public Brush\r
653 {\r
654 public:\r
655         PathGradientBrush(const PointF *points, INT count,\r
656                         WrapMode wrapMode = WrapModeClamp)\r
657         {\r
658                 GpPathGradient *nativePathGradient = NULL;\r
659                 lastStatus = DllExports::GdipCreatePathGradient(\r
660                                 points, count, wrapMode, &nativePathGradient);\r
661                 nativeBrush = nativePathGradient;\r
662         }\r
663         PathGradientBrush(const Point *points, INT count,\r
664                         WrapMode wrapMode = WrapModeClamp)\r
665         {\r
666                 GpPathGradient *nativePathGradient = NULL;\r
667                 lastStatus = DllExports::GdipCreatePathGradientI(\r
668                                 points, count, wrapMode, &nativePathGradient);\r
669                 nativeBrush = nativePathGradient;\r
670         }\r
671         PathGradientBrush(const GraphicsPath *path)\r
672         {\r
673                 GpPathGradient *nativePathGradient = NULL;\r
674                 lastStatus = DllExports::GdipCreatePathGradientFromPath(\r
675                                 path ? path->nativePath : NULL,\r
676                                 &nativePathGradient);\r
677                 nativeBrush = nativePathGradient;\r
678         }\r
679         virtual PathGradientBrush *Clone() const\r
680         {\r
681                 GpBrush *cloneBrush = NULL;\r
682                 Status status = updateStatus(DllExports::GdipCloneBrush(\r
683                                 nativeBrush, &cloneBrush));\r
684                 if (status == Ok) {\r
685                         PathGradientBrush *result =\r
686                                 new PathGradientBrush(cloneBrush, lastStatus);\r
687                         if (!result) {\r
688                                 DllExports::GdipDeleteBrush(cloneBrush);\r
689                                 updateStatus(OutOfMemory);\r
690                         }\r
691                         return result;\r
692                 } else {\r
693                         return NULL;\r
694                 }\r
695         }\r
696 \r
697         Status GetBlend(REAL *blendFactors, REAL *blendPositions,\r
698                         INT count) const\r
699         {\r
700                 return updateStatus(DllExports::GdipGetPathGradientBlend(\r
701                                 (GpPathGradient*) nativeBrush,\r
702                                 blendFactors, blendPositions, count));\r
703         }\r
704         INT GetBlendCount() const\r
705         {\r
706                 INT result = 0;\r
707                 updateStatus(DllExports::GdipGetPathGradientBlendCount(\r
708                                 (GpPathGradient*) nativeBrush, &result));\r
709                 return result;\r
710         }\r
711         Status GetCenterColor(Color *color) const\r
712         {\r
713                 return updateStatus(DllExports::GdipGetPathGradientCenterColor(\r
714                                 (GpPathGradient*) nativeBrush,\r
715                                 color ? &color->Value : NULL));\r
716         }\r
717         Status GetCenterPoint(PointF *point) const\r
718         {\r
719                 return updateStatus(DllExports::GdipGetPathGradientCenterPoint(\r
720                                 (GpPathGradient*) nativeBrush, point));\r
721         }\r
722         Status GetCenterPoint(Point *point) const\r
723         {\r
724                 return updateStatus(DllExports::GdipGetPathGradientCenterPointI(\r
725                                 (GpPathGradient*) nativeBrush, point));\r
726         }\r
727         Status GetFocusScales(REAL *xScale, REAL *yScale) const\r
728         {\r
729                 return updateStatus(DllExports::GdipGetPathGradientFocusScales(\r
730                                 (GpPathGradient*) nativeBrush, xScale, yScale));\r
731         }\r
732         BOOL GetGammaCorrection() const\r
733         {\r
734                 BOOL result = FALSE;\r
735                 updateStatus(DllExports::GdipGetPathGradientGammaCorrection(\r
736                                 (GpPathGradient*) nativeBrush, &result));\r
737                 return result;\r
738         }\r
739         //Status GetGraphicsPath(GraphicsPath *path) const\r
740         //{\r
741         //      // TODO: implement PathGradientBrush::GetGraphicsPath\r
742         //      return updateStatus(NotImplemented);\r
743         //}\r
744         INT GetInterpolationColorCount() const\r
745         {\r
746                 INT result = 0;\r
747                 updateStatus(DllExports::GdipGetPathGradientPresetBlendCount(\r
748                                 (GpPathGradient*) nativeBrush, &result));\r
749                 return result;\r
750         }\r
751         Status GetInterpolationColors(Color *presetColors,\r
752                         REAL *blendPositions, INT count) const\r
753         {\r
754                 if (!presetColors || count <= 0)\r
755                         return lastStatus = InvalidParameter;\r
756 \r
757                 ARGB *presetArgb =\r
758                         (ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));\r
759                 if (!presetArgb)\r
760                         return lastStatus = OutOfMemory;\r
761 \r
762                 Status status = updateStatus(DllExports::GdipGetPathGradientPresetBlend(\r
763                                 (GpPathGradient*) nativeBrush,\r
764                                 presetArgb, blendPositions, count));\r
765                 for (INT i = 0; i < count; ++i) {\r
766                         presetColors[i].SetValue(presetArgb[i]);\r
767                 }\r
768                 DllExports::GdipFree((void*) presetArgb);\r
769                 return status;\r
770         }\r
771         INT GetPointCount() const\r
772         {\r
773                 INT result = 0;\r
774                 updateStatus(DllExports::GdipGetPathGradientPointCount(\r
775                                 (GpPathGradient*) nativeBrush, &result));\r
776                 return result;\r
777         }\r
778         Status GetRectangle(RectF *rect) const\r
779         {\r
780                 return updateStatus(DllExports::GdipGetPathGradientRect(\r
781                                 (GpPathGradient*) nativeBrush, rect));\r
782         }\r
783         Status GetRectangle(Rect *rect) const\r
784         {\r
785                 return updateStatus(DllExports::GdipGetPathGradientRectI(\r
786                                 (GpPathGradient*) nativeBrush, rect));\r
787         }\r
788         INT GetSurroundColorCount() const\r
789         {\r
790                 INT result = 0;\r
791                 updateStatus(DllExports::GdipGetPathGradientSurroundColorCount(\r
792                                 (GpPathGradient*) nativeBrush, &result));\r
793                 return result;\r
794         }\r
795         Status GetSurroundColors(Color *colors, INT *count)\r
796         {\r
797                 if (!colors || !count || *count <= 0)\r
798                         return lastStatus = InvalidParameter;\r
799 \r
800                 ARGB *colorsArgb =\r
801                         (ARGB*) DllExports::GdipAlloc(*count * sizeof(ARGB));\r
802                 if (!colorsArgb)\r
803                         return lastStatus = OutOfMemory;\r
804 \r
805                 Status status = updateStatus(DllExports::GdipGetPathGradientSurroundColorsWithCount(\r
806                                 (GpPathGradient*) nativeBrush,\r
807                                 colorsArgb, count));\r
808                 for (INT i = 0; i < *count; ++i) {\r
809                         colors[i].SetValue(colorsArgb[i]);\r
810                 }\r
811                 DllExports::GdipFree((void*) colorsArgb);\r
812                 return status;\r
813         }\r
814         Status GetTransform(Matrix *matrix) const\r
815         {\r
816                 return updateStatus(DllExports::GdipGetPathGradientTransform(\r
817                                 (GpPathGradient*) nativeBrush,\r
818                                 matrix ? matrix->nativeMatrix : NULL));\r
819         }\r
820         WrapMode GetWrapMode() const\r
821         {\r
822                 WrapMode result = WrapModeTile;\r
823                 updateStatus(DllExports::GdipGetPathGradientWrapMode(\r
824                                 (GpPathGradient*) nativeBrush, &result));\r
825                 return result;\r
826         }\r
827         Status MultiplyTransform(const Matrix *matrix,\r
828                         MatrixOrder order = MatrixOrderPrepend)\r
829         {\r
830                 return updateStatus(DllExports::GdipMultiplyPathGradientTransform(\r
831                                 (GpPathGradient*) nativeBrush,\r
832                                 matrix ? matrix->nativeMatrix : NULL, order));\r
833         }\r
834         Status ResetTransform()\r
835         {\r
836                 return updateStatus(DllExports::GdipResetPathGradientTransform(\r
837                                 (GpPathGradient*) nativeBrush));\r
838         }\r
839         Status RotateTransform(REAL angle,\r
840                         MatrixOrder order = MatrixOrderPrepend)\r
841         {\r
842                 return updateStatus(DllExports::GdipRotatePathGradientTransform(\r
843                                 (GpPathGradient*) nativeBrush, angle, order));\r
844         }\r
845         Status ScaleTransform(REAL sx, REAL sy,\r
846                         MatrixOrder order = MatrixOrderPrepend)\r
847         {\r
848                 return updateStatus(DllExports::GdipScalePathGradientTransform(\r
849                                 (GpPathGradient*) nativeBrush, sx, sy, order));\r
850         }\r
851         Status SetBlend(REAL *blendFactors, REAL *blendPositions, INT count)\r
852         {\r
853                 return updateStatus(DllExports::GdipSetPathGradientBlend(\r
854                                 (GpPathGradient*) nativeBrush,\r
855                                 blendFactors, blendPositions, count));\r
856         }\r
857         Status SetBlendBellShape(REAL focus, REAL scale = 1.0f)\r
858         {\r
859                 return updateStatus(DllExports::GdipSetPathGradientSigmaBlend(\r
860                                 (GpPathGradient*) nativeBrush, focus, scale));\r
861         }\r
862         Status SetBlendTriangularShape(REAL focus, REAL scale = 1.0f)\r
863         {\r
864                 return updateStatus(DllExports::GdipSetPathGradientLinearBlend(\r
865                                 (GpPathGradient*) nativeBrush, focus, scale));\r
866         }\r
867         Status SetCenterColor(const Color& color)\r
868         {\r
869                 return updateStatus(DllExports::GdipSetPathGradientCenterColor(\r
870                                 (GpPathGradient*) nativeBrush,\r
871                                 color.GetValue()));\r
872         }\r
873         Status SetCenterPoint(const PointF& point)\r
874         {\r
875                 return updateStatus(DllExports::GdipSetPathGradientCenterPoint(\r
876                                 (GpPathGradient*) nativeBrush, &point));\r
877         }\r
878         Status SetCenterPoint(const Point& point)\r
879         {\r
880                 return updateStatus(DllExports::GdipSetPathGradientCenterPointI(\r
881                                 (GpPathGradient*) nativeBrush, &point));\r
882         }\r
883         Status SetFocusScales(REAL xScale, REAL yScale)\r
884         {\r
885                 return updateStatus(DllExports::GdipSetPathGradientFocusScales(\r
886                                 (GpPathGradient*) nativeBrush, xScale, yScale));\r
887         }\r
888         Status SetGammaCorrection(BOOL useGammaCorrection)\r
889         {\r
890                 return updateStatus(DllExports::GdipSetPathGradientGammaCorrection(\r
891                                 (GpPathGradient*) nativeBrush,\r
892                                 useGammaCorrection));\r
893         }\r
894         //Status SetGraphicsPath(const GraphicsPath *path)\r
895         //{\r
896         //      // TODO: implement PathGradientBrush::SetGraphicsPath\r
897         //      return updateStatus(NotImplemented);\r
898         //}\r
899         Status SetInterpolationColors(const Color *presetColors,\r
900                         REAL *blendPositions, INT count)\r
901         {\r
902                 if (!presetColors || count <= 0)\r
903                         return lastStatus = InvalidParameter;\r
904 \r
905                 ARGB *presetArgb =\r
906                         (ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));\r
907                 if (!presetArgb)\r
908                         return lastStatus = OutOfMemory;\r
909                 for (INT i = 0; i < count; ++i) {\r
910                         presetArgb[i] = presetColors[i].GetValue();\r
911                 }\r
912 \r
913                 Status status = updateStatus(DllExports::GdipSetPathGradientPresetBlend(\r
914                                 (GpPathGradient*) nativeBrush,\r
915                                 presetArgb, blendPositions, count));\r
916                 DllExports::GdipFree((void*) presetArgb);\r
917                 return status;\r
918         }\r
919         Status SetSurroundColors(const Color *colors, INT *count)\r
920         {\r
921                 if (!colors || !count || *count <= 0)\r
922                         return lastStatus = InvalidParameter;\r
923 \r
924                 ARGB *colorsArgb =\r
925                         (ARGB*) DllExports::GdipAlloc(*count * sizeof(ARGB));\r
926                 if (!colorsArgb)\r
927                         return lastStatus = OutOfMemory;\r
928                 for (INT i = 0; i < *count; ++i) {\r
929                         colorsArgb[i] = colors[i].GetValue();\r
930                 }\r
931 \r
932                 Status status = updateStatus(DllExports::GdipSetPathGradientSurroundColorsWithCount(\r
933                                 (GpPathGradient*) nativeBrush,\r
934                                 colorsArgb, count));\r
935                 DllExports::GdipFree((void*) colorsArgb);\r
936                 return status;\r
937         }\r
938         Status SetTransform(const Matrix *matrix)\r
939         {\r
940                 return updateStatus(DllExports::GdipSetPathGradientTransform(\r
941                                 (GpPathGradient*) nativeBrush,\r
942                                 matrix ? matrix->nativeMatrix : NULL));\r
943         }\r
944         Status SetWrapMode(WrapMode wrapMode)\r
945         {\r
946                 return updateStatus(DllExports::GdipSetPathGradientWrapMode(\r
947                                 (GpPathGradient*) nativeBrush, wrapMode));\r
948         }\r
949         Status TranslateTransform(REAL dx, REAL dy,\r
950                         MatrixOrder order = MatrixOrderPrepend)\r
951         {\r
952                 return updateStatus(DllExports::GdipTranslatePathGradientTransform(\r
953                                 (GpPathGradient*) nativeBrush, dx, dy, order));\r
954         }\r
955 \r
956 private:\r
957         PathGradientBrush(GpBrush *brush, Status status): Brush(brush, status) {}\r
958         PathGradientBrush(const PathGradientBrush&);\r
959         PathGradientBrush& operator=(const PathGradientBrush&);\r
960 };\r
961 \r
962 \r
963 \r
964 #endif /* __GDIPLUS_PATH_H */\r