home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 8.1 KB | 283 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWInk.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #if defined(FW_PROFILER_CALLS) && defined(__MWERKS__)
- #pragma profile on
- #endif
-
- #ifndef FWINK_H
- #include "FWInk.h"
- #endif
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__QUICKDRAW__)
- #include <Quickdraw.h>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- FW_DEFINE_CLASS_M1(FW_PInk, FW_CGraphicCountedPtr)
- FW_DEFINE_CLASS_M1(FW_CInkRep, FW_CGraphicCountedPtrRep)
-
- FW_REGISTER_ARCHIVABLE_CLASS(FW_LInkRep, FW_CInkRep, FW_CInkRep::Read, FW_CGraphicCountedPtrRep::Write)
-
- //========================================================================================
- // class FW_PInk
- //========================================================================================
-
- static FW_TransferModes PrivStdInkToTransferMode(FW_EStandardInks std)
- {
- switch (std)
- {
- default:
- case FW_kNormalInk:
- return FW_kCopy;
-
- case FW_kNormalTextInk:
- return FW_kOr;
-
- case FW_kInvertInk:
- return FW_kInvert;
-
- case FW_kWhiteEraseInk:
- return FW_kErase;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::FW_PInk
- //----------------------------------------------------------------------------------------
-
- FW_PInk::FW_PInk() :
- FW_CGraphicCountedPtr()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::FW_PInk
- //----------------------------------------------------------------------------------------
-
- FW_PInk::FW_PInk(const FW_CColor& foreColor, const FW_CColor& backColor, FW_TransferModes tranferMode) :
- FW_CGraphicCountedPtr()
- {
- SetRep(new FW_CInkRep(foreColor, backColor, tranferMode));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::FW_PInk
- //----------------------------------------------------------------------------------------
-
- FW_PInk::FW_PInk(FW_TransferModes tranferMode) :
- FW_CGraphicCountedPtr()
- {
- SetRep(new FW_CInkRep(FW_kRGBBlack, FW_kRGBWhite, tranferMode));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::FW_PInk
- //----------------------------------------------------------------------------------------
-
- FW_PInk::FW_PInk(const FW_PInk& other) :
- FW_CGraphicCountedPtr(other)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::FW_PInk
- //----------------------------------------------------------------------------------------
-
- FW_PInk::~FW_PInk()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::operator=
- //----------------------------------------------------------------------------------------
-
- FW_PInk& FW_PInk::operator=(const FW_PInk& other)
- {
- // We don't need to test this == &other because SetRep will do it
- SetRep(other.GetRep());
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::FW_PInk
- //----------------------------------------------------------------------------------------
-
-
- FW_PInk::FW_PInk(FW_EStandardInks std)
- {
- SetRep(new FW_CInkRep(FW_kRGBBlack, FW_kRGBWhite, PrivStdInkToTransferMode(std)));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PInk::operator=
- //----------------------------------------------------------------------------------------
-
- FW_PInk& FW_PInk::operator=(FW_EStandardInks std)
- {
- SetRep(new FW_CInkRep(FW_kRGBBlack, FW_kRGBWhite, PrivStdInkToTransferMode(std)));
- return *this;
- }
-
- //========================================================================================
- // class FW_CInkRep
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- FW_CInkRep::FW_CInkRep():
- FW_CGraphicCountedPtrRep(),
- fForeColor(FW_kRGBBlack),
- fBackColor(FW_kRGBWhite),
- fTransferMode(FW_kCopy)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- FW_CInkRep::FW_CInkRep(const FW_CColor& foreColor, const FW_CColor& backColor, FW_TransferModes transferMode):
- FW_CGraphicCountedPtrRep(),
- fForeColor(foreColor),
- fBackColor(backColor),
- fTransferMode(transferMode)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- FW_CInkRep::FW_CInkRep(const FW_CInkRep& otherRep):
- FW_CGraphicCountedPtrRep(),
- fForeColor(otherRep.fForeColor),
- fBackColor(otherRep.fBackColor),
- fTransferMode(otherRep.fTransferMode)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- FW_CInkRep::FW_CInkRep(FW_CReadableStream& archive) :
- FW_CGraphicCountedPtrRep()
- {
- archive >> fForeColor;
- archive >> fBackColor;
- archive >> fTransferMode;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::~FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- FW_CInkRep::~FW_CInkRep()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::FW_CInkRep
- //----------------------------------------------------------------------------------------
-
- FW_CInkRep& FW_CInkRep::operator=(const FW_CInkRep& otherRep)
- {
- fForeColor = otherRep.fForeColor;
- fBackColor = otherRep.fBackColor;
- fTransferMode = otherRep.fTransferMode;
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::Copy
- //----------------------------------------------------------------------------------------
-
- FW_PInk FW_CInkRep::Copy() const
- {
- return FW_PInk(fForeColor, fBackColor, fTransferMode);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::IsEqual
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CInkRep::IsEqual(const FW_CGraphicCountedPtrRep* other) const
- {
- if (other == this)
- return TRUE;
-
- FW_CInkRep *inkRep = FW_DYNAMIC_CAST(FW_CInkRep, other);
- if (inkRep)
- {
- return fForeColor == inkRep->fForeColor &&
- fBackColor == inkRep->fBackColor &&
- fTransferMode == inkRep->fTransferMode;
- }
-
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CInkRep::Flatten(FW_CWritableStream& archive) const
- {
- archive << fForeColor;
- archive << fBackColor;
- archive << fTransferMode;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CInkRep::Read
- //----------------------------------------------------------------------------------------
-
- void* FW_CInkRep::Read(FW_CReadableStream& archive)
- {
- FW_CInkRep* objectRep = new FW_CInkRep(archive);
- return objectRep;
- }
-
-