PageRenderTime 62ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/mingw-w64-headers/include/gdiplus/gdiplustypes.h

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