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 / FWBndShp.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  5.8 KB  |  198 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWBndShp.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 FWBNDSHP_H
  13. #include "FWBndShp.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. // ----- OpenDoc Includes -----
  25.  
  26. #ifndef _TRANSFORM_
  27. #include <Trnsform.xh>
  28. #endif
  29.  
  30. //========================================================================================
  31. //    RunTime Info
  32. //========================================================================================
  33.  
  34. #if FW_LIB_EXPORT_PRAGMAS
  35. #pragma lib_export on
  36. #endif
  37.  
  38. #ifdef FW_BUILD_MAC
  39. #pragma segment fwgraphxshape
  40. #endif
  41.  
  42. FW_DEFINE_CLASS_M1(FW_CBoundedShape, FW_CShape)
  43.  
  44. //========================================================================================
  45. //    class FW_CBoundedShape
  46. //========================================================================================
  47.  
  48. //----------------------------------------------------------------------------------------
  49. //    FW_CBoundedShape::FW_CBoundedShape
  50. //----------------------------------------------------------------------------------------
  51.  
  52. FW_CBoundedShape::FW_CBoundedShape(const FW_CBoundedShape& other) :
  53.     FW_CShape(other),
  54.     fRect(other.fRect)
  55. {
  56.     FW_END_CONSTRUCTOR
  57. }
  58.  
  59. //----------------------------------------------------------------------------------------
  60. //    FW_CBoundedShape::FW_CBoundedShape
  61. //----------------------------------------------------------------------------------------
  62.  
  63. FW_CBoundedShape::FW_CBoundedShape(const FW_CRect& rect,
  64.                                    FW_ERenderVerbs renderVerb,
  65.                                    const FW_PInk& ink,
  66.                                    const FW_PStyle& style,
  67.                                    const FW_PFont& font) :
  68.     FW_CShape(renderVerb, ink, style, font),
  69.     fRect(rect)
  70. {
  71.     FW_END_CONSTRUCTOR
  72. }
  73.  
  74. //----------------------------------------------------------------------------------------
  75. // FW_CBoundedShape::FW_CBoundedShape
  76. //----------------------------------------------------------------------------------------
  77.  
  78. FW_CBoundedShape::FW_CBoundedShape(FW_CReadableStream& archive) :
  79.     FW_CShape(archive)
  80. {
  81.     archive >> fRect;
  82.     FW_END_CONSTRUCTOR
  83. }
  84.  
  85. //----------------------------------------------------------------------------------------
  86. //    FW_CBoundedShape::~FW_CBoundedShape
  87. //----------------------------------------------------------------------------------------
  88.  
  89. FW_CBoundedShape::~FW_CBoundedShape()
  90. {
  91.     FW_START_DESTRUCTOR
  92. }
  93.  
  94. //----------------------------------------------------------------------------------------
  95. //    FW_CBoundedShape::operator=
  96. //----------------------------------------------------------------------------------------
  97.  
  98. FW_CBoundedShape& FW_CBoundedShape::operator=(const FW_CBoundedShape& other)
  99. {
  100.     if (this != &other)
  101.     {
  102.         FW_CShape::operator=(other);    
  103.         fRect = other.fRect;
  104.     }
  105.     
  106.     return *this;
  107. }
  108.  
  109. //----------------------------------------------------------------------------------------
  110. //    FW_CBoundedShape::HitTest
  111. //----------------------------------------------------------------------------------------
  112. //    Only test if the point is inside the bounds
  113.  
  114. FW_Boolean FW_CBoundedShape::HitTest(FW_CGraphicContext& gc,
  115.                                      const FW_CPoint& test,
  116.                                      FW_CFixed tolerance) const
  117. {
  118.     if(fRenderVerb == FW_kNoRendering)
  119.         return FALSE;
  120.  
  121.     FW_CRect bounds(fRect);
  122.     bounds.Inset(-tolerance, -tolerance);
  123.     return bounds.Contains(test);
  124. }
  125.  
  126. //----------------------------------------------------------------------------------------
  127. //    FW_CBoundedShape::Transform
  128. //----------------------------------------------------------------------------------------
  129.  
  130. void FW_CBoundedShape::Transform(Environment *ev, ODTransform* transform)
  131. {
  132.     fRect.Transform(ev, transform);
  133. }
  134.  
  135. //----------------------------------------------------------------------------------------
  136. //    FW_CBoundedShape::Inset
  137. //----------------------------------------------------------------------------------------
  138.  
  139. void FW_CBoundedShape::Inset(FW_CFixed h, FW_CFixed v)
  140. {
  141.     fRect.Inset(h, v);
  142. }
  143.  
  144. //----------------------------------------------------------------------------------------
  145. //    FW_CBoundedShape::GetBounds
  146. //----------------------------------------------------------------------------------------
  147.  
  148. void FW_CBoundedShape::GetBounds(FW_CGraphicContext& gc, FW_CRect& rect) const
  149. {
  150. FW_UNUSED(gc);
  151.  
  152.     rect = fRect;
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. //    FW_CBoundedShape::InverseTransform
  157. //----------------------------------------------------------------------------------------
  158.  
  159. void FW_CBoundedShape::InverseTransform(Environment *ev, ODTransform* transform)
  160. {
  161.     fRect.InverseTransform(ev, transform);
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------
  165. //    FW_CBoundedShape::MoveShape
  166. //----------------------------------------------------------------------------------------
  167.  
  168. void FW_CBoundedShape::MoveShape(FW_CFixed deltaX, FW_CFixed deltaY)
  169. {
  170.     fRect.left += deltaX;
  171.     fRect.top += deltaY;
  172.     fRect.right += deltaX;
  173.     fRect.bottom += deltaY;
  174. }
  175.  
  176. //----------------------------------------------------------------------------------------
  177. //    FW_CBoundedShape::MoveShapeTo
  178. //----------------------------------------------------------------------------------------
  179.  
  180. void FW_CBoundedShape::MoveShapeTo(FW_CFixed x, FW_CFixed y)
  181. {
  182.     fRect.right += x - fRect.left;
  183.     fRect.bottom += y - fRect.top;
  184.     fRect.left = x;
  185.     fRect.top = y;
  186. }
  187.  
  188. //----------------------------------------------------------------------------------------
  189. //    FW_CBoundedShape::Flatten
  190. //----------------------------------------------------------------------------------------
  191.  
  192. void FW_CBoundedShape::Flatten(FW_CWritableStream& archive) const
  193. {
  194.     FW_CShape::Flatten(archive);
  195.     archive << fRect;
  196. }
  197.  
  198.