home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWRegion.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  7.1 KB  |  197 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRegion.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9. //
  10. //    This file contains a set of cross-platform functions to manipulate platform regions
  11. //
  12.  
  13. #ifndef FWREGION_H
  14. #define FWREGION_H
  15.  
  16. #ifndef FWGCONST_H
  17. #include "FWGConst.h"
  18. #endif
  19.  
  20. #ifndef FWRECT_H
  21. #include "FWRect.h"
  22. #endif
  23.  
  24. #if FW_LIB_EXPORT_PRAGMAS
  25. #pragma lib_export on
  26. #endif
  27.  
  28. //========================================================================================
  29. //    Forward declarations
  30. //========================================================================================
  31.  
  32. class FW_CLASS_ATTR FW_CWritableStream;
  33. class FW_CLASS_ATTR FW_CReadableStream;
  34.  
  35. //========================================================================================
  36. //    Platform Region functions
  37. //========================================================================================
  38.  
  39. // ----- Region Creation -----
  40. FW_FUNC_ATTR ODRgnHandle    FW_NewRegion();
  41.  
  42. FW_FUNC_ATTR ODRgnHandle    FW_CreateRectRegion(const FW_CRect& rect);
  43. FW_FUNC_ATTR ODRgnHandle    FW_CreateOvalRegion(const FW_CRect& oval);
  44. FW_FUNC_ATTR ODRgnHandle    FW_CreateRoundRectRegion(const FW_CRect& oval, const FW_CPoint& ovalSize);
  45. FW_FUNC_ATTR ODRgnHandle    FW_CreateArcRegion(const FW_CRect& rect, short startAngle, short arcAngle);
  46. FW_FUNC_ATTR ODRgnHandle    FW_CreatePolygonRegion(unsigned long pointCount, const FW_CPoint* pointArray);
  47. FW_FUNC_ATTR ODRgnHandle    FW_CreateLineRegion(const FW_CPoint& startPt, const FW_CPoint& endPt, const FW_CPoint& lineThickness);
  48.  
  49. // ----- Copy -----
  50. FW_FUNC_ATTR ODRgnHandle    FW_CopyRegion(ODRgnHandle srcRgn);
  51. FW_FUNC_ATTR void            FW_CopyRegion(ODRgnHandle srcRgn, ODRgnHandle dstRgn);
  52.  
  53. // ----- Dispose -----
  54. FW_FUNC_ATTR void            FW_DisposeRegion(ODRgnHandle rgnHandle);
  55.  
  56. // ----- Read/Write -----
  57. FW_FUNC_ATTR void            FW_WriteRegion(ODRgnHandle rgnHandle, FW_CWritableStream& stream);
  58. FW_FUNC_ATTR ODRgnHandle    FW_ReadRegion(FW_CReadableStream& stream);
  59.  
  60. // ----- Equality -----
  61. FW_FUNC_ATTR FW_Boolean        FW_IsEqualRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
  62.  
  63. // ----- Bounding Box -----
  64. FW_FUNC_ATTR void            FW_GetRegionBoundingBox(ODRgnHandle rgn, FW_CRect& rect);
  65.  
  66. // ----- Tests -----
  67. FW_FUNC_ATTR FW_Boolean        FW_IsEmptyRegion(ODRgnHandle rgn);
  68. FW_FUNC_ATTR FW_Boolean        FW_PointInRegion(ODRgnHandle rgn, const FW_CPoint& point);
  69. FW_FUNC_ATTR FW_Boolean        FW_RectInRegion(ODRgnHandle rgn, const FW_CRect& rect);
  70.     
  71. // ----- Region Operations -----
  72. FW_FUNC_ATTR ODRgnHandle    FW_UnionRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
  73. FW_FUNC_ATTR ODRgnHandle    FW_XorRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
  74. FW_FUNC_ATTR ODRgnHandle    FW_SubtractRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);    // rgn1 - rgn2
  75. FW_FUNC_ATTR ODRgnHandle    FW_IntersectRegion(ODRgnHandle rgn1, ODRgnHandle rgn2);
  76.  
  77. FW_FUNC_ATTR void            FW_UnionRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);
  78. FW_FUNC_ATTR void            FW_XorRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);    // rgn1 - rgn2
  79. FW_FUNC_ATTR void            FW_SubtractRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);
  80. FW_FUNC_ATTR void            FW_IntersectRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn);
  81.  
  82. FW_FUNC_ATTR void            FW_OutlineRegion(ODRgnHandle rgn, FW_CFixed outlineSize);
  83.  
  84. FW_FUNC_ATTR void            FW_EmptyRegion(ODRgnHandle rgn);
  85. FW_FUNC_ATTR void            FW_InsetRegion(ODRgnHandle rgn, FW_CFixed x, FW_CFixed y);
  86. FW_FUNC_ATTR void            FW_MapRegion(ODRgnHandle rgn, const FW_CRect& srcRect, const FW_CRect& dstRect);
  87. FW_FUNC_ATTR void            FW_OffsetRegion(ODRgnHandle rgn, FW_CFixed x, FW_CFixed y);
  88.         
  89. #ifdef FW_BUILD_MAC
  90. GrafPtr        FW_PrivMacOpenRegion();
  91. ODRgnHandle    FW_PrivMacCloseRegion(GrafPtr svPort);
  92. #endif
  93.  
  94. //========================================================================================
  95. //    inlines
  96. //========================================================================================
  97.  
  98. //----------------------------------------------------------------------------------------
  99. //    FW_IsEqualRegion
  100. //----------------------------------------------------------------------------------------
  101. inline FW_FUNC_ATTR FW_Boolean FW_IsEqualRegion(ODRgnHandle rgn1, ODRgnHandle rgn2)
  102. {
  103.     return ::EqualRgn(rgn1, rgn2);
  104. }
  105.  
  106. //----------------------------------------------------------------------------------------
  107. //    FW_IsEmptyRegion
  108. //----------------------------------------------------------------------------------------
  109. inline FW_FUNC_ATTR FW_Boolean FW_IsEmptyRegion(ODRgnHandle rgn)
  110. {
  111. #ifdef FW_BUILD_MAC
  112.     return ::EmptyRgn(rgn);
  113. #endif
  114. #ifdef FW_BUILD_WIN
  115.     return ::CombineRgn(rgn, rgn, rgn, RGN_AND) == NULLREGION;
  116. #endif
  117. }
  118.  
  119. //----------------------------------------------------------------------------------------
  120. //    FW_UnionRegion
  121. //----------------------------------------------------------------------------------------
  122. inline FW_FUNC_ATTR void FW_UnionRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
  123. {
  124. #ifdef FW_BUILD_MAC
  125.     ::UnionRgn(rgn1, rgn2, dstRgn);
  126. #endif
  127. #ifdef FW_BUILD_WIN
  128.     ::CombineRgn(dstRgn, rgn1, rgn2, RGN_OR);
  129. #endif
  130. }
  131.  
  132. //----------------------------------------------------------------------------------------
  133. //    FW_XorRegion
  134. //----------------------------------------------------------------------------------------
  135. inline FW_FUNC_ATTR void FW_XorRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
  136. {
  137. #ifdef FW_BUILD_MAC
  138.     ::XorRgn(rgn1, rgn2, dstRgn);
  139. #endif
  140. #ifdef FW_BUILD_WIN
  141.     ::CombineRgn(dstRgn, rgn1, rgn2, RGN_XOR);
  142. #endif
  143. }
  144.  
  145. //----------------------------------------------------------------------------------------
  146. //    FW_SubtractRegion
  147. //----------------------------------------------------------------------------------------
  148. inline FW_FUNC_ATTR void FW_SubtractRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
  149. {
  150. #ifdef FW_BUILD_MAC
  151.     ::DiffRgn(rgn1, rgn2, dstRgn);
  152. #endif
  153. #ifdef FW_BUILD_WIN
  154.     ::CombineRgn(dstRgn, rgn1, rgn2, RGN_DIFF);
  155. #endif
  156. }
  157.  
  158. //----------------------------------------------------------------------------------------
  159. //    FW_IntersectRegion
  160. //----------------------------------------------------------------------------------------
  161. inline FW_FUNC_ATTR void FW_IntersectRegion(ODRgnHandle rgn1, ODRgnHandle rgn2, ODRgnHandle dstRgn)
  162. {
  163. #ifdef FW_BUILD_MAC
  164.     ::SectRgn(rgn1, rgn2, dstRgn);
  165. #endif
  166. #ifdef FW_BUILD_WIN
  167.     ::CombineRgn(dstRgn, rgn1, rgn2, RGN_AND);
  168. #endif
  169. }
  170.  
  171. //----------------------------------------------------------------------------------------
  172. //    FW_EmptyRegion
  173. //----------------------------------------------------------------------------------------
  174. inline FW_FUNC_ATTR void FW_EmptyRegion(ODRgnHandle rgn)
  175. {
  176. #ifdef FW_BUILD_MAC
  177.     ::SetEmptyRgn(rgn);
  178. #endif
  179. #ifdef FW_BUILD_WIN
  180.     ::SetRectRgn(rgn, 0, 0, 0, 0);
  181. #endif
  182. }
  183.  
  184. //----------------------------------------------------------------------------------------
  185. //    FW_OffsetRegion
  186. //----------------------------------------------------------------------------------------
  187. inline FW_FUNC_ATTR void FW_OffsetRegion(ODRgnHandle rgn, FW_CFixed x, FW_CFixed y)
  188. {
  189.     ::OffsetRgn(rgn, x.AsInt(), y.AsInt());
  190. }
  191.  
  192. #if FW_LIB_EXPORT_PRAGMAS
  193. #pragma lib_export off
  194. #endif
  195.  
  196. #endif
  197.