3 * @copy 2012 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 /* Created by Markus Koenig <markus@stber-koenig.de> */
25 #ifndef __GDIPLUS_PATH_H
26 #define __GDIPLUS_PATH_H
27 #pragma GCC system_header
31 * GDI+ GraphicsPath class
35 #error "A C++ compiler is required to include gdipluspath.h."
38 // Note that some methods of GraphicsPath are implemented in gdiplusimpl.h.
39 // This avoids a cyclic dependency on Graphics and Pen.
41 class GraphicsPath: public GdiplusBase
43 friend class CustomLineCap;
44 friend class Graphics;
45 friend class GraphicsPathIterator;
46 friend class PathGradientBrush;
50 GraphicsPath(FillMode fillMode = FillModeAlternate):
51 nativePath(NULL), lastStatus(Ok)
53 lastStatus = DllExports::GdipCreatePath(fillMode, &nativePath);
55 GraphicsPath(const PointF *points, const BYTE *types, INT count,
56 FillMode fillMode = FillModeAlternate):
57 nativePath(NULL), lastStatus(Ok)
59 lastStatus = DllExports::GdipCreatePath2(
60 points, types, count, fillMode, &nativePath);
62 GraphicsPath(const Point *points, const BYTE *types, INT count,
63 FillMode fillMode = FillModeAlternate):
64 nativePath(NULL), lastStatus(Ok)
66 lastStatus = DllExports::GdipCreatePath2I(
67 points, types, count, fillMode, &nativePath);
71 DllExports::GdipDeletePath(nativePath);
73 GraphicsPath* Clone() const
75 GpPath *clonePath = NULL;
76 Status status = updateStatus(DllExports::GdipClonePath(
77 nativePath, &clonePath));
79 GraphicsPath *result = new GraphicsPath(clonePath, lastStatus);
81 DllExports::GdipDeletePath(clonePath);
82 lastStatus = OutOfMemory;
90 Status AddArc(REAL x, REAL y, REAL width, REAL height,
91 REAL startAngle, REAL sweepAngle)
93 return updateStatus(DllExports::GdipAddPathArc(nativePath,
94 x, y, width, height, startAngle, sweepAngle));
96 Status AddArc(INT x, INT y, INT width, INT height,
97 REAL startAngle, REAL sweepAngle)
99 return updateStatus(DllExports::GdipAddPathArcI(nativePath,
100 x, y, width, height, startAngle, sweepAngle));
102 Status AddArc(const RectF& rect, REAL startAngle, REAL sweepAngle)
104 return updateStatus(DllExports::GdipAddPathArc(nativePath,
105 rect.X, rect.Y, rect.Width, rect.Height,
106 startAngle, sweepAngle));
108 Status AddArc(const Rect& rect, REAL startAngle, REAL sweepAngle)
110 return updateStatus(DllExports::GdipAddPathArcI(nativePath,
111 rect.X, rect.Y, rect.Width, rect.Height,
112 startAngle, sweepAngle));
114 Status AddBezier(REAL x1, REAL y1, REAL x2, REAL y2,
115 REAL x3, REAL y3, REAL x4, REAL y4)
117 return updateStatus(DllExports::GdipAddPathBezier(nativePath,
118 x1, y1, x2, y2, x3, y3, x4, y4));
120 Status AddBezier(INT x1, INT y1, INT x2, INT y2,
121 INT x3, INT y3, INT x4, INT y4)
123 return updateStatus(DllExports::GdipAddPathBezierI(nativePath,
124 x1, y1, x2, y2, x3, y3, x4, y4));
126 Status AddBezier(const PointF& pt1, const PointF& pt2,
127 const PointF& pt3, const PointF& pt4)
129 return updateStatus(DllExports::GdipAddPathBezier(nativePath,
130 pt1.X, pt1.Y, pt2.X, pt2.Y,
131 pt3.X, pt3.Y, pt4.X, pt4.Y));
133 Status AddBezier(const Point& pt1, const Point& pt2,
134 const Point& pt3, const Point& pt4)
136 return updateStatus(DllExports::GdipAddPathBezierI(nativePath,
137 pt1.X, pt1.Y, pt2.X, pt2.Y,
138 pt3.X, pt3.Y, pt4.X, pt4.Y));
140 Status AddBeziers(const PointF *points, INT count)
142 return updateStatus(DllExports::GdipAddPathBeziers(
143 nativePath, points, count));
145 Status AddBeziers(const Point *points, INT count)
147 return updateStatus(DllExports::GdipAddPathBeziersI(
148 nativePath, points, count));
150 Status AddClosedCurve(const PointF *points, INT count)
152 return updateStatus(DllExports::GdipAddPathClosedCurve(
153 nativePath, points, count));
155 Status AddClosedCurve(const Point *points, INT count)
157 return updateStatus(DllExports::GdipAddPathClosedCurveI(
158 nativePath, points, count));
160 Status AddClosedCurve(const PointF *points, INT count, REAL tension)
162 return updateStatus(DllExports::GdipAddPathClosedCurve2(
163 nativePath, points, count, tension));
165 Status AddClosedCurve(const Point *points, INT count, REAL tension)
167 return updateStatus(DllExports::GdipAddPathClosedCurve2I(
168 nativePath, points, count, tension));
170 Status AddCurve(const PointF *points, INT count)
172 return updateStatus(DllExports::GdipAddPathCurve(
173 nativePath, points, count));
175 Status AddCurve(const Point *points, INT count)
177 return updateStatus(DllExports::GdipAddPathCurveI(
178 nativePath, points, count));
180 Status AddCurve(const PointF *points, INT count, REAL tension)
182 return updateStatus(DllExports::GdipAddPathCurve2(
183 nativePath, points, count, tension));
185 Status AddCurve(const Point *points, INT count, REAL tension)
187 return updateStatus(DllExports::GdipAddPathCurve2I(
188 nativePath, points, count, tension));
190 Status AddCurve(const PointF *points, INT count, INT offset,
191 INT numberOfSegments, REAL tension)
193 return updateStatus(DllExports::GdipAddPathCurve3(
194 nativePath, points, count,
195 offset, numberOfSegments, tension));
197 Status AddCurve(const Point *points, INT count, INT offset,
198 INT numberOfSegments, REAL tension)
200 return updateStatus(DllExports::GdipAddPathCurve3I(
201 nativePath, points, count,
202 offset, numberOfSegments, tension));
204 Status AddEllipse(REAL x, REAL y, REAL width, REAL height)
206 return updateStatus(DllExports::GdipAddPathEllipse(nativePath,
207 x, y, width, height));
209 Status AddEllipse(INT x, INT y, INT width, INT height)
211 return updateStatus(DllExports::GdipAddPathEllipseI(nativePath,
212 x, y, width, height));
214 Status AddEllipse(const RectF& rect)
216 return updateStatus(DllExports::GdipAddPathEllipse(nativePath,
217 rect.X, rect.Y, rect.Width, rect.Height));
219 Status AddEllipse(const Rect& rect)
221 return updateStatus(DllExports::GdipAddPathEllipseI(nativePath,
222 rect.X, rect.Y, rect.Width, rect.Height));
224 Status AddLine(REAL x1, REAL y1, REAL x2, REAL y2)
226 return updateStatus(DllExports::GdipAddPathLine(nativePath,
229 Status AddLine(INT x1, INT y1, INT x2, INT y2)
231 return updateStatus(DllExports::GdipAddPathLineI(nativePath,
234 Status AddLine(const PointF& pt1, const PointF& pt2)
236 return updateStatus(DllExports::GdipAddPathLine(nativePath,
237 pt1.X, pt1.Y, pt2.X, pt2.Y));
239 Status AddLine(const Point& pt1, const Point& pt2)
241 return updateStatus(DllExports::GdipAddPathLineI(nativePath,
242 pt1.X, pt1.Y, pt2.X, pt2.Y));
244 Status AddLines(const PointF *points, INT count)
246 return updateStatus(DllExports::GdipAddPathLine2(nativePath,
249 Status AddLines(const Point *points, INT count)
251 return updateStatus(DllExports::GdipAddPathLine2I(nativePath,
254 Status AddPath(const GraphicsPath *addingPath, BOOL connect)
256 return updateStatus(DllExports::GdipAddPathPath(nativePath,
257 addingPath ? addingPath->nativePath : NULL,
260 Status AddPie(REAL x, REAL y, REAL width, REAL height,
261 REAL startAngle, REAL sweepAngle)
263 return updateStatus(DllExports::GdipAddPathPie(nativePath,
264 x, y, width, height, startAngle, sweepAngle));
266 Status AddPie(INT x, INT y, INT width, INT height,
267 REAL startAngle, REAL sweepAngle)
269 return updateStatus(DllExports::GdipAddPathPieI(nativePath,
270 x, y, width, height, startAngle, sweepAngle));
272 Status AddPie(const RectF& rect, REAL startAngle, REAL sweepAngle)
274 return updateStatus(DllExports::GdipAddPathPie(nativePath,
275 rect.X, rect.Y, rect.Width, rect.Height,
276 startAngle, sweepAngle));
278 Status AddPie(const Rect& rect, REAL startAngle, REAL sweepAngle)
280 return updateStatus(DllExports::GdipAddPathPieI(nativePath,
281 rect.X, rect.Y, rect.Width, rect.Height,
282 startAngle, sweepAngle));
284 Status AddPolygon(const PointF *points, INT count)
286 return updateStatus(DllExports::GdipAddPathPolygon(nativePath,
289 Status AddPolygon(const Point *points, INT count)
291 return updateStatus(DllExports::GdipAddPathPolygonI(nativePath,
294 Status AddRectangle(const RectF& rect)
296 return updateStatus(DllExports::GdipAddPathRectangle(nativePath,
297 rect.X, rect.Y, rect.Width, rect.Height));
299 Status AddRectangle(const Rect& rect)
301 return updateStatus(DllExports::GdipAddPathRectangleI(
303 rect.X, rect.Y, rect.Width, rect.Height));
305 Status AddRectangles(const RectF *rects, INT count)
307 return updateStatus(DllExports::GdipAddPathRectangles(
308 nativePath, rects, count));
310 Status AddRectangles(const Rect *rects, INT count)
312 return updateStatus(DllExports::GdipAddPathRectanglesI(
313 nativePath, rects, count));
315 Status AddString(const WCHAR *string, INT length,
316 const FontFamily *family, INT style, REAL emSize,
317 const PointF& origin, const StringFormat *format)
319 RectF layoutRect(origin, SizeF(0.0f, 0.0f));
320 return updateStatus(DllExports::GdipAddPathString(nativePath,
322 family ? family->nativeFontFamily : NULL,
323 style, emSize, &layoutRect,
324 format ? format->nativeStringFormat : NULL));
326 Status AddString(const WCHAR *string, INT length,
327 const FontFamily *family, INT style, REAL emSize,
328 const Point& origin, const StringFormat *format)
330 Rect layoutRect(origin, Size(0, 0));
331 return updateStatus(DllExports::GdipAddPathStringI(nativePath,
333 family ? family->nativeFontFamily : NULL,
334 style, emSize, &layoutRect,
335 format ? format->nativeStringFormat : NULL));
337 Status AddString(const WCHAR *string, INT length,
338 const FontFamily *family, INT style, REAL emSize,
339 const RectF& layoutRect, const StringFormat *format)
341 return updateStatus(DllExports::GdipAddPathString(nativePath,
343 family ? family->nativeFontFamily : NULL,
344 style, emSize, &layoutRect,
345 format ? format->nativeStringFormat : NULL));
347 Status AddString(const WCHAR *string, INT length,
348 const FontFamily *family, INT style, REAL emSize,
349 const Rect& layoutRect, const StringFormat *format)
351 return updateStatus(DllExports::GdipAddPathStringI(nativePath,
353 family ? family->nativeFontFamily : NULL,
354 style, emSize, &layoutRect,
355 format ? format->nativeStringFormat : NULL));
357 Status ClearMarkers()
359 return updateStatus(DllExports::GdipClearPathMarkers(
362 Status CloseAllFigures()
364 return updateStatus(DllExports::GdipClosePathFigures(
369 return updateStatus(DllExports::GdipClosePathFigure(
372 Status Flatten(const Matrix *matrix = NULL,
373 REAL flatness = FlatnessDefault)
375 return updateStatus(DllExports::GdipFlattenPath(nativePath,
376 matrix ? matrix->nativeMatrix : NULL,
379 Status GetBounds(RectF *bounds, const Matrix *matrix = NULL,
380 const Pen *pen = NULL) const
382 return updateStatus(DllExports::GdipGetPathWorldBounds(
384 matrix ? matrix->nativeMatrix : NULL,
385 pen ? pen->nativePen : NULL));
387 Status GetBounds(Rect *bounds, const Matrix *matrix = NULL,
388 const Pen *pen = NULL) const
390 return updateStatus(DllExports::GdipGetPathWorldBoundsI(
392 matrix ? matrix->nativeMatrix : NULL,
393 pen ? pen->nativePen : NULL));
395 FillMode GetFillMode() const
397 FillMode result = FillModeAlternate;
398 updateStatus(DllExports::GdipGetPathFillMode(nativePath,
402 Status GetLastPoint(PointF *lastPoint) const
404 return updateStatus(DllExports::GdipGetPathLastPoint(
405 nativePath, lastPoint));
407 Status GetLastStatus() const
409 Status result = lastStatus;
413 Status GetPathData(PathData *pathData) const
415 if (!pathData) return lastStatus = InvalidParameter;
420 status = updateStatus(DllExports::GdipGetPointCount(
421 nativePath, &count));
422 if (status != Ok) return status;
424 status = updateStatus(pathData->AllocateArrays(count));
425 if (status != Ok) return status;
427 return updateStatus(DllExports::GdipGetPathData(
428 nativePath, (GpPathData*) pathData));
430 Status GetPathPoints(PointF *points, INT count) const
432 return updateStatus(DllExports::GdipGetPathPoints(nativePath,
435 Status GetPathPoints(Point *points, INT count) const
437 return updateStatus(DllExports::GdipGetPathPointsI(nativePath,
440 Status GetPathTypes(BYTE *types, INT count) const
442 return updateStatus(DllExports::GdipGetPathTypes(nativePath,
445 INT GetPointCount() const
448 updateStatus(DllExports::GdipGetPointCount(nativePath,
452 BOOL IsOutlineVisible(REAL x, REAL y, const Pen *pen,
453 const Graphics *g = NULL) const;
454 BOOL IsOutlineVisible(INT x, INT y, const Pen *pen,
455 const Graphics *g = NULL) const;
456 BOOL IsOutlineVisible(const PointF& point, const Pen *pen,
457 const Graphics *g = NULL) const;
458 BOOL IsOutlineVisible(const Point& point, const Pen *pen,
459 const Graphics *g = NULL) const;
460 BOOL IsVisible(REAL x, REAL y, const Graphics *g = NULL) const;
461 BOOL IsVisible(INT x, INT y, const Graphics *g = NULL) const;
462 BOOL IsVisible(const PointF& point, const Graphics *g = NULL) const;
463 BOOL IsVisible(const Point& point, const Graphics *g = NULL) const;
464 Status Outline(const Matrix *matrix = NULL,
465 REAL flatness = FlatnessDefault)
467 return updateStatus(DllExports::GdipWindingModeOutline(
469 matrix ? matrix->nativeMatrix : NULL,
474 return updateStatus(DllExports::GdipResetPath(nativePath));
478 return updateStatus(DllExports::GdipReversePath(nativePath));
480 Status SetFillMode(FillMode fillMode)
482 return updateStatus(DllExports::GdipSetPathFillMode(
483 nativePath, fillMode));
487 return updateStatus(DllExports::GdipSetPathMarker(nativePath));
491 return updateStatus(DllExports::GdipStartPathFigure(
494 Status Transform(const Matrix *matrix)
496 return updateStatus(DllExports::GdipTransformPath(
498 matrix ? matrix->nativeMatrix : NULL));
500 Status Warp(const PointF *destPoints, INT count, const RectF& srcRect,
501 const Matrix *matrix = NULL,
502 WarpMode warpMode = WarpModePerspective,
503 REAL flatness = FlatnessDefault)
505 return updateStatus(DllExports::GdipWarpPath(nativePath,
506 matrix ? matrix->nativeMatrix : NULL,
508 srcRect.X, srcRect.Y,
509 srcRect.Width, srcRect.Height,
510 warpMode, flatness));
512 Status Widen(const Pen *pen, const Matrix *matrix = NULL,
513 REAL flatness = FlatnessDefault)
515 return updateStatus(DllExports::GdipWidenPath(nativePath,
516 pen ? pen->nativePen : NULL,
517 matrix ? matrix->nativeMatrix : NULL,
522 GraphicsPath(GpPath *path, Status status):
523 nativePath(path), lastStatus(status) {}
524 GraphicsPath(const GraphicsPath&);
525 GraphicsPath& operator=(const GraphicsPath&);
527 Status updateStatus(Status newStatus) const
529 if (newStatus != Ok) lastStatus = newStatus;
534 mutable Status lastStatus;
537 class GraphicsPathIterator: public GdiplusBase
540 GraphicsPathIterator(GraphicsPath *path):
541 nativePathIterator(NULL), lastStatus(Ok)
543 lastStatus = DllExports::GdipCreatePathIter(
545 path ? path->nativePath : NULL);
547 ~GraphicsPathIterator()
549 DllExports::GdipDeletePathIter(nativePathIterator);
552 INT CopyData(PointF *points, BYTE *types, INT startIndex, INT endIndex)
555 updateStatus(DllExports::GdipPathIterCopyData(
556 nativePathIterator, &result,
557 points, types, startIndex, endIndex));
560 INT Enumerate(PointF *points, BYTE *types, INT count)
563 updateStatus(DllExports::GdipPathIterEnumerate(
564 nativePathIterator, &result,
565 points, types, count));
571 updateStatus(DllExports::GdipPathIterGetCount(
572 nativePathIterator, &result));
575 Status GetLastStatus() const
577 Status result = lastStatus;
581 INT GetSubpathCount() const
584 updateStatus(DllExports::GdipPathIterGetSubpathCount(
585 nativePathIterator, &result));
588 BOOL HasCurve() const
591 updateStatus(DllExports::GdipPathIterHasCurve(
592 nativePathIterator, &result));
595 INT NextMarker(INT *startIndex, INT *endIndex)
598 updateStatus(DllExports::GdipPathIterNextMarker(
599 nativePathIterator, &result,
600 startIndex, endIndex));
603 INT NextMarker(GraphicsPath *path)
606 updateStatus(DllExports::GdipPathIterNextMarkerPath(
607 nativePathIterator, &result,
608 path ? path->nativePath : NULL));
611 INT NextPathType(BYTE *pathType, INT *startIndex, INT *endIndex)
614 updateStatus(DllExports::GdipPathIterNextPathType(
615 nativePathIterator, &result,
616 pathType, startIndex, endIndex));
619 INT NextSubpath(INT *startIndex, INT *endIndex, BOOL *isClosed)
622 updateStatus(DllExports::GdipPathIterNextSubpath(
623 nativePathIterator, &result,
624 startIndex, endIndex, isClosed));
627 INT NextSubpath(GraphicsPath *path, BOOL *isClosed)
630 updateStatus(DllExports::GdipPathIterNextSubpathPath(
631 nativePathIterator, &result,
632 path ? path->nativePath : NULL, isClosed));
637 updateStatus(DllExports::GdipPathIterRewind(
638 nativePathIterator));
642 GraphicsPathIterator(GpPathIterator *pathIterator, Status status):
643 nativePathIterator(pathIterator), lastStatus(status) {}
644 GraphicsPathIterator(const GraphicsPathIterator&);
645 GraphicsPathIterator& operator=(const GraphicsPathIterator&);
647 Status updateStatus(Status newStatus) const
649 if (newStatus != Ok) lastStatus = newStatus;
653 GpPathIterator *nativePathIterator;
654 mutable Status lastStatus;
657 class PathGradientBrush: public Brush
660 PathGradientBrush(const PointF *points, INT count,
661 WrapMode wrapMode = WrapModeClamp)
663 GpPathGradient *nativePathGradient = NULL;
664 lastStatus = DllExports::GdipCreatePathGradient(
665 points, count, wrapMode, &nativePathGradient);
666 nativeBrush = nativePathGradient;
668 PathGradientBrush(const Point *points, INT count,
669 WrapMode wrapMode = WrapModeClamp)
671 GpPathGradient *nativePathGradient = NULL;
672 lastStatus = DllExports::GdipCreatePathGradientI(
673 points, count, wrapMode, &nativePathGradient);
674 nativeBrush = nativePathGradient;
676 PathGradientBrush(const GraphicsPath *path)
678 GpPathGradient *nativePathGradient = NULL;
679 lastStatus = DllExports::GdipCreatePathGradientFromPath(
680 path ? path->nativePath : NULL,
681 &nativePathGradient);
682 nativeBrush = nativePathGradient;
684 virtual PathGradientBrush *Clone() const
686 GpBrush *cloneBrush = NULL;
687 Status status = updateStatus(DllExports::GdipCloneBrush(
688 nativeBrush, &cloneBrush));
690 PathGradientBrush *result =
691 new PathGradientBrush(cloneBrush, lastStatus);
693 DllExports::GdipDeleteBrush(cloneBrush);
694 updateStatus(OutOfMemory);
702 Status GetBlend(REAL *blendFactors, REAL *blendPositions,
705 return updateStatus(DllExports::GdipGetPathGradientBlend(
706 (GpPathGradient*) nativeBrush,
707 blendFactors, blendPositions, count));
709 INT GetBlendCount() const
712 updateStatus(DllExports::GdipGetPathGradientBlendCount(
713 (GpPathGradient*) nativeBrush, &result));
716 Status GetCenterColor(Color *color) const
718 return updateStatus(DllExports::GdipGetPathGradientCenterColor(
719 (GpPathGradient*) nativeBrush,
720 color ? &color->Value : NULL));
722 Status GetCenterPoint(PointF *point) const
724 return updateStatus(DllExports::GdipGetPathGradientCenterPoint(
725 (GpPathGradient*) nativeBrush, point));
727 Status GetCenterPoint(Point *point) const
729 return updateStatus(DllExports::GdipGetPathGradientCenterPointI(
730 (GpPathGradient*) nativeBrush, point));
732 Status GetFocusScales(REAL *xScale, REAL *yScale) const
734 return updateStatus(DllExports::GdipGetPathGradientFocusScales(
735 (GpPathGradient*) nativeBrush, xScale, yScale));
737 BOOL GetGammaCorrection() const
740 updateStatus(DllExports::GdipGetPathGradientGammaCorrection(
741 (GpPathGradient*) nativeBrush, &result));
744 //Status GetGraphicsPath(GraphicsPath *path) const
746 // // TODO: implement PathGradientBrush::GetGraphicsPath
747 // return updateStatus(NotImplemented);
749 INT GetInterpolationColorCount() const
752 updateStatus(DllExports::GdipGetPathGradientPresetBlendCount(
753 (GpPathGradient*) nativeBrush, &result));
756 Status GetInterpolationColors(Color *presetColors,
757 REAL *blendPositions, INT count) const
759 if (!presetColors || count <= 0)
760 return lastStatus = InvalidParameter;
763 (ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));
765 return lastStatus = OutOfMemory;
767 Status status = updateStatus(DllExports::GdipGetPathGradientPresetBlend(
768 (GpPathGradient*) nativeBrush,
769 presetArgb, blendPositions, count));
770 for (INT i = 0; i < count; ++i) {
771 presetColors[i].SetValue(presetArgb[i]);
773 DllExports::GdipFree((void*) presetArgb);
776 INT GetPointCount() const
779 updateStatus(DllExports::GdipGetPathGradientPointCount(
780 (GpPathGradient*) nativeBrush, &result));
783 Status GetRectangle(RectF *rect) const
785 return updateStatus(DllExports::GdipGetPathGradientRect(
786 (GpPathGradient*) nativeBrush, rect));
788 Status GetRectangle(Rect *rect) const
790 return updateStatus(DllExports::GdipGetPathGradientRectI(
791 (GpPathGradient*) nativeBrush, rect));
793 INT GetSurroundColorCount() const
796 updateStatus(DllExports::GdipGetPathGradientSurroundColorCount(
797 (GpPathGradient*) nativeBrush, &result));
800 Status GetSurroundColors(Color *colors, INT *count)
802 if (!colors || !count || *count <= 0)
803 return lastStatus = InvalidParameter;
806 (ARGB*) DllExports::GdipAlloc(*count * sizeof(ARGB));
808 return lastStatus = OutOfMemory;
810 Status status = updateStatus(DllExports::GdipGetPathGradientSurroundColorsWithCount(
811 (GpPathGradient*) nativeBrush,
813 for (INT i = 0; i < *count; ++i) {
814 colors[i].SetValue(colorsArgb[i]);
816 DllExports::GdipFree((void*) colorsArgb);
819 Status GetTransform(Matrix *matrix) const
821 return updateStatus(DllExports::GdipGetPathGradientTransform(
822 (GpPathGradient*) nativeBrush,
823 matrix ? matrix->nativeMatrix : NULL));
825 WrapMode GetWrapMode() const
827 WrapMode result = WrapModeTile;
828 updateStatus(DllExports::GdipGetPathGradientWrapMode(
829 (GpPathGradient*) nativeBrush, &result));
832 Status MultiplyTransform(const Matrix *matrix,
833 MatrixOrder order = MatrixOrderPrepend)
835 return updateStatus(DllExports::GdipMultiplyPathGradientTransform(
836 (GpPathGradient*) nativeBrush,
837 matrix ? matrix->nativeMatrix : NULL, order));
839 Status ResetTransform()
841 return updateStatus(DllExports::GdipResetPathGradientTransform(
842 (GpPathGradient*) nativeBrush));
844 Status RotateTransform(REAL angle,
845 MatrixOrder order = MatrixOrderPrepend)
847 return updateStatus(DllExports::GdipRotatePathGradientTransform(
848 (GpPathGradient*) nativeBrush, angle, order));
850 Status ScaleTransform(REAL sx, REAL sy,
851 MatrixOrder order = MatrixOrderPrepend)
853 return updateStatus(DllExports::GdipScalePathGradientTransform(
854 (GpPathGradient*) nativeBrush, sx, sy, order));
856 Status SetBlend(REAL *blendFactors, REAL *blendPositions, INT count)
858 return updateStatus(DllExports::GdipSetPathGradientBlend(
859 (GpPathGradient*) nativeBrush,
860 blendFactors, blendPositions, count));
862 Status SetBlendBellShape(REAL focus, REAL scale = 1.0f)
864 return updateStatus(DllExports::GdipSetPathGradientSigmaBlend(
865 (GpPathGradient*) nativeBrush, focus, scale));
867 Status SetBlendTriangularShape(REAL focus, REAL scale = 1.0f)
869 return updateStatus(DllExports::GdipSetPathGradientLinearBlend(
870 (GpPathGradient*) nativeBrush, focus, scale));
872 Status SetCenterColor(const Color& color)
874 return updateStatus(DllExports::GdipSetPathGradientCenterColor(
875 (GpPathGradient*) nativeBrush,
878 Status SetCenterPoint(const PointF& point)
880 return updateStatus(DllExports::GdipSetPathGradientCenterPoint(
881 (GpPathGradient*) nativeBrush, &point));
883 Status SetCenterPoint(const Point& point)
885 return updateStatus(DllExports::GdipSetPathGradientCenterPointI(
886 (GpPathGradient*) nativeBrush, &point));
888 Status SetFocusScales(REAL xScale, REAL yScale)
890 return updateStatus(DllExports::GdipSetPathGradientFocusScales(
891 (GpPathGradient*) nativeBrush, xScale, yScale));
893 Status SetGammaCorrection(BOOL useGammaCorrection)
895 return updateStatus(DllExports::GdipSetPathGradientGammaCorrection(
896 (GpPathGradient*) nativeBrush,
897 useGammaCorrection));
899 //Status SetGraphicsPath(const GraphicsPath *path)
901 // // TODO: implement PathGradientBrush::SetGraphicsPath
902 // return updateStatus(NotImplemented);
904 Status SetInterpolationColors(const Color *presetColors,
905 REAL *blendPositions, INT count)
907 if (!presetColors || count <= 0)
908 return lastStatus = InvalidParameter;
911 (ARGB*) DllExports::GdipAlloc(count * sizeof(ARGB));
913 return lastStatus = OutOfMemory;
914 for (INT i = 0; i < count; ++i) {
915 presetArgb[i] = presetColors[i].GetValue();
918 Status status = updateStatus(DllExports::GdipSetPathGradientPresetBlend(
919 (GpPathGradient*) nativeBrush,
920 presetArgb, blendPositions, count));
921 DllExports::GdipFree((void*) presetArgb);
924 Status SetSurroundColors(const Color *colors, INT *count)
926 if (!colors || !count || *count <= 0)
927 return lastStatus = InvalidParameter;
930 (ARGB*) DllExports::GdipAlloc(*count * sizeof(ARGB));
932 return lastStatus = OutOfMemory;
933 for (INT i = 0; i < *count; ++i) {
934 colorsArgb[i] = colors[i].GetValue();
937 Status status = updateStatus(DllExports::GdipSetPathGradientSurroundColorsWithCount(
938 (GpPathGradient*) nativeBrush,
940 DllExports::GdipFree((void*) colorsArgb);
943 Status SetTransform(const Matrix *matrix)
945 return updateStatus(DllExports::GdipSetPathGradientTransform(
946 (GpPathGradient*) nativeBrush,
947 matrix ? matrix->nativeMatrix : NULL));
949 Status SetWrapMode(WrapMode wrapMode)
951 return updateStatus(DllExports::GdipSetPathGradientWrapMode(
952 (GpPathGradient*) nativeBrush, wrapMode));
954 Status TranslateTransform(REAL dx, REAL dy,
955 MatrixOrder order = MatrixOrderPrepend)
957 return updateStatus(DllExports::GdipTranslatePathGradientTransform(
958 (GpPathGradient*) nativeBrush, dx, dy, order));
962 PathGradientBrush(GpBrush *brush, Status status): Brush(brush, status) {}
963 PathGradientBrush(const PathGradientBrush&);
964 PathGradientBrush& operator=(const PathGradientBrush&);
969 #endif /* __GDIPLUS_PATH_H */