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

  1. //========================================================================================
  2. //
  3. //    File:                FWPicShp.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 FWPICSHP_H
  13. #include "FWPicShp.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 FWBMPSHP_H
  25. #include "FWBmpShp.h"
  26. #endif
  27.  
  28. #ifndef FWRECT_H
  29. #include "FWRect.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. #ifndef FWDEBUG_H
  43. #include "FWDebug.h"
  44. #endif
  45.  
  46. #ifndef FWMEMORY_H
  47. #include "FWMemory.h"
  48. #endif
  49.  
  50. //========================================================================================
  51. // File scope definitions
  52. //========================================================================================
  53.  
  54. #ifdef FW_BUILD_MAC
  55. #pragma segment FWGraphics_PictureShape
  56. #endif
  57.  
  58. //========================================================================================
  59. //    class FW_CPictureShape
  60. //========================================================================================
  61.  
  62. FW_DEFINE_AUTO(FW_CPictureShape)
  63. FW_DEFINE_CLASS_M1(FW_CPictureShape, FW_CBoundedShape)
  64.  
  65. // This class is archivable, but we provide the archiving implementation in a separate
  66. // translation unit in order to enable deadstripping of the archiving-related code
  67. // in parts that do not use archiving with this class.
  68.  
  69. //----------------------------------------------------------------------------------------
  70. //    FW_CPictureShape::FW_CPictureShape
  71. //----------------------------------------------------------------------------------------
  72.  
  73. FW_CPictureShape::FW_CPictureShape(FW_CPicture picture, const FW_CRect& rect) :
  74.     FW_CBoundedShape(rect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
  75.     fPicture(picture)
  76. {
  77.     FW_END_CONSTRUCTOR
  78. }
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    FW_CPictureShape::FW_CPictureShape
  82. //----------------------------------------------------------------------------------------
  83.  
  84. FW_CPictureShape::FW_CPictureShape(const FW_CPictureShape& other) :
  85.     FW_CBoundedShape(other),
  86.     fPicture(other.fPicture)
  87. {
  88.     FW_END_CONSTRUCTOR
  89. }
  90.  
  91. //----------------------------------------------------------------------------------------
  92. //    FW_CPictureShape::FW_CPictureShape
  93. //----------------------------------------------------------------------------------------
  94.  
  95. FW_CPictureShape::FW_CPictureShape(FW_CReadableStream& stream) :
  96.     FW_CBoundedShape(stream),
  97.     fPicture()
  98. {
  99.     stream >> fPicture;
  100.     
  101.     FW_END_CONSTRUCTOR
  102. }
  103.  
  104. //----------------------------------------------------------------------------------------
  105. //    FW_CPictureShape::~FW_CPictureShape
  106. //----------------------------------------------------------------------------------------
  107.  
  108. FW_CPictureShape::~FW_CPictureShape()
  109. {
  110.     FW_START_DESTRUCTOR
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    FW_CPictureShape::operator=
  115. //----------------------------------------------------------------------------------------
  116.  
  117. FW_CPictureShape& FW_CPictureShape::operator=(const FW_CPictureShape& other)
  118. {
  119.     if (this != &other)
  120.     {
  121.         FW_CBoundedShape::operator=(other);
  122.     
  123.         fPicture = other.fPicture;
  124.     }
  125.     
  126.     return *this;
  127. }
  128.  
  129. //----------------------------------------------------------------------------------------
  130. //    FW_CPictureShape::Render
  131. //----------------------------------------------------------------------------------------
  132.  
  133. void FW_CPictureShape::Render(FW_CGraphicContext& gc) const
  134. {
  135.     FW_PrivRenderPicture(gc.GetEnvironment(),
  136.         gc,
  137.         fPicture,
  138.         fRect,
  139.         GetRenderVerb());
  140.     FW_FailOnEvError(gc.GetEnvironment());
  141. }
  142.  
  143. //----------------------------------------------------------------------------------------
  144. //    FW_CPictureShape::RenderPicture
  145. //----------------------------------------------------------------------------------------
  146.  
  147. void FW_CPictureShape::RenderPicture(FW_CGraphicContext& gc,
  148.                                     FW_CPicture picture,
  149.                                     const FW_CRect& dstRect)
  150. {
  151.     FW_PrivRenderPicture(gc.GetEnvironment(),
  152.         gc,
  153.         picture,
  154.         dstRect,
  155.         FW_kFill);
  156.     FW_FailOnEvError(gc.GetEnvironment());
  157. }
  158.  
  159. //----------------------------------------------------------------------------------------
  160. //    FW_CPictureShape::GetGeometry
  161. //----------------------------------------------------------------------------------------
  162.  
  163. void FW_CPictureShape::GetGeometry(FW_CPicture& picture, FW_CRect& dstRect) const
  164. {
  165.     picture = fPicture;
  166.     dstRect = fRect;
  167. }
  168.  
  169. //----------------------------------------------------------------------------------------
  170. //    FW_CPictureShape::SetGeometry
  171. //----------------------------------------------------------------------------------------
  172.  
  173. void FW_CPictureShape::SetGeometry(const FW_CPicture& picture, const FW_CRect& dstRect)
  174. {
  175.     fPicture = picture;
  176.     fRect = dstRect;
  177. }
  178.  
  179. //----------------------------------------------------------------------------------------
  180. //    FW_CPictureShape::Flatten
  181. //----------------------------------------------------------------------------------------
  182.  
  183. void FW_CPictureShape::Flatten(FW_CWritableStream& stream) const
  184. {
  185.     FW_CBoundedShape::Flatten(stream);
  186.     stream << fPicture;
  187. }
  188.  
  189. //----------------------------------------------------------------------------------------
  190. //    FW_CPictureShape::Copy
  191. //----------------------------------------------------------------------------------------
  192.  
  193. FW_CShape* FW_CPictureShape::Copy() const
  194. {
  195.     return FW_NEW(FW_CPictureShape, (*this));
  196. }
  197.  
  198.