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

  1. //========================================================================================
  2. //
  3. //    File:                FWIconSh.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWICONSH_H
  13. #include "FWIconSh.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef FWRASTER_H
  21. #include "FWRaster.h"
  22. #endif
  23.  
  24. // ----- Foundation Includes -----
  25.  
  26. #ifndef FWSTREAM_H
  27. #include "FWStream.h"
  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 FWGraphx_IconShape
  40. #endif
  41.  
  42. FW_DEFINE_CLASS_M1(FW_CIconShape, FW_CBoundedShape)
  43. FW_REGISTER_ARCHIVABLE_CLASS(FW_LIconShape, FW_CIconShape, FW_CIconShape::Read, FW_CShape::Write)
  44.  
  45. //========================================================================================
  46. //    class FW_CIconShape
  47. //========================================================================================
  48.  
  49. //----------------------------------------------------------------------------------------
  50. //    FW_CIconShape::FW_CIconShape
  51. //----------------------------------------------------------------------------------------
  52.  
  53. FW_CIconShape::FW_CIconShape(const FW_PIcon& Icon,
  54.                              const FW_CRect& rect,
  55.                              FW_RenderIconOptions options) :
  56.     FW_CBoundedShape(rect, FW_kFrame, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
  57.     fIcon(Icon),
  58.     fOptions(options)
  59. {
  60.     FW_END_CONSTRUCTOR
  61. }
  62.  
  63. //----------------------------------------------------------------------------------------
  64. //    FW_CIconShape::FW_CIconShape
  65. //----------------------------------------------------------------------------------------
  66.  
  67. FW_CIconShape::FW_CIconShape(const FW_CIconShape& other) :
  68.     FW_CBoundedShape(other),
  69.     fIcon(other.fIcon),
  70.     fOptions(other.fOptions)
  71. {
  72.     FW_END_CONSTRUCTOR
  73. }
  74.  
  75. //----------------------------------------------------------------------------------------
  76. //    FW_CIconShape::FW_CIconShape
  77. //----------------------------------------------------------------------------------------
  78.  
  79. FW_CIconShape::FW_CIconShape(FW_CReadableStream& archive) :
  80.     FW_CBoundedShape(archive)
  81. {
  82.     archive >> fIcon;
  83.     archive >> fOptions;
  84.  
  85.     FW_END_CONSTRUCTOR
  86. }
  87.  
  88. //----------------------------------------------------------------------------------------
  89. //    FW_CIconShape::~FW_CIconShape
  90. //----------------------------------------------------------------------------------------
  91.  
  92. FW_CIconShape::~FW_CIconShape()
  93. {
  94.     FW_START_DESTRUCTOR
  95. }
  96.  
  97. //----------------------------------------------------------------------------------------
  98. //    FW_CIconShape::operator=
  99. //----------------------------------------------------------------------------------------
  100.  
  101. FW_CIconShape& FW_CIconShape::operator=(const FW_CIconShape& other)
  102. {
  103.     FW_CBoundedShape::operator=(other);
  104.  
  105.     fIcon = other.fIcon;
  106.     fOptions = other.fOptions;
  107.  
  108.     return *this;
  109. }
  110.  
  111. //----------------------------------------------------------------------------------------
  112. //    FW_CIconShape::Render
  113. //----------------------------------------------------------------------------------------
  114.  
  115. void FW_CIconShape::Render(FW_CGraphicContext& gc) const
  116. {
  117.     gc.GetRasterizer()->RenderIcon(
  118.         gc,
  119.         fIcon,
  120.         fRect,
  121.         fOptions,
  122.         GetRenderVerb());
  123. }
  124.  
  125.  
  126. //----------------------------------------------------------------------------------------
  127. //    FW_CIconShape::Copy
  128. //----------------------------------------------------------------------------------------
  129.  
  130. FW_CShape* FW_CIconShape::Copy() const
  131. {
  132.     return FW_NEW(FW_CIconShape, (*this));
  133. }
  134.  
  135. //----------------------------------------------------------------------------------------
  136. //    FW_CIconShape::Flatten
  137. //----------------------------------------------------------------------------------------
  138.  
  139. void FW_CIconShape::Flatten(FW_CWritableStream& archive) const
  140. {
  141.     FW_CBoundedShape::Flatten(archive);
  142.     
  143.     archive << fIcon;
  144.     archive << fOptions;
  145. }
  146.  
  147. //----------------------------------------------------------------------------------------
  148. //    FW_CIconShape::RenderIcon
  149. //----------------------------------------------------------------------------------------
  150.  
  151. void FW_CIconShape::RenderIcon(FW_CGraphicContext& gc,
  152.                                const FW_PIcon& icon,
  153.                                const FW_CRect& rect,
  154.                                FW_RenderIconOptions options)
  155. {
  156.     gc.GetRasterizer()->RenderIcon(
  157.         gc,
  158.         icon,
  159.         rect,
  160.         options,
  161.         FW_kFill);
  162. }
  163.  
  164. //----------------------------------------------------------------------------------------
  165. //    FW_CIconShape::Read
  166. //----------------------------------------------------------------------------------------
  167.  
  168. void* FW_CIconShape::Read(FW_CReadableStream& archive)
  169. {
  170.     return FW_NEW(FW_CIconShape, (archive));
  171. }
  172.  
  173. //----------------------------------------------------------------------------------------
  174. //    FW_CIconShape::GetGeometry
  175. //----------------------------------------------------------------------------------------
  176.  
  177. void FW_CIconShape::GetGeometry(FW_PIcon& icon,
  178.                                 FW_RenderIconOptions options,
  179.                                 FW_CRect& bounds) const
  180. {
  181.     icon = fIcon;
  182.     options = fOptions;
  183.     bounds = fRect;
  184. }
  185.  
  186. //----------------------------------------------------------------------------------------
  187. //    FW_CIconShape::SetGeometry
  188. //----------------------------------------------------------------------------------------
  189.  
  190. void FW_CIconShape::SetGeometry(const FW_PIcon& icon,
  191.                                 FW_RenderIconOptions options,
  192.                                 const FW_CRect& bounds)
  193. {
  194.     fIcon = icon;
  195.     fOptions = options;
  196.     fRect = bounds;
  197. }
  198.  
  199.