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