Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gdiplustypes.h « gdiplus « include « w32api « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9ac8de5b5fdffc9cab11360556af98a5381b1a2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
/*
 * gdiplustypes.h
 *
 * GDI+ basic type declarations
 *
 * This file is part of the w32api package.
 *
 * Contributors:
 *   Created by Markus Koenig <markus@stber-koenig.de>
 *
 * THIS SOFTWARE IS NOT COPYRIGHTED
 *
 * This source code is offered for use in the public domain. You may
 * use, modify or distribute it freely.
 *
 * This code is distributed in the hope that it will be useful but
 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 * DISCLAIMED. This includes but is not limited to warranties of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#ifndef __GDIPLUS_TYPES_H
#define __GDIPLUS_TYPES_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif

#define WINGDIPAPI __stdcall
#define GDIPCONST const

typedef enum GpStatus {
	Ok = 0,
	GenericError = 1,
	InvalidParameter = 2,
	OutOfMemory = 3,
	ObjectBusy = 4,
	InsufficientBuffer = 5,
	NotImplemented = 6,
	Win32Error = 7,
	WrongState = 8,
	Aborted = 9,
	FileNotFound = 10,
	ValueOverflow = 11,
	AccessDenied = 12,
	UnknownImageFormat = 13,
	FontFamilyNotFound = 14,
	FontStyleNotFound = 15,
	NotTrueTypeFont = 16,
	UnsupportedGdiplusVersion = 17,
	GdiplusNotInitialized = 18,
	PropertyNotFound = 19,
	PropertyNotSupported = 20,
	ProfileNotFound = 21
} GpStatus;

#ifdef __cplusplus
typedef GpStatus Status;
#endif

typedef struct Size {
	INT Width;
	INT Height;

	#ifdef __cplusplus
	Size(): Width(0), Height(0) {}
	Size(INT width, INT height): Width(width), Height(height) {}
	Size(const Size& size): Width(size.Width), Height(size.Height) {}
	
	BOOL Empty() const {
		return Width == 0 && Height == 0;
	}
	BOOL Equals(const Size& size) const {
		return Width == size.Width && Height == size.Height;
	}
	Size operator+(const Size& size) const {
		return Size(Width + size.Width, Height + size.Height);
	}
	Size operator-(const Size& size) const {
		return Size(Width - size.Width, Height - size.Height);
	}
	#endif /* __cplusplus */
} Size;

typedef struct SizeF {
	REAL Width;
	REAL Height;

	#ifdef __cplusplus
	SizeF(): Width(0.0f), Height(0.0f) {}
	SizeF(REAL width, REAL height): Width(width), Height(height) {}
	SizeF(const SizeF& size): Width(size.Width), Height(size.Height) {}
	
	BOOL Empty() const {
		return Width == 0.0f && Height == 0.0f;
	}
	BOOL Equals(const SizeF& size) const {
		return Width == size.Width && Height == size.Height;
	}
	SizeF operator+(const SizeF& size) const {
		return SizeF(Width + size.Width, Height + size.Height);
	}
	SizeF operator-(const SizeF& size) const {
		return SizeF(Width - size.Width, Height - size.Height);
	}
	#endif /* __cplusplus */
} SizeF;

typedef struct Point {
	INT X;
	INT Y;

	#ifdef __cplusplus
	Point(): X(0), Y(0) {}
	Point(INT x, INT y): X(x), Y(y) {}
	Point(const Point& point): X(point.X), Y(point.Y) {}
	Point(const Size& size): X(size.Width), Y(size.Height) {}
	
	BOOL Equals(const Point& point) const {
		return X == point.X && Y == point.Y;
	}
	Point operator+(const Point& point) const {
		return Point(X + point.X, Y + point.Y);
	}
	Point operator-(const Point& point) const {
		return Point(X - point.X, Y - point.Y);
	}
	#endif /* __cplusplus */
} Point;

typedef struct PointF {
	REAL X;
	REAL Y;

	#ifdef __cplusplus
	PointF(): X(0.0f), Y(0.0f) {}
	PointF(REAL x, REAL y): X(x), Y(y) {}
	PointF(const PointF& point): X(point.X), Y(point.Y) {}
	PointF(const SizeF& size): X(size.Width), Y(size.Height) {}
	
	BOOL Equals(const PointF& point) const {
		return X == point.X && Y == point.Y;
	}
	PointF operator+(const PointF& point) const {
		return PointF(X + point.X, Y + point.Y);
	}
	PointF operator-(const PointF& point) const {
		return PointF(X - point.X, Y - point.Y);
	}
	#endif /* __cplusplus */
} PointF;

