home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.4 KB | 194 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWStyle.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWSTYLE_H
- #include "FWStyle.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef FWSTRMRW_H
- #include "FWStrmRW.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Style
- #endif
-
- //========================================================================================
- // Template instantiation
- //========================================================================================
-
- #include "FWGrRef.tpp"
-
- FW_DEFINE_AUTO_TEMPLATE(FW_TGrRefPtr, FW_HStyle)
-
- #ifdef FW_USE_TEMPLATE_PRAGMAS
-
- #pragma template_access public
- #pragma template FW_TGrRefPtr<FW_HStyle>
-
- #else
-
- template class FW_TGrRefPtr<FW_HStyle>;
-
- #endif
-
- //========================================================================================
- // class FW_CStyle
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CStyle)
-
- //----------------------------------------------------------------------------------------
- // FW_PrivAcquireGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivAcquireGrRep(FW_HStyle rep)
- {
- if (rep != 0)
- FW_PrivStyle_Acquire(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivReleaseGrRep
- //----------------------------------------------------------------------------------------
-
- void FW_PrivReleaseGrRep(FW_HStyle rep)
- {
- if (rep != 0)
- FW_PrivStyle_Release(rep);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::FW_CStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle::FW_CStyle(FW_Fixed penSize, FW_EStyleDash dash)
- {
- FW_PlatformError error;
- FW_HStyle rep = FW_PrivStyle_CreateDash(penSize, dash, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::FW_CStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle::FW_CStyle(FW_Fixed penSize, const FW_CPattern& pattern)
- {
- FW_PlatformError error;
- FW_HStyle rep = FW_PrivStyle_CreatePattern(penSize, pattern, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::FW_CStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle::FW_CStyle(const FW_CStyle& other) :
- FW_TGrRefPtr<FW_HStyle>(other)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::FW_CStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle::FW_CStyle(FW_EStandardStyles std)
- {
- FW_PlatformError error;
- FW_HStyle rep = FW_PrivStyle_CreateStandard(std, &error);
- FW_FailOnError(error);
- SetRep(rep);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::~FW_CStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle::~FW_CStyle()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CStyle& FW_CStyle::operator=(const FW_CStyle& other)
- {
- FW_TGrRefPtr<FW_HStyle>::operator=(other);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CStyle& FW_CStyle::operator=(FW_EStandardStyles std)
- {
- FW_PlatformError error;
- FW_HStyle rep = FW_PrivStyle_CreateStandard(std, &error);
- FW_FailOnError(error);
- SetRep(rep);
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CStyle::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CStyle FW_CStyle::Copy() const
- {
- FW_PlatformError error;
- FW_HStyle rep = FW_PrivStyle_Copy(fRep, &error);
- FW_FailOnError(error);
-
- FW_CStyle style;
- style.SetRep(rep);
- return style;
- }
-
- //----------------------------------------------------------------------------------------
- // operator <<
- //----------------------------------------------------------------------------------------
-
- FW_CWritableStream& operator << (FW_CWritableStream& stream, const FW_CStyle& style)
- {
- FW_PlatformError error;
- FW_PrivStyle_Write(style.fRep, stream, &error);
- FW_FailOnError(error);
- return stream;
- }
-
- //----------------------------------------------------------------------------------------
- // operator >>
- //----------------------------------------------------------------------------------------
-
- FW_CReadableStream& operator >> (FW_CReadableStream& stream, FW_CStyle& style)
- {
- FW_PlatformError error;
- FW_HStyle rep = FW_PrivStyle_Read(stream, &error);
- FW_FailOnError(error);
- style.SetRep(rep);
- return stream;
- }
-
-