OSDN Git Service

d8425e0725fc0aebeb85bb47b945aa4e3f7700c4
[mingw/mingw-org-wsl.git] / include / gdiplus / gdiplusgraphics.h
1 /**
2  * @file gdiplusgraphics.h
3  * @copy 2012 MinGW.org project
4  *
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:
11  * 
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
14  * Software.
15  * 
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.
23  */
24 #ifndef __GDIPLUS_GRAPHICS_H
25 #define __GDIPLUS_GRAPHICS_H
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 /*
30  * GDI+ Graphics class
31  */
32
33 #ifndef __cplusplus
34 #error "A C++ compiler is required to include gdiplusgraphics.h."
35 #endif
36
37 class Graphics: public GdiplusBase
38 {
39         friend class Bitmap;
40         friend class CachedBitmap;
41         friend class Font;
42         friend class GraphicsPath;
43         friend class Metafile;
44         friend class Region;
45
46 public:
47         static Graphics* FromHDC(HDC hdc)
48         {
49                 return new Graphics(hdc);
50         }
51         static Graphics* FromHDC(HDC hdc, HANDLE hdevice)
52         {
53                 return new Graphics(hdc, hdevice);
54         }
55         static Graphics* FromHWND(HWND hwnd, BOOL icm = FALSE)
56         {
57                 return new Graphics(hwnd, icm);
58         }
59         static Graphics* FromImage(Image *image)
60         {
61                 return new Graphics(image);
62         }
63         static HPALETTE GetHalftonePalette()
64         {
65                 return DllExports::GdipCreateHalftonePalette();
66         }
67
68         Graphics(Image *image): nativeGraphics(NULL), lastStatus(Ok)
69         {
70                 lastStatus = DllExports::GdipGetImageGraphicsContext(
71                                 image ? image->nativeImage : NULL,
72                                 &nativeGraphics);
73         }
74         Graphics(HDC hdc): nativeGraphics(NULL), lastStatus(Ok)
75         {
76                 lastStatus = DllExports::GdipCreateFromHDC(
77                                 hdc, &nativeGraphics);
78         }
79         Graphics(HDC hdc, HANDLE hdevice): nativeGraphics(NULL), lastStatus(Ok)
80         {
81                 lastStatus = DllExports::GdipCreateFromHDC2(
82                                 hdc, hdevice, &nativeGraphics);
83         }
84         Graphics(HWND hwnd, BOOL icm = FALSE):
85                 nativeGraphics(NULL), lastStatus(Ok)
86         {
87                 if (icm) {
88                         lastStatus = DllExports::GdipCreateFromHWNDICM(
89                                         hwnd, &nativeGraphics);
90                 } else {
91                         lastStatus = DllExports::GdipCreateFromHWND(
92                                         hwnd, &nativeGraphics);
93                 }
94         }
95         ~Graphics()
96         {
97                 DllExports::GdipDeleteGraphics(nativeGraphics);
98         }
99
100         Status AddMetafileComment(const BYTE *data, UINT sizeData)
101         {
102                 return updateStatus(DllExports::GdipComment(
103                                 nativeGraphics, sizeData, data));
104         }
105         GraphicsContainer BeginContainer()
106         {
107                 GraphicsContainer result = 0;
108                 updateStatus(DllExports::GdipBeginContainer2(
109                                 nativeGraphics, &result));
110                 return result;
111         }
112         GraphicsContainer BeginContainer(const RectF& dstrect,
113                         const RectF& srcrect, Unit unit)
114         {
115                 GraphicsContainer result = 0;
116                 updateStatus(DllExports::GdipBeginContainer(
117                                 nativeGraphics, &dstrect, &srcrect, unit,
118                                 &result));
119                 return result;
120         }
121         GraphicsContainer BeginContainer(const Rect& dstrect,
122                         const Rect& srcrect, Unit unit)
123         {
124                 GraphicsContainer result = 0;
125                 updateStatus(DllExports::GdipBeginContainerI(
126                                 nativeGraphics, &dstrect, &srcrect, unit,
127                                 &result));
128                 return result;
129         }
130         Status Clear(const Color& color)
131         {
132                 return updateStatus(DllExports::GdipGraphicsClear(
133                                 nativeGraphics, color.GetValue()));
134         }
135         Status DrawArc(const Pen *pen, REAL x, REAL y, REAL width, REAL height,
136                         REAL startAngle, REAL sweepAngle)
137         {
138                 return updateStatus(DllExports::GdipDrawArc(
139                                 nativeGraphics, pen ? pen->nativePen : NULL,
140                                 x, y, width, height, startAngle, sweepAngle));
141         }
142         Status DrawArc(const Pen *pen, INT x, INT y, INT width, INT height,
143                         REAL startAngle, REAL sweepAngle)
144         {
145                 return updateStatus(DllExports::GdipDrawArcI(
146                                 nativeGraphics, pen ? pen->nativePen : NULL,
147                                 x, y, width, height, startAngle, sweepAngle));
148         }
149         Status DrawArc(const Pen *pen, const RectF& rect,
150                         REAL startAngle, REAL sweepAngle)
151         {
152                 return updateStatus(DllExports::GdipDrawArc(
153                                 nativeGraphics, pen ? pen->nativePen : NULL,
154                                 rect.X, rect.Y, rect.Width, rect.Height,
155                                 startAngle, sweepAngle));
156         }
157         Status DrawArc(const Pen *pen, const Rect& rect,
158                         REAL startAngle, REAL sweepAngle)
159         {
160                 return updateStatus(DllExports::GdipDrawArcI(
161                                 nativeGraphics, pen ? pen->nativePen : NULL,
162                                 rect.X, rect.Y, rect.Width, rect.Height,
163                                 startAngle, sweepAngle));
164         }
165         Status DrawBezier(const Pen *pen,
166                         REAL x1, REAL y1, REAL x2, REAL y2,
167                         REAL x3, REAL y3, REAL x4, REAL y4)
168         {
169                 return updateStatus(DllExports::GdipDrawBezier(
170                                 nativeGraphics, pen ? pen->nativePen : NULL,
171                                 x1, y1, x2, y2, x3, y3, x4, y4));
172         }
173         Status DrawBezier(const Pen *pen,
174                         INT x1, INT y1, INT x2, INT y2,
175                         INT x3, INT y3, INT x4, INT y4)
176         {
177                 return updateStatus(DllExports::GdipDrawBezierI(
178                                 nativeGraphics, pen ? pen->nativePen : NULL,
179                                 x1, y1, x2, y2, x3, y3, x4, y4));
180         }
181         Status DrawBezier(const Pen *pen,
182                         const PointF& pt1, const PointF& pt2,
183                         const PointF& pt3, const PointF& pt4)
184         {
185                 return updateStatus(DllExports::GdipDrawBezier(
186                                 nativeGraphics, pen ? pen->nativePen : NULL,
187                                 pt1.X, pt1.Y, pt2.X, pt2.Y,
188                                 pt3.X, pt3.Y, pt4.X, pt4.Y));
189         }
190         Status DrawBezier(const Pen *pen,
191                         const Point& pt1, const Point& pt2,
192                         const Point& pt3, const Point& pt4)
193         {
194                 return updateStatus(DllExports::GdipDrawBezierI(
195                                 nativeGraphics, pen ? pen->nativePen : NULL,
196                                 pt1.X, pt1.Y, pt2.X, pt2.Y,
197                                 pt3.X, pt3.Y, pt4.X, pt4.Y));
198         }
199         Status DrawBeziers(const Pen *pen, const PointF *points, INT count)
200         {
201                 return updateStatus(DllExports::GdipDrawBeziers(
202                                 nativeGraphics, pen ? pen->nativePen : NULL,
203                                 points, count));
204         }
205         Status DrawBeziers(const Pen *pen, const Point *points, INT count)
206         {
207                 return updateStatus(DllExports::GdipDrawBeziersI(
208                                 nativeGraphics, pen ? pen->nativePen : NULL,
209                                 points, count));
210         }
211         Status DrawCachedBitmap(CachedBitmap *cb, INT x, INT y)
212         {
213                 return updateStatus(DllExports::GdipDrawCachedBitmap(
214                                 nativeGraphics,
215                                 cb ? cb->nativeCachedBitmap : NULL,
216                                 x, y));
217         }
218         Status DrawClosedCurve(const Pen *pen, const PointF *points, INT count)
219         {
220                 return updateStatus(DllExports::GdipDrawClosedCurve(
221                                 nativeGraphics, pen ? pen->nativePen : NULL,
222                                 points, count));
223         }
224         Status DrawClosedCurve(const Pen *pen, const Point *points, INT count)
225         {
226                 return updateStatus(DllExports::GdipDrawClosedCurveI(
227                                 nativeGraphics, pen ? pen->nativePen : NULL,
228                                 points, count));
229         }
230         Status DrawClosedCurve(const Pen *pen, const PointF *points, INT count,
231                         REAL tension)
232         {
233                 return updateStatus(DllExports::GdipDrawClosedCurve2(
234                                 nativeGraphics, pen ? pen->nativePen : NULL,
235                                 points, count, tension));
236         }
237         Status DrawClosedCurve(const Pen *pen, const Point *points, INT count,
238                         REAL tension)
239         {
240                 return updateStatus(DllExports::GdipDrawClosedCurve2I(
241                                 nativeGraphics, pen ? pen->nativePen : NULL,
242                                 points, count, tension));
243         }
244         Status DrawCurve(const Pen *pen, const PointF *points, INT count)
245         {
246                 return updateStatus(DllExports::GdipDrawCurve(
247                                 nativeGraphics, pen ? pen->nativePen : NULL,
248                                 points, count));
249         }
250         Status DrawCurve(const Pen *pen, const Point *points, INT count)
251         {
252                 return updateStatus(DllExports::GdipDrawCurveI(
253                                 nativeGraphics, pen ? pen->nativePen : NULL,
254                                 points, count));
255         }
256         Status DrawCurve(const Pen *pen, const PointF *points, INT count,
257                         REAL tension)
258         {
259                 return updateStatus(DllExports::GdipDrawCurve2(
260                                 nativeGraphics, pen ? pen->nativePen : NULL,
261                                 points, count, tension));
262         }
263         Status DrawCurve(const Pen *pen, const Point *points, INT count,
264                         REAL tension)
265         {
266                 return updateStatus(DllExports::GdipDrawCurve2I(
267                                 nativeGraphics, pen ? pen->nativePen : NULL,
268                                 points, count, tension));
269         }
270         Status DrawCurve(const Pen *pen, const PointF *points, INT count,
271                         INT offset, INT numberOfSegments, REAL tension)
272         {
273                 return updateStatus(DllExports::GdipDrawCurve3(
274                                 nativeGraphics, pen ? pen->nativePen : NULL,
275                                 points, count, offset,
276                                 numberOfSegments, tension));
277         }
278         Status DrawCurve(const Pen *pen, const Point *points, INT count,
279                         INT offset, INT numberOfSegments, REAL tension)
280         {
281                 return updateStatus(DllExports::GdipDrawCurve3I(
282                                 nativeGraphics, pen ? pen->nativePen : NULL,
283                                 points, count, offset,
284                                 numberOfSegments, tension));
285         }
286         Status DrawDriverString(const UINT16 *text, INT length,
287                         const Font *font, const Brush *brush,
288                         const PointF *positions, INT flags,
289                         const Matrix *matrix)
290         {
291                 return updateStatus(DllExports::GdipDrawDriverString(
292                                 nativeGraphics, text, length,
293                                 font ? font->nativeFont : NULL,
294                                 brush ? brush->nativeBrush : NULL,
295                                 positions, flags,
296                                 matrix ? matrix->nativeMatrix : NULL));
297         }
298         Status DrawEllipse(const Pen *pen,
299                         REAL x, REAL y, REAL width, REAL height)
300         {
301                 return updateStatus(DllExports::GdipDrawEllipse(
302                                 nativeGraphics, pen ? pen->nativePen : NULL,
303                                 x, y, width, height));
304         }
305         Status DrawEllipse(const Pen *pen, INT x, INT y, INT width, INT height)
306         {
307                 return updateStatus(DllExports::GdipDrawEllipseI(
308                                 nativeGraphics, pen ? pen->nativePen : NULL,
309                                 x, y, width, height));
310         }
311         Status DrawEllipse(const Pen *pen, const RectF& rect)
312         {
313                 return updateStatus(DllExports::GdipDrawEllipse(
314                                 nativeGraphics, pen ? pen->nativePen : NULL,
315                                 rect.X, rect.Y, rect.Width, rect.Height));
316         }
317         Status DrawEllipse(const Pen *pen, const Rect& rect)
318         {
319                 return updateStatus(DllExports::GdipDrawEllipseI(
320                                 nativeGraphics, pen ? pen->nativePen : NULL,
321                                 rect.X, rect.Y, rect.Width, rect.Height));
322         }
323         Status DrawImage(Image *image, REAL x, REAL y)
324         {
325                 return updateStatus(DllExports::GdipDrawImage(
326                                 nativeGraphics,
327                                 image ? image->nativeImage : NULL,
328                                 x, y));
329         }
330         Status DrawImage(Image *image, INT x, INT y)
331         {
332                 return updateStatus(DllExports::GdipDrawImageI(
333                                 nativeGraphics,
334                                 image ? image->nativeImage : NULL,
335                                 x, y));
336         }
337         Status DrawImage(Image *image, const PointF& point)
338         {
339                 return updateStatus(DllExports::GdipDrawImage(
340                                 nativeGraphics,
341                                 image ? image->nativeImage : NULL,
342                                 point.X, point.Y));
343         }
344         Status DrawImage(Image *image, const Point& point)
345         {
346                 return updateStatus(DllExports::GdipDrawImageI(
347                                 nativeGraphics,
348                                 image ? image->nativeImage : NULL,
349                                 point.X, point.Y));
350         }
351         Status DrawImage(Image *image, REAL x, REAL y, REAL width, REAL height)
352         {
353                 return updateStatus(DllExports::GdipDrawImageRect(
354                                 nativeGraphics,
355                                 image ? image->nativeImage : NULL,
356                                 x, y, width, height));
357         }
358         Status DrawImage(Image *image, INT x, INT y, INT width, INT height)
359         {
360                 return updateStatus(DllExports::GdipDrawImageRectI(
361                                 nativeGraphics,
362                                 image ? image->nativeImage : NULL,
363                                 x, y, width, height));
364         }
365         Status DrawImage(Image *image, const RectF& rect)
366         {
367                 return updateStatus(DllExports::GdipDrawImageRect(
368                                 nativeGraphics,
369                                 image ? image->nativeImage : NULL,
370                                 rect.X, rect.Y, rect.Width, rect.Height));
371         }
372         Status DrawImage(Image *image, const Rect& rect)
373         {
374                 return updateStatus(DllExports::GdipDrawImageRectI(
375                                 nativeGraphics,
376                                 image ? image->nativeImage : NULL,
377                                 rect.X, rect.Y, rect.Width, rect.Height));
378         }
379         Status DrawImage(Image *image, const PointF *destPoints, INT count)
380         {
381                 return updateStatus(DllExports::GdipDrawImagePoints(
382                                 nativeGraphics,
383                                 image ? image->nativeImage : NULL,
384                                 destPoints, count));
385         }
386         Status DrawImage(Image *image, const Point *destPoints, INT count)
387         {
388                 return updateStatus(DllExports::GdipDrawImagePointsI(
389                                 nativeGraphics,
390                                 image ? image->nativeImage : NULL,
391                                 destPoints, count));
392         }
393         Status DrawImage(Image *image, REAL x, REAL y, REAL srcx, REAL srcy,
394                         REAL srcwidth, REAL srcheight, Unit srcUnit)
395         {
396                 return updateStatus(DllExports::GdipDrawImagePointRect(
397                                 nativeGraphics,
398                                 image ? image->nativeImage : NULL,
399                                 x, y, srcx, srcy, srcwidth, srcheight,
400                                 srcUnit));
401         }
402         Status DrawImage(Image *image, INT x, INT y, INT srcx, INT srcy,
403                         INT srcwidth, INT srcheight, Unit srcUnit)
404         {
405                 return updateStatus(DllExports::GdipDrawImagePointRectI(
406                                 nativeGraphics,
407                                 image ? image->nativeImage : NULL,
408                                 x, y, srcx, srcy, srcwidth, srcheight,
409                                 srcUnit));
410         }
411         Status DrawImage(Image *image, const RectF& destRect,
412                         REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight,
413                         Unit srcUnit,
414                         const ImageAttributes *imageAttributes = NULL,
415                         DrawImageAbort callback = NULL,
416                         VOID *callbackData = NULL)
417         {
418                 return updateStatus(DllExports::GdipDrawImageRectRect(
419                                 nativeGraphics,
420                                 image ? image->nativeImage : NULL,
421                                 destRect.X, destRect.Y,
422                                 destRect.Width, destRect.Height,
423                                 srcx, srcy, srcwidth, srcheight, srcUnit,
424                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
425                                 callback, callbackData));
426         }
427         Status DrawImage(Image *image, const Rect& destRect,
428                         INT srcx, INT srcy, INT srcwidth, INT srcheight,
429                         Unit srcUnit,
430                         const ImageAttributes *imageAttributes = NULL,
431                         DrawImageAbort callback = NULL,
432                         VOID *callbackData = NULL)
433         {
434                 return updateStatus(DllExports::GdipDrawImageRectRectI(
435                                 nativeGraphics,
436                                 image ? image->nativeImage : NULL,
437                                 destRect.X, destRect.Y,
438                                 destRect.Width, destRect.Height,
439                                 srcx, srcy, srcwidth, srcheight, srcUnit,
440                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
441                                 callback, callbackData));
442         }
443         Status DrawImage(Image *image, const RectF& destRect,
444                         const RectF& sourceRect, Unit srcUnit,
445                         const ImageAttributes *imageAttributes = NULL)
446         {
447                 return updateStatus(DllExports::GdipDrawImageRectRectI(
448                                 nativeGraphics,
449                                 image ? image->nativeImage : NULL,
450                                 destRect.X, destRect.Y,
451                                 destRect.Width, destRect.Height,
452                                 sourceRect.X, sourceRect.Y,
453                                 sourceRect.Width, sourceRect.Height, srcUnit,
454                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
455                                 NULL, NULL));
456         }
457         Status DrawImage(Image *image, const PointF *destPoints, INT count,
458                         REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight,
459                         Unit srcUnit,
460                         const ImageAttributes *imageAttributes = NULL,
461                         DrawImageAbort callback = NULL,
462                         VOID *callbackData = NULL)
463         {
464                 return updateStatus(DllExports::GdipDrawImagePointsRect(
465                                 nativeGraphics,
466                                 image ? image->nativeImage : NULL,
467                                 destPoints, count,
468                                 srcx, srcy, srcwidth, srcheight, srcUnit,
469                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
470                                 callback, callbackData));
471         }
472         Status DrawImage(Image *image, const Point *destPoints, INT count,
473                         INT srcx, INT srcy, INT srcwidth, INT srcheight,
474                         Unit srcUnit,
475                         const ImageAttributes *imageAttributes = NULL,
476                         DrawImageAbort callback = NULL,
477                         VOID *callbackData = NULL)
478         {
479                 return updateStatus(DllExports::GdipDrawImagePointsRectI(
480                                 nativeGraphics,
481                                 image ? image->nativeImage : NULL,
482                                 destPoints, count,
483                                 srcx, srcy, srcwidth, srcheight, srcUnit,
484                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
485                                 callback, callbackData));
486         }
487         // TODO: [GDI+ 1.1] Graphics::DrawImage(..Effect..)
488         //Status DrawImage(Image *image, RectF *sourceRect, Matrix *matrix,
489         //              Effect *effect, ImageAttributes *imageAttributes,
490         //              Unit srcUnit)
491         //{
492         //      return updateStatus(DllExports::GdipDrawImageFX(
493         //                      nativeGraphics,
494         //                      image ? image->nativeImage : NULL,
495         //                      sourceRect,
496         //                      matrix ? matrix->nativeMatrix : NULL,
497         //                      effect ? effect->nativeEffect : NULL,
498         //                      imageAttributes ? imageAttributes->nativeImageAttributes : NULL,
499         //                      srcUnit));
500         //}
501         Status DrawLine(const Pen *pen, REAL x1, REAL y1, REAL x2, REAL y2)
502         {
503                 return updateStatus(DllExports::GdipDrawLine(
504                                 nativeGraphics, pen ? pen->nativePen : NULL,
505                                 x1, y1, x2, y2));
506         }
507         Status DrawLine(const Pen *pen, INT x1, INT y1, INT x2, INT y2)
508         {
509                 return updateStatus(DllExports::GdipDrawLineI(
510                                 nativeGraphics, pen ? pen->nativePen : NULL,
511                                 x1, y1, x2, y2));
512         }
513         Status DrawLine(const Pen *pen, const PointF& pt1, const PointF& pt2)
514         {
515                 return updateStatus(DllExports::GdipDrawLine(
516                                 nativeGraphics, pen ? pen->nativePen : NULL,
517                                 pt1.X, pt1.Y, pt2.X, pt2.Y));
518         }
519         Status DrawLine(const Pen *pen, const Point& pt1, const Point& pt2)
520         {
521                 return updateStatus(DllExports::GdipDrawLineI(
522                                 nativeGraphics, pen ? pen->nativePen : NULL,
523                                 pt1.X, pt1.Y, pt2.X, pt2.Y));
524         }
525         Status DrawLines(const Pen *pen, const PointF *points, INT count)
526         {
527                 return updateStatus(DllExports::GdipDrawLines(
528                                 nativeGraphics, pen ? pen->nativePen : NULL,
529                                 points, count));
530         }
531         Status DrawLines(const Pen *pen, const Point *points, INT count)
532         {
533                 return updateStatus(DllExports::GdipDrawLinesI(
534                                 nativeGraphics, pen ? pen->nativePen : NULL,
535                                 points, count));
536         }
537         Status DrawPath(const Pen *pen, const GraphicsPath *path)
538         {
539                 return updateStatus(DllExports::GdipDrawPath(
540                                 nativeGraphics, pen ? pen->nativePen : NULL,
541                                 path ? path->nativePath : NULL));
542         }
543         Status DrawPie(const Pen *pen, REAL x, REAL y, REAL width, REAL height,
544                         REAL startAngle, REAL sweepAngle)
545         {
546                 return updateStatus(DllExports::GdipDrawPie(
547                                 nativeGraphics, pen ? pen->nativePen : NULL,
548                                 x, y, width, height, startAngle, sweepAngle));
549         }
550         Status DrawPie(const Pen *pen, INT x, INT y, INT width, INT height,
551                         REAL startAngle, REAL sweepAngle)
552         {
553                 return updateStatus(DllExports::GdipDrawPieI(
554                                 nativeGraphics, pen ? pen->nativePen : NULL,
555                                 x, y, width, height, startAngle, sweepAngle));
556         }
557         Status DrawPie(const Pen *pen, const RectF& rect,
558                         REAL startAngle, REAL sweepAngle)
559         {
560                 return updateStatus(DllExports::GdipDrawPie(
561                                 nativeGraphics, pen ? pen->nativePen : NULL,
562                                 rect.X, rect.Y, rect.Width, rect.Height,
563                                 startAngle, sweepAngle));
564         }
565         Status DrawPie(const Pen *pen, const Rect& rect,
566                         REAL startAngle, REAL sweepAngle)
567         {
568                 return updateStatus(DllExports::GdipDrawPieI(
569                                 nativeGraphics, pen ? pen->nativePen : NULL,
570                                 rect.X, rect.Y, rect.Width, rect.Height,
571                                 startAngle, sweepAngle));
572         }
573         Status DrawPolygon(const Pen *pen, const PointF *points, INT count)
574         {
575                 return updateStatus(DllExports::GdipDrawPolygon(
576                                 nativeGraphics, pen ? pen->nativePen : NULL,
577                                 points, count));
578         }
579         Status DrawPolygon(const Pen *pen, const Point *points, INT count)
580         {
581                 return updateStatus(DllExports::GdipDrawPolygonI(
582                                 nativeGraphics, pen ? pen->nativePen : NULL,
583                                 points, count));
584         }
585         Status DrawRectangle(const Pen *pen,
586                         REAL x, REAL y, REAL width, REAL height)
587         {
588                 return updateStatus(DllExports::GdipDrawRectangle(
589                                 nativeGraphics, pen ? pen->nativePen : NULL,
590                                 x, y, width, height));
591         }
592         Status DrawRectangle(const Pen *pen,
593                         INT x, INT y, INT width, INT height)
594         {
595                 return updateStatus(DllExports::GdipDrawRectangleI(
596                                 nativeGraphics, pen ? pen->nativePen : NULL,
597                                 x, y, width, height));
598         }
599         Status DrawRectangle(const Pen *pen, const RectF& rect)
600         {
601                 return updateStatus(DllExports::GdipDrawRectangle(
602                                 nativeGraphics, pen ? pen->nativePen : NULL,
603                                 rect.X, rect.Y, rect.Width, rect.Height));
604         }
605         Status DrawRectangle(const Pen *pen, const Rect& rect)
606         {
607                 return updateStatus(DllExports::GdipDrawRectangleI(
608                                 nativeGraphics, pen ? pen->nativePen : NULL,
609                                 rect.X, rect.Y, rect.Width, rect.Height));
610         }
611         Status DrawRectangles(const Pen *pen, const RectF *rects, INT count)
612         {
613                 return updateStatus(DllExports::GdipDrawRectangles(
614                                 nativeGraphics, pen ? pen->nativePen : NULL,
615                                 rects, count));
616         }
617         Status DrawRectangles(const Pen *pen, const Rect *rects, INT count)
618         {
619                 return updateStatus(DllExports::GdipDrawRectanglesI(
620                                 nativeGraphics, pen ? pen->nativePen : NULL,
621                                 rects, count));
622         }
623         Status DrawString(const WCHAR *string, INT length, const Font *font,
624                         const PointF& origin, const Brush *brush)
625         {
626                 RectF layoutRect(origin.X, origin.Y, 0.0f, 0.0f);
627                 return updateStatus(DllExports::GdipDrawString(
628                                 nativeGraphics, string, length,
629                                 font ? font->nativeFont : NULL,
630                                 &layoutRect, NULL,
631                                 brush ? brush->nativeBrush : NULL));
632         }
633         Status DrawString(const WCHAR *string, INT length,
634                         const Font *font, const PointF& origin,
635                         const StringFormat *stringFormat, const Brush *brush)
636         {
637                 RectF layoutRect(origin.X, origin.Y, 0.0f, 0.0f);
638                 return updateStatus(DllExports::GdipDrawString(
639                                 nativeGraphics, string, length,
640                                 font ? font->nativeFont : NULL,
641                                 &layoutRect,
642                                 stringFormat ? stringFormat->nativeStringFormat : NULL,
643                                 brush ? brush->nativeBrush : NULL));
644         }
645         Status DrawString(const WCHAR *string, INT length,
646                         const Font *font, const RectF& layoutRect,
647                         const StringFormat *stringFormat, const Brush *brush)
648         {
649                 return updateStatus(DllExports::GdipDrawString(
650                                 nativeGraphics, string, length,
651                                 font ? font->nativeFont : NULL,
652                                 &layoutRect,
653                                 stringFormat ? stringFormat->nativeStringFormat : NULL,
654                                 brush ? brush->nativeBrush : NULL));
655         }
656         Status EndContainer(GraphicsContainer state)
657         {
658                 return updateStatus(DllExports::GdipEndContainer(
659                                 nativeGraphics, state));
660         }
661         Status EnumerateMetafile(const Metafile *metafile,
662                         const PointF& destPoint,
663                         EnumerateMetafileProc callback,
664                         VOID *callbackData = NULL,
665                         ImageAttributes *imageAttributes = NULL)
666         {
667                 return updateStatus(DllExports::GdipEnumerateMetafileDestPoint(
668                                 nativeGraphics,
669                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
670                                 destPoint, callback, callbackData,
671                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
672         }
673         Status EnumerateMetafile(const Metafile *metafile,
674                         const Point& destPoint,
675                         EnumerateMetafileProc callback,
676                         VOID *callbackData = NULL,
677                         ImageAttributes *imageAttributes = NULL)
678         {
679                 return updateStatus(DllExports::GdipEnumerateMetafileDestPointI(
680                                 nativeGraphics,
681                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
682                                 destPoint, callback, callbackData,
683                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
684         }
685         Status EnumerateMetafile(const Metafile *metafile,
686                         const RectF& destRect,
687                         EnumerateMetafileProc callback,
688                         VOID *callbackData = NULL,
689                         ImageAttributes *imageAttributes = NULL)
690         {
691                 return updateStatus(DllExports::GdipEnumerateMetafileDestRect(
692                                 nativeGraphics,
693                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
694                                 destRect, callback, callbackData,
695                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
696         }
697         Status EnumerateMetafile(const Metafile *metafile,
698                         const Rect& destRect,
699                         EnumerateMetafileProc callback,
700                         VOID *callbackData = NULL,
701                         ImageAttributes *imageAttributes = NULL)
702         {
703                 return updateStatus(DllExports::GdipEnumerateMetafileDestRectI(
704                                 nativeGraphics,
705                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
706                                 destRect, callback, callbackData,
707                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
708         }
709         Status EnumerateMetafile(const Metafile *metafile,
710                         const PointF *destPoints, INT count,
711                         EnumerateMetafileProc callback,
712                         VOID *callbackData = NULL,
713                         ImageAttributes *imageAttributes = NULL)
714         {
715                 return updateStatus(DllExports::GdipEnumerateMetafileDestPoints(
716                                 nativeGraphics,
717                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
718                                 destPoints, count, callback, callbackData,
719                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
720         }
721         Status EnumerateMetafile(const Metafile *metafile,
722                         const Point *destPoints, INT count,
723                         EnumerateMetafileProc callback,
724                         VOID *callbackData = NULL,
725                         ImageAttributes *imageAttributes = NULL)
726         {
727                 return updateStatus(DllExports::GdipEnumerateMetafileDestPointsI(
728                                 nativeGraphics,
729                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
730                                 destPoints, count, callback, callbackData,
731                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
732         }
733         Status EnumerateMetafile(const Metafile *metafile,
734                         const PointF& destPoint,
735                         const RectF& srcRect, Unit srcUnit,
736                         EnumerateMetafileProc callback,
737                         VOID *callbackData = NULL,
738                         ImageAttributes *imageAttributes = NULL)
739         {
740                 return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoint(
741                                 nativeGraphics,
742                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
743                                 destPoint, srcRect, srcUnit,
744                                 callback, callbackData,
745                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
746         }
747         Status EnumerateMetafile(const Metafile *metafile,
748                         const Point& destPoint,
749                         const Rect& srcRect, Unit srcUnit,
750                         EnumerateMetafileProc callback,
751                         VOID *callbackData = NULL,
752                         ImageAttributes *imageAttributes = NULL)
753         {
754                 return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointI(
755                                 nativeGraphics,
756                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
757                                 destPoint, srcRect, srcUnit,
758                                 callback, callbackData,
759                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
760         }
761         Status EnumerateMetafile(const Metafile *metafile,
762                         const RectF& destRect,
763                         const RectF& srcRect, Unit srcUnit,
764                         EnumerateMetafileProc callback,
765                         VOID *callbackData = NULL,
766                         ImageAttributes *imageAttributes = NULL)
767         {
768                 return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestRect(
769                                 nativeGraphics,
770                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
771                                 destRect, srcRect, srcUnit,
772                                 callback, callbackData,
773                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
774         }
775         Status EnumerateMetafile(const Metafile *metafile,
776                         const Rect& destRect,
777                         const Rect& srcRect, Unit srcUnit,
778                         EnumerateMetafileProc callback,
779                         VOID *callbackData = NULL,
780                         ImageAttributes *imageAttributes = NULL)
781         {
782                 return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestRectI(
783                                 nativeGraphics,
784                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
785                                 destRect, srcRect, srcUnit,
786                                 callback, callbackData,
787                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
788         }
789         Status EnumerateMetafile(const Metafile *metafile,
790                         const PointF* destPoints, INT count,
791                         const RectF& srcRect, Unit srcUnit,
792                         EnumerateMetafileProc callback,
793                         VOID *callbackData = NULL,
794                         ImageAttributes *imageAttributes = NULL)
795         {
796                 return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPoints(
797                                 nativeGraphics,
798                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
799                                 destPoints, count, srcRect, srcUnit,
800                                 callback, callbackData,
801                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
802         }
803         Status EnumerateMetafile(const Metafile *metafile,
804                         const Point* destPoints, INT count,
805                         const Rect& srcRect, Unit srcUnit,
806                         EnumerateMetafileProc callback,
807                         VOID *callbackData = NULL,
808                         ImageAttributes *imageAttributes = NULL)
809         {
810                 return updateStatus(DllExports::GdipEnumerateMetafileSrcRectDestPointsI(
811                                 nativeGraphics,
812                                 metafile ? ((GpMetafile*) metafile->nativeImage) : NULL,
813                                 destPoints, count, srcRect, srcUnit,
814                                 callback, callbackData,
815                                 imageAttributes ? imageAttributes->nativeImageAttributes : NULL));
816         }
817         Status ExcludeClip(const RectF& rect)
818         {
819                 return updateStatus(DllExports::GdipSetClipRect(
820                                 nativeGraphics,
821                                 rect.X, rect.Y, rect.Width, rect.Height,
822                                 CombineModeExclude));
823         }
824         Status ExcludeClip(const Rect& rect)
825         {
826                 return updateStatus(DllExports::GdipSetClipRectI(
827                                 nativeGraphics,
828                                 rect.X, rect.Y, rect.Width, rect.Height,
829                                 CombineModeExclude));
830         }
831         Status ExcludeClip(const Region *region)
832         {
833                 return updateStatus(DllExports::GdipSetClipRegion(
834                                 nativeGraphics,
835                                 region ? region->nativeRegion : NULL,
836                                 CombineModeExclude));
837         }
838         Status FillClosedCurve(const Brush *brush,
839                         const PointF *points, INT count)
840         {
841                 return updateStatus(DllExports::GdipFillClosedCurve(
842                                 nativeGraphics,
843                                 brush ? brush->nativeBrush : NULL,
844                                 points, count));
845         }
846         Status FillClosedCurve(const Brush *brush,
847                         const Point *points, INT count)
848         {
849                 return updateStatus(DllExports::GdipFillClosedCurveI(
850                                 nativeGraphics,
851                                 brush ? brush->nativeBrush : NULL,
852                                 points, count));
853         }
854         Status FillClosedCurve(const Brush *brush,
855                         const PointF *points, INT count,
856                         FillMode fillMode, REAL tension = 0.5f)
857         {
858                 return updateStatus(DllExports::GdipFillClosedCurve2(
859                                 nativeGraphics,
860                                 brush ? brush->nativeBrush : NULL,
861                                 points, count, tension, fillMode));
862         }
863         Status FillClosedCurve(const Brush *brush,
864                         const Point *points, INT count,
865                         FillMode fillMode, REAL tension = 0.5f)
866         {
867                 return updateStatus(DllExports::GdipFillClosedCurve2I(
868                                 nativeGraphics,
869                                 brush ? brush->nativeBrush : NULL,
870                                 points, count, tension, fillMode));
871         }
872         Status FillEllipse(const Brush *brush,
873                         REAL x, REAL y, REAL width, REAL height)
874         {
875                 return updateStatus(DllExports::GdipFillEllipse(
876                                 nativeGraphics,
877                                 brush ? brush->nativeBrush : NULL,
878                                 x, y, width, height));
879         }
880         Status FillEllipse(const Brush *brush,
881                         INT x, INT y, INT width, INT height)
882         {
883                 return updateStatus(DllExports::GdipFillEllipseI(
884                                 nativeGraphics,
885                                 brush ? brush->nativeBrush : NULL,
886                                 x, y, width, height));
887         }
888         Status FillEllipse(const Brush *brush, const RectF& rect)
889         {
890                 return updateStatus(DllExports::GdipFillEllipse(
891                                 nativeGraphics,
892                                 brush ? brush->nativeBrush : NULL,
893                                 rect.X, rect.Y, rect.Width, rect.Height));
894         }
895         Status FillEllipse(const Brush *brush, const Rect& rect)
896         {
897                 return updateStatus(DllExports::GdipFillEllipseI(
898                                 nativeGraphics,
899                                 brush ? brush->nativeBrush : NULL,
900                                 rect.X, rect.Y, rect.Width, rect.Height));
901         }
902         Status FillPath(const Brush *brush, const GraphicsPath *path)
903         {
904                 return updateStatus(DllExports::GdipFillPath(
905                                 nativeGraphics,
906                                 brush ? brush->nativeBrush : NULL,
907                                 path ? path->nativePath : NULL));
908         }
909         Status FillPie(const Brush *brush,
910                         REAL x, REAL y, REAL width, REAL height,
911                         REAL startAngle, REAL sweepAngle)
912         {
913                 return updateStatus(DllExports::GdipFillPie(
914                                 nativeGraphics,
915                                 brush ? brush->nativeBrush : NULL,
916                                 x, y, width, height, startAngle, sweepAngle));
917         }
918         Status FillPie(const Brush *brush, INT x, INT y, INT width, INT height,
919                         REAL startAngle, REAL sweepAngle)
920         {
921                 return updateStatus(DllExports::GdipFillPieI(
922                                 nativeGraphics,
923                                 brush ? brush->nativeBrush : NULL,
924                                 x, y, width, height, startAngle, sweepAngle));
925         }
926         Status FillPie(const Brush *brush, const RectF& rect,
927                         REAL startAngle, REAL sweepAngle)
928         {
929                 return updateStatus(DllExports::GdipFillPie(
930                                 nativeGraphics,
931                                 brush ? brush->nativeBrush : NULL,
932                                 rect.X, rect.Y, rect.Width, rect.Height,
933                                 startAngle, sweepAngle));
934         }
935         Status FillPie(const Brush *brush, const Rect& rect,
936                         REAL startAngle, REAL sweepAngle)
937         {
938                 return updateStatus(DllExports::GdipFillPieI(
939                                 nativeGraphics,
940                                 brush ? brush->nativeBrush : NULL,
941                                 rect.X, rect.Y, rect.Width, rect.Height,
942                                 startAngle, sweepAngle));
943         }
944         Status FillPolygon(const Brush *brush, const PointF *points, INT count)
945         {
946                 return updateStatus(DllExports::GdipFillPolygon(
947                                 nativeGraphics,
948                                 brush ? brush->nativeBrush : NULL,
949                                 points, count, FillModeAlternate));
950         }
951         Status FillPolygon(const Brush *brush, const Point *points, INT count)
952         {
953                 return updateStatus(DllExports::GdipFillPolygonI(
954                                 nativeGraphics,
955                                 brush ? brush->nativeBrush : NULL,
956                                 points, count, FillModeAlternate));
957         }
958         Status FillPolygon(const Brush *brush, const PointF *points, INT count,
959                         FillMode fillMode)
960         {
961                 return updateStatus(DllExports::GdipFillPolygon(
962                                 nativeGraphics,
963                                 brush ? brush->nativeBrush : NULL,
964                                 points, count, fillMode));
965         }
966         Status FillPolygon(const Brush *brush, const Point *points, INT count,
967                         FillMode fillMode)
968         {
969                 return updateStatus(DllExports::GdipFillPolygonI(
970                                 nativeGraphics,
971                                 brush ? brush->nativeBrush : NULL,
972                                 points, count, fillMode));
973         }
974         Status FillRectangle(const Brush *brush,
975                         REAL x, REAL y, REAL width, REAL height)
976         {
977                 return updateStatus(DllExports::GdipFillRectangle(
978                                 nativeGraphics,
979                                 brush ? brush->nativeBrush : NULL,
980                                 x, y, width, height));
981         }
982         Status FillRectangle(const Brush *brush,
983                         INT x, INT y, INT width, INT height)
984         {
985                 return updateStatus(DllExports::GdipFillRectangleI(
986                                 nativeGraphics,
987                                 brush ? brush->nativeBrush : NULL,
988                                 x, y, width, height));
989         }
990         Status FillRectangle(const Brush *brush, const RectF& rect)
991         {
992                 return updateStatus(DllExports::GdipFillRectangle(
993                                 nativeGraphics,
994                                 brush ? brush->nativeBrush : NULL,
995                                 rect.X, rect.Y, rect.Width, rect.Height));
996         }
997         Status FillRectangle(const Brush *brush, const Rect& rect)
998         {
999                 return updateStatus(DllExports::GdipFillRectangleI(
1000                                 nativeGraphics,
1001                                 brush ? brush->nativeBrush : NULL,
1002                                 rect.X, rect.Y, rect.Width, rect.Height));
1003         }
1004         Status FillRectangles(const Brush *brush, const RectF *rects, INT count)
1005         {
1006                 return updateStatus(DllExports::GdipFillRectangles(
1007                                 nativeGraphics,
1008                                 brush ? brush->nativeBrush : NULL,
1009                                 rects, count));
1010         }
1011         Status FillRectangles(const Brush *brush, const Rect *rects, INT count)
1012         {
1013                 return updateStatus(DllExports::GdipFillRectanglesI(
1014                                 nativeGraphics,
1015                                 brush ? brush->nativeBrush : NULL,
1016                                 rects, count));
1017         }
1018         Status FillRegion(const Brush *brush, const Region *region)
1019         {
1020                 return updateStatus(DllExports::GdipFillRegion(
1021                                 nativeGraphics,
1022                                 brush ? brush->nativeBrush : NULL,
1023                                 region ? region->nativeRegion : NULL));
1024         }
1025         VOID Flush(FlushIntention intention = FlushIntentionFlush)
1026         {
1027                 updateStatus(DllExports::GdipFlush(nativeGraphics, intention));
1028         }
1029         Status GetClip(Region *region) const
1030         {
1031                 return updateStatus(DllExports::GdipGetClip(
1032                                 nativeGraphics,
1033                                 region ? region->nativeRegion : NULL));
1034         }
1035         Status GetClipBounds(RectF *rect) const
1036         {
1037                 return updateStatus(DllExports::GdipGetClipBounds(
1038                                 nativeGraphics, rect));
1039         }
1040         Status GetClipBounds(Rect *rect) const
1041         {
1042                 return updateStatus(DllExports::GdipGetClipBoundsI(
1043                                 nativeGraphics, rect));
1044         }
1045         CompositingMode GetCompositingMode() const
1046         {
1047                 CompositingMode result = CompositingModeSourceOver;
1048                 updateStatus(DllExports::GdipGetCompositingMode(
1049                                 nativeGraphics, &result));
1050                 return result;
1051         }
1052         CompositingQuality GetCompositingQuality() const
1053         {
1054                 CompositingQuality result = CompositingQualityDefault;
1055                 updateStatus(DllExports::GdipGetCompositingQuality(
1056                                 nativeGraphics, &result));
1057                 return result;
1058         }
1059         REAL GetDpiX() const
1060         {
1061                 REAL result = 0.0f;
1062                 updateStatus(DllExports::GdipGetDpiX(nativeGraphics, &result));
1063                 return result;
1064         }
1065         REAL GetDpiY() const
1066         {
1067                 REAL result = 0.0f;
1068                 updateStatus(DllExports::GdipGetDpiY(nativeGraphics, &result));
1069                 return result;
1070         }
1071         HDC GetHDC()
1072         {
1073                 HDC result = NULL;
1074                 updateStatus(DllExports::GdipGetDC(nativeGraphics, &result));
1075                 return result;
1076         }
1077         InterpolationMode GetInterpolationMode() const
1078         {
1079                 InterpolationMode result = InterpolationModeDefault;
1080                 updateStatus(DllExports::GdipGetInterpolationMode(
1081                                 nativeGraphics, &result));
1082                 return result;
1083         }
1084         Status GetLastStatus() const
1085         {
1086                 Status result = lastStatus;
1087                 lastStatus = Ok;
1088                 return result;
1089         }
1090         Status GetNearestColor(Color *color) const
1091         {
1092                 return updateStatus(DllExports::GdipGetNearestColor(
1093                                 nativeGraphics, color ? &color->Value : NULL));
1094         }
1095         REAL GetPageScale() const
1096         {
1097                 REAL result = 0.0f;
1098                 updateStatus(DllExports::GdipGetPageScale(
1099                                 nativeGraphics, &result));
1100                 return result;
1101         }
1102         Unit GetPageUnit() const
1103         {
1104                 Unit result = UnitWorld;
1105                 updateStatus(DllExports::GdipGetPageUnit(
1106                                 nativeGraphics, &result));
1107                 return result;
1108         }
1109         PixelOffsetMode GetPixelOffsetMode() const
1110         {
1111                 PixelOffsetMode result = PixelOffsetModeDefault;
1112                 updateStatus(DllExports::GdipGetPixelOffsetMode(
1113                                 nativeGraphics, &result));
1114                 return result;
1115         }
1116         Status GetRenderingOrigin(INT *x, INT *y) const
1117         {
1118                 return updateStatus(DllExports::GdipGetRenderingOrigin(
1119                                 nativeGraphics, x, y));
1120         }
1121         SmoothingMode GetSmoothingMode() const
1122         {
1123                 SmoothingMode result = SmoothingModeDefault;
1124                 updateStatus(DllExports::GdipGetSmoothingMode(
1125                                 nativeGraphics, &result));
1126                 return result;
1127         }
1128         UINT GetTextContrast() const
1129         {
1130                 UINT result = 0;
1131                 updateStatus(DllExports::GdipGetTextContrast(
1132                                 nativeGraphics, &result));
1133                 return result;
1134         }
1135         TextRenderingHint GetTextRenderingHint() const
1136         {
1137                 TextRenderingHint result = TextRenderingHintSystemDefault;
1138                 updateStatus(DllExports::GdipGetTextRenderingHint(
1139                                 nativeGraphics, &result));
1140                 return result;
1141         }
1142         Status GetTransform(Matrix *matrix) const
1143         {
1144                 return updateStatus(DllExports::GdipGetWorldTransform(
1145                                 nativeGraphics,
1146                                 matrix ? matrix->nativeMatrix : NULL));
1147         }
1148         Status GetVisibleClipBounds(RectF *rect) const
1149         {
1150                 return updateStatus(DllExports::GdipGetVisibleClipBounds(
1151                                 nativeGraphics, rect));
1152         }
1153         Status GetVisibleClipBounds(Rect *rect) const
1154         {
1155                 return updateStatus(DllExports::GdipGetVisibleClipBoundsI(
1156                                 nativeGraphics, rect));
1157         }
1158         Status IntersectClip(const RectF& rect)
1159         {
1160                 return updateStatus(DllExports::GdipSetClipRect(
1161                                 nativeGraphics,
1162                                 rect.X, rect.Y, rect.Width, rect.Height,
1163                                 CombineModeIntersect));
1164         }
1165         Status IntersectClip(const Rect& rect)
1166         {
1167                 return updateStatus(DllExports::GdipSetClipRectI(
1168                                 nativeGraphics,
1169                                 rect.X, rect.Y, rect.Width, rect.Height,
1170                                 CombineModeIntersect));
1171         }
1172         Status IntersectClip(const Region *region)
1173         {
1174                 return updateStatus(DllExports::GdipSetClipRegion(
1175                                 nativeGraphics,
1176                                 region ? region->nativeRegion : NULL,
1177                                 CombineModeIntersect));
1178         }
1179         BOOL IsClipEmpty() const
1180         {
1181                 BOOL result = FALSE;
1182                 updateStatus(DllExports::GdipIsClipEmpty(
1183                                 nativeGraphics, &result));
1184                 return result;
1185         }
1186         BOOL IsVisible(REAL x, REAL y) const
1187         {
1188                 BOOL result = FALSE;
1189                 updateStatus(DllExports::GdipIsVisiblePoint(
1190                                 nativeGraphics, x, y, &result));
1191                 return result;
1192         }
1193         BOOL IsVisible(INT x, INT y) const
1194         {
1195                 BOOL result = FALSE;
1196                 updateStatus(DllExports::GdipIsVisiblePointI(
1197                                 nativeGraphics, x, y, &result));
1198                 return result;
1199         }
1200         BOOL IsVisible(const PointF& point) const
1201         {
1202                 BOOL result = FALSE;
1203                 updateStatus(DllExports::GdipIsVisiblePoint(
1204                                 nativeGraphics, point.X, point.Y, &result));
1205                 return result;
1206         }
1207         BOOL IsVisible(const Point& point) const
1208         {
1209                 BOOL result = FALSE;
1210                 updateStatus(DllExports::GdipIsVisiblePointI(
1211                                 nativeGraphics, point.X, point.Y, &result));
1212                 return result;
1213         }
1214         BOOL IsVisible(REAL x, REAL y, REAL width, REAL height) const
1215         {
1216                 BOOL result = FALSE;
1217                 updateStatus(DllExports::GdipIsVisibleRect(
1218                                 nativeGraphics, x, y, width, height, &result));
1219                 return result;
1220         }
1221         BOOL IsVisible(INT x, INT y, INT width, INT height) const
1222         {
1223                 BOOL result = FALSE;
1224                 updateStatus(DllExports::GdipIsVisibleRectI(
1225                                 nativeGraphics, x, y, width, height, &result));
1226                 return result;
1227         }
1228         BOOL IsVisible(const RectF& rect) const
1229         {
1230                 BOOL result = FALSE;
1231                 updateStatus(DllExports::GdipIsVisibleRect(
1232                                 nativeGraphics, rect.X, rect.Y,
1233                                 rect.Width, rect.Height, &result));
1234                 return result;
1235         }
1236         BOOL IsVisible(const Rect& rect) const
1237         {
1238                 BOOL result = FALSE;
1239                 updateStatus(DllExports::GdipIsVisibleRectI(
1240                                 nativeGraphics, rect.X, rect.Y,
1241                                 rect.Width, rect.Height, &result));
1242                 return result;
1243         }
1244         BOOL IsVisibleClipEmpty() const
1245         {
1246                 BOOL result = FALSE;
1247                 updateStatus(DllExports::GdipIsVisibleClipEmpty(
1248                                 nativeGraphics, &result));
1249                 return result;
1250         }
1251         Status MeasureCharacterRanges(const WCHAR *string, INT length,
1252                         const Font *font, const RectF& layoutRect,
1253                         const StringFormat *stringFormat,
1254                         INT regionCount, Region *regions) const
1255         {
1256                 if (regionCount <= 0 || !regions)
1257                         return lastStatus = InvalidParameter;
1258
1259                 GpRegion **nativeRegionArray = (GpRegion**)
1260                         DllExports::GdipAlloc(regionCount * sizeof(GpRegion*));
1261                 if (!nativeRegionArray)
1262                         return lastStatus = OutOfMemory;
1263                 for (int i = 0; i < regionCount; ++i) {
1264                         nativeRegionArray[i] = regions[i].nativeRegion;
1265                 }
1266                 Status status = updateStatus(DllExports::GdipMeasureCharacterRanges(
1267                                 nativeGraphics, string, length,
1268                                 font ? font->nativeFont : NULL,
1269                                 layoutRect,
1270                                 stringFormat ? stringFormat->nativeStringFormat : NULL,
1271                                 regionCount, nativeRegionArray));
1272                 DllExports::GdipFree(nativeRegionArray);
1273                 return status;
1274         }
1275         Status MeasureDriverString(const UINT16 *text, INT length,
1276                         const Font *font, const PointF *positions, INT flags,
1277                         const Matrix *matrix, RectF *boundingBox) const
1278         {
1279                 return updateStatus(DllExports::GdipMeasureDriverString(
1280                                 nativeGraphics, text, length,
1281                                 font ? font->nativeFont : NULL,
1282                                 positions, flags,
1283                                 matrix ? matrix->nativeMatrix : NULL,
1284                                 boundingBox));
1285         }
1286         Status MeasureString(const WCHAR *string, INT length,
1287                         const Font *font, const RectF& layoutRect,
1288                         RectF *boundingBox) const
1289         {
1290                 return updateStatus(DllExports::GdipMeasureString(
1291                                 nativeGraphics, string, length,
1292                                 font ? font->nativeFont : NULL,
1293                                 &layoutRect, NULL, boundingBox, NULL, NULL));
1294         }
1295         Status MeasureString(const WCHAR *string, INT length,
1296                         const Font *font, const RectF& layoutRect,
1297                         const StringFormat *stringFormat, RectF *boundingBox,
1298                         INT *codepointsFitted = NULL,
1299                         INT *linesFitted = NULL) const
1300         {
1301                 return updateStatus(DllExports::GdipMeasureString(
1302                                 nativeGraphics, string, length,
1303                                 font ? font->nativeFont : NULL,
1304                                 &layoutRect,
1305                                 stringFormat ? stringFormat->nativeStringFormat : NULL,
1306                                 boundingBox, codepointsFitted, linesFitted));
1307         }
1308         Status MeasureString(const WCHAR *string, INT length,
1309                         const Font *font, const SizeF& layoutRectSize,
1310                         const StringFormat *stringFormat, SizeF *size,
1311                         INT *codepointsFitted = NULL,
1312                         INT *linesFitted = NULL) const
1313         {
1314                 if (!size) return lastStatus = InvalidParameter;
1315                 RectF layoutRect(PointF(0.0f, 0.0f), layoutRectSize);
1316                 RectF boundingBox;
1317                 Status status = updateStatus(DllExports::GdipMeasureString(
1318                                 nativeGraphics, string, length,
1319                                 font ? font->nativeFont : NULL,
1320                                 &layoutRect,
1321                                 stringFormat ? stringFormat->nativeStringFormat : NULL,
1322                                 &boundingBox, codepointsFitted, linesFitted));
1323                 boundingBox.GetSize(size);
1324                 return status;
1325         }
1326         Status MeasureString(const WCHAR *string, INT length,
1327                         const Font *font, const PointF& origin,
1328                         RectF *boundingBox) const
1329         {
1330                 RectF layoutRect(origin, SizeF(0.0f, 0.0f));
1331                 return updateStatus(DllExports::GdipMeasureString(
1332                                 nativeGraphics, string, length,
1333                                 font ? font->nativeFont : NULL,
1334                                 &layoutRect, NULL, boundingBox, NULL, NULL));
1335         }
1336         Status MeasureString(const WCHAR *string, INT length,
1337                         const Font *font, const PointF& origin,
1338                         const StringFormat *stringFormat,
1339                         RectF *boundingBox) const
1340         {
1341                 RectF layoutRect(origin, SizeF(0.0f, 0.0f));
1342                 return updateStatus(DllExports::GdipMeasureString(
1343                                 nativeGraphics, string, length,
1344                                 font ? font->nativeFont : NULL,
1345                                 &layoutRect,
1346                                 stringFormat ? stringFormat->nativeStringFormat : NULL,
1347                                 boundingBox, NULL, NULL));
1348         }
1349         Status MultiplyTransform(const Matrix *matrix,
1350                         MatrixOrder order = MatrixOrderPrepend)
1351         {
1352                 return updateStatus(DllExports::GdipMultiplyWorldTransform(
1353                                 nativeGraphics,
1354                                 matrix ? matrix->nativeMatrix : NULL, order));
1355         }
1356         VOID ReleaseHDC(HDC hdc)
1357         {
1358                 updateStatus(DllExports::GdipReleaseDC(nativeGraphics, hdc));
1359         }
1360         Status ResetClip()
1361         {
1362                 return updateStatus(DllExports::GdipResetClip(nativeGraphics));
1363         }
1364         Status ResetTransform()
1365         {
1366                 return updateStatus(DllExports::GdipResetWorldTransform(
1367                                 nativeGraphics));
1368         }
1369         Status Restore(GraphicsState state)
1370         {
1371                 return updateStatus(DllExports::GdipRestoreGraphics(
1372                                 nativeGraphics, state));
1373         }
1374         Status RotateTransform(REAL angle,
1375                         MatrixOrder order = MatrixOrderPrepend)
1376         {
1377                 return updateStatus(DllExports::GdipRotateWorldTransform(
1378                                 nativeGraphics, angle, order));
1379         }
1380         GraphicsState Save() const
1381         {
1382                 GraphicsState result = 0;
1383                 updateStatus(DllExports::GdipSaveGraphics(
1384                                 nativeGraphics, &result));
1385                 return result;
1386         }
1387         Status ScaleTransform(REAL sx, REAL sy,
1388                         MatrixOrder order = MatrixOrderPrepend)
1389         {
1390                 return updateStatus(DllExports::GdipScaleWorldTransform(
1391                                 nativeGraphics, sx, sy, order));
1392         }
1393         VOID SetAbort()
1394         {
1395                 updateStatus(NotImplemented);
1396         }
1397         Status SetClip(const Graphics *g,
1398                         CombineMode combineMode = CombineModeReplace)
1399         {
1400                 return updateStatus(DllExports::GdipSetClipGraphics(
1401                                 nativeGraphics, g ? g->nativeGraphics : NULL,
1402                                 combineMode));
1403         }
1404         Status SetClip(const RectF& rect,
1405                         CombineMode combineMode = CombineModeReplace)
1406         {
1407                 return updateStatus(DllExports::GdipSetClipRect(
1408                                 nativeGraphics,
1409                                 rect.X, rect.Y, rect.Width, rect.Height,
1410                                 combineMode));
1411         }
1412         Status SetClip(const Rect& rect,
1413                         CombineMode combineMode = CombineModeReplace)
1414         {
1415                 return updateStatus(DllExports::GdipSetClipRectI(
1416                                 nativeGraphics,
1417                                 rect.X, rect.Y, rect.Width, rect.Height,
1418                                 combineMode));
1419         }
1420         Status SetClip(const GraphicsPath *path,
1421                         CombineMode combineMode = CombineModeReplace)
1422         {
1423                 return updateStatus(DllExports::GdipSetClipPath(
1424                                 nativeGraphics,
1425                                 path ? path->nativePath : NULL,
1426                                 combineMode));
1427         }
1428         Status SetClip(const Region *region,
1429                         CombineMode combineMode = CombineModeReplace)
1430         {
1431                 return updateStatus(DllExports::GdipSetClipRegion(
1432                                 nativeGraphics,
1433                                 region ? region->nativeRegion : NULL,
1434                                 combineMode));
1435         }
1436         Status SetClip(HRGN hRgn, CombineMode combineMode = CombineModeReplace)
1437         {
1438                 return updateStatus(DllExports::GdipSetClipHrgn(
1439                                 nativeGraphics, hRgn, combineMode));
1440         }
1441         Status SetCompositingMode(CompositingMode compositingMode)
1442         {
1443                 return updateStatus(DllExports::GdipSetCompositingMode(
1444                                 nativeGraphics, compositingMode));
1445         }
1446         Status SetCompositingQuality(CompositingQuality compositingQuality)
1447         {
1448                 return updateStatus(DllExports::GdipSetCompositingQuality(
1449                                 nativeGraphics, compositingQuality));
1450         }
1451         Status SetInterpolationMode(InterpolationMode interpolationMode)
1452         {
1453                 return updateStatus(DllExports::GdipSetInterpolationMode(
1454                                 nativeGraphics, interpolationMode));
1455         }
1456         Status SetPageScale(REAL scale)
1457         {
1458                 return updateStatus(DllExports::GdipSetPageScale(
1459                                 nativeGraphics, scale));
1460         }
1461         Status SetPageUnit(Unit unit)
1462         {
1463                 return updateStatus(DllExports::GdipSetPageUnit(
1464                                 nativeGraphics, unit));
1465         }
1466         Status SetPixelOffsetMode(PixelOffsetMode pixelOffsetMode)
1467         {
1468                 return updateStatus(DllExports::GdipSetPixelOffsetMode(
1469                                 nativeGraphics, pixelOffsetMode));
1470         }
1471         Status SetRenderingOrigin(INT x, INT y)
1472         {
1473                 return updateStatus(DllExports::GdipSetRenderingOrigin(
1474                                 nativeGraphics, x, y));
1475         }
1476         Status SetSmoothingMode(SmoothingMode smoothingMode)
1477         {
1478                 return updateStatus(DllExports::GdipSetSmoothingMode(
1479                                 nativeGraphics, smoothingMode));
1480         }
1481         Status SetTextContrast(UINT contrast)
1482         {
1483                 return updateStatus(DllExports::GdipSetTextContrast(
1484                                 nativeGraphics, contrast));
1485         }
1486         Status SetTextRenderingHint(TextRenderingHint textRenderingHint)
1487         {
1488                 return updateStatus(DllExports::GdipSetTextRenderingHint(
1489                                 nativeGraphics, textRenderingHint));
1490         }
1491         Status SetTransform(const Matrix *matrix)
1492         {
1493                 return updateStatus(DllExports::GdipSetWorldTransform(
1494                                 nativeGraphics,
1495                                 matrix ? matrix->nativeMatrix : NULL));
1496         }
1497         Status TransformPoints(CoordinateSpace destSpace,
1498                         CoordinateSpace srcSpace,
1499                         PointF *pts, INT count) const
1500         {
1501                 return updateStatus(DllExports::GdipTransformPoints(
1502                                 nativeGraphics, destSpace, srcSpace,
1503                                 pts, count));
1504         }
1505         Status TransformPoints(CoordinateSpace destSpace,
1506                         CoordinateSpace srcSpace,
1507                         Point *pts, INT count) const
1508         {
1509                 return updateStatus(DllExports::GdipTransformPointsI(
1510                                 nativeGraphics, destSpace, srcSpace,
1511                                 pts, count));
1512         }
1513         Status TranslateClip(REAL dx, REAL dy)
1514         {
1515                 return updateStatus(DllExports::GdipTranslateClip(
1516                                 nativeGraphics, dx, dy));
1517         }
1518         Status TranslateClip(INT dx, INT dy)
1519         {
1520                 return updateStatus(DllExports::GdipTranslateClipI(
1521                                 nativeGraphics, dx, dy));
1522         }
1523         Status TranslateTransform(REAL dx, REAL dy,
1524                         MatrixOrder order = MatrixOrderPrepend)
1525         {
1526                 return updateStatus(DllExports::GdipTranslateWorldTransform(
1527                                 nativeGraphics, dx, dy, order));
1528         }
1529
1530 private:
1531         Graphics(const Graphics&);
1532         Graphics& operator=(const Graphics&);
1533
1534         Status updateStatus(Status newStatus) const
1535         {
1536                 if (newStatus != Ok) lastStatus = newStatus;
1537                 return newStatus;
1538         }
1539
1540         GpGraphics *nativeGraphics;
1541         mutable Status lastStatus;
1542 };
1543
1544 #endif /* __GDIPLUS_GRAPHICS_H */