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 / Sources / FWOvlShp.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  4.9 KB  |  187 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWOvlShp.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWOVLSHP_H
  13. #include "FWOvlShp.h"
  14. #endif
  15.  
  16. #ifndef FWGRGLOB_H
  17. #include "FWGrGlob.h"
  18. #endif
  19.  
  20. #ifndef FWGC_H
  21. #include "FWGC.h"
  22. #endif
  23.  
  24. #ifndef FWGRUTIL_H
  25. #include "FWGrUtil.h"
  26. #endif
  27.  
  28. #ifndef FWFXMATH_H
  29. #include "FWFxMath.h"
  30. #endif
  31.  
  32. #ifndef FWRASTER_H
  33. #include "FWRaster.h"
  34. #endif
  35.  
  36. // ----- Foundation Includes -----
  37.  
  38. #ifndef FWSTREAM_H
  39. #include "FWStream.h"
  40. #endif
  41.  
  42. // ----- OpenDoc Includes -----
  43.  
  44. #ifndef SOM_ODTransform_xh
  45. #include <Trnsform.xh>
  46. #endif
  47.  
  48. //========================================================================================
  49. //    RunTime Info
  50. //========================================================================================
  51.  
  52. #if FW_LIB_EXPORT_PRAGMAS
  53. #pragma lib_export on
  54. #endif
  55.  
  56. #ifdef FW_BUILD_MAC
  57. #pragma segment FWGraphics_OvalShape
  58. #endif
  59.  
  60. FW_DEFINE_CLASS_M1(FW_COvalShape, FW_CBoundedShape)
  61.  
  62. FW_REGISTER_ARCHIVABLE_CLASS(FW_LOvalShape, FW_COvalShape, FW_COvalShape::Read, FW_CShape::Write)
  63.  
  64. //========================================================================================
  65. //    class FW_COvalShape
  66. //========================================================================================
  67.  
  68. //----------------------------------------------------------------------------------------
  69. //    FW_COvalShape::FW_COvalShape
  70. //----------------------------------------------------------------------------------------
  71.  
  72. FW_COvalShape::FW_COvalShape(const FW_COvalShape& other) :
  73.     FW_CBoundedShape(other)
  74. {
  75.     FW_END_CONSTRUCTOR
  76. }
  77.  
  78. //----------------------------------------------------------------------------------------
  79. //    FW_COvalShape::FW_COvalShape
  80. //----------------------------------------------------------------------------------------
  81.  
  82. FW_COvalShape::FW_COvalShape(const FW_CRect& rect,
  83.                              FW_ERenderVerbs renderVerb,
  84.                              const FW_PInk& ink,
  85.                              const FW_PStyle& style) :
  86.     FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont)
  87. {
  88.     FW_END_CONSTRUCTOR
  89. }
  90.  
  91. //----------------------------------------------------------------------------------------
  92. //    FW_COvalShape::FW_COvalShape
  93. //----------------------------------------------------------------------------------------
  94.  
  95. FW_COvalShape::FW_COvalShape(FW_CReadableStream& archive) :
  96.     FW_CBoundedShape(archive)
  97. {
  98.     FW_END_CONSTRUCTOR
  99. }
  100.  
  101. //----------------------------------------------------------------------------------------
  102. //    FW_COvalShape::~FW_COvalShape
  103. //----------------------------------------------------------------------------------------
  104.  
  105. FW_COvalShape::~FW_COvalShape()
  106. {
  107.     FW_START_DESTRUCTOR
  108. }
  109.  
  110. //----------------------------------------------------------------------------------------
  111. //    FW_COvalShape::Render
  112. //----------------------------------------------------------------------------------------
  113.  
  114. void FW_COvalShape::Render(FW_CGraphicContext& gc) const
  115. {    
  116.     gc.GetRasterizer()->RenderOval(gc,
  117.                                     fRect,
  118.                                     GetRenderVerb(),
  119.                                     fInk,
  120.                                     fStyle);
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. //    FW_COvalShape::RenderOval
  125. //----------------------------------------------------------------------------------------
  126.  
  127. void FW_COvalShape::RenderOval(FW_CGraphicContext& gc,
  128.                                 const FW_CRect& rect, 
  129.                                 FW_ERenderVerbs renderVerb, 
  130.                                 const FW_PInk& ink,
  131.                                 const FW_PStyle& style)
  132. {    
  133.     gc.GetRasterizer()->RenderOval(gc,
  134.                                     rect,
  135.                                     renderVerb,
  136.                                     ink,
  137.                                     style);
  138. }
  139.  
  140. //----------------------------------------------------------------------------------------
  141. //    FW_COvalShape::HitTest
  142. //----------------------------------------------------------------------------------------
  143.  
  144. FW_Boolean FW_COvalShape::HitTest(FW_CGraphicContext& gc,
  145.                                   const FW_CPoint& test,
  146.                                   FW_CFixed tolerance) const
  147. {
  148.     if(fRenderVerb == FW_kNoRendering)
  149.         return FALSE;
  150.  
  151.     FW_CRect ovalRect(fRect);
  152.     ovalRect.Inset(-tolerance, -tolerance);
  153.     
  154.     if (!::FW_PtInOval(ovalRect, test))
  155.         return FALSE;
  156.     
  157.     if (fRenderVerb == FW_kFrame)
  158.     {
  159.         ovalRect = fRect;
  160.         FW_CFixed inset = tolerance + GetPenSize();
  161.         ovalRect.Inset(inset, inset);
  162.         return ! ::FW_PtInOval(ovalRect, test);
  163.     }
  164.     
  165.     return TRUE;
  166. }
  167.  
  168. //----------------------------------------------------------------------------------------
  169. //    FW_COvalShape::Copy
  170. //----------------------------------------------------------------------------------------
  171.  
  172. FW_CShape* FW_COvalShape::Copy() const
  173. {
  174.     return FW_NEW(FW_COvalShape, (*this));
  175. }
  176.  
  177. //----------------------------------------------------------------------------------------
  178. //    FW_COvalShape::Read
  179. //----------------------------------------------------------------------------------------
  180.  
  181. void* FW_COvalShape::Read(FW_CReadableStream& archive)
  182. {
  183.     return FW_NEW(FW_COvalShape, (archive));
  184. }
  185.  
  186.  
  187.