Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

563 lines
12 KiB

  1. /*
  2. File: CGGeometry.h
  3. Contains: CoreGraphics geometry
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 2000-2001 by Apple Computer, Inc., all rights reserved.
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef CGGEOMETRY_H_
  11. #define CGGEOMETRY_H_
  12. #ifndef __CGBASE__
  13. #include <CGBase.h>
  14. #endif
  15. #if PRAGMA_ONCE
  16. #pragma once
  17. #endif
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #if PRAGMA_IMPORT
  22. #pragma import on
  23. #endif
  24. #if PRAGMA_STRUCT_ALIGN
  25. #pragma options align=mac68k
  26. #elif PRAGMA_STRUCT_PACKPUSH
  27. #pragma pack(push, 2)
  28. #elif PRAGMA_STRUCT_PACK
  29. #pragma pack(2)
  30. #endif
  31. #if PRAGMA_ENUM_ALWAYSINT
  32. #if defined(__fourbyteints__) && !__fourbyteints__
  33. #define __CGGEOMETRY__RESTORE_TWOBYTEINTS
  34. #pragma fourbyteints on
  35. #endif
  36. #pragma enumsalwaysint on
  37. #elif PRAGMA_ENUM_OPTIONS
  38. #pragma option enum=int
  39. #elif PRAGMA_ENUM_PACK
  40. #if __option(pack_enums)
  41. #define __CGGEOMETRY__RESTORE_PACKED_ENUMS
  42. #pragma options(!pack_enums)
  43. #endif
  44. #endif
  45. /* Points. */
  46. struct CGPoint {
  47. float x;
  48. float y;
  49. };
  50. typedef struct CGPoint CGPoint;
  51. /* Sizes. */
  52. struct CGSize {
  53. float width;
  54. float height;
  55. };
  56. typedef struct CGSize CGSize;
  57. /* Rectangles. */
  58. struct CGRect {
  59. CGPoint origin;
  60. CGSize size;
  61. };
  62. typedef struct CGRect CGRect;
  63. /* Rectangle edges. */
  64. enum CGRectEdge {
  65. CGRectMinXEdge = 0,
  66. CGRectMinYEdge = 1,
  67. CGRectMaxXEdge = 2,
  68. CGRectMaxYEdge = 3
  69. };
  70. typedef enum CGRectEdge CGRectEdge;
  71. #if TARGET_OS_MAC
  72. /* The "zero" point -- equivalent to CGPointMake(0, 0). */
  73. /*
  74. * CGPointZero
  75. *
  76. * Availability:
  77. * Non-Carbon CFM: not available
  78. * CarbonLib: not available
  79. * Mac OS X: in version 10.0 and later
  80. */
  81. extern const CGPoint CGPointZero;
  82. /* The "zero" size -- equivalent to CGSizeMake(0, 0). */
  83. /*
  84. * CGSizeZero
  85. *
  86. * Availability:
  87. * Non-Carbon CFM: not available
  88. * CarbonLib: not available
  89. * Mac OS X: in version 10.0 and later
  90. */
  91. extern const CGSize CGSizeZero;
  92. /* The "zero" rectangle -- equivalent to CGRectMake(0, 0, 0, 0). */
  93. /*
  94. * CGRectZero
  95. *
  96. * Availability:
  97. * Non-Carbon CFM: not available
  98. * CarbonLib: not available
  99. * Mac OS X: in version 10.0 and later
  100. */
  101. extern const CGRect CGRectZero;
  102. /* The "empty" rect. This is the rectangle returned when, for example, we
  103. * intersect two disjoint rectangles. Note that the null rect is not the
  104. * same as the zero rect. */
  105. /*
  106. * CGRectNull
  107. *
  108. * Availability:
  109. * Non-Carbon CFM: not available
  110. * CarbonLib: not available
  111. * Mac OS X: in version 10.0 and later
  112. */
  113. extern const CGRect CGRectNull;
  114. #else
  115. #define CGPointZero CGPointMake(0, 0)
  116. #define CGSizeZero CGSizeMake(0, 0)
  117. #define CGRectZero CGRectMake(0, 0, 0, 0)
  118. #define CGRectNull CGRectMake(INFINITY, INFINITY, 0, 0)
  119. #endif
  120. /* Make a point from `(x, y)'. */
  121. /*
  122. * CGPointMake()
  123. *
  124. * Availability:
  125. * Non-Carbon CFM: not available
  126. * CarbonLib: not available
  127. * Mac OS X: in version 10.0 and later
  128. */
  129. EXTERN_API_C( CGPoint )
  130. CGPointMake(
  131. float x,
  132. float y);
  133. /* Make a size from `(width, height)'. */
  134. /*
  135. * CGSizeMake()
  136. *
  137. * Availability:
  138. * Non-Carbon CFM: not available
  139. * CarbonLib: not available
  140. * Mac OS X: in version 10.0 and later
  141. */
  142. EXTERN_API_C( CGSize )
  143. CGSizeMake(
  144. float width,
  145. float height);
  146. /* Make a rect from `(x, y; width, height)'. */
  147. /*
  148. * CGRectMake()
  149. *
  150. * Availability:
  151. * Non-Carbon CFM: not available
  152. * CarbonLib: not available
  153. * Mac OS X: in version 10.0 and later
  154. */
  155. EXTERN_API_C( CGRect )
  156. CGRectMake(
  157. float x,
  158. float y,
  159. float width,
  160. float height);
  161. /* Return the leftmost x-value of `rect'. */
  162. /*
  163. * CGRectGetMinX()
  164. *
  165. * Availability:
  166. * Non-Carbon CFM: not available
  167. * CarbonLib: not available
  168. * Mac OS X: in version 10.0 and later
  169. */
  170. EXTERN_API_C( float )
  171. CGRectGetMinX(CGRect rect);
  172. /* Return the midpoint x-value of `rect'. */
  173. /*
  174. * CGRectGetMidX()
  175. *
  176. * Availability:
  177. * Non-Carbon CFM: not available
  178. * CarbonLib: not available
  179. * Mac OS X: in version 10.0 and later
  180. */
  181. EXTERN_API_C( float )
  182. CGRectGetMidX(CGRect rect);
  183. /* Return the rightmost x-value of `rect'. */
  184. /*
  185. * CGRectGetMaxX()
  186. *
  187. * Availability:
  188. * Non-Carbon CFM: not available
  189. * CarbonLib: not available
  190. * Mac OS X: in version 10.0 and later
  191. */
  192. EXTERN_API_C( float )
  193. CGRectGetMaxX(CGRect rect);
  194. /* Return the bottommost y-value of `rect'. */
  195. /*
  196. * CGRectGetMinY()
  197. *
  198. * Availability:
  199. * Non-Carbon CFM: not available
  200. * CarbonLib: not available
  201. * Mac OS X: in version 10.0 and later
  202. */
  203. EXTERN_API_C( float )
  204. CGRectGetMinY(CGRect rect);
  205. /* Return the midpoint y-value of `rect'. */
  206. /*
  207. * CGRectGetMidY()
  208. *
  209. * Availability:
  210. * Non-Carbon CFM: not available
  211. * CarbonLib: not available
  212. * Mac OS X: in version 10.0 and later
  213. */
  214. EXTERN_API_C( float )
  215. CGRectGetMidY(CGRect rect);
  216. /* Return the topmost y-value of `rect'. */
  217. /*
  218. * CGRectGetMaxY()
  219. *
  220. * Availability:
  221. * Non-Carbon CFM: not available
  222. * CarbonLib: not available
  223. * Mac OS X: in version 10.0 and later
  224. */
  225. EXTERN_API_C( float )
  226. CGRectGetMaxY(CGRect rect);
  227. /* Return the width of `rect'. */
  228. /*
  229. * CGRectGetWidth()
  230. *
  231. * Availability:
  232. * Non-Carbon CFM: not available
  233. * CarbonLib: not available
  234. * Mac OS X: in version 10.0 and later
  235. */
  236. EXTERN_API_C( float )
  237. CGRectGetWidth(CGRect rect);
  238. /* Return the height of `rect'. */
  239. /*
  240. * CGRectGetHeight()
  241. *
  242. * Availability:
  243. * Non-Carbon CFM: not available
  244. * CarbonLib: not available
  245. * Mac OS X: in version 10.0 and later
  246. */
  247. EXTERN_API_C( float )
  248. CGRectGetHeight(CGRect rect);
  249. /* Return 1 if `point1' and `point2' are the same, 0 otherwise. */
  250. /*
  251. * CGPointEqualToPoint()
  252. *
  253. * Availability:
  254. * Non-Carbon CFM: not available
  255. * CarbonLib: not available
  256. * Mac OS X: in version 10.0 and later
  257. */
  258. EXTERN_API_C( int )
  259. CGPointEqualToPoint(
  260. CGPoint point1,
  261. CGPoint point2);
  262. /* Return 1 if `size1' and `size2' are the same, 0 otherwise. */
  263. /*
  264. * CGSizeEqualToSize()
  265. *
  266. * Availability:
  267. * Non-Carbon CFM: not available
  268. * CarbonLib: not available
  269. * Mac OS X: in version 10.0 and later
  270. */
  271. EXTERN_API_C( int )
  272. CGSizeEqualToSize(
  273. CGSize size1,
  274. CGSize size2);
  275. /* Return 1 if `rect1' and `rect2' are the same, 0 otherwise. */
  276. /*
  277. * CGRectEqualToRect()
  278. *
  279. * Availability:
  280. * Non-Carbon CFM: not available
  281. * CarbonLib: not available
  282. * Mac OS X: in version 10.0 and later
  283. */
  284. EXTERN_API_C( int )
  285. CGRectEqualToRect(
  286. CGRect rect1,
  287. CGRect rect2);
  288. /* Standardize `rect' -- i.e., convert it to an equivalent rect which has
  289. * positive width and height. */
  290. /*
  291. * CGRectStandardize()
  292. *
  293. * Availability:
  294. * Non-Carbon CFM: not available
  295. * CarbonLib: not available
  296. * Mac OS X: in version 10.0 and later
  297. */
  298. EXTERN_API_C( CGRect )
  299. CGRectStandardize(CGRect rect);
  300. /* Return 1 if `rect' is empty -- i.e., if it has zero width or height. A
  301. * null rect is defined to be empty. */
  302. /*
  303. * CGRectIsEmpty()
  304. *
  305. * Availability:
  306. * Non-Carbon CFM: not available
  307. * CarbonLib: not available
  308. * Mac OS X: in version 10.0 and later
  309. */
  310. EXTERN_API_C( int )
  311. CGRectIsEmpty(CGRect rect);
  312. /* Return 1 if `rect' is null -- e.g., the result of intersecting two
  313. * disjoint rectangles is a null rect. */
  314. /*
  315. * CGRectIsNull()
  316. *
  317. * Availability:
  318. * Non-Carbon CFM: not available
  319. * CarbonLib: not available
  320. * Mac OS X: in version 10.0 and later
  321. */
  322. EXTERN_API_C( int )
  323. CGRectIsNull(CGRect rect);
  324. /* Inset `rect' by `(dx, dy)' -- i.e., offset its origin by `(dx, dy)', and
  325. * decrease its size by `(2*dx, 2*dy)'. */
  326. /*
  327. * CGRectInset()
  328. *
  329. * Availability:
  330. * Non-Carbon CFM: not available
  331. * CarbonLib: not available
  332. * Mac OS X: in version 10.0 and later
  333. */
  334. EXTERN_API_C( CGRect )
  335. CGRectInset(
  336. CGRect rect,
  337. float dx,
  338. float dy);
  339. /* Expand `rect' to the smallest rect containing it with integral origin
  340. * and size. */
  341. /*
  342. * CGRectIntegral()
  343. *
  344. * Availability:
  345. * Non-Carbon CFM: not available
  346. * CarbonLib: not available
  347. * Mac OS X: in version 10.0 and later
  348. */
  349. EXTERN_API_C( CGRect )
  350. CGRectIntegral(CGRect rect);
  351. /* Return the union of `r1' and `r2'. */
  352. /*
  353. * CGRectUnion()
  354. *
  355. * Availability:
  356. * Non-Carbon CFM: not available
  357. * CarbonLib: not available
  358. * Mac OS X: in version 10.0 and later
  359. */
  360. EXTERN_API_C( CGRect )
  361. CGRectUnion(
  362. CGRect r1,
  363. CGRect r2);
  364. /* Return the intersection of `r1' and `r2'. This may return a null
  365. * rect. */
  366. /*
  367. * CGRectIntersection()
  368. *
  369. * Availability:
  370. * Non-Carbon CFM: not available
  371. * CarbonLib: not available
  372. * Mac OS X: in version 10.0 and later
  373. */
  374. EXTERN_API_C( CGRect )
  375. CGRectIntersection(
  376. CGRect r1,
  377. CGRect r2);
  378. /* Offset `rect' by `(dx, dy)'. */
  379. /*
  380. * CGRectOffset()
  381. *
  382. * Availability:
  383. * Non-Carbon CFM: not available
  384. * CarbonLib: not available
  385. * Mac OS X: in version 10.0 and later
  386. */
  387. EXTERN_API_C( CGRect )
  388. CGRectOffset(
  389. CGRect rect,
  390. float dx,
  391. float dy);
  392. /* Make two new rectangles, `slice' and `remainder', by dividing `rect'
  393. * with a line that's parallel to one of its sides, specified by `edge' --
  394. * either `CGRectMinXEdge', `CGRectMinYEdge', `CGRectMaxXEdge', or
  395. * `CGRectMaxYEdge'. The size of `slice' is determined by `amount', which
  396. * measures the distance from the specified edge. */
  397. /*
  398. * CGRectDivide()
  399. *
  400. * Availability:
  401. * Non-Carbon CFM: not available
  402. * CarbonLib: not available
  403. * Mac OS X: in version 10.0 and later
  404. */
  405. EXTERN_API_C( void )
  406. CGRectDivide(
  407. CGRect rect,
  408. CGRect * slice,
  409. CGRect * remainder,
  410. float amount,
  411. CGRectEdge edge);
  412. /* Return 1 if `point' is contained in `rect', 0 otherwise. */
  413. /*
  414. * CGRectContainsPoint()
  415. *
  416. * Availability:
  417. * Non-Carbon CFM: not available
  418. * CarbonLib: not available
  419. * Mac OS X: in version 10.0 and later
  420. */
  421. EXTERN_API_C( int )
  422. CGRectContainsPoint(
  423. CGRect rect,
  424. CGPoint point);
  425. /* Return 1 if `rect2' is contained in `rect1', 0 otherwise. `rect2' is
  426. * contained in `rect1' if the union of `rect1' and `rect2' is equal to
  427. * `rect1'. */
  428. /*
  429. * CGRectContainsRect()
  430. *
  431. * Availability:
  432. * Non-Carbon CFM: not available
  433. * CarbonLib: not available
  434. * Mac OS X: in version 10.0 and later
  435. */
  436. EXTERN_API_C( int )
  437. CGRectContainsRect(
  438. CGRect rect1,
  439. CGRect rect2);
  440. /* Return 1 if `rect1' intersects `rect2', 0 otherwise. `rect1' intersects
  441. * `rect2' if the intersection of `rect1' and `rect2' is not the null
  442. * rect. */
  443. /*
  444. * CGRectIntersectsRect()
  445. *
  446. * Availability:
  447. * Non-Carbon CFM: not available
  448. * CarbonLib: not available
  449. * Mac OS X: in version 10.0 and later
  450. */
  451. EXTERN_API_C( int )
  452. CGRectIntersectsRect(
  453. CGRect rect1,
  454. CGRect rect2);
  455. #if PRAGMA_ENUM_ALWAYSINT
  456. #pragma enumsalwaysint reset
  457. #ifdef __CGGEOMETRY__RESTORE_TWOBYTEINTS
  458. #pragma fourbyteints off
  459. #endif
  460. #elif PRAGMA_ENUM_OPTIONS
  461. #pragma option enum=reset
  462. #elif defined(__CGGEOMETRY__RESTORE_PACKED_ENUMS)
  463. #pragma options(pack_enums)
  464. #endif
  465. #if PRAGMA_STRUCT_ALIGN
  466. #pragma options align=reset
  467. #elif PRAGMA_STRUCT_PACKPUSH
  468. #pragma pack(pop)
  469. #elif PRAGMA_STRUCT_PACK
  470. #pragma pack()
  471. #endif
  472. #ifdef PRAGMA_IMPORT_OFF
  473. #pragma import off
  474. #elif PRAGMA_IMPORT
  475. #pragma import reset
  476. #endif
  477. #ifdef __cplusplus
  478. }
  479. #endif
  480. #endif /* CGGEOMETRY_H_ */