OSDN Git Service

Avoid an implication that the API is exclusively 32-bit.
[mingw/mingw-org-wsl.git] / wslapi / include / gdiplus / gdiplustypes.h
1 /*\r
2  * gdiplustypes.h\r
3  *\r
4  * GDI+ basic type declarations\r
5  *\r
6  * This file is part of the w32api package.\r
7  *\r
8  * Contributors:\r
9  *   Created by Markus Koenig <markus@stber-koenig.de>\r
10  *\r
11  * THIS SOFTWARE IS NOT COPYRIGHTED\r
12  *\r
13  * This source code is offered for use in the public domain. You may\r
14  * use, modify or distribute it freely.\r
15  *\r
16  * This code is distributed in the hope that it will be useful but\r
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY\r
18  * DISCLAIMED. This includes but is not limited to warranties of\r
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
20  *\r
21  */\r
22 \r
23 #ifndef __GDIPLUS_TYPES_H\r
24 #define __GDIPLUS_TYPES_H\r
25 #if __GNUC__ >=3\r
26 #pragma GCC system_header\r
27 #endif\r
28 \r
29 #define WINGDIPAPI __stdcall\r
30 #define GDIPCONST const\r
31 \r
32 typedef enum GpStatus {\r
33         Ok = 0,\r
34         GenericError = 1,\r
35         InvalidParameter = 2,\r
36         OutOfMemory = 3,\r
37         ObjectBusy = 4,\r
38         InsufficientBuffer = 5,\r
39         NotImplemented = 6,\r
40         Win32Error = 7,\r
41         WrongState = 8,\r
42         Aborted = 9,\r
43         FileNotFound = 10,\r
44         ValueOverflow = 11,\r
45         AccessDenied = 12,\r
46         UnknownImageFormat = 13,\r
47         FontFamilyNotFound = 14,\r
48         FontStyleNotFound = 15,\r
49         NotTrueTypeFont = 16,\r
50         UnsupportedGdiplusVersion = 17,\r
51         GdiplusNotInitialized = 18,\r
52         PropertyNotFound = 19,\r
53         PropertyNotSupported = 20,\r
54         ProfileNotFound = 21\r
55 } GpStatus;\r
56 \r
57 #ifdef __cplusplus\r
58 typedef GpStatus Status;\r
59 #endif\r
60 \r
61 typedef struct Size {\r
62         INT Width;\r
63         INT Height;\r
64 \r
65         #ifdef __cplusplus\r
66         Size(): Width(0), Height(0) {}\r
67         Size(INT width, INT height): Width(width), Height(height) {}\r
68         Size(const Size& size): Width(size.Width), Height(size.Height) {}\r
69         \r
70         BOOL Empty() const {\r
71                 return Width == 0 && Height == 0;\r
72         }\r
73         BOOL Equals(const Size& size) const {\r
74                 return Width == size.Width && Height == size.Height;\r
75         }\r
76         Size operator+(const Size& size) const {\r
77                 return Size(Width + size.Width, Height + size.Height);\r
78         }\r
79         Size operator-(const Size& size) const {\r
80                 return Size(Width - size.Width, Height - size.Height);\r
81         }\r
82         #endif /* __cplusplus */\r
83 } Size;\r
84 \r
85 typedef struct SizeF {\r
86         REAL Width;\r
87         REAL Height;\r
88 \r
89         #ifdef __cplusplus\r
90         SizeF(): Width(0.0f), Height(0.0f) {}\r
91         SizeF(REAL width, REAL height): Width(width), Height(height) {}\r
92         SizeF(const SizeF& size): Width(size.Width), Height(size.Height) {}\r
93         \r
94         BOOL Empty() const {\r
95                 return Width == 0.0f && Height == 0.0f;\r
96         }\r
97         BOOL Equals(const SizeF& size) const {\r
98                 return Width == size.Width && Height == size.Height;\r
99         }\r
100         SizeF operator+(const SizeF& size) const {\r
101                 return SizeF(Width + size.Width, Height + size.Height);\r
102         }\r
103         SizeF operator-(const SizeF& size) const {\r
104                 return SizeF(Width - size.Width, Height - size.Height);\r
105         }\r
106         #endif /* __cplusplus */\r
107 } SizeF;\r
108 \r
109 typedef struct Point {\r
110         INT X;\r
111         INT Y;\r
112 \r
113         #ifdef __cplusplus\r
114         Point(): X(0), Y(0) {}\r
115         Point(INT x, INT y): X(x), Y(y) {}\r
116         Point(const Point& point): X(point.X), Y(point.Y) {}\r
117         Point(const Size& size): X(size.Width), Y(size.Height) {}\r
118         \r
119         BOOL Equals(const Point& point) const {\r
120                 return X == point.X && Y == point.Y;\r
121         }\r
122         Point operator+(const Point& point) const {\r
123                 return Point(X + point.X, Y + point.Y);\r
124         }\r
125         Point operator-(const Point& point) const {\r
126                 return Point(X - point.X, Y - point.Y);\r
127         }\r
128         #endif /* __cplusplus */\r
129 } Point;\r
130 \r
131 typedef struct PointF {\r
132         REAL X;\r
133         REAL Y;\r
134 \r
135         #ifdef __cplusplus\r
136         PointF(): X(0.0f), Y(0.0f) {}\r
137         PointF(REAL x, REAL y): X(x), Y(y) {}\r
138         PointF(const PointF& point): X(point.X), Y(point.Y) {}\r
139         PointF(const SizeF& size): X(size.Width), Y(size.Height) {}\r
140         \r
141         BOOL Equals(const PointF& point) const {\r
142                 return X == point.X && Y == point.Y;\r
143         }\r
144         PointF operator+(const PointF& point) const {\r
145                 return PointF(X + point.X, Y + point.Y);\r
146         }\r
147         PointF operator-(const PointF& point) const {\r
148                 return PointF(X - point.X, Y - point.Y);\r
149         }\r
150         #endif /* __cplusplus */\r
151 } PointF;\r
152 \r
153 typedef struct Rect {\r
154         INT X;\r
155         INT Y;\r
156         INT Width;\r
157         INT Height;\r
158 \r
159         #ifdef __cplusplus\r
160         Rect(): X(0), Y(0), Width(0), Height(0) {}\r
161         Rect(const Point& location, const Size& size):\r
162                 X(location.X), Y(location.Y),\r
163                 Width(size.Width), Height(size.Height) {}\r
164         Rect(INT x, INT y, INT width, INT height):\r
165                 X(x), Y(y), Width(width), Height(height) {}\r
166         \r
167         Rect* Clone() const {\r
168                 return new Rect(X, Y, Width, Height);\r
169         }\r
170         BOOL Contains(INT x, INT y) const {\r
171                 return X <= x && Y <= y && x < X+Width && y < Y+Height;\r
172         }\r
173         BOOL Contains(const Point& point) const {\r
174                 return Contains(point.X, point.Y);\r
175         }\r
176         BOOL Contains(const Rect& rect) const {\r
177                 return X <= rect.X && Y <= rect.Y\r
178                         && rect.X+rect.Width <= X+Width\r
179                         && rect.Y+rect.Height <= Y+Height;\r
180         }\r
181         BOOL Equals(const Rect& rect) const {\r
182                 return X == rect.X && Y == rect.Y\r
183                         && Width == rect.Width && Height == rect.Height;\r
184         }\r
185         INT GetBottom() const {\r
186                 return Y+Height;\r
187         }\r
188         VOID GetBounds(Rect *rect) const {\r
189                 if (rect != NULL) {\r
190                         rect->X = X;\r
191                         rect->Y = Y;\r
192                         rect->Width = Width;\r
193                         rect->Height = Height;\r
194                 }\r
195         }\r
196         INT GetLeft() const {\r
197                 return X;\r
198         }\r
199         VOID GetLocation(Point *point) const {\r
200                 if (point != NULL) {\r
201                         point->X = X;\r
202                         point->Y = Y;\r
203                 }\r
204         }\r
205         INT GetRight() const {\r
206                 return X+Width;\r
207         }\r
208         VOID GetSize(Size *size) const {\r
209                 if (size != NULL) {\r
210                         size->Width = Width;\r
211                         size->Height = Height;\r
212                 }\r
213         }\r
214         INT GetTop() const {\r
215                 return Y;\r
216         }\r
217         BOOL IsEmptyArea() const {\r
218                 return Width <= 0 || Height <= 0;\r
219         }\r
220         VOID Inflate(INT dx, INT dy) {\r
221                 X -= dx;\r
222                 Y -= dy;\r
223                 Width += 2*dx;\r
224                 Height += 2*dy;\r
225         }\r
226         VOID Inflate(const Point& point) {\r
227                 Inflate(point.X, point.Y);\r
228         }\r
229         static BOOL Intersect(Rect& c, const Rect& a, const Rect& b) {\r
230                 INT intersectLeft   = (a.X < b.X) ? b.X : a.X;\r
231                 INT intersectTop    = (a.Y < b.Y) ? b.Y : a.Y; \r
232                 INT intersectRight  = (a.GetRight() < b.GetRight())\r
233                                         ? a.GetRight() : b.GetRight();\r
234                 INT intersectBottom = (a.GetBottom() < b.GetBottom())\r
235                                         ? a.GetBottom() : b.GetBottom();\r
236                 c.X = intersectLeft;\r
237                 c.Y = intersectTop;\r
238                 c.Width = intersectRight - intersectLeft;\r
239                 c.Height = intersectBottom - intersectTop;\r
240                 return !c.IsEmptyArea();  \r
241         }\r
242         BOOL Intersect(const Rect& rect) {\r
243                 return Intersect(*this, *this, rect);\r
244         }\r
245         BOOL IntersectsWith(const Rect& rc) const {\r
246                 INT intersectLeft   = (X < rc.X) ? rc.X : X;\r
247                 INT intersectTop    = (Y < rc.Y) ? rc.Y : Y; \r
248                 INT intersectRight  = (GetRight() < rc.GetRight())\r
249                                         ? GetRight() : rc.GetRight();\r
250                 INT intersectBottom = (GetBottom() < rc.GetBottom())\r
251                                         ? GetBottom() : rc.GetBottom();\r
252                 return intersectLeft < intersectRight\r
253                         && intersectTop < intersectBottom;\r
254         }\r
255         VOID Offset(INT dx, INT dy) {\r
256                 X += dx;\r
257                 Y += dy;\r
258         }\r
259         VOID Offset(const Point& point) {\r
260                 Offset(point.X, point.Y);\r
261         }\r
262         static BOOL Union(Rect& c, const Rect& a, const Rect& b) {\r
263                 INT unionLeft   = (a.X < b.X) ? a.X : b.X;\r
264                 INT unionTop    = (a.Y < b.Y) ? a.Y : b.Y; \r
265                 INT unionRight  = (a.GetRight() < b.GetRight())\r
266                                         ? b.GetRight() : a.GetRight();\r
267                 INT unionBottom = (a.GetBottom() < b.GetBottom())\r
268                                         ? b.GetBottom() : a.GetBottom();\r
269                 c.X = unionLeft;\r
270                 c.Y = unionTop;\r
271                 c.Width = unionRight - unionLeft;\r
272                 c.Height = unionBottom - unionTop;\r
273                 return !c.IsEmptyArea();\r
274         }\r
275         #endif /* __cplusplus */\r
276 } Rect;\r
277 \r
278 typedef struct RectF {\r
279         REAL X;\r
280         REAL Y;\r
281         REAL Width;\r
282         REAL Height;\r
283 \r
284         #ifdef __cplusplus\r
285         RectF(): X(0.0f), Y(0.0f), Width(0.0f), Height(0.0f) {}\r
286         RectF(const PointF& location, const SizeF& size):\r
287                 X(location.X), Y(location.Y),\r
288                 Width(size.Width), Height(size.Height) {}\r
289         RectF(REAL x, REAL y, REAL width, REAL height):\r
290                 X(x), Y(y), Width(width), Height(height) {}\r
291         \r
292         RectF* Clone() const {\r
293                 return new RectF(X, Y, Width, Height);\r
294         }\r
295         BOOL Contains(REAL x, REAL y) const {\r
296                 return X <= x && Y <= y && x < X+Width && y < Y+Height;\r
297         }\r
298         BOOL Contains(const PointF& point) const {\r
299                 return Contains(point.X, point.Y);\r
300         }\r
301         BOOL Contains(const RectF& rect) const {\r
302                 return X <= rect.X && Y <= rect.Y\r
303                         && rect.X+rect.Width <= X+Width\r
304                         && rect.Y+rect.Height <= Y+Height;\r
305         }\r
306         BOOL Equals(const RectF& rect) const {\r
307                 return X == rect.X && Y == rect.Y\r
308                         && Width == rect.Width && Height == rect.Height;\r
309         }\r
310         REAL GetBottom() const {\r
311                 return Y+Height;\r
312         }\r
313         VOID GetBounds(RectF *rect) const {\r
314                 if (rect != NULL) {\r
315                         rect->X = X;\r
316                         rect->Y = Y;\r
317                         rect->Width = Width;\r
318                         rect->Height = Height;\r
319                 }\r
320         }\r
321         REAL GetLeft() const {\r
322                 return X;\r
323         }\r
324         VOID GetLocation(PointF *point) const {\r
325                 if (point != NULL) {\r
326                         point->X = X;\r
327                         point->Y = Y;\r
328                 }\r
329         }\r
330         REAL GetRight() const {\r
331                 return X+Width;\r
332         }\r
333         VOID GetSize(SizeF *size) const {\r
334                 if (size != NULL) {\r
335                         size->Width = Width;\r
336                         size->Height = Height;\r
337                 }\r
338         }\r
339         REAL GetTop() const {\r
340                 return Y;\r
341         }\r
342         BOOL IsEmptyArea() const {\r
343                 return Width <= 0.0f || Height <= 0.0f;\r
344         }\r
345         VOID Inflate(REAL dx, REAL dy) {\r
346                 X -= dx;\r
347                 Y -= dy;\r
348                 Width += 2*dx;\r
349                 Height += 2*dy;\r
350         }\r
351         VOID Inflate(const PointF& point) {\r
352                 Inflate(point.X, point.Y);\r
353         }\r
354         static BOOL Intersect(RectF& c, const RectF& a, const RectF& b) {\r
355                 INT intersectLeft   = (a.X < b.X) ? b.X : a.X;\r
356                 INT intersectTop    = (a.Y < b.Y) ? b.Y : a.Y; \r
357                 INT intersectRight  = (a.GetRight() < b.GetRight())\r
358                                         ? a.GetRight() : b.GetRight();\r
359                 INT intersectBottom = (a.GetBottom() < b.GetBottom())\r
360                                         ? a.GetBottom() : b.GetBottom();\r
361                 c.X = intersectLeft;\r
362                 c.Y = intersectTop;\r
363                 c.Width = intersectRight - intersectLeft;\r
364                 c.Height = intersectBottom - intersectTop;\r
365                 return !c.IsEmptyArea();  \r
366         }\r
367         BOOL Intersect(const RectF& rect) {\r
368                 return Intersect(*this, *this, rect);\r
369         }\r
370         BOOL IntersectsWith(const RectF& rc) const {\r
371                 INT intersectLeft   = (X < rc.X) ? rc.X : X;\r
372                 INT intersectTop    = (Y < rc.Y) ? rc.Y : Y; \r
373                 INT intersectRight  = (GetRight() < rc.GetRight())\r
374                                         ? GetRight() : rc.GetRight();\r
375                 INT intersectBottom = (GetBottom() < rc.GetBottom())\r
376                                         ? GetBottom() : rc.GetBottom();\r
377                 return intersectLeft < intersectRight\r
378                         && intersectTop < intersectBottom;\r
379         }\r
380         VOID Offset(REAL dx, REAL dy) {\r
381                 X += dx;\r
382                 Y += dy;\r
383         }\r
384         VOID Offset(const PointF& point) {\r
385                 Offset(point.X, point.Y);\r
386         }\r
387         static BOOL Union(RectF& c, const RectF& a, const RectF& b) {\r
388                 INT unionLeft   = (a.X < b.X) ? a.X : b.X;\r
389                 INT unionTop    = (a.Y < b.Y) ? a.Y : b.Y; \r
390                 INT unionRight  = (a.GetRight() < b.GetRight())\r
391                                         ? b.GetRight() : a.GetRight();\r
392                 INT unionBottom = (a.GetBottom() < b.GetBottom())\r
393                                         ? b.GetBottom() : a.GetBottom();\r
394                 c.X = unionLeft;\r
395                 c.Y = unionTop;\r
396                 c.Width = unionRight - unionLeft;\r
397                 c.Height = unionBottom - unionTop;\r
398                 return !c.IsEmptyArea();\r
399         }\r
400         #endif /* __cplusplus */\r
401 } RectF;\r
402 \r
403 /* FIXME: Are descendants of this class, when compiled with g++,\r
404    binary compatible with MSVC++ code (especially GDIPLUS.DLL of course)? */\r
405 #ifdef __cplusplus\r
406 struct GdiplusAbort {\r
407         virtual HRESULT __stdcall Abort(void) { return NO_ERROR; }\r
408 };\r
409 #else\r
410 typedef struct GdiplusAbort GdiplusAbort;  /* incomplete type */\r
411 #endif\r
412 \r
413 typedef struct CharacterRange {\r
414         INT First;\r
415         INT Length;\r
416 \r
417         #ifdef __cplusplus\r
418         CharacterRange(): First(0), Length(0) {}\r
419         CharacterRange(INT first, INT length): First(first), Length(length) {}\r
420         CharacterRange& operator=(const CharacterRange& rhs) {\r
421                 /* This gracefully handles self-assignment */\r
422                 First = rhs.First;\r
423                 Length = rhs.Length;\r
424                 return *this;\r
425         }\r
426         #endif /* __cplusplus */\r
427 } CharacterRange;\r
428 \r
429 typedef struct PathData {\r
430         INT Count;\r
431         PointF *Points;\r
432         BYTE *Types;\r
433 \r
434         #ifdef __cplusplus\r
435         friend class GraphicsPath;\r
436 \r
437         PathData(): Count(0), Points(NULL), Types(NULL) {}\r
438         ~PathData() {\r
439                 FreeArrays();\r
440         }\r
441 private:\r
442         /* used by GraphicsPath::GetPathData, defined in gdipluspath.h */\r
443         Status AllocateArrays(INT capacity);\r
444         VOID FreeArrays();\r
445         #endif /* __cplusplus */\r
446 } PathData;\r
447 \r
448 /* Callback function types */\r
449 /* FIXME: need a correct definition for these function pointer types */\r
450 typedef void *DebugEventProc;\r
451 typedef BOOL CALLBACK (*EnumerateMetafileProc)(EmfPlusRecordType,UINT,UINT,const BYTE*,VOID*);\r
452 typedef void *DrawImageAbort;\r
453 typedef void *GetThumbnailImageAbort;\r
454 \r
455 \r
456 #endif /* __GDIPLUS_TYPES_H */\r