home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 4.8 KB | 177 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWShape.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWSHAPE_H
- #include "FWShape.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWGraphics_Shape
- #endif
-
- FW_DEFINE_CLASS_M0(FW_CShape)
-
- //========================================================================================
- // class FW_CShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::FW_CShape(FW_ERenderVerbs renderVerb,
- const FW_PInk& ink,
- const FW_PStyle& style,
- const FW_PFont& font) :
- fRenderVerb(renderVerb),
- fInk(ink),
- fStyle(style),
- fFont(font)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::FW_CShape(const FW_CShape& other):
- fInk(other.fInk),
- fStyle(other.fStyle),
- fFont(other.fFont),
- fRenderVerb(other.GetRenderVerb())
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::FW_CShape(FW_CReadableStream& archive)
- {
- archive >> fInk;
- archive >> fStyle;
- archive >> fFont;
- archive.Read((char*)&fRenderVerb, sizeof(fRenderVerb));
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::~FW_CShape
- //----------------------------------------------------------------------------------------
-
- FW_CShape::~FW_CShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CShape& FW_CShape::operator=(const FW_CShape& other)
- {
- if (this != &other)
- {
- fInk = other.fInk;
- fStyle = other.fStyle;
- fFont = other.fFont;
- fRenderVerb = other.fRenderVerb;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::Purge
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::Purge()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::Flatten(FW_CWritableStream& archive) const
- {
- archive << fInk;
- archive << fStyle;
- archive << fFont;
- archive.Write((char*)&fRenderVerb, sizeof(fRenderVerb));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::GetUnSharedInk
- //----------------------------------------------------------------------------------------
-
- FW_PInk& FW_CShape::GetUnSharedInk()
- {
- if (fInk->GetRefCount() > 1)
- fInk = fInk->Copy();
-
- return fInk;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::GetUnSharedStyle
- //----------------------------------------------------------------------------------------
-
- FW_PStyle& FW_CShape::GetUnSharedStyle()
- {
- if (fStyle->GetRefCount() > 1)
- fStyle = fStyle->Copy();
-
- return fStyle;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::GetUnSharedFont
- //----------------------------------------------------------------------------------------
-
- FW_PFont& FW_CShape::GetUnSharedFont()
- {
- if (fFont->GetRefCount() > 1)
- fFont = fFont->Copy();
-
- return fFont;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CShape::Write
- //----------------------------------------------------------------------------------------
-
- void FW_CShape::Write(FW_CWritableStream& archive, const void* shape)
- {
- ((FW_CShape*)shape)->Flatten(archive);
- }
-