// $Revision: 1.3 $ #ifndef Taligent_SHAREDCOLORSTYLE #include "SharedColorStyle.h" #endif #ifndef Taligent_TOKENS #include #endif #ifndef Talignet_RGBCOLOR #include #endif MCollectibleDefinitionsMacro(TSharedColorStyle, kOriginalVersion); TSharedColorStyle::TSharedColorStyle(const TColor& color) { AdoptByManager(new (TAllocationHeap(this)) TInternalColorAttribute(color)); } TSharedColorStyle::TSharedColorStyle(const TSharedColorStyle& source) { TSharedStyle::SetInternalAttribute(source.GetInternalAttribute()); } TSharedColorStyle::~TSharedColorStyle() { } TSharedColorStyle& TSharedColorStyle::operator=(const TSharedColorStyle& source) { if (&source != this) { TSharedStyle::operator=(source); } return *this; } TStream& TSharedColorStyle::operator>>=(TStream& toStream) const { ::WriteVersion(toStream, kOriginalVersion); TSharedStyle::operator>>=(toStream); return toStream; } TStream& TSharedColorStyle::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); TSharedStyle::operator<<=(fromStream); return fromStream; } const TColor* TSharedColorStyle::GetColor() const { return ((TInternalColorAttribute*)GetInternalAttribute())->GetColor(); } MCollectibleDefinitionsMacro(TInternalColorAttribute, kOriginalVersion); const TToken TInternalColorAttribute::fgName = TToken("Shared Color Style"); const TRGBColor TInternalColorAttribute::fgDefaultColor; TInternalColorAttribute::TInternalColorAttribute(const TColor& color) : fColorRef(color), fOwnedColor(NIL) { } TInternalColorAttribute::TInternalColorAttribute() : fColorRef(fgDefaultColor), fOwnedColor(NIL) { } TInternalColorAttribute::TInternalColorAttribute(const TInternalColorAttribute& source) : fColorRef(source.fColorRef), fOwnedColor(::CopyPointer(source.fOwnedColor)) { } TInternalColorAttribute::~TInternalColorAttribute() { delete fOwnedColor; } void TInternalColorAttribute::Finalize() { fOwnedColor = ::Copy(fColorRef); } const TToken& TInternalColorAttribute::GetName() const { return fgName; } const TColor* TInternalColorAttribute::GetColor() const { return fOwnedColor; } long TInternalColorAttribute::Hash() const { return GetName().Hash() ^ fOwnedColor->Hash(); } bool TInternalColorAttribute::IsEqual(const MCollectible* obj) const { return NamesMatch((TInternalAttribute*)obj) && (*fOwnedColor == *((TInternalColorAttribute*)obj)->fOwnedColor); } TInternalColorAttribute& TInternalColorAttribute::operator=(const TInternalColorAttribute&) { return *this; } TStream& TInternalColorAttribute::operator>>=(TStream& toStream) const { ::WriteVersion(toStream, kOriginalVersion); MCollectible::operator>>=(toStream); ::Flatten(fOwnedColor, toStream); return toStream; } TStream& TInternalColorAttribute::operator<<=(TStream& fromStream) { ::ReadVersion(fromStream, kOriginalVersion, kOriginalVersion); MCollectible::operator<<=(fromStream); delete fOwnedColor; ::Resurrect(fOwnedColor, fromStream); return fromStream; }