ReactOS 0.4.17-dev-246-gaf10f35
gdiplustypes.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007 Google (Evan Stade)
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#ifndef _GDIPLUSTYPES_H
20#define _GDIPLUSTYPES_H
21
22typedef float REAL;
23
24enum Status{
25 Ok = 0,
47};
48
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
58
60
61#ifdef __cplusplus
62}
63#endif
64
65
66#ifdef __cplusplus
67
68class Size;
69
70class Point
71{
72public:
73 Point()
74 {
75 X = Y = 0;
76 }
77
78 Point(IN const Point &pt)
79 {
80 X = pt.X;
81 Y = pt.Y;
82 }
83
84 Point(const Size &size);
85
86 Point(IN INT x, IN INT y)
87 {
88 X = x;
89 Y = y;
90 }
91
92 Point operator+(IN const Point& pt) const
93 {
94 return Point(X + pt.X, Y + pt.Y);
95 }
96
97 Point operator-(IN const Point& pt) const
98 {
99 return Point(X - pt.X, Y - pt.Y);
100 }
101
102 BOOL Equals(IN const Point& pt)
103 {
104 return (X == pt.X) && (Y == pt.Y);
105 }
106
107public:
108 INT X;
109 INT Y;
110};
111
112class SizeF;
113
114class PointF
115{
116public:
117 PointF()
118 {
119 X = Y = 0.0f;
120 }
121
122 PointF(IN const PointF &pt)
123 {
124 X = pt.X;
125 Y = pt.Y;
126 }
127
128 PointF(const SizeF &size);
129
131 {
132 X = x;
133 Y = y;
134 }
135
136 PointF operator+(IN const PointF& pt) const
137 {
138 return PointF(X + pt.X, Y + pt.Y);
139 }
140
141 PointF operator-(IN const PointF& pt) const
142 {
143 return PointF(X - pt.X, Y - pt.Y);
144 }
145
146 BOOL Equals(IN const PointF& pt)
147 {
148 return (X == pt.X) && (Y == pt.Y);
149 }
150
151public:
152 REAL X;
153 REAL Y;
154};
155
156class PathData
157{
158public:
159 PathData()
160 {
161 Count = 0;
162 Points = NULL;
163 Types = NULL;
164 }
165
166 ~PathData()
167 {
168 if (Points != NULL)
169 {
170 delete Points;
171 }
172
173 if (Types != NULL)
174 {
175 delete Types;
176 }
177 }
178
179private:
180 PathData(const PathData &);
181 PathData& operator=(const PathData &);
182
183public:
184 INT Count;
185 PointF* Points;
186 BYTE* Types;
187};
188
189class SizeF
190{
191 public:
192 REAL Width;
193 REAL Height;
194
195 SizeF() : Width(0), Height(0)
196 {
197 }
198
199 SizeF(const SizeF &size) : Width(size.Width), Height(size.Height)
200 {
201 }
202
204 {
205 }
206
207 BOOL
208 Empty() const
209 {
210 return Width == 0 && Height == 0;
211 }
212
213 BOOL
214 Equals(const SizeF &sz) const
215 {
216 return Width == sz.Width && Height == sz.Height;
217 }
218
219 SizeF
220 operator+(const SizeF &sz) const
221 {
222 return SizeF(Width + sz.Width, Height + sz.Height);
223 }
224
225 SizeF
226 operator-(const SizeF &sz) const
227 {
228 return SizeF(Width - sz.Width, Height - sz.Height);
229 }
230};
231
232#define REAL_EPSILON 1.192092896e-07F /* FLT_EPSILON */
233
234class RectF
235{
236public:
237 REAL X;
238 REAL Y;
239 REAL Width;
240 REAL Height;
241
242 RectF()
243 : X(0), Y(0), Width(0), Height(0)
244 {
245 }
246
247 RectF(const PointF &location, const SizeF &size)
249 {
250 }
251
253 : X(x), Y(y), Width(width), Height(height)
254 {
255 }
256
257 RectF *
258 Clone() const
259 {
260 return new RectF(X, Y, Width, Height);
261 }
262
263 BOOL
264 Contains(const PointF &pt) const
265 {
266 return Contains(pt.X, pt.Y);
267 }
268
269 BOOL
270 Contains(const RectF &rect) const
271 {
272 return X <= rect.X && rect.GetRight() <= GetRight() && Y <= rect.Y && rect.GetBottom() <= GetBottom();
273 }
274
275 BOOL
276 Contains(REAL x, REAL y) const
277 {
278 return X <= x && x < X + Width && Y <= y && y < Y + Height;
279 }
280
281 BOOL
282 Equals(const RectF &rect) const
283 {
284 return X == rect.X && Y == rect.Y && Width == rect.Width && Height == rect.Height;
285 }
286
287 REAL
288 GetBottom() const
289 {
290 return Y + Height;
291 }
292
293 VOID
294 GetBounds(RectF *rect) const
295 {
296 rect->X = X;
297 rect->Y = Y;
298 rect->Width = Width;
299 rect->Height = Height;
300 }
301
302 REAL
303 GetLeft() const
304 {
305 return X;
306 }
307
308 VOID
309 GetLocation(PointF *point) const
310 {
311 point->X = X;
312 point->Y = Y;
313 }
314
315 REAL
316 GetRight() const
317 {
318 return X + Width;
319 }
320
321 VOID
322 GetSize(SizeF *size) const
323 {
324 size->Width = Width;
325 size->Height = Height;
326 }
327
328 REAL
329 GetTop() const
330 {
331 return Y;
332 }
333
334 VOID
335 Inflate(REAL dx, REAL dy)
336 {
337 X -= dx;
338 Y -= dy;
339 Width += 2 * dx;
340 Height += 2 * dy;
341 }
342
343 VOID
344 Inflate(const PointF &point)
345 {
346 Inflate(point.X, point.Y);
347 }
348
349 static BOOL
350 Intersect(RectF &c, const RectF &a, const RectF &b)
351 {
352 // FIXME
353 return FALSE;
354 }
355
356 BOOL
357 Intersect(const RectF &rect)
358 {
359 return Intersect(*this, *this, rect);
360 }
361
362 BOOL
363 IntersectsWith(const RectF &rect) const
364 {
365 return GetLeft() < rect.GetRight() && GetTop() < rect.GetTop() && GetRight() > rect.GetLeft() &&
366 GetBottom() > rect.GetTop();
367 }
368
369 BOOL
370 IsEmptyArea() const
371 {
372 return (Width <= REAL_EPSILON) || (Height <= REAL_EPSILON);
373 }
374
375 VOID
377 {
378 X += dx;
379 Y += dy;
380 }
381
382 VOID
383 Offset(const PointF &point)
384 {
385 Offset(point.X, point.Y);
386 }
387
388 static BOOL
389 Union(RectF &c, const RectF &a, const RectF &b)
390 {
391 // FIXME
392 return FALSE;
393 }
394};
395
396class Size
397{
398 public:
399 INT Width;
400 INT Height;
401
402 Size() : Width(0), Height(0)
403 {
404 }
405
407 {
408 }
409
411 {
412 }
413
414 BOOL
415 Empty() const
416 {
417 return Width == 0 && Height == 0;
418 }
419
420 BOOL
421 Equals(const Size &sz) const
422 {
423 return Width == sz.Width && Height == sz.Height;
424 }
425
426 Size
427 operator+(const Size &sz) const
428 {
429 return Size(Width + sz.Width, Height + sz.Height);
430 }
431
432 Size
433 operator-(const Size &sz) const
434 {
435 return Size(Width - sz.Width, Height - sz.Height);
436 }
437};
438
439class Rect
440{
441public:
442 INT X;
443 INT Y;
444 INT Width;
445 INT Height;
446
447 Rect()
448 : X(0), Y(0), Width(0), Height(0)
449 {
450 }
451
453 {
454 }
455
457 : X(x), Y(y), Width(width), Height(height)
458 {
459 }
460
461 Rect *
462 Clone() const
463 {
464 return new Rect(X, Y, Width, Height);
465 }
466
467 BOOL
468 Contains(const Point &pt) const
469 {
470 return Contains(pt.X, pt.Y);
471 }
472
473 BOOL
474 Contains(const Rect &rect) const
475 {
476 return X <= rect.X && rect.GetRight() <= GetRight() && Y <= rect.Y && rect.GetBottom() <= GetBottom();
477 }
478
479 BOOL
480 Contains(INT x, INT y) const
481 {
482 return X <= x && x < X + Width && Y <= y && y < Y + Height;
483 }
484
485 BOOL
486 Equals(const Rect &rect) const
487 {
488 return X == rect.X && Y == rect.Y && Width == rect.Width && Height == rect.Height;
489 }
490
491 INT
492 GetBottom() const
493 {
494 return Y + Height;
495 }
496
497 VOID
498 GetBounds(Rect *rect) const
499 {
500 rect->X = X;
501 rect->Y = Y;
502 rect->Width = Width;
503 rect->Height = Height;
504 }
505
506 INT
507 GetLeft() const
508 {
509 return X;
510 }
511
512 VOID
513 GetLocation(Point *point) const
514 {
515 point->X = X;
516 point->Y = Y;
517 }
518
519 INT
520 GetRight() const
521 {
522 return X + Width;
523 }
524
525 VOID
526 GetSize(Size *size) const
527 {
528 size->Width = Width;
529 size->Height = Height;
530 }
531
532 INT
533 GetTop() const
534 {
535 return Y;
536 }
537
538 VOID
539 Inflate(INT dx, INT dy)
540 {
541 X -= dx;
542 Y -= dy;
543 Width += 2 * dx;
544 Height += 2 * dy;
545 }
546
547 VOID
548 Inflate(const Point &point)
549 {
550 Inflate(point.X, point.Y);
551 }
552
553 static BOOL
554 Intersect(Rect &c, const Rect &a, const Rect &b)
555 {
556 // FIXME
557 return FALSE;
558 }
559
560 BOOL
561 Intersect(const Rect &rect)
562 {
563 return Intersect(*this, *this, rect);
564 }
565
566 BOOL
567 IntersectsWith(const Rect &rect) const
568 {
569 return GetLeft() < rect.GetRight() && GetTop() < rect.GetTop() && GetRight() > rect.GetLeft() &&
570 GetBottom() > rect.GetTop();
571 }
572
573 BOOL
574 IsEmptyArea() const
575 {
576 return Width <= 0 || Height <= 0;
577 }
578
579 VOID
580 Offset(INT dx, INT dy)
581 {
582 X += dx;
583 Y += dy;
584 }
585
586 VOID
587 Offset(const Point &point)
588 {
589 Offset(point.X, point.Y);
590 }
591
592 static BOOL
593 Union(Rect &c, const Rect &a, const Rect &b)
594 {
595 // FIXME
596 return FALSE;
597 }
598};
599
600class CharacterRange
601{
602public:
604 {
605 First = Length = 0;
606 }
607
609 {
610 First = first;
611 Length = length;
612 }
613
614 CharacterRange& operator=(const CharacterRange& rhs)
615 {
616 First = rhs.First;
617 Length = rhs.Length;
618 return *this;
619 }
620public:
621 INT First;
622 INT Length;
623};
624
625inline Point::Point(const Size &size) : X(size.Width), Y(size.Height)
626{
627}
628
629inline PointF::PointF(const SizeF &size) : X(size.Width), Y(size.Height)
630{
631}
632
633#else /* end of c++ typedefs */
634
635typedef struct Point
636{
640
641typedef struct PointF
642{
646
647typedef struct PathData
648{
653
654typedef struct RectF
655{
661
662typedef struct Rect
663{
669
670typedef struct CharacterRange
671{
675
676typedef enum Status Status;
677
678#endif /* end of c typedefs */
679
680#endif
complex< _Tp > _STLP_CALL operator-(const complex< _Tp > &__z)
Definition: _complex.h:622
CHString WINAPI operator+(CHSTRING_WCHAR ch, const CHString &string)
Definition: chstring.cpp:1356
RECT rect
Definition: combotst.c:67
DWORD WINAPI GetSize(LPVOID)
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
float REAL
Definition: types.h:41
#define Y(I)
#define CALLBACK
Definition: compat.h:35
#define pt(x, y)
Definition: drawing.c:79
@ Empty
Definition: npfs.h:125
POINTL point
Definition: edittest.c:50
unsigned int BOOL
Definition: ntddk_ex.h:94
EmfPlusRecordType
Definition: gdiplusenums.h:491
ImageAbort DrawImageAbort
Definition: gdiplustypes.h:55
struct GdiplusAbort GdiplusAbort
Definition: gdiplustypes.h:57
struct Point Point
ImageAbort GetThumbnailImageAbort
Definition: gdiplustypes.h:56
BOOL(CALLBACK * ImageAbort)(VOID *)
Definition: gdiplustypes.h:54
Status
Definition: gdiplustypes.h:24
@ ProfileNotFound
Definition: gdiplustypes.h:46
@ Ok
Definition: gdiplustypes.h:25
@ GdiplusNotInitialized
Definition: gdiplustypes.h:43
@ WrongState
Definition: gdiplustypes.h:33
@ UnsupportedGdiplusVersion
Definition: gdiplustypes.h:42
@ PropertyNotSupported
Definition: gdiplustypes.h:45
@ FileNotFound
Definition: gdiplustypes.h:35
@ ObjectBusy
Definition: gdiplustypes.h:29
@ AccessDenied
Definition: gdiplustypes.h:37
@ ValueOverflow
Definition: gdiplustypes.h:36
@ InvalidParameter
Definition: gdiplustypes.h:27
@ OutOfMemory
Definition: gdiplustypes.h:28
@ NotTrueTypeFont
Definition: gdiplustypes.h:41
@ PropertyNotFound
Definition: gdiplustypes.h:44
@ Win32Error
Definition: gdiplustypes.h:32
@ Aborted
Definition: gdiplustypes.h:34
@ InsufficientBuffer
Definition: gdiplustypes.h:30
@ NotImplemented
Definition: gdiplustypes.h:31
@ FontStyleNotFound
Definition: gdiplustypes.h:40
@ FontFamilyNotFound
Definition: gdiplustypes.h:39
@ GenericError
Definition: gdiplustypes.h:26
@ UnknownImageFormat
Definition: gdiplustypes.h:38
float REAL
Definition: gdiplustypes.h:22
BOOL(CALLBACK * EnumerateMetafileProc)(EmfPlusRecordType, UINT, UINT, const BYTE *, VOID *)
Definition: gdiplustypes.h:59
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
const GLint * first
Definition: glext.h:5794
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
STDMETHOD() Clone(THIS_ IEnumAssociationElements **ppNew) PURE
PointF * Points
Definition: gdiplustypes.h:650
BYTE * Types
Definition: gdiplustypes.h:651
REAL Y
Definition: gdiplustypes.h:644
REAL X
Definition: gdiplustypes.h:643
REAL Height
Definition: gdiplustypes.h:659
REAL X
Definition: gdiplustypes.h:656
REAL Width
Definition: gdiplustypes.h:658
REAL Y
Definition: gdiplustypes.h:657
INT Width
Definition: gdiplustypes.h:666
INT Height
Definition: gdiplustypes.h:667
INT X
Definition: gdiplustypes.h:664
INT Y
Definition: gdiplustypes.h:665
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
unsigned char BYTE
Definition: xxhash.c:193