home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / SLPoly.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  4.0 KB  |  194 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                SLPoly.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef SLPOLY_H
  13. #include "SLPoly.h"
  14. #endif
  15.  
  16. #ifndef PRPOLY_H
  17. #include "PRPoly.h"
  18. #endif
  19.  
  20. #ifndef FWODEXCE_H
  21. #include "FWODExce.h"
  22. #endif
  23.  
  24. #ifndef FWPOINT_H
  25. #include "FWPoint.h"
  26. #endif
  27.  
  28. #ifndef FWSTRMRW_H
  29. #include "FWStrmRW.h"
  30. #endif
  31.  
  32. #ifdef FW_BUILD_MAC
  33. #pragma segment FWGraphics_Polygon
  34. #endif
  35.  
  36.  
  37. // Creation
  38.  
  39. FW_HPolygon            SL_API    FW_PrivPolygon_CreateFromPoints(
  40.                                 long                 count,
  41.                                 const FW_SPoint*     points,
  42.                                 FW_PlatformError*     error)
  43. {
  44.     FW_ERR_TRY
  45.     {
  46.         return FW_NEW(FW_CPrivPolygonRep, (count, points));
  47.     }
  48.     FW_ERR_CATCH
  49.     return 0;    
  50. }
  51.  
  52. FW_HPolygon            SL_API    FW_PrivPolygon_Copy(FW_HPolygon poly, FW_PlatformError* error)
  53. {
  54.     FW_ERR_TRY
  55.     {
  56.         return FW_NEW(FW_CPrivPolygonRep, (*poly));
  57.     }
  58.     FW_ERR_CATCH
  59.     return 0;    
  60. }
  61.  
  62. // Reference counting
  63.  
  64. void                SL_API    FW_PrivPolygon_Acquire(FW_HPolygon poly)
  65. {
  66.     // No try block necessary - Do not throw
  67.     poly->Acquire();
  68. }
  69.  
  70. long                SL_API    FW_PrivPolygon_GetRefCount(FW_HPolygon poly)
  71. {
  72.     // No try block necessary - Do not throw
  73.     return poly->GetRefCount();
  74. }
  75.  
  76. void                SL_API    FW_PrivPolygon_Release(FW_HPolygon poly)
  77. {
  78.     // No try block necessary - Do not throw
  79.     poly->Release();
  80. }
  81.  
  82. // Geometric Operations
  83.  
  84. void                SL_API    FW_PrivPolygon_Transform(FW_HPolygon poly, Environment *ev, ODTransform* transform)
  85. {    
  86.     FW_SOM_TRY
  87.     {
  88.         poly->Transform(ev, transform);
  89.     }
  90.     FW_SOM_CATCH
  91. }
  92.  
  93. void                SL_API    FW_PrivPolygon_InverseTransform(FW_HPolygon poly, Environment *ev, ODTransform* transform)
  94. {    
  95.     FW_SOM_TRY
  96.     {
  97.         poly->InverseTransform(ev, transform);
  98.     }
  99.     FW_SOM_CATCH
  100. }
  101.  
  102. FW_PlatformError    SL_API    FW_PrivPolygon_Move(FW_HPolygon poly, FW_Fixed deltaX, FW_Fixed deltaY)
  103. {
  104.     // No try block necessary - Do not throw
  105.     poly->Move(deltaX, deltaY);
  106.     return FW_xNoError;
  107. }
  108.  
  109. FW_PlatformError    SL_API    FW_PrivPolygon_MoveTo(FW_HPolygon poly, FW_Fixed x, FW_Fixed y)
  110. {
  111.     // No try block necessary - Do not throw
  112.     poly->MoveTo(x, y);
  113.     return FW_xNoError;
  114. }
  115.  
  116. FW_PlatformError    SL_API    FW_PrivPolygon_Inset(FW_HPolygon poly, FW_Fixed x, FW_Fixed y)
  117. {
  118.     // No try block necessary - Do not throw
  119.     poly->Inset(x, y);
  120.     return FW_xNoError;
  121. }
  122.  
  123. FW_PlatformError    SL_API    FW_PrivPolygon_GetBounds(FW_HPolygon poly, FW_SRect& rect)
  124. {
  125.     // No try block necessary - Do not throw
  126.     poly->GetBounds(rect);
  127.     return FW_xNoError;
  128. }
  129.  
  130. // Point access
  131.  
  132. FW_PlatformError    SL_API    FW_PrivPolygon_SetPoints(
  133.                                 FW_HPolygon         poly,
  134.                                 const FW_SPoint*     points,
  135.                                 long                 startIndex,
  136.                                 long                 pointCount)
  137. {
  138.     // No try block necessary - Do not throw
  139.     poly->SetPoints(points, startIndex, pointCount);
  140.     return FW_xNoError;
  141. }
  142.  
  143. FW_PlatformError    SL_API    FW_PrivPolygon_GetPoints(
  144.                                 FW_HPolygon         poly,
  145.                                 FW_SPoint*             points,
  146.                                 long                 startIndex,
  147.                                 long                 pointCount)
  148. {
  149.     // No try block necessary - Do not throw
  150.     poly->GetPoints(points, startIndex, pointCount);
  151.     return FW_xNoError;
  152. }
  153.  
  154. long                SL_API    FW_PrivPolygon_GetCount(FW_HPolygon poly)
  155. {
  156.     // No try block necessary - Do not throw
  157.     return poly->GetCount();
  158. }
  159.  
  160. FW_SPoint*            SL_API    FW_PrivPolygon_GetPointArray(FW_HPolygon poly)
  161. {
  162.     // No try block necessary - Do not throw
  163.     return poly->GetPoints();
  164. }
  165.  
  166. FW_Boolean            SL_API    FW_PrivPolygon_IsEqual(FW_HPolygon poly, FW_HPolygon poly2)
  167. {
  168.     // No try block necessary - Do not throw
  169.     return poly->IsEqual(poly2);
  170. }
  171.  
  172. // Streaming
  173.  
  174. void                SL_API    FW_PrivPolygon_Write(FW_HPolygon poly, FW_HWritableStream hStream, FW_PlatformError* error)
  175. {
  176.     FW_ERR_TRY
  177.     {
  178.         FW_CWritableStream stream(hStream);
  179.         poly->Write(stream);
  180.     }
  181.     FW_ERR_CATCH
  182. }
  183.  
  184. FW_HPolygon         SL_API    FW_PrivPolygon_Read(FW_HReadableStream hStream, FW_PlatformError* error)
  185. {
  186.     FW_ERR_TRY
  187.     {
  188.         FW_CReadableStream stream(hStream);
  189.         return FW_NEW(FW_CPrivPolygonRep, (stream));
  190.     }
  191.     FW_ERR_CATCH
  192.     return 0;    
  193. }
  194.