typedef struct Rect {
	INT X;
	INT Y;
	INT Width;
	INT Height;

	#ifdef __cplusplus
	Rect(): X(0), Y(0), Width(0), Height(0) {}
	Rect(const Point& location, const Size& size):
		X(location.X), Y(location.Y),
		Width(size.Width), Height(size.Height) {}
	Rect(INT x, INT y, INT width, INT height):
		X(x), Y(y), Width(width), Height(height) {}
	
	Rect* Clone() const {
		return new Rect(X, Y, Width, Height);
	}
	BOOL Contains(INT x, INT y) const {
		return X <= x && Y <= y && x < X+Width && y < Y+Height;
	}
	BOOL Contains(const Point& point) const {
		return Contains(point.X, point.Y);
	}
	BOOL Contains(const Rect& rect) const {
		return X <= rect.X && Y <= rect.Y
			&& rect.X+rect.Width <= X+Width
			&& rect.Y+rect.Height <= Y+Height;
	}
	BOOL Equals(const Rect& rect) const {
		return X == rect.X && Y == rect.Y
			&& Width == rect.Width && Height == rect.Height;
	}
	INT GetBottom() const {
		return Y+Height;
	}
	VOID GetBounds(Rect *rect) const {
		if (rect != NULL) {
			rect->X = X;
			rect->Y = Y;
			rect->Width = Width;
			rect->Height = Height;
		}
	}
	INT GetLeft() const {
		return X;
	}
	VOID GetLocation(Point *point) const {
		if (point != NULL) {
			point->X = X;
			point->Y = Y;
		}
	}
	INT GetRight() const {
		return X+Width;
	}
	VOID GetSize(Size *size) const {
		if (size != NULL) {
			size->Width = Width;
			size->Height = Height;
		}
	}
	INT GetTop() const {
		return Y;
	}
	BOOL IsEmptyArea() const {
		return Width <= 0 || Height <= 0;
	}
	VOID Inflate(INT dx, INT dy) {
		X -= dx;
		Y -= dy;
		Width += 2*dx;
		Height += 2*dy;
	}
	VOID Inflate(const Point& point) {
		Inflate(point.X, point.Y);
	}
	static BOOL Intersect(Rect& c, const Rect& a, const Rect& b) {
		INT intersectLeft   = (a.X < b.X) ? b.X : a.X;
		INT intersectTop    = (a.Y < b.Y) ? b.Y : a.Y; 
		INT intersectRight  = (a.GetRight() < b.GetRight())
					? a.GetRight() : b.GetRight();
		INT intersectBottom = (a.GetBottom() < b.GetBottom())
					? a.GetBottom() : b.GetBottom();
		c.X = intersectLeft;
		c.Y = intersectTop;
		c.Width = intersectRight - intersectLeft;
		c.Height = intersectBottom - intersectTop;
		return !c.IsEmptyArea();  
	}
	BOOL Intersect(const Rect& rect) {
		return Intersect(*this, *this, rect);
	}
	BOOL IntersectsWith(const Rect& rc) const {
		INT intersectLeft   = (X < rc.X) ? rc.X : X;
		INT intersectTop    = (Y < rc.Y) ? rc.Y : Y; 
		INT intersectRight  = (GetRight() < rc.GetRight())
					? GetRight() : rc.GetRight();
		INT intersectBottom = (GetBottom() < rc.GetBottom())
					? GetBottom() : rc.GetBottom();
		return intersectLeft < intersectRight
			&& intersectTop < intersectBottom;
	}
	VOID Offset(INT dx, INT dy) {
		X += dx;
		Y += dy;
	}
	VOID Offset(const Point& point) {
		Offset(point.X, point.Y);
	}
	static BOOL Union(Rect& c, const Rect& a, const Rect& b) {
		INT unionLeft   = (a.X < b.X) ? a.X : b.X;
		INT unionTop    = (a.Y < b.Y) ? a.Y : b.Y; 
		INT unionRight  = (a.GetRight() < b.GetRight())
					? b.GetRight() : a.GetRight();
		INT unionBottom = (a.GetBottom() < b.GetBottom())
					? b.GetBottom() : a.GetBottom();
		c.X = unionLeft;
		c.Y = unionTop;
		c.Width = unionRight - unionLeft;
		c.Height = unionBottom - unionTop;
		return !c.IsEmptyArea();
	}
	#endif /* __cplusplus */
} Rect;

