home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWRecShp.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  8.5 KB  |  289 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRecShp.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWRECSHP_H
  13. #include "FWRecShp.h"
  14. #endif
  15.  
  16. #ifndef FWSHAPE_H
  17. #include "FWShape.h"
  18. #endif
  19.  
  20. #ifndef FWGC_H
  21. #include "FWGC.h"
  22. #endif
  23.  
  24. #ifndef FWDFAULT_H
  25. #include "FWDFault.h"
  26. #endif
  27.  
  28. #ifndef FWOVLSHP_H
  29. #include "FWOvlShp.h"
  30. #endif
  31.  
  32. #ifndef FWRRCSHP_H
  33. #include "FWRRcShp.h"
  34. #endif
  35.  
  36. #ifndef FWARCSHP_H
  37. #include "FWArcShp.h"
  38. #endif
  39.  
  40. #ifndef FWLINSHP_H
  41. #include "FWLinShp.h"
  42. #endif
  43.  
  44. #ifndef FWRGNSHP_H
  45. #include "FWRgnShp.h"
  46. #endif
  47.  
  48. // ----- OpenDoc Includes -----
  49.  
  50. #ifndef _TRNSFORM_
  51. #include <Trnsform.h>
  52. #endif
  53.  
  54. //==============================================================================
  55. //    •• RunTime Info
  56. //==============================================================================
  57.  
  58. #ifdef FW_BUILD_MAC
  59. #pragma segment fwgraphx
  60. #endif
  61.  
  62. //==============================================================================
  63. //    •• class FW_CRectShape
  64. //==============================================================================
  65.  
  66. //------------------------------------------------------------------------------
  67. // FW_CRectShape::FW_CRectShape
  68. //------------------------------------------------------------------------------
  69.  
  70. FW_CRectShape::FW_CRectShape() :
  71.     FW_CShape()
  72. {
  73. }
  74.  
  75. //------------------------------------------------------------------------------
  76. // FW_CRectShape::FW_CRectShape
  77. //------------------------------------------------------------------------------
  78.  
  79. FW_CRectShape::FW_CRectShape(const FW_CRect& rect) :
  80.     FW_CShape()
  81. {
  82.     SetRep(new FW_CRectShapeRep(rect));
  83. }
  84.  
  85. //------------------------------------------------------------------------------
  86. // FW_CRectShape::FW_CRectShape
  87. //------------------------------------------------------------------------------
  88.  
  89. FW_CRectShape::FW_CRectShape(const FW_CRectShape& other) :
  90.     FW_CShape(other)
  91. {
  92. }
  93.  
  94. //------------------------------------------------------------------------------
  95. // FW_CRectShape::FW_CRectShape
  96. //------------------------------------------------------------------------------
  97.  
  98. FW_CRectShape::FW_CRectShape(FW_CRectShapeRep* other) :
  99.     FW_CShape(other)
  100. {
  101. }
  102.  
  103. //------------------------------------------------------------------------------
  104. // FW_CRectShape::operator=
  105. //------------------------------------------------------------------------------
  106.  
  107. FW_CRectShape& FW_CRectShape::operator=(const FW_CRectShape& other)
  108. {
  109.     SetRep(other.GetRep());
  110.     return *this;
  111. }
  112.  
  113. //------------------------------------------------------------------------------
  114. // FW_CRectShape::operator=
  115. //------------------------------------------------------------------------------
  116.  
  117. FW_CRectShape& FW_CRectShape::operator=(FW_CRectShapeRep* other)
  118. {
  119.     SetRep(other);
  120.     return *this;
  121. }
  122.  
  123. //------------------------------------------------------------------------------
  124. // FW_CRectShape::operator FW_COvalShape
  125. //------------------------------------------------------------------------------
  126.  
  127. FW_CRectShape::operator FW_COvalShape() const
  128. {    
  129.     FW_COvalShape ovalShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  130.     ovalShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  131.     return ovalShape;
  132. }
  133.  
  134. //------------------------------------------------------------------------------
  135. // FW_CRectShape::operator FW_CRoundRectShape
  136. //------------------------------------------------------------------------------
  137.  
  138. FW_CRectShape::operator FW_CRoundRectShape() const
  139. {    
  140.     FW_CRoundRectShape roundRectShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), FW_kZeroPoint);
  141.     roundRectShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  142.     return roundRectShape;
  143. }
  144.  
  145. //------------------------------------------------------------------------------
  146. // FW_CRectShape::operator FW_CArcShape
  147. //------------------------------------------------------------------------------
  148.  
  149. FW_CRectShape::operator FW_CArcShape() const
  150. {    
  151.     FW_CArcShape arcShape(((FW_CShapeRep*)GetRep())->GetShapeBounds(), 0, 0);
  152.     arcShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  153.     return arcShape;
  154. }
  155.  
  156. //------------------------------------------------------------------------------
  157. // FW_CRectShape::operator FW_CLineShape
  158. //------------------------------------------------------------------------------
  159.  
  160. FW_CRectShape::operator FW_CLineShape() const
  161. {    
  162.     FW_CRect rect = ((FW_CShapeRep*)GetRep())->GetShapeBounds();
  163.     FW_CLineShape lineShape(rect[FW_kTopLeft], rect[FW_kBotRight]);
  164.     lineShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  165.     return lineShape;
  166. }
  167.  
  168. //------------------------------------------------------------------------------
  169. // FW_CRectShape::operator FW_CRegionShape
  170. //------------------------------------------------------------------------------
  171.  
  172. FW_CRectShape::operator FW_CRegionShape() const
  173. {    
  174.     FW_CRegionShape regionShape(((FW_CShapeRep*)GetRep())->GetShapeBounds());
  175.     regionShape->SetShapeFill(((FW_CShapeRep*)GetRep())->GetShapeFill());
  176.     return regionShape;
  177. }
  178.  
  179. //==============================================================================
  180. //    •• class FW_CRectShapeRep
  181. //==============================================================================
  182.  
  183. //------------------------------------------------------------------------------
  184. //    • FW_CRectShapeRep::FW_CRectShapeRep
  185. //------------------------------------------------------------------------------
  186.  
  187. FW_CRectShapeRep::FW_CRectShapeRep() :
  188.     FW_CBoundedShapeRep(gGraphicGlobales.gRect, FW_CRect(0,0,0,0))
  189. {
  190. }
  191.  
  192. //------------------------------------------------------------------------------
  193. //    • FW_CRectShapeRep::FW_CRectShapeRep
  194. //------------------------------------------------------------------------------
  195.  
  196. FW_CRectShapeRep::FW_CRectShapeRep(const FW_CRect& rect) :
  197.     FW_CBoundedShapeRep(gGraphicGlobales.gRect, rect)
  198. {
  199. }
  200.  
  201. //------------------------------------------------------------------------------
  202. //    • FW_CRectShapeRep::~FW_CRectShapeRep
  203. //------------------------------------------------------------------------------
  204.  
  205. FW_CRectShapeRep::~FW_CRectShapeRep()
  206. {
  207. }
  208.  
  209. //------------------------------------------------------------------------------
  210. //    • FW_CRectShapeRep::Draw
  211. //------------------------------------------------------------------------------
  212.  
  213. void FW_CRectShapeRep::Draw(FW_CGraphicContext* graphicContext)
  214. {    
  215.     FW_ShapeFills shapeFill = GetShapeFill();
  216.     
  217.     if (shapeFill == FW_kNullShape)
  218.         return;
  219.         
  220.     graphicContext->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kGeometricShape, shapeFill);
  221.  
  222.     FW_SPlatformRect rect = graphicContext->AsPlatformRect(fRect);
  223.  
  224. #ifdef FW_BUILD_MAC
  225.     if (shapeFill == FW_kFramed)
  226.         ::FrameRect(&rect);
  227.     else
  228.         ::PaintRect(&rect);
  229. #endif
  230. #ifdef FW_BUILD_WIN
  231.     ::Rectangle(graphicContext->GetHDC(), rect.left, rect.top, rect.right, rect.bottom);
  232. #endif
  233. }
  234.  
  235. //------------------------------------------------------------------------------
  236. //    • FW_CRectShapeRep::DrawRect
  237. //------------------------------------------------------------------------------
  238.  
  239. void FW_CRectShapeRep::DrawRect(FW_CGraphicContext* graphicContext, const FW_CRect& rect)
  240. {        
  241.     if (gGraphicGlobales.gRect.fFill == FW_kNullShape)
  242.         return;
  243.  
  244.     graphicContext->SelectInkAndStyle(gGraphicGlobales.gRect.fInk, 
  245.                                         gGraphicGlobales.gRect.fStyle, 
  246.                                         FW_kGeometricShape, 
  247.                                         gGraphicGlobales.gRect.fFill);
  248.  
  249.     FW_SPlatformRect qdRect = graphicContext->AsPlatformRect(rect);
  250.  
  251. #ifdef FW_BUILD_MAC
  252.     if (gGraphicGlobales.gRect.fFill == FW_kFramed)
  253.         ::FrameRect(&qdRect);
  254.     else
  255.         ::PaintRect(&qdRect);
  256. #endif
  257. #ifdef FW_BUILD_WIN
  258.     ::Rectangle(graphicContext->GetHDC(), qdRect.left, qdRect.top, qdRect.right, qdRect.bottom);
  259. #endif
  260. }
  261.  
  262. //------------------------------------------------------------------------------
  263. //    • FW_CRectShapeRep::SetAsDefault
  264. //------------------------------------------------------------------------------
  265.  
  266. void FW_CRectShapeRep::SetAsDefault() const
  267. {
  268.     SetDefaultProperties(gGraphicGlobales.gRect);
  269. }
  270.  
  271. //------------------------------------------------------------------------------
  272. //    • FW_CRectShapeRep::HitTest
  273. //------------------------------------------------------------------------------
  274.  
  275. FW_HitTestPart FW_CRectShapeRep::HitTest(const FW_CPoint& test) const
  276. {
  277.     return FW_kOutside;
  278. }
  279.  
  280. //------------------------------------------------------------------------------
  281. //    • FW_CRectShapeRep::Copy
  282. //------------------------------------------------------------------------------
  283.  
  284. FW_CRectShape FW_CRectShapeRep::Copy() const
  285. {
  286.     FW_CRectShape rect(fRect);
  287.     return rect;
  288. }
  289.