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 / FWRecShp.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  5.0 KB  |  179 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRecShp.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 FWRECSHP_H
  13. #include "FWRecShp.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef SLGRGLOB_H
  21. #include "SLGrGlob.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 SLRENDER_H
  33. #include "SLRender.h"
  34. #endif
  35.  
  36. // ----- Foundation Includes -----
  37.  
  38. #ifndef FWSTREAM_H
  39. #include "FWStream.h"
  40. #endif
  41.  
  42. //========================================================================================
  43. // File scope definitions
  44. //========================================================================================
  45.  
  46. #ifdef FW_BUILD_MAC
  47. #pragma segment FWGraphics_RectShape
  48. #endif
  49.  
  50. //========================================================================================
  51. //    class FW_CRectShape
  52. //========================================================================================
  53.  
  54. FW_DEFINE_AUTO(FW_CRectShape)
  55. FW_DEFINE_CLASS_M1(FW_CRectShape, FW_CBoundedShape)
  56.  
  57. // This class is archivable, but we provide the archiving implementation in a separate
  58. // translation unit in order to enable deadstripping of the archiving-related code
  59. // in parts that do not use archiving with this class.
  60.  
  61. //----------------------------------------------------------------------------------------
  62. //    FW_CRectShape::FW_CRectShape
  63. //----------------------------------------------------------------------------------------
  64.  
  65. FW_CRectShape::FW_CRectShape() :
  66.     FW_CBoundedShape(FW_kZeroRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont)
  67. {
  68.     FW_END_CONSTRUCTOR
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. //    FW_CRectShape::FW_CRectShape
  73. //----------------------------------------------------------------------------------------
  74.  
  75. FW_CRectShape::FW_CRectShape(const FW_CRectShape& other) :
  76.     FW_CBoundedShape(other)
  77. {
  78.     FW_END_CONSTRUCTOR
  79. }
  80.  
  81. //----------------------------------------------------------------------------------------
  82. //    FW_CRectShape::FW_CRectShape
  83. //----------------------------------------------------------------------------------------
  84.  
  85. FW_CRectShape::FW_CRectShape(const FW_CRect& rect,
  86.                              FW_ERenderVerbs renderVerb,
  87.                              const FW_CInk& ink,
  88.                               const FW_CStyle& style) :
  89.     FW_CBoundedShape(rect, renderVerb, ink, style, FW_kNormalFont)
  90. {
  91.     FW_END_CONSTRUCTOR
  92. }
  93.  
  94. //----------------------------------------------------------------------------------------
  95. //    FW_CRectShape::FW_CRectShape
  96. //----------------------------------------------------------------------------------------
  97.  
  98. FW_CRectShape::FW_CRectShape(FW_CReadableStream& stream) :
  99.     FW_CBoundedShape(stream)
  100. {
  101.     FW_END_CONSTRUCTOR
  102. }
  103.  
  104. //----------------------------------------------------------------------------------------
  105. //    FW_CRectShape::~FW_CRectShape
  106. //----------------------------------------------------------------------------------------
  107.  
  108. FW_CRectShape::~FW_CRectShape()
  109. {
  110.     FW_START_DESTRUCTOR
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    FW_CRectShape::Render
  115. //----------------------------------------------------------------------------------------
  116.  
  117. void FW_CRectShape::Render(FW_CGraphicContext& gc) const
  118. {    
  119.     FW_PrivRenderRect(gc.GetEnvironment(),
  120.         gc,
  121.         fRect,
  122.         GetRenderVerb(),
  123.         fInk,
  124.         fStyle);
  125.     FW_FailOnEvError(gc.GetEnvironment());
  126. }
  127.  
  128. //----------------------------------------------------------------------------------------
  129. //    FW_CRectShape::RenderRect
  130. //----------------------------------------------------------------------------------------
  131.  
  132. void FW_CRectShape::RenderRect(FW_CGraphicContext& gc,
  133.                                 const FW_CRect& rect, 
  134.                                 FW_ERenderVerbs renderVerb, 
  135.                                 const FW_CInk& ink,
  136.                                 const FW_CStyle& style)
  137. {    
  138.     FW_PrivRenderRect(gc.GetEnvironment(),
  139.         gc,
  140.         rect,
  141.         renderVerb,
  142.         ink,
  143.         style);
  144.     FW_FailOnEvError(gc.GetEnvironment());
  145. }
  146.  
  147. //----------------------------------------------------------------------------------------
  148. //    FW_CRectShape::HitTest
  149. //----------------------------------------------------------------------------------------
  150.  
  151. FW_Boolean FW_CRectShape::HitTest(FW_CGraphicContext& gc,
  152.                                   const FW_CPoint& test,
  153.                                   FW_Fixed tolerance) const
  154. {    
  155.     if (FW_CBoundedShape::HitTest(gc, test, tolerance))
  156.     {
  157.         if (fRenderVerb == FW_kFrame)
  158.         {            
  159.             FW_CRect bounds(fRect);
  160.             FW_Fixed inset = tolerance + GetPenSize();
  161.             bounds.Inset(inset, inset);
  162.             return ! bounds.Contains(test);
  163.         }
  164.         
  165.         return TRUE;
  166.     }
  167.     
  168.     return FALSE;
  169. }
  170.  
  171. //----------------------------------------------------------------------------------------
  172. //    FW_CRectShape::Copy
  173. //----------------------------------------------------------------------------------------
  174.  
  175. FW_CShape* FW_CRectShape::Copy() const
  176. {
  177.     return FW_NEW(FW_CRectShape, (*this));
  178. }
  179.