3383018d7a69c982325cf81aedcfe0fc84d4ec5f
[reactos.git] / sdk / include / psdk / gdiplusheaders.h
1 /*
2 * GdiPlusHeaders.h
3 *
4 * Windows GDI+
5 *
6 * This file is part of the w32api package.
7 *
8 * THIS SOFTWARE IS NOT COPYRIGHTED
9 *
10 * This source code is offered for use in the public domain. You may
11 * use, modify or distribute it freely.
12 *
13 * This code is distributed in the hope that it will be useful but
14 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
15 * DISCLAIMED. This includes but is not limited to warranties of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 */
18
19 #ifndef _GDIPLUSHEADERS_H
20 #define _GDIPLUSHEADERS_H
21
22 class Image : public GdiplusBase
23 {
24 public:
25 friend class Graphics;
26
27 Image(IStream *stream, BOOL useEmbeddedColorManagement = FALSE) : nativeImage(NULL)
28 {
29 if (useEmbeddedColorManagement)
30 lastStatus = DllExports::GdipLoadImageFromStreamICM(stream, &nativeImage);
31 else
32 lastStatus = DllExports::GdipLoadImageFromStream(stream, &nativeImage);
33 }
34
35 Image(const WCHAR *filename, BOOL useEmbeddedColorManagement = FALSE) : nativeImage(NULL)
36 {
37 if (useEmbeddedColorManagement)
38 lastStatus = DllExports::GdipLoadImageFromFileICM(filename, &nativeImage);
39 else
40 lastStatus = DllExports::GdipLoadImageFromFile(filename, &nativeImage);
41 }
42
43 Image *
44 Clone()
45 {
46 GpImage *cloneimage = NULL;
47 SetStatus(DllExports::GdipCloneImage(nativeImage, &cloneimage));
48 return new Image(cloneimage, lastStatus);
49 }
50
51 virtual ~Image()
52 {
53 DllExports::GdipDisposeImage(nativeImage);
54 }
55
56 static Image *
57 FromFile(const WCHAR *filename, BOOL useEmbeddedColorManagement = FALSE)
58 {
59 return new Image(filename, useEmbeddedColorManagement);
60 }
61
62 static Image *
63 FromStream(IStream *stream, BOOL useEmbeddedColorManagement = FALSE)
64 {
65 return new Image(stream, useEmbeddedColorManagement);
66 }
67
68 Status
69 GetAllPropertyItems(UINT totalBufferSize, UINT numProperties, PropertyItem *allItems)
70 {
71 if (allItems == NULL)
72 return SetStatus(InvalidParameter);
73 return SetStatus(DllExports::GdipGetAllPropertyItems(nativeImage, totalBufferSize, numProperties, allItems));
74 }
75
76 Status
77 GetBounds(RectF *srcRect, Unit *srcUnit)
78 {
79 return SetStatus(DllExports::GdipGetImageBounds(nativeImage, srcRect, srcUnit));
80 }
81
82 Status
83 GetEncoderParameterList(const CLSID *clsidEncoder, UINT size, EncoderParameters *buffer)
84 {
85 #if 1
86 // FIXME: Not available yet
87 return SetStatus(NotImplemented);
88 #else
89 return SetStatus(DllExports::GdipGetEncoderParameterList(nativeImage, clsidEncoder, size, buffer));
90 #endif
91 }
92
93 UINT
94 GetEncoderParameterListSize(const CLSID *clsidEncoder)
95 {
96 #if 1
97 // FIXME: Not available yet
98 return SetStatus(NotImplemented);
99 #else
100 UINT size = 0;
101 SetStatus(DllExports::GdipGetEncoderParameterListSize(nativeImage, clsidEncoder, &size));
102 return size;
103 #endif
104 }
105
106 UINT
107 GetFlags()
108 {
109 UINT flags = 0;
110 SetStatus(DllExports::GdipGetImageFlags(nativeImage, &flags));
111 return flags;
112 }
113
114 UINT
115 GetFrameCount(const GUID *dimensionID)
116 {
117 UINT count = 0;
118 SetStatus(DllExports::GdipImageGetFrameCount(nativeImage, dimensionID, &count));
119 return count;
120 }
121
122 UINT
123 GetFrameDimensionsCount()
124 {
125 UINT count = 0;
126 SetStatus(DllExports::GdipImageGetFrameDimensionsCount(nativeImage, &count));
127 return count;
128 }
129
130 Status
131 GetFrameDimensionsList(GUID *dimensionIDs, UINT count)
132 {
133 return SetStatus(DllExports::GdipImageGetFrameDimensionsList(nativeImage, dimensionIDs, count));
134 }
135
136 UINT
137 GetHeight()
138 {
139 UINT height = 0;
140 SetStatus(DllExports::GdipGetImageHeight(nativeImage, &height));
141 return height;
142 }
143
144 REAL
145 GetHorizontalResolution()
146 {
147 REAL resolution = 0.0f;
148 SetStatus(DllExports::GdipGetImageHorizontalResolution(nativeImage, &resolution));
149 return resolution;
150 }
151
152 Status
153 GetLastStatus()
154 {
155 return lastStatus;
156 }
157
158 Status
159 GetPalette(ColorPalette *palette, INT size)
160 {
161 return SetStatus(DllExports::GdipGetImagePalette(nativeImage, palette, size));
162 }
163
164 INT
165 GetPaletteSize()
166 {
167 INT size = 0;
168 SetStatus(DllExports::GdipGetImagePaletteSize(nativeImage, &size));
169 return size;
170 }
171
172 Status
173 GetPhysicalDimension(SizeF *size)
174 {
175 if (size == NULL)
176 return SetStatus(InvalidParameter);
177
178 return SetStatus(DllExports::GdipGetImageDimension(nativeImage, &size->Width, &size->Height));
179 }
180
181 PixelFormat
182 GetPixelFormat()
183 {
184 PixelFormat format;
185 SetStatus(DllExports::GdipGetImagePixelFormat(nativeImage, &format));
186 return format;
187 }
188
189 UINT
190 GetPropertyCount()
191 {
192 UINT numOfProperty = 0;
193 SetStatus(DllExports::GdipGetPropertyCount(nativeImage, &numOfProperty));
194 return numOfProperty;
195 }
196
197 Status
198 GetPropertyIdList(UINT numOfProperty, PROPID *list)
199 {
200 return SetStatus(DllExports::GdipGetPropertyIdList(nativeImage, numOfProperty, list));
201 }
202
203 Status
204 GetPropertyItem(PROPID propId, UINT propSize, PropertyItem *buffer)
205 {
206 return SetStatus(DllExports::GdipGetPropertyItem(nativeImage, propId, propSize, buffer));
207 }
208
209 UINT
210 GetPropertyItemSize(PROPID propId)
211 {
212 UINT size = 0;
213 SetStatus(DllExports::GdipGetPropertyItemSize(nativeImage, propId, &size));
214 return size;
215 }
216
217 Status
218 GetPropertySize(UINT *totalBufferSize, UINT *numProperties)
219 {
220 return SetStatus(DllExports::GdipGetPropertySize(nativeImage, totalBufferSize, numProperties));
221 }
222
223 Status
224 GetRawFormat(GUID *format)
225 {
226 return SetStatus(DllExports::GdipGetImageRawFormat(nativeImage, format));
227 }
228
229 Image *
230 GetThumbnailImage(UINT thumbWidth, UINT thumbHeight, GetThumbnailImageAbort callback, VOID *callbackData)
231 {
232 GpImage *thumbImage = NULL;
233 SetStatus(DllExports::GdipGetImageThumbnail(
234 nativeImage, thumbWidth, thumbHeight, &thumbImage, callback, callbackData));
235 Image *newImage = new Image(thumbImage, lastStatus);
236 if (newImage == NULL)
237 {
238 DllExports::GdipDisposeImage(thumbImage);
239 }
240 return newImage;
241 }
242
243 ImageType
244 GetType()
245 {
246 ImageType type;
247 SetStatus(DllExports::GdipGetImageType(nativeImage, &type));
248 return type;
249 }
250
251 REAL
252 GetVerticalResolution()
253 {
254 REAL resolution = 0.0f;
255 SetStatus(DllExports::GdipGetImageVerticalResolution(nativeImage, &resolution));
256 return resolution;
257 }
258
259 UINT
260 GetWidth()
261 {
262 UINT width = 0;
263 SetStatus(DllExports::GdipGetImageWidth(nativeImage, &width));
264 return width;
265 }
266
267 Status
268 RemovePropertyItem(PROPID propId)
269 {
270 return SetStatus(DllExports::GdipRemovePropertyItem(nativeImage, propId));
271 }
272
273 Status
274 RotateFlip(RotateFlipType rotateFlipType)
275 {
276 return SetStatus(DllExports::GdipImageRotateFlip(nativeImage, rotateFlipType));
277 }
278
279 Status
280 Save(IStream *stream, const CLSID *clsidEncoder, const EncoderParameters *encoderParams)
281 {
282 return SetStatus(DllExports::GdipSaveImageToStream(nativeImage, stream, clsidEncoder, encoderParams));
283 }
284
285 Status
286 Save(const WCHAR *filename, const CLSID *clsidEncoder, const EncoderParameters *encoderParams)
287 {
288 return SetStatus(DllExports::GdipSaveImageToFile(nativeImage, filename, clsidEncoder, encoderParams));
289 }
290
291 Status
292 SaveAdd(const EncoderParameters *encoderParams)
293 {
294 #if 1
295 // FIXME: Not available yet
296 return SetStatus(NotImplemented);
297 #else
298 return SetStatus(DllExports::GdipSaveAdd(nativeImage, encoderParams));
299 #endif
300 }
301
302 Status
303 SaveAdd(Image *newImage, const EncoderParameters *encoderParams)
304 {
305 #if 1
306 // FIXME: Not available yet
307 return SetStatus(NotImplemented);
308 #else
309 if (!newImage)
310 return SetStatus(InvalidParameter);
311
312 return SetStatus(DllExports::GdipSaveAddImage(nativeImage, newImage->nativeImage, encoderParams));
313 #endif
314 }
315
316 Status
317 SelectActiveFrame(const GUID *dimensionID, UINT frameIndex)
318 {
319 return SetStatus(DllExports::GdipImageSelectActiveFrame(nativeImage, dimensionID, frameIndex));
320 }
321
322 Status
323 SetPalette(const ColorPalette *palette)
324 {
325 return SetStatus(DllExports::GdipSetImagePalette(nativeImage, palette));
326 }
327
328 Status
329 SetPropertyItem(const PropertyItem *item)
330 {
331 return SetStatus(DllExports::GdipSetPropertyItem(nativeImage, item));
332 }
333
334 #if 0
335 ImageLayout
336 GetLayout() const
337 {
338 return SetStatus(NotImplemented);
339 }
340
341 Status
342 SetLayout(const ImageLayout layout)
343 {
344 return SetStatus(NotImplemented);
345 }
346 #endif
347
348 protected:
349 GpImage *nativeImage;
350 mutable Status lastStatus;
351
352 Image()
353 {
354 }
355
356 Image(GpImage *image, Status status) : nativeImage(image), lastStatus(status)
357 {
358 }
359
360 Status
361 SetStatus(Status status) const
362 {
363 if (status != Ok)
364 lastStatus = status;
365 return status;
366 }
367
368 void
369 SetNativeImage(GpImage *image)
370 {
371 nativeImage = image;
372 }
373
374 private:
375 // Image is not copyable
376 Image(const Image &);
377 Image &
378 operator=(const Image &);
379 };
380
381 class Bitmap : public Image
382 {
383 friend class CachedBitmap;
384
385 public:
386 // Bitmap(IDirectDrawSurface7 *surface) // <-- FIXME: compiler does not like this
387 // {
388 // lastStatus = DllExports::GdipCreateBitmapFromDirectDrawSurface(surface, &bitmap);
389 // }
390
391 Bitmap(INT width, INT height, Graphics *target)
392 {
393 GpBitmap *bitmap = NULL;
394 lastStatus = DllExports::GdipCreateBitmapFromGraphics(width, height, target ? target->graphics : NULL, &bitmap);
395 SetNativeImage(bitmap);
396 }
397
398 Bitmap(const BITMAPINFO *gdiBitmapInfo, VOID *gdiBitmapData)
399 {
400 GpBitmap *bitmap = NULL;
401 lastStatus = DllExports::GdipCreateBitmapFromGdiDib(gdiBitmapInfo, gdiBitmapData, &bitmap);
402 SetNativeImage(bitmap);
403 }
404
405 Bitmap(INT width, INT height, PixelFormat format)
406 {
407 GpBitmap *bitmap = NULL;
408 lastStatus = DllExports::GdipCreateBitmapFromScan0(width, height, 0, format, NULL, &bitmap);
409 SetNativeImage(bitmap);
410 }
411
412 Bitmap(HBITMAP hbm, HPALETTE hpal)
413 {
414 GpBitmap *bitmap = NULL;
415 lastStatus = DllExports::GdipCreateBitmapFromHBITMAP(hbm, hpal, &bitmap);
416 SetNativeImage(bitmap);
417 }
418
419 Bitmap(INT width, INT height, INT stride, PixelFormat format, BYTE *scan0)
420 {
421 GpBitmap *bitmap = NULL;
422 lastStatus = DllExports::GdipCreateBitmapFromScan0(width, height, stride, format, scan0, &bitmap);
423 SetNativeImage(bitmap);
424 }
425
426 Bitmap(const WCHAR *filename, BOOL useIcm)
427 {
428 GpBitmap *bitmap = NULL;
429
430 if (useIcm)
431 lastStatus = DllExports::GdipCreateBitmapFromFileICM(filename, &bitmap);
432 else
433 lastStatus = DllExports::GdipCreateBitmapFromFile(filename, &bitmap);
434
435 SetNativeImage(bitmap);
436 }
437
438 Bitmap(HINSTANCE hInstance, const WCHAR *bitmapName)
439 {
440 GpBitmap *bitmap = NULL;
441 lastStatus = DllExports::GdipCreateBitmapFromResource(hInstance, bitmapName, &bitmap);
442 SetNativeImage(bitmap);
443 }
444
445 Bitmap(HICON hicon)
446 {
447 GpBitmap *bitmap = NULL;
448 lastStatus = DllExports::GdipCreateBitmapFromHICON(hicon, &bitmap);
449 SetNativeImage(bitmap);
450 }
451
452 Bitmap(IStream *stream, BOOL useIcm)
453 {
454 GpBitmap *bitmap = NULL;
455 if (useIcm)
456 lastStatus = DllExports::GdipCreateBitmapFromStreamICM(stream, &bitmap);
457 else
458 lastStatus = DllExports::GdipCreateBitmapFromStream(stream, &bitmap);
459 SetNativeImage(bitmap);
460 }
461
462 Bitmap *
463 Clone(const Rect &rect, PixelFormat format)
464 {
465 return Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
466 }
467
468 Bitmap *
469 Clone(const RectF &rect, PixelFormat format)
470 {
471 return Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
472 }
473
474 Bitmap *
475 Clone(REAL x, REAL y, REAL width, REAL height, PixelFormat format)
476 {
477 GpBitmap *bitmap = NULL;
478 lastStatus = DllExports::GdipCloneBitmapArea(x, y, width, height, format, GetNativeBitmap(), &bitmap);
479
480 if (lastStatus != Ok)
481 return NULL;
482
483 Bitmap *newBitmap = new Bitmap(bitmap);
484 if (newBitmap == NULL)
485 {
486 DllExports::GdipDisposeImage(bitmap);
487 }
488
489 return newBitmap;
490 }
491
492 Bitmap *
493 Clone(INT x, INT y, INT width, INT height, PixelFormat format)
494 {
495 GpBitmap *bitmap = NULL;
496 lastStatus = DllExports::GdipCloneBitmapAreaI(x, y, width, height, format, GetNativeBitmap(), &bitmap);
497
498 if (lastStatus != Ok)
499 return NULL;
500
501 Bitmap *newBitmap = new Bitmap(bitmap);
502 if (newBitmap == NULL)
503 {
504 DllExports::GdipDisposeImage(bitmap);
505 }
506
507 return newBitmap;
508 }
509
510 static Bitmap *
511 FromBITMAPINFO(const BITMAPINFO *gdiBitmapInfo, VOID *gdiBitmapData)
512 {
513 return new Bitmap(gdiBitmapInfo, gdiBitmapData);
514 }
515
516 // static Bitmap *FromDirectDrawSurface7(IDirectDrawSurface7 *surface) // <-- FIXME: compiler does not like this
517 // {
518 // return new Bitmap(surface);
519 // }
520
521 static Bitmap *
522 FromFile(const WCHAR *filename, BOOL useEmbeddedColorManagement)
523 {
524 return new Bitmap(filename, useEmbeddedColorManagement);
525 }
526
527 static Bitmap *
528 FromHBITMAP(HBITMAP hbm, HPALETTE hpal)
529 {
530 return new Bitmap(hbm, hpal);
531 }
532
533 static Bitmap *
534 FromHICON(HICON hicon)
535 {
536 return new Bitmap(hicon);
537 }
538
539 static Bitmap *
540 FromResource(HINSTANCE hInstance, const WCHAR *bitmapName)
541 {
542 return new Bitmap(hInstance, bitmapName);
543 }
544
545 static Bitmap *
546 FromStream(IStream *stream, BOOL useEmbeddedColorManagement)
547 {
548 return new Bitmap(stream, useEmbeddedColorManagement);
549 }
550
551 Status
552 GetHBITMAP(const Color &colorBackground, HBITMAP *hbmReturn)
553 {
554 return SetStatus(
555 DllExports::GdipCreateHBITMAPFromBitmap(GetNativeBitmap(), hbmReturn, colorBackground.GetValue()));
556 }
557
558 Status
559 GetHICON(HICON *hicon)
560 {
561 return SetStatus(DllExports::GdipCreateHICONFromBitmap(GetNativeBitmap(), hicon));
562 }
563
564 Status
565 GetPixel(INT x, INT y, Color *color)
566 {
567 ARGB argb;
568 Status s = SetStatus(DllExports::GdipBitmapGetPixel(GetNativeBitmap(), x, y, &argb));
569 if (color)
570 color->SetValue(argb);
571 return s;
572 }
573
574 Status
575 LockBits(const Rect *rect, UINT flags, PixelFormat format, BitmapData *lockedBitmapData)
576 {
577 return SetStatus(DllExports::GdipBitmapLockBits(GetNativeBitmap(), rect, flags, format, lockedBitmapData));
578 }
579
580 Status
581 SetPixel(INT x, INT y, const Color &color)
582 {
583 return SetStatus(DllExports::GdipBitmapSetPixel(GetNativeBitmap(), x, y, color.GetValue()));
584 }
585
586 Status
587 SetResolution(REAL xdpi, REAL ydpi)
588 {
589 return SetStatus(DllExports::GdipBitmapSetResolution(GetNativeBitmap(), xdpi, ydpi));
590 }
591
592 Status
593 UnlockBits(BitmapData *lockedBitmapData)
594 {
595 return SetStatus(DllExports::GdipBitmapUnlockBits(GetNativeBitmap(), lockedBitmapData));
596 }
597
598 protected:
599 Bitmap()
600 {
601 }
602
603 Bitmap(GpBitmap *nativeBitmap)
604 {
605 lastStatus = Ok;
606 SetNativeImage(nativeBitmap);
607 }
608
609 GpBitmap *
610 GetNativeBitmap() const
611 {
612 return static_cast<GpBitmap *>(nativeImage);
613 }
614 };
615
616 class CachedBitmap : public GdiplusBase
617 {
618 public:
619 CachedBitmap(Bitmap *bitmap, Graphics *graphics)
620 {
621 nativeCachedBitmap = NULL;
622 lastStatus = DllExports::GdipCreateCachedBitmap(
623 bitmap->GetNativeBitmap(), graphics ? graphics->graphics : NULL, &nativeCachedBitmap);
624 }
625
626 ~CachedBitmap()
627 {
628 DllExports::GdipDeleteCachedBitmap(nativeCachedBitmap);
629 }
630
631 Status
632 GetLastStatus()
633 {
634 return lastStatus;
635 }
636
637 protected:
638 mutable Status lastStatus;
639 GpCachedBitmap *nativeCachedBitmap;
640
641 private:
642 // CachedBitmap is not copyable
643 CachedBitmap(const CachedBitmap &);
644 CachedBitmap &
645 operator=(const CachedBitmap &);
646 };
647
648 class FontCollection : public GdiplusBase
649 {
650 friend class FontFamily;
651
652 public:
653 FontCollection()
654 {
655 }
656
657 Status
658 GetFamilies(INT numSought, FontFamily *gpfamilies, INT *numFound) const
659 {
660 return NotImplemented;
661 }
662
663 INT
664 GetFamilyCount() const
665 {
666 return 0;
667 }
668
669 Status
670 GetLastStatus()
671 {
672 return NotImplemented;
673 }
674
675 private:
676 GpFontCollection *fontCollection;
677 };
678
679 class FontFamily : public GdiplusBase
680 {
681 friend class Font;
682
683 public:
684 FontFamily()
685 {
686 }
687
688 FontFamily(const WCHAR *name, const FontCollection *fontCollection)
689 {
690 status = DllExports::GdipCreateFontFamilyFromName(
691 name, fontCollection ? fontCollection->fontCollection : NULL, &fontFamily);
692 }
693
694 FontFamily *
695 Clone()
696 {
697 return NULL;
698 }
699
700 static const FontFamily *
701 GenericMonospace()
702 {
703 FontFamily *genericMonospace = new FontFamily();
704 genericMonospace->status =
705 DllExports::GdipGetGenericFontFamilyMonospace(genericMonospace ? &genericMonospace->fontFamily : NULL);
706 return genericMonospace;
707 }
708
709 static const FontFamily *
710 GenericSansSerif()
711 {
712 FontFamily *genericSansSerif = new FontFamily();
713 genericSansSerif->status =
714 DllExports::GdipGetGenericFontFamilySansSerif(genericSansSerif ? &genericSansSerif->fontFamily : NULL);
715 return genericSansSerif;
716 }
717
718 static const FontFamily *
719 GenericSerif()
720 {
721 FontFamily *genericSerif = new FontFamily();
722 genericSerif->status =
723 DllExports::GdipGetGenericFontFamilyMonospace(genericSerif ? &genericSerif->fontFamily : NULL);
724 return genericSerif;
725 }
726
727 UINT16
728 GetCellAscent(INT style) const
729 {
730 UINT16 CellAscent;
731 SetStatus(DllExports::GdipGetCellAscent(fontFamily, style, &CellAscent));
732 return CellAscent;
733 }
734
735 UINT16
736 GetCellDescent(INT style) const
737 {
738 UINT16 CellDescent;
739 SetStatus(DllExports::GdipGetCellDescent(fontFamily, style, &CellDescent));
740 return CellDescent;
741 }
742
743 UINT16
744 GetEmHeight(INT style)
745 {
746 UINT16 EmHeight;
747 SetStatus(DllExports::GdipGetEmHeight(fontFamily, style, &EmHeight));
748 return EmHeight;
749 }
750
751 Status
752 GetFamilyName(WCHAR name[LF_FACESIZE], WCHAR language) const
753 {
754 return SetStatus(DllExports::GdipGetFamilyName(fontFamily, name, language));
755 }
756
757 Status
758 GetLastStatus() const
759 {
760 return status;
761 }
762
763 UINT16
764 GetLineSpacing(INT style) const
765 {
766 UINT16 LineSpacing;
767 SetStatus(DllExports::GdipGetLineSpacing(fontFamily, style, &LineSpacing));
768 return LineSpacing;
769 }
770
771 BOOL
772 IsAvailable() const
773 {
774 return FALSE;
775 }
776
777 BOOL
778 IsStyleAvailable(INT style) const
779 {
780 BOOL StyleAvailable;
781 SetStatus(DllExports::GdipIsStyleAvailable(fontFamily, style, &StyleAvailable));
782 return StyleAvailable;
783 }
784
785 private:
786 mutable Status status;
787 GpFontFamily *fontFamily;
788
789 Status
790 SetStatus(Status status) const
791 {
792 if (status == Ok)
793 return status;
794 this->status = status;
795 return status;
796 }
797 };
798
799 class InstalledFontFamily : public FontFamily
800 {
801 public:
802 InstalledFontFamily()
803 {
804 }
805 };
806
807 class PrivateFontCollection : public FontCollection
808 {
809 public:
810 PrivateFontCollection()
811 {
812 }
813
814 Status
815 AddFontFile(const WCHAR *filename)
816 {
817 return NotImplemented;
818 }
819
820 Status
821 AddMemoryFont(const VOID *memory, INT length)
822 {
823 return NotImplemented;
824 }
825 };
826
827 class Font : public GdiplusBase
828 {
829 public:
830 friend class FontFamily;
831 friend class FontCollection;
832 friend class Graphics;
833
834 Font(const FontFamily *family, REAL emSize, INT style, Unit unit)
835 {
836 status = DllExports::GdipCreateFont(family->fontFamily, emSize, style, unit, &font);
837 }
838
839 Font(HDC hdc, const HFONT hfont)
840 {
841 }
842
843 Font(HDC hdc, const LOGFONTA *logfont)
844 {
845 status = DllExports::GdipCreateFontFromLogfontA(hdc, logfont, &font);
846 }
847
848 Font(HDC hdc, const LOGFONTW *logfont)
849 {
850 status = DllExports::GdipCreateFontFromLogfontW(hdc, logfont, &font);
851 }
852
853 Font(const WCHAR *familyName, REAL emSize, INT style, Unit unit, const FontCollection *fontCollection)
854 {
855 }
856
857 Font(HDC hdc)
858 {
859 status = DllExports::GdipCreateFontFromDC(hdc, &font);
860 }
861
862 Font *
863 Clone() const
864 {
865 Font *cloneFont = new Font();
866 cloneFont->status = DllExports::GdipCloneFont(font, cloneFont ? &cloneFont->font : NULL);
867 return cloneFont;
868 }
869
870 Status
871 GetFamily(FontFamily *family) const
872 {
873 return SetStatus(DllExports::GdipGetFamily(font, family ? &family->fontFamily : NULL));
874 }
875
876 REAL
877 GetHeight(const Graphics *graphics) const
878 {
879 REAL height;
880 SetStatus(DllExports::GdipGetFontHeight(font, graphics ? graphics->graphics : NULL, &height));
881 return height;
882 }
883
884 REAL
885 GetHeight(REAL dpi) const
886 {
887 REAL height;
888 SetStatus(DllExports::GdipGetFontHeightGivenDPI(font, dpi, &height));
889 return height;
890 }
891
892 Status
893 GetLastStatus() const
894 {
895 return status;
896 }
897
898 Status
899 GetLogFontA(const Graphics *g, LOGFONTA *logfontA) const
900 {
901 return SetStatus(DllExports::GdipGetLogFontA(font, g ? g->graphics : NULL, logfontA));
902 }
903
904 Status
905 GetLogFontW(const Graphics *g, LOGFONTW *logfontW) const
906 {
907 return SetStatus(DllExports::GdipGetLogFontW(font, g ? g->graphics : NULL, logfontW));
908 }
909
910 REAL
911 GetSize() const
912 {
913 REAL size;
914 SetStatus(DllExports::GdipGetFontSize(font, &size));
915 return size;
916 }
917
918 INT
919 GetStyle() const
920 {
921 INT style;
922 SetStatus(DllExports::GdipGetFontStyle(font, &style));
923 return style;
924 }
925
926 Unit
927 GetUnit() const
928 {
929 Unit unit;
930 SetStatus(DllExports::GdipGetFontUnit(font, &unit));
931 return unit;
932 }
933
934 BOOL
935 IsAvailable() const
936 {
937 return FALSE;
938 }
939
940 protected:
941 Font()
942 {
943 }
944
945 private:
946 mutable Status status;
947 GpFont *font;
948
949 Status
950 SetStatus(Status status) const
951 {
952 if (status == Ok)
953 return status;
954 this->status = status;
955 return status;
956 }
957 };
958
959 class Region : public GdiplusBase
960 {
961 public:
962 friend class Graphics;
963 friend class GraphicsPath;
964 friend class Matrix;
965
966 Region(const Rect &rect)
967 {
968 status = DllExports::GdipCreateRegionRectI(&rect, &region);
969 }
970
971 Region()
972 {
973 status = DllExports::GdipCreateRegion(&region);
974 }
975
976 Region(const BYTE *regionData, INT size)
977 {
978 status = DllExports::GdipCreateRegionRgnData(regionData, size, &region);
979 }
980
981 Region(const GraphicsPath *path)
982 {
983 status = DllExports::GdipCreateRegionPath(path->path, &region);
984 }
985
986 Region(HRGN hRgn)
987 {
988 status = DllExports::GdipCreateRegionHrgn(hRgn, &region);
989 }
990
991 Region(const RectF &rect)
992 {
993 status = DllExports::GdipCreateRegionRect(&rect, &region);
994 }
995
996 Region *
997 Clone()
998 {
999 Region *cloneRegion = new Region();
1000 cloneRegion->status = DllExports::GdipCloneRegion(region, cloneRegion ? &cloneRegion->region : NULL);
1001 return cloneRegion;
1002 }
1003
1004 Status
1005 Complement(const GraphicsPath *path)
1006 {
1007 return SetStatus(DllExports::GdipCombineRegionPath(region, path ? path->path : NULL, CombineModeComplement));
1008 }
1009
1010 Status
1011 Complement(const Region *region)
1012 {
1013 return SetStatus(
1014 DllExports::GdipCombineRegionRegion(this->region, region ? region->region : NULL, CombineModeComplement));
1015 }
1016
1017 Status
1018 Complement(const Rect &rect)
1019 {
1020 return SetStatus(DllExports::GdipCombineRegionRectI(region, &rect, CombineModeComplement));
1021 }
1022
1023 Status
1024 Complement(const RectF &rect)
1025 {
1026 return SetStatus(DllExports::GdipCombineRegionRect(region, &rect, CombineModeComplement));
1027 }
1028
1029 BOOL
1030 Equals(const Region *region, const Graphics *g) const
1031 {
1032 BOOL result;
1033 SetStatus(DllExports::GdipIsEqualRegion(
1034 this->region, region ? region->region : NULL, g ? g->graphics : NULL, &result));
1035 return result;
1036 }
1037
1038 Status
1039 Exclude(const GraphicsPath *path)
1040 {
1041 return SetStatus(DllExports::GdipCombineRegionPath(region, path ? path->path : NULL, CombineModeExclude));
1042 }
1043
1044 Status
1045 Exclude(const RectF &rect)
1046 {
1047 return SetStatus(DllExports::GdipCombineRegionRect(region, &rect, CombineModeExclude));
1048 }
1049
1050 Status
1051 Exclude(const Rect &rect)
1052 {
1053 return SetStatus(DllExports::GdipCombineRegionRectI(region, &rect, CombineModeExclude));
1054 }
1055
1056 Status
1057 Exclude(const Region *region)
1058 {
1059 return SetStatus(
1060 DllExports::GdipCombineRegionRegion(this->region, region ? region->region : NULL, CombineModeExclude));
1061 }
1062
1063 static Region *
1064 FromHRGN(HRGN hRgn)
1065 {
1066 return new Region(hRgn);
1067 }
1068
1069 Status
1070 GetBounds(Rect *rect, const Graphics *g) const
1071 {
1072 return SetStatus(DllExports::GdipGetRegionBoundsI(region, g ? g->graphics : NULL, rect));
1073 }
1074
1075 Status
1076 GetBounds(RectF *rect, const Graphics *g) const
1077 {
1078 return SetStatus(DllExports::GdipGetRegionBounds(region, g ? g->graphics : NULL, rect));
1079 }
1080
1081 Status
1082 GetData(BYTE *buffer, UINT bufferSize, UINT *sizeFilled) const
1083 {
1084 return SetStatus(DllExports::GdipGetRegionData(region, buffer, bufferSize, sizeFilled));
1085 }
1086
1087 UINT
1088 GetDataSize() const
1089 {
1090 UINT bufferSize;
1091 SetStatus(DllExports::GdipGetRegionDataSize(region, &bufferSize));
1092 return bufferSize;
1093 }
1094
1095 HRGN
1096 GetHRGN(const Graphics *g) const
1097 {
1098 HRGN hRgn;
1099 SetStatus(DllExports::GdipGetRegionHRgn(region, g ? g->graphics : NULL, &hRgn));
1100 return hRgn;
1101 }
1102
1103 Status
1104 GetLastStatus()
1105 {
1106 return status;
1107 }
1108
1109 Status
1110 GetRegionScans(const Matrix *matrix, Rect *rects, INT *count) const
1111 {
1112 return SetStatus(DllExports::GdipGetRegionScansI(region, rects, count, matrix ? matrix->matrix : NULL));
1113 }
1114
1115 Status
1116 GetRegionScans(const Matrix *matrix, RectF *rects, INT *count) const
1117 {
1118 return SetStatus(DllExports::GdipGetRegionScans(region, rects, count, matrix ? matrix->matrix : NULL));
1119 }
1120
1121 UINT
1122 GetRegionScansCount(const Matrix *matrix) const
1123 {
1124 UINT count;
1125 SetStatus(DllExports::GdipGetRegionScansCount(region, &count, matrix ? matrix->matrix : NULL));
1126 return count;
1127 }
1128
1129 Status
1130 Intersect(const Rect &rect)
1131 {
1132 return SetStatus(DllExports::GdipCombineRegionRectI(region, &rect, CombineModeIntersect));
1133 }
1134
1135 Status
1136 Intersect(const GraphicsPath *path)
1137 {
1138 return SetStatus(DllExports::GdipCombineRegionPath(region, path ? path->path : NULL, CombineModeIntersect));
1139 }
1140
1141 Status
1142 Intersect(const RectF &rect)
1143 {
1144 return SetStatus(DllExports::GdipCombineRegionRect(region, &rect, CombineModeIntersect));
1145 }
1146
1147 Status
1148 Intersect(const Region *region)
1149 {
1150 return SetStatus(
1151 DllExports::GdipCombineRegionRegion(this->region, region ? region->region : NULL, CombineModeIntersect));
1152 }
1153
1154 BOOL
1155 IsEmpty(const Graphics *g) const
1156 {
1157 BOOL result;
1158 SetStatus(DllExports::GdipIsEmptyRegion(region, g ? g->graphics : NULL, &result));
1159 return result;
1160 }
1161
1162 BOOL
1163 IsInfinite(const Graphics *g) const
1164 {
1165 BOOL result;
1166 SetStatus(DllExports::GdipIsInfiniteRegion(region, g ? g->graphics : NULL, &result));
1167 return result;
1168 }
1169
1170 BOOL
1171 IsVisible(const PointF &point, const Graphics *g) const
1172 {
1173 BOOL result;
1174 SetStatus(DllExports::GdipIsVisibleRegionPoint(region, point.X, point.Y, g ? g->graphics : NULL, &result));
1175 return result;
1176 }
1177
1178 BOOL
1179 IsVisible(const RectF &rect, const Graphics *g) const
1180 {
1181 BOOL result;
1182 SetStatus(DllExports::GdipIsVisibleRegionRect(
1183 region, rect.X, rect.Y, rect.Width, rect.Height, g ? g->graphics : NULL, &result));
1184 return result;
1185 }
1186
1187 BOOL
1188 IsVisible(const Rect &rect, const Graphics *g) const
1189 {
1190 BOOL result;
1191 SetStatus(DllExports::GdipIsVisibleRegionRectI(
1192 region, rect.X, rect.Y, rect.Width, rect.Height, g ? g->graphics : NULL, &result));
1193 return result;
1194 }
1195
1196 BOOL
1197 IsVisible(INT x, INT y, const Graphics *g) const
1198 {
1199 BOOL result;
1200 SetStatus(DllExports::GdipIsVisibleRegionPointI(region, x, y, g ? g->graphics : NULL, &result));
1201 return result;
1202 }
1203
1204 BOOL
1205 IsVisible(REAL x, REAL y, const Graphics *g) const
1206 {
1207 BOOL result;
1208 SetStatus(DllExports::GdipIsVisibleRegionPoint(region, x, y, g ? g->graphics : NULL, &result));
1209 return result;
1210 }
1211
1212 BOOL
1213 IsVisible(INT x, INT y, INT width, INT height, const Graphics *g) const
1214 {
1215 BOOL result;
1216 SetStatus(DllExports::GdipIsVisibleRegionRectI(region, x, y, width, height, g ? g->graphics : NULL, &result));
1217 return result;
1218 }
1219
1220 BOOL
1221 IsVisible(const Point &point, const Graphics *g) const
1222 {
1223 BOOL result;
1224 SetStatus(DllExports::GdipIsVisibleRegionPointI(region, point.X, point.Y, g ? g->graphics : NULL, &result));
1225 return result;
1226 }
1227
1228 BOOL
1229 IsVisible(REAL x, REAL y, REAL width, REAL height, const Graphics *g) const
1230 {
1231 BOOL result;
1232 SetStatus(DllExports::GdipIsVisibleRegionRect(region, x, y, width, height, g ? g->graphics : NULL, &result));
1233 return result;
1234 }
1235
1236 Status
1237 MakeEmpty()
1238 {
1239 return SetStatus(DllExports::GdipSetEmpty(region));
1240 }
1241
1242 Status
1243 MakeInfinite()
1244 {
1245 return SetStatus(DllExports::GdipSetInfinite(region));
1246 }
1247
1248 Status
1249 Transform(const Matrix *matrix)
1250 {
1251 return SetStatus(DllExports::GdipTransformRegion(region, matrix ? matrix->matrix : NULL));
1252 }
1253
1254 Status
1255 Translate(REAL dx, REAL dy)
1256 {
1257 return SetStatus(DllExports::GdipTranslateRegion(region, dx, dy));
1258 }
1259
1260 Status
1261 Translate(INT dx, INT dy)
1262 {
1263 return SetStatus(DllExports::GdipTranslateRegionI(region, dx, dy));
1264 }
1265
1266 Status
1267 Union(const Rect &rect)
1268 {
1269 return SetStatus(DllExports::GdipCombineRegionRectI(region, &rect, CombineModeUnion));
1270 }
1271
1272 Status
1273 Union(const Region *region)
1274 {
1275 return SetStatus(
1276 DllExports::GdipCombineRegionRegion(this->region, region ? region->region : NULL, CombineModeUnion));
1277 }
1278
1279 Status
1280 Union(const RectF &rect)
1281 {
1282 return SetStatus(DllExports::GdipCombineRegionRect(region, &rect, CombineModeUnion));
1283 }
1284
1285 Status
1286 Union(const GraphicsPath *path)
1287 {
1288 return SetStatus(DllExports::GdipCombineRegionPath(region, path ? path->path : NULL, CombineModeUnion));
1289 }
1290
1291 Status
1292 Xor(const GraphicsPath *path)
1293 {
1294 return SetStatus(DllExports::GdipCombineRegionPath(region, path ? path->path : NULL, CombineModeXor));
1295 }
1296
1297 Status
1298 Xor(const RectF &rect)
1299 {
1300 return SetStatus(DllExports::GdipCombineRegionRect(region, &rect, CombineModeXor));
1301 }
1302
1303 Status
1304 Xor(const Rect &rect)
1305 {
1306 return SetStatus(DllExports::GdipCombineRegionRectI(region, &rect, CombineModeXor));
1307 }
1308
1309 Status
1310 Xor(const Region *region)
1311 {
1312 return SetStatus(
1313 DllExports::GdipCombineRegionRegion(this->region, region ? region->region : NULL, CombineModeXor));
1314 }
1315
1316 private:
1317 mutable Status status;
1318 GpRegion *region;
1319
1320 Status
1321 SetStatus(Status status) const
1322 {
1323 if (status == Ok)
1324 return status;
1325 this->status = status;
1326 return status;
1327 }
1328 };
1329
1330 class CustomLineCap : public GdiplusBase
1331 {
1332 public:
1333 CustomLineCap(const GraphicsPath *fillPath, const GraphicsPath *strokePath, LineCap baseCap, REAL baseInset);
1334 CustomLineCap *
1335 Clone();
1336 LineCap
1337 GetBaseCap();
1338 REAL
1339 GetBaseInset();
1340 Status
1341 GetLastStatus();
1342
1343 Status
1344 GetStrokeCaps(LineCap *startCap, LineCap *endCap);
1345
1346 LineJoin
1347 GetStrokeJoin();
1348 REAL
1349 GetWidthScale();
1350
1351 Status
1352 SetBaseCap(LineCap baseCap);
1353
1354 Status
1355 SetBaseInset(REAL inset);
1356
1357 Status
1358 SetStrokeCap(LineCap strokeCap);
1359
1360 Status
1361 SetStrokeCaps(LineCap startCap, LineCap endCap);
1362
1363 Status
1364 SetStrokeJoin(LineJoin lineJoin);
1365
1366 Status
1367 SetWidthScale(IN REAL widthScale);
1368
1369 protected:
1370 CustomLineCap();
1371 };
1372
1373 #endif /* _GDIPLUSHEADERS_H */