typedef struct RectF {
	REAL X;
	REAL Y;
	REAL Width;
	REAL Height;

	#ifdef __cplusplus
	RectF(): X(0.0f), Y(0.0f), Width(0.0f), Height(0.0f) {}
	RectF(const PointF& location, const SizeF& size):
		X(location.X), Y(location.Y),
		Width(size.Width), Height(size.Height) {}
	RectF(REAL x, REAL y, REAL width, REAL height):
		X(x), Y(y), Width(width), Height(height) {}
	
	RectF* Clone() const {
		return new RectF(X, Y, Width, Height);
	}
	BOOL Contains(REAL x, REAL y) const {
		return X <= x && Y <= y && x < X+Width && y < Y+Height;
	}
	BOOL Contains(const PointF& point) const {
		return Contains(point.X, point.Y);
	}
	BOOL Contains(const RectF& rect) const {
		return X <= rect.X && Y <= rect.Y
			&& rect.X+rect.Width <= X+Width
			&& rect.Y+rect.Height <= Y+Height;
	}
	BOOL Equals(const RectF& rect) const {
		return X == rect.X && Y == rect.Y
			&& Width == rect.Width && Height == rect.Height;
	}
	REAL GetBottom() const {
		return Y+Height;
	}
	VOID GetBounds(RectF *rect) const {
		if (rect != NULL) {
			rect->X = X;
			rect->Y = Y;
			rect->Width = Width;
			rect->Height = Height;
		}
	}
	REAL GetLeft() const {
		return X;
	}
	VOID GetLocation(PointF *point) const {
		if (point != NULL) {
			point->X = X;
			point->Y = Y;
		}
	}
	REAL GetRight() const {
		return X+Width;
	}
	VOID GetSize(SizeF *size) const {
		if (size != NULL) {
			size->Width = Width;
			size->Height = Height;
		}
	}
	REAL GetTop() const {
		return Y;
	}
	BOOL IsEmptyArea() const {
		return Width <= 0.0f || Height <= 0.0f;
	}
	VOID Inflate(REAL dx, REAL dy) {
		X -= dx;
		Y -= dy;
		Width += 2*dx;
		Height += 2*dy;
	}
	VOID Inflate(const PointF& point) {
		Inflate(point.X, point.Y);
	}
	static BOOL Intersect(RectF& c, const RectF& a, const RectF& b) {
		INT intersectLeft   = (a.X < b.X) ? b.X : a.X;
		INT intersectTop    = (a.Y < b.Y) ? b.Y : a.Y; 
		INT intersectRight  = (a.GetRight() < b.GetRight())
					? a.GetRight() : b.GetRight();
		INT intersectBottom = (a.GetBottom() < b.GetBottom())
					? a.GetBottom() : b.GetBottom();
		c.X = intersectLeft;
		c.Y = intersectTop;
		c.Width = intersectRight - intersectLeft;
		c.Height = intersectBottom - intersectTop;
		return !c.IsEmptyArea();  
	}
	BOOL Intersect(const RectF& rect) {
		return Intersect(*this, *this, rect);
	}
	BOOL IntersectsWith(const RectF& rc) const {
		INT intersectLeft   = (X < rc.X) ? rc.X : X;
		INT intersectTop    = (Y < rc.Y) ? rc.Y : Y; 
		INT intersectRight  = (GetRight() < rc.GetRight())
					? GetRight() : rc.GetRight();
		INT intersectBottom = (GetBottom() < rc.GetBottom())
					? GetBottom() : rc.GetBottom();
		return intersectLeft < intersectRight
			&& intersectTop < intersectBottom;
	}
	VOID Offset(REAL dx, REAL dy) {
		X += dx;
		Y += dy;
	}
	VOID Offset(const PointF& point) {
		Offset(point.X, point.Y);
	}
	static BOOL Union(RectF& c, const RectF& a, const RectF& b) {
		INT unionLeft   = (a.X < b.X) ? a.X : b.X;
		INT unionTop    = (a.Y < b.Y) ? a.Y : b.Y; 
		INT unionRight  = (a.GetRight() < b.GetRight())
					? b.GetRight() : a.GetRight();
		INT unionBottom = (a.GetBottom() < b.GetBottom())
					? b.GetBottom() : a.GetBottom();
		c.X = unionLeft;
		c.Y = unionTop;
		c.Width = unionRight - unionLeft;
		c.Height = unionBottom - unionTop;
		return !c.IsEmptyArea();
	}
	#endif /* __cplusplus */
} RectF;

/* FIXME: Are descendants of this class, when compiled with g++,
   binary compatible with MSVC++ code (especially GDIPLUS.DLL of course)? */
#ifdef __cplusplus
struct GdiplusAbort {
	virtual HRESULT __stdcall Abort(void) {}
};
#else
typedef struct GdiplusAbort GdiplusAbort;  /* incomplete type */
#endif

typedef struct CharacterRange {
	INT First;
	INT Length;

	#ifdef __cplusplus
	CharacterRange(): First(0), Length(0) {}
	CharacterRange(INT first, INT length): First(first), Length(length) {}
	CharacterRange& operator=(const CharacterRange& rhs) {
		/* This gracefully handles self-assignment */
		First = rhs.First;
		Length = rhs.Length;
		return *this;
	}
	#endif /* __cplusplus */
} CharacterRange;

typedef struct PathData {
	INT Count;
	PointF *Points;
	BYTE *Types;

	#ifdef __cplusplus
	friend class GraphicsPath;

	PathData(): Count(0), Points(NULL), Types(NULL) {}
	~PathData() {
		FreeArrays();
	}
private:
	/* used by GraphicsPath::GetPathData, defined in gdipluspath.h */
	Status AllocateArrays(INT capacity);
	VOID FreeArrays();
	#endif /* __cplusplus */
} PathData;

/* Callback function types */
/* FIXME: need a correct definition for these function pointer types */
typedef void *DebugEventProc;
typedef BOOL CALLBACK (*EnumerateMetafileProc)(EmfPlusRecordType,UINT,UINT,const BYTE*,VOID*);
typedef void *DrawImageAbort;
typedef void *GetThumbnailImageAbort;


#endif /* __GDIPLUS_TYPES_H */