Mac OS 9
CGGeometry.h
Go to the documentation of this file.
1 
19 #ifndef __CGGEOMETRY__
20 #define __CGGEOMETRY__
21 
22 #ifndef __CGBASE__
23 #include <CGBase.h>
24 #endif
25 
26 #if PRAGMA_ONCE
27 #pragma once
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 #if PRAGMA_IMPORT
36 #pragma import on
37 #endif
38 
39 #if PRAGMA_STRUCT_ALIGN
40 #pragma options align = mac68k
41 #elif PRAGMA_STRUCT_PACKPUSH
42 #pragma pack(push, 2)
43 #elif PRAGMA_STRUCT_PACK
44 #pragma pack(2)
45 #endif
46 
47 #if PRAGMA_ENUM_ALWAYSINT
48 #if defined(__fourbyteints__) && !__fourbyteints__
49 #define __CGGEOMETRY__RESTORE_TWOBYTEINTS
50 #pragma fourbyteints on
51 #endif
52 #pragma enumsalwaysint on
53 #elif PRAGMA_ENUM_OPTIONS
54 #pragma option enum =int
55 #elif PRAGMA_ENUM_PACK
56 #if __option(pack_enums)
57 #define __CGGEOMETRY__RESTORE_PACKED_ENUMS
58 #pragma options(!pack_enums)
59 #endif
60 #endif
61 
62  /* Points. */
63  struct CGPoint
64  {
65  float x;
66  float y;
67  };
68  typedef struct CGPoint CGPoint;
69  /* Sizes. */
70  struct CGSize
71  {
72  float width;
73  float height;
74  };
75  typedef struct CGSize CGSize;
76  /* Rectangles. */
77  struct CGRect
78  {
79  CGPoint origin;
80  CGSize size;
81  };
82  typedef struct CGRect CGRect;
83  /* Rectangle edges. */
84  enum CGRectEdge
85  {
86  CGRectMinXEdge = 0,
87  CGRectMinYEdge = 1,
88  CGRectMaxXEdge = 2,
89  CGRectMaxYEdge = 3
90  };
91  typedef enum CGRectEdge CGRectEdge;
92 
93  /* The "zero" point -- equivalent to CGPointMake(0, 0). */
102  extern const CGPoint CGPointZero;
103  /* The "zero" size -- equivalent to CGSizeMake(0, 0). */
112  extern const CGSize CGSizeZero;
113  /* The "zero" rectangle -- equivalent to CGRectMake(0, 0, 0, 0). */
122  extern const CGRect CGRectZero;
123  /* The "empty" rect. This is the rectangle returned when, for example, we
124  * intersect two disjoint rectangles. Note that the null rect is not the
125  * same as the zero rect. */
134  extern const CGRect CGRectNull;
135 
136  /* Make a point from `(x, y)'. */
145  CGPoint
146  CGPointMake(float x, float y);
147 
148  /* Make a size from `(width, height)'. */
157  CGSize
158  CGSizeMake(float width, float height);
159 
160  /* Make a rect from `(x, y; width, height)'. */
169  CGRect
170  CGRectMake(float x, float y, float width, float height);
171 
172  /* Return the leftmost x-value of `rect'. */
181  float
183 
184  /* Return the midpoint x-value of `rect'. */
193  float
195 
196  /* Return the rightmost x-value of `rect'. */
205  float
207 
208  /* Return the bottommost y-value of `rect'. */
217  float
219 
220  /* Return the midpoint y-value of `rect'. */
229  float
231 
232  /* Return the topmost y-value of `rect'. */
241  float
243 
244  /* Return the width of `rect'. */
253  float
255 
256  /* Return the height of `rect'. */
265  float
267 
268  /* Return 1 if `point1' and `point2' are the same, 0 otherwise. */
277  int CGPointEqualToPoint(CGPoint point1, CGPoint point2);
278 
279  /* Return 1 if `size1' and `size2' are the same, 0 otherwise. */
288  int CGSizeEqualToSize(CGSize size1, CGSize size2);
289 
290  /* Return 1 if `rect1' and `rect2' are the same, 0 otherwise. */
299  int CGRectEqualToRect(CGRect rect1, CGRect rect2);
300 
301  /* Standardize `rect' -- i.e., convert it to an equivalent rect which has
302  * positive width and height. */
311  CGRect
313 
314  /* Return 1 if `rect' is empty -- i.e., if it has zero width or height. A
315  * null rect is defined to be empty. */
325 
326  /* Return 1 if `rect' is null -- e.g., the result of intersecting two
327  * disjoint rectangles is a null rect. */
336  int CGRectIsNull(CGRect rect);
337 
338  /* Inset `rect' by `(dx, dy)' -- i.e., offset its origin by `(dx, dy)', and
339  * decrease its size by `(2*dx, 2*dy)'. */
348  CGRect
349  CGRectInset(CGRect rect, float dx, float dy);
350 
351  /* Expand `rect' to the smallest rect containing it with integral origin
352  * and size. */
361  CGRect
363 
364  /* Return the union of `r1' and `r2'. */
373  CGRect
375 
376  /* Return the intersection of `r1' and `r2'. This may return a null
377  * rect. */
386  CGRect
388 
389  /* Offset `rect' by `(dx, dy)'. */
398  CGRect
399  CGRectOffset(CGRect rect, float dx, float dy);
400 
401  /* Make two new rectangles, `slice' and `remainder', by dividing `rect'
402  * with a line that's parallel to one of its sides, specified by `edge' --
403  * either `CGRectMinXEdge', `CGRectMinYEdge', `CGRectMaxXEdge', or
404  * `CGRectMaxYEdge'. The size of `slice' is determined by `amount', which
405  * measures the distance from the specified edge. */
414  void
415  CGRectDivide(CGRect rect, CGRect *slice, CGRect *remainder, float amount,
416  CGRectEdge edge);
417 
418  /* Return 1 if `point' is contained in `rect', 0 otherwise. */
428 
429  /* Return 1 if `rect2' is contained in `rect1', 0 otherwise. `rect2' is
430  * contained in `rect1' if the union of `rect1' and `rect2' is equal to
431  * `rect1'. */
440  int CGRectContainsRect(CGRect rect1, CGRect rect2);
441 
442  /* Return 1 if `rect1' intersects `rect2', 0 otherwise. `rect1' intersects
443  * `rect2' if the intersection of `rect1' and `rect2' is not the null
444  * rect. */
453  int CGRectIntersectsRect(CGRect rect1, CGRect rect2);
454 
455 #ifdef __MWERKS__
456  CG_INLINE CGPoint __CGPointMake(float x, float y)
457  {
458  CGPoint p;
459  p.x = x;
460  p.y = y;
461  return p;
462  }
463 #define CGPointMake __CGPointMake
464 
465  CG_INLINE CGSize __CGSizeMake(float width, float height)
466  {
467  CGSize size;
468  size.width = width;
469  size.height = height;
470  return size;
471  }
472 #define CGSizeMake __CGSizeMake
473 
474  CG_INLINE CGRect __CGRectMake(float x, float y, float width, float height)
475  {
476  CGRect rect;
477  rect.origin.x = x;
478  rect.origin.y = y;
479  rect.size.width = width;
480  rect.size.height = height;
481  return rect;
482  }
483 #define CGRectMake __CGRectMake
484 #endif /* __MWERKS__ */
485 
486 #if PRAGMA_ENUM_ALWAYSINT
487 #pragma enumsalwaysint reset
488 #ifdef __CGGEOMETRY__RESTORE_TWOBYTEINTS
489 #pragma fourbyteints off
490 #endif
491 #elif PRAGMA_ENUM_OPTIONS
492 #pragma option enum =reset
493 #elif defined(__CGGEOMETRY__RESTORE_PACKED_ENUMS)
494 #pragma options(pack_enums)
495 #endif
496 
497 #if PRAGMA_STRUCT_ALIGN
498 #pragma options align = reset
499 #elif PRAGMA_STRUCT_PACKPUSH
500 #pragma pack(pop)
501 #elif PRAGMA_STRUCT_PACK
502 #pragma pack()
503 #endif
504 
505 #ifdef PRAGMA_IMPORT_OFF
506 #pragma import off
507 #elif PRAGMA_IMPORT
508 #pragma import reset
509 #endif
510 
511 #ifdef __cplusplus
512 }
513 #endif
514 
515 #endif /* __CGGEOMETRY__ */
xxx put contents here xxx
const CGPoint CGPointZero
CGRect CGRectStandardize(CGRect rect)
int CGRectContainsRect(CGRect rect1, CGRect rect2)
int CGRectEqualToRect(CGRect rect1, CGRect rect2)
float CGRectGetWidth(CGRect rect)
void CGRectDivide(CGRect rect, CGRect *slice, CGRect *remainder, float amount, CGRectEdge edge)
CGRect CGRectInset(CGRect rect, float dx, float dy)
int CGRectIntersectsRect(CGRect rect1, CGRect rect2)
CGRect CGRectIntegral(CGRect rect)
float CGRectGetMaxY(CGRect rect)
CGSize CGSizeMake(float width, float height)
int CGPointEqualToPoint(CGPoint point1, CGPoint point2)
CGRect CGRectIntersection(CGRect r1, CGRect r2)
CGRect CGRectMake(float x, float y, float width, float height)
const CGRect CGRectZero
float CGRectGetMidX(CGRect rect)
CGPoint CGPointMake(float x, float y)
int CGSizeEqualToSize(CGSize size1, CGSize size2)
float CGRectGetMinY(CGRect rect)
int CGRectContainsPoint(CGRect rect, CGPoint point)
float CGRectGetMaxX(CGRect rect)
int CGRectIsNull(CGRect rect)
CGRect CGRectOffset(CGRect rect, float dx, float dy)
float CGRectGetMidY(CGRect rect)
const CGSize CGSizeZero
int CGRectIsEmpty(CGRect rect)
float CGRectGetHeight(CGRect rect)
const CGRect CGRectNull
float CGRectGetMinX(CGRect rect)
CGRect CGRectUnion(CGRect r1, CGRect r2)
x
Definition: ToolUtils.h:163
Definition: CGGeometry.h:64
Definition: CGGeometry.h:78
Definition: CGGeometry.h:71