Constructors and destructor
// Copyright (C) 1995 Taligent, Inc. All rights reserved.
TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd () :
fColor (NIL),
fUndoRedoMemory (NIL)
{
fUndoRedoMemory = new TCanvasGraphicAssociationsWith<MCanvasGraphic>;
}
TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd (const TColor& color) :
fColor (NIL),
fUndoRedoMemory (NIL)
{
fColor = ::Copy(color);
fUndoRedoMemory = new TCanvasGraphicAssociationsWith<MCanvasGraphic>;
}
TSetCanvasGraphicFillColorCmd::TSetCanvasGraphicFillColorCmd (const TSetCanvasGraphicFillColorCmd& source) :
TChangeCanvasGraphicCmd (source),
fColor (NIL),
fUndoRedoMemory (NIL)
{
fColor = ::Copy (*source.fColor.GetObject());
fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject());
}
TSetCanvasGraphicFillColorCmd::~TSetCanvasGraphicFillColorCmd ()
{
}
MCollectible overrides
// Copyright (C) 1995 Taligent, Inc. All rights reserved.
//========================================
// MCollectible Overrides
//========================================
MCollectibleDefinitionsMacro (TSetCanvasGraphicFillColorCmd, kOriginalVersion);
TStream&
TSetCanvasGraphicFillColorCmd::operator>>= (TStream& toWhere) const
{
WriteVersion (toWhere);
TChangeCanvasGraphicCmd::operator>>= (toWhere);
::Flatten (fColor.GetObject(), toWhere);
::Flatten (fUndoRedoMemory.GetObject(), toWhere);
return toWhere;
}
TStream&
TSetCanvasGraphicFillColorCmd::operator<<= (TStream& fromWhere)
{
VersionInfo version = ReadVersion (fromWhere);
if ( version != kOriginalVersion )
throw TInvalidVersionException (kStreamBadVersion, 0);
TChangeCanvasGraphicCmd::operator<<= (fromWhere);
TColor* color;
Resurrect (color, fromWhere);
fColor = color;
TCanvasGraphicAssociationsWith<MCanvasGraphic>* undoRedoMemory;
Resurrect (undoRedoMemory, fromWhere);
fUndoRedoMemory = undoRedoMemory;
return fromWhere;
}
TSetCanvasGraphicFillColorCmd&
TSetCanvasGraphicFillColorCmd::operator= (const TSetCanvasGraphicFillColorCmd& source)
{
if ( this != &source ) {
TChangeCanvasGraphicCmd::operator= (source);
fColor = ::Copy(*source.fColor.GetObject());
fUndoRedoMemory = ::Copy (*source.fUndoRedoMemory.GetObject());
}
return *this;
}
void
TSetCanvasGraphicFillColorCmd::SetColor (const TColor& color)
{
fColor = ::Copy (color);
}
TChangeCanvasGraphicCmd overrides
// Copyright (C) 1995 Taligent, Inc. All rights reserved.
//========================================
// TChangeCanvasGraphicCmd Overrides
//========================================
void
TSetCanvasGraphicFillColorCmd::BeginChange (MCanvasRepresentation&, MCanvasGraphic& graphic)
{
fUndoRedoMemory->AdoptAssociation (graphic.GetID(), ::Copy(graphic));
TRGBColor* test = (TRGBColor*)fColor.GetObject();
if ( fColor ) {
TColorPaint* newPaint = new TColorPaint (*fColor);
if ( newPaint ) {
TGrafBundle* bundle = graphic.OrphanBundle ();
if ( bundle ) {
bundle->AdoptFillPaint (newPaint);
graphic.AdoptBundle (bundle);
}
else
delete newPaint;
}
}
}
void
TSetCanvasGraphicFillColorCmd::ContinueChange (MCanvasRepresentation&, MCanvasGraphic& graphic)
{
TRGBColor* test = (TRGBColor*)fColor.GetObject();
if ( fColor ) {
TColorPaint* newPaint = new TColorPaint (*fColor);
if ( newPaint ) {
TGrafBundle* bundle = graphic.OrphanBundle ();
if ( bundle ) {
bundle->AdoptFillPaint (newPaint);
graphic.AdoptBundle (bundle);
}
else
delete newPaint;
}
}
}
void
TSetCanvasGraphicFillColorCmd::UndoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic)
{
TCanvasGraphicID id = graphic.GetID ();
MCanvasGraphic* undoGraphic = fUndoRedoMemory->OrphanAssociation (id);
MCanvasGraphic* redoGraphic = rep.Swap (id, undoGraphic);
fUndoRedoMemory->AdoptAssociation (id, redoGraphic);
}
void
TSetCanvasGraphicFillColorCmd::RedoChange (MCanvasRepresentation& rep, MCanvasGraphic& graphic)
{
TCanvasGraphicID id = graphic.GetID ();
MCanvasGraphic* redoGraphic = fUndoRedoMemory->OrphanAssociation (id);
MCanvasGraphic* undoGraphic = rep.Swap (id, redoGraphic);
fUndoRedoMemory->AdoptAssociation (id, undoGraphic);
}
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.