PageRenderTime 30ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/win32/MinGW/include/gdiplus/gdiplustypes.h

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