4 * GDI+ basic type declarations
\r
6 * This file is part of the w32api package.
\r
9 * Created by Markus Koenig <markus@stber-koenig.de>
\r
11 * THIS SOFTWARE IS NOT COPYRIGHTED
\r
13 * This source code is offered for use in the public domain. You may
\r
14 * use, modify or distribute it freely.
\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
23 #ifndef __GDIPLUS_TYPES_H
\r
24 #define __GDIPLUS_TYPES_H
\r
26 #pragma GCC system_header
\r
29 #define WINGDIPAPI __stdcall
\r
30 #define GDIPCONST const
\r
32 typedef enum GpStatus {
\r
35 InvalidParameter = 2,
\r
38 InsufficientBuffer = 5,
\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
58 typedef GpStatus Status;
\r
61 typedef struct Size {
\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
70 BOOL Empty() const {
\r
71 return Width == 0 && Height == 0;
\r
73 BOOL Equals(const Size& size) const {
\r
74 return Width == size.Width && Height == size.Height;
\r
76 Size operator+(const Size& size) const {
\r
77 return Size(Width + size.Width, Height + size.Height);
\r
79 Size operator-(const Size& size) const {
\r
80 return Size(Width - size.Width, Height - size.Height);
\r
82 #endif /* __cplusplus */
\r
85 typedef struct SizeF {
\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
94 BOOL Empty() const {
\r
95 return Width == 0.0f && Height == 0.0f;
\r
97 BOOL Equals(const SizeF& size) const {
\r
98 return Width == size.Width && Height == size.Height;
\r
100 SizeF operator+(const SizeF& size) const {
\r
101 return SizeF(Width + size.Width, Height + size.Height);
\r
103 SizeF operator-(const SizeF& size) const {
\r
104 return SizeF(Width - size.Width, Height - size.Height);
\r
106 #endif /* __cplusplus */
\r
109 typedef struct Point {
\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
119 BOOL Equals(const Point& point) const {
\r
120 return X == point.X && Y == point.Y;
\r
122 Point operator+(const Point& point) const {
\r
123 return Point(X + point.X, Y + point.Y);
\r
125 Point operator-(const Point& point) const {
\r
126 return Point(X - point.X, Y - point.Y);
\r
128 #endif /* __cplusplus */
\r
131 typedef struct PointF {
\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
141 BOOL Equals(const PointF& point) const {
\r
142 return X == point.X && Y == point.Y;
\r
144 PointF operator+(const PointF& point) const {
\r
145 return PointF(X + point.X, Y + point.Y);
\r
147 PointF operator-(const PointF& point) const {
\r
148 return PointF(X - point.X, Y - point.Y);
\r
150 #endif /* __cplusplus */
\r
153 typedef struct Rect {
\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
167 Rect* Clone() const {
\r
168 return new Rect(X, Y, Width, Height);
\r
170 BOOL Contains(INT x, INT y) const {
\r
171 return X <= x && Y <= y && x < X+Width && y < Y+Height;
\r
173 BOOL Contains(const Point& point) const {
\r
174 return Contains(point.X, point.Y);
\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
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
185 INT GetBottom() const {
\r
188 VOID GetBounds(Rect *rect) const {
\r
189 if (rect != NULL) {
\r
192 rect->Width = Width;
\r
193 rect->Height = Height;
\r
196 INT GetLeft() const {
\r
199 VOID GetLocation(Point *point) const {
\r
200 if (point != NULL) {
\r
205 INT GetRight() const {
\r
208 VOID GetSize(Size *size) const {
\r
209 if (size != NULL) {
\r
210 size->Width = Width;
\r
211 size->Height = Height;
\r
214 INT GetTop() const {
\r
217 BOOL IsEmptyArea() const {
\r
218 return Width <= 0 || Height <= 0;
\r
220 VOID Inflate(INT dx, INT dy) {
\r
226 VOID Inflate(const Point& point) {
\r
227 Inflate(point.X, point.Y);
\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
242 BOOL Intersect(const Rect& rect) {
\r
243 return Intersect(*this, *this, rect);
\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
255 VOID Offset(INT dx, INT dy) {
\r
259 VOID Offset(const Point& point) {
\r
260 Offset(point.X, point.Y);
\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
271 c.Width = unionRight - unionLeft;
\r
272 c.Height = unionBottom - unionTop;
\r
273 return !c.IsEmptyArea();
\r
275 #endif /* __cplusplus */
\r
278 typedef struct RectF {
\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
292 RectF* Clone() const {
\r
293 return new RectF(X, Y, Width, Height);
\r
295 BOOL Contains(REAL x, REAL y) const {
\r
296 return X <= x && Y <= y && x < X+Width && y < Y+Height;
\r
298 BOOL Contains(const PointF& point) const {
\r
299 return Contains(point.X, point.Y);
\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
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
310 REAL GetBottom() const {
\r
313 VOID GetBounds(RectF *rect) const {
\r
314 if (rect != NULL) {
\r
317 rect->Width = Width;
\r
318 rect->Height = Height;
\r
321 REAL GetLeft() const {
\r
324 VOID GetLocation(PointF *point) const {
\r
325 if (point != NULL) {
\r
330 REAL GetRight() const {
\r
333 VOID GetSize(SizeF *size) const {
\r
334 if (size != NULL) {
\r
335 size->Width = Width;
\r
336 size->Height = Height;
\r
339 REAL GetTop() const {
\r
342 BOOL IsEmptyArea() const {
\r
343 return Width <= 0.0f || Height <= 0.0f;
\r
345 VOID Inflate(REAL dx, REAL dy) {
\r
351 VOID Inflate(const PointF& point) {
\r
352 Inflate(point.X, point.Y);
\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
367 BOOL Intersect(const RectF& rect) {
\r
368 return Intersect(*this, *this, rect);
\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
380 VOID Offset(REAL dx, REAL dy) {
\r
384 VOID Offset(const PointF& point) {
\r
385 Offset(point.X, point.Y);
\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
396 c.Width = unionRight - unionLeft;
\r
397 c.Height = unionBottom - unionTop;
\r
398 return !c.IsEmptyArea();
\r
400 #endif /* __cplusplus */
\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
406 struct GdiplusAbort {
\r
407 virtual HRESULT __stdcall Abort(void) { return NO_ERROR; }
\r
410 typedef struct GdiplusAbort GdiplusAbort; /* incomplete type */
\r
413 typedef struct CharacterRange {
\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
423 Length = rhs.Length;
\r
426 #endif /* __cplusplus */
\r
429 typedef struct PathData {
\r
435 friend class GraphicsPath;
\r
437 PathData(): Count(0), Points(NULL), Types(NULL) {}
\r
442 /* used by GraphicsPath::GetPathData, defined in gdipluspath.h */
\r
443 Status AllocateArrays(INT capacity);
\r
445 #endif /* __cplusplus */
\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
456 #endif /* __GDIPLUS_TYPES_H */
\r