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

  1. //========================================================================================
  2. //
  3. //    File:                FWStyle.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 FWSTYLE_H
  13. #include "FWStyle.h"
  14. #endif
  15.  
  16. #ifndef FWFXMATH_H
  17. #include "FWFxMath.h"
  18. #endif
  19.  
  20. #ifndef FWSTRMRW_H
  21. #include "FWStrmRW.h"
  22. #endif
  23.  
  24. #ifdef FW_BUILD_MAC
  25. #pragma segment FWGraphics_Style
  26. #endif
  27.  
  28. //========================================================================================
  29. //    Template instantiation
  30. //========================================================================================
  31.  
  32. #include "FWGrRef.tpp"
  33.  
  34. FW_DEFINE_AUTO_TEMPLATE(FW_TGrRefPtr, FW_HStyle)
  35.  
  36. #ifdef FW_USE_TEMPLATE_PRAGMAS
  37.  
  38. #pragma template_access public
  39. #pragma template FW_TGrRefPtr<FW_HStyle>
  40.  
  41. #else
  42.  
  43. template class FW_TGrRefPtr<FW_HStyle>;
  44.  
  45. #endif
  46.  
  47. //========================================================================================
  48. //    class FW_CStyle
  49. //========================================================================================
  50.  
  51. FW_DEFINE_AUTO(FW_CStyle)
  52.  
  53. //----------------------------------------------------------------------------------------
  54. //    FW_PrivAcquireGrRep
  55. //----------------------------------------------------------------------------------------
  56.  
  57. void FW_PrivAcquireGrRep(FW_HStyle rep)
  58. {
  59.     if (rep != 0)
  60.         FW_PrivStyle_Acquire(rep);
  61. }
  62.  
  63. //----------------------------------------------------------------------------------------
  64. //    FW_PrivReleaseGrRep
  65. //----------------------------------------------------------------------------------------
  66.  
  67. void FW_PrivReleaseGrRep(FW_HStyle rep)
  68. {
  69.     if (rep != 0)
  70.         FW_PrivStyle_Release(rep);
  71. }
  72.  
  73. //----------------------------------------------------------------------------------------
  74. //    FW_CStyle::FW_CStyle
  75. //----------------------------------------------------------------------------------------
  76.  
  77. FW_CStyle::FW_CStyle(FW_Fixed penSize, FW_EStyleDash dash)
  78. {
  79.     FW_PlatformError error;
  80.     FW_HStyle rep = FW_PrivStyle_CreateDash(penSize, dash, &error);
  81.     FW_FailOnError(error);
  82.     SetRep(rep);
  83.     FW_END_CONSTRUCTOR
  84. }
  85.  
  86. //----------------------------------------------------------------------------------------
  87. //    FW_CStyle::FW_CStyle
  88. //----------------------------------------------------------------------------------------
  89.  
  90. FW_CStyle::FW_CStyle(FW_Fixed penSize, const FW_CPattern& pattern)
  91. {
  92.     FW_PlatformError error;
  93.     FW_HStyle rep = FW_PrivStyle_CreatePattern(penSize, pattern, &error);
  94.     FW_FailOnError(error);
  95.     SetRep(rep);
  96.     FW_END_CONSTRUCTOR
  97. }
  98.  
  99. //----------------------------------------------------------------------------------------
  100. //    FW_CStyle::FW_CStyle
  101. //----------------------------------------------------------------------------------------
  102.  
  103. FW_CStyle::FW_CStyle(const FW_CStyle& other) :
  104.     FW_TGrRefPtr<FW_HStyle>(other)
  105. {
  106.     FW_END_CONSTRUCTOR
  107. }
  108.  
  109. //----------------------------------------------------------------------------------------
  110. //    FW_CStyle::FW_CStyle
  111. //----------------------------------------------------------------------------------------
  112.  
  113. FW_CStyle::FW_CStyle(FW_EStandardStyles std)
  114. {
  115.     FW_PlatformError error;
  116.     FW_HStyle rep = FW_PrivStyle_CreateStandard(std, &error);
  117.     FW_FailOnError(error);
  118.     SetRep(rep);
  119.     FW_END_CONSTRUCTOR
  120. }
  121.  
  122. //----------------------------------------------------------------------------------------
  123. //    FW_CStyle::~FW_CStyle
  124. //----------------------------------------------------------------------------------------
  125.  
  126. FW_CStyle::~FW_CStyle()
  127. {
  128.     FW_START_DESTRUCTOR
  129. }
  130.  
  131. //----------------------------------------------------------------------------------------
  132. //    FW_CStyle::operator=
  133. //----------------------------------------------------------------------------------------
  134.  
  135. FW_CStyle& FW_CStyle::operator=(const FW_CStyle& other)
  136. {
  137.     FW_TGrRefPtr<FW_HStyle>::operator=(other);
  138.     return *this;
  139. }
  140.  
  141. //----------------------------------------------------------------------------------------
  142. //    FW_CStyle::operator=
  143. //----------------------------------------------------------------------------------------
  144.  
  145. FW_CStyle& FW_CStyle::operator=(FW_EStandardStyles std)
  146. {
  147.     FW_PlatformError error;
  148.     FW_HStyle rep = FW_PrivStyle_CreateStandard(std, &error);
  149.     FW_FailOnError(error);
  150.     SetRep(rep);
  151.     return *this;
  152. }
  153.  
  154. //----------------------------------------------------------------------------------------
  155. //    FW_CStyle::Copy
  156. //----------------------------------------------------------------------------------------
  157.  
  158. FW_CStyle FW_CStyle::Copy() const
  159. {
  160.     FW_PlatformError error;
  161.     FW_HStyle rep = FW_PrivStyle_Copy(fRep, &error);
  162.     FW_FailOnError(error);
  163.     
  164.     FW_CStyle style;
  165.     style.SetRep(rep);
  166.     return style;
  167. }
  168.  
  169. //----------------------------------------------------------------------------------------
  170. //    operator <<
  171. //----------------------------------------------------------------------------------------
  172.  
  173. FW_CWritableStream& operator << (FW_CWritableStream& stream, const FW_CStyle& style)
  174. {
  175.     FW_PlatformError error;
  176.     FW_PrivStyle_Write(style.fRep, stream, &error);
  177.     FW_FailOnError(error);
  178.     return stream;
  179. }
  180.  
  181. //----------------------------------------------------------------------------------------
  182. //    operator >>
  183. //----------------------------------------------------------------------------------------
  184.  
  185. FW_CReadableStream& operator >> (FW_CReadableStream& stream, FW_CStyle& style)
  186. {
  187.     FW_PlatformError error;
  188.     FW_HStyle rep = FW_PrivStyle_Read(stream, &error);
  189.     FW_FailOnError(error);
  190.     style.SetRep(rep);
  191.     return stream;
  192. }
  193.  
  194.