OpColourChange Class Reference

#include <colormgr.h>

Inheritance diagram for OpColourChange:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpColourChange ()
 OpColourChange constructor (Creates an undoable operation).
 ~OpColourChange ()
 OpColourChange destructor.
void Do (OpDescriptor *)
 (Performs the colour change operation) OpColourChange has a special overloaded Do operator which takes parameters describing what is to be done - that version of Do must be used
void DoWithParam (OpDescriptor *, OpParam *)
 Performs the colour change operation, which swaps (with undo) the data members two given colours.
virtual void PerformMergeProcessing (void)
 This virtual function gets called to allow for the merging of ColourChange operations - this allows a multitude of sequential colour edits to be merged into a single undo stage.
virtual BOOL Undo ()
 Undoes whatever Do() or Redo() did.
virtual BOOL Redo ()
 Redoes whatever Undo() undid.

Static Public Member Functions

static BOOL Init ()
 OpColourChange initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the OpColourChange's state.

Protected Attributes

IndexedColourUndoRecord
IndexedColourRedoRecord

Detailed Description

Definition at line 419 of file colormgr.h.


Constructor & Destructor Documentation

OpColourChange::OpColourChange  ) 
 

OpColourChange constructor (Creates an undoable operation).

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 3112 of file colormgr.cpp.

03112                                : UndoableOperation()
03113 {
03114     UndoRecord = NULL;
03115     RedoRecord = NULL;
03116 }

OpColourChange::~OpColourChange  ) 
 

OpColourChange destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 3135 of file colormgr.cpp.

03136 {
03137     // We 'own' the UNDO record, so we are responsible for deleting it
03138     if (UndoRecord != NULL)
03139         delete UndoRecord;
03140 
03141     // We do not own the RedoRecord, so we leave it alone
03142 }


Member Function Documentation

void OpColourChange::Do OpDescriptor NotUsed  )  [virtual]
 

(Performs the colour change operation) OpColourChange has a special overloaded Do operator which takes parameters describing what is to be done - that version of Do must be used

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: Always generates an ENSURE failure because this Do doesn't.

See also:
-

Reimplemented from Operation.

Definition at line 3216 of file colormgr.cpp.

03217 {
03218     ENSURE(FALSE, "OpColourChange does not provide a Do() function - Use DoWithParam");
03219     End();
03220 }

void OpColourChange::DoWithParam OpDescriptor pOp,
OpParam Param
[virtual]
 

Performs the colour change operation, which swaps (with undo) the data members two given colours.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
pOp - OpDescriptor as for all Do() functions [INPUTS] Param - points to a ColourChangeInfo structure with parameters: ParentList - The List in which the colours reside Target - The colour to be changed NewDefn - The new definition for Target InvisibleChange - TRUE if the change is not to a visible feature of the colour (so objects drawn in this colour need not be redrawn)
- [OUTPUTS]
Returns:
-
Note: Both colours are used to provide the primary- and undo-storage, so you must NOT delete either of them after invoking this op. They will be deleted as part of the undo record if necessary.

DO NOT call this directly - use ColourManager::ChangeColour

Note that sequential colour changes for the same colour will be merged into a single undo step.

See also:
ColourManager::ChangeColour

Reimplemented from Operation.

Definition at line 3255 of file colormgr.cpp.

03256 {
03257     ColourChangeInfo *Info = (ColourChangeInfo *) Param;
03258 
03259     // Remember the undo record so we don't get memory leakage
03260     UndoRecord = Info->NewDefn;     // We 'own' the undo record and must delete it
03261     RedoRecord = Info->Target;      // We do NOT own the target: For OpMerging info only
03262 
03263     ERROR3IF(UndoRecord == NULL || RedoRecord == NULL || Info->ParentList == NULL,
03264                     "Illegal NULL OpParams for OpColourChange");
03265 
03266     // Set our scope variables
03267     pOurDoc = (Document *)Info->ParentList->GetParentDocument();
03268     pOurView = NULL;
03269     if (!pOurDoc->IsKindOf(CC_RUNTIME_CLASS(Document)))
03270     {
03271         pOurDoc = NULL;     // Arrrgh! It must be a basedoc or something!
03272         End();
03273         return;
03274     }
03275 
03276     
03277     // Create an action to Undo the hiding operation
03278     ActionColourChange *ACC;
03279     if (ActionColourChange::Init(this, &UndoActions, sizeof(ActionColourChange),
03280                             RedoRecord, UndoRecord, Info->InvisibleChange,
03281                             (Action**)(&ACC)) == AC_OK)
03282     {
03283         // Apply the initial 'Do' operation - swap the colours
03284         RedoRecord->SwapWith(UndoRecord);
03285 
03286         // We have made the change, so broadcast that the list for this doc has changed
03287         if (Info->InvisibleChange)
03288             ColourManager::ColourHasChangedInvisible(GetWorkingDoc(), Info->ParentList, RedoRecord);
03289         else
03290             ColourManager::ColourHasChanged(GetWorkingDoc(), Info->ParentList, RedoRecord);
03291     }
03292 
03293     End();
03294 }

OpState OpColourChange::GetState String_256 UIDescription,
OpDescriptor
[static]
 

For finding the OpColourChange's state.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpColourChange operation

Definition at line 3190 of file colormgr.cpp.

03191 {
03192     OpState OpSt;
03193     return(OpSt);
03194 }

BOOL OpColourChange::Init void   )  [static]
 

OpColourChange initialiser method.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Reimplemented from SimpleCCObject.

Definition at line 3161 of file colormgr.cpp.

03162 {
03163     return (RegisterOpDescriptor(
03164                                     0,
03165                                     _R(IDS_COLOURCHANGEOP),
03166                                     CC_RUNTIME_CLASS(OpColourChange),
03167                                     OPTOKEN_COLOURCHANGE,
03168                                     OpColourChange::GetState,
03169                                     0,  /* help ID */
03170                                     0,  /* Bubble help ID */
03171                                     0   /* bitmap ID */
03172                                 ));
03173 }

void OpColourChange::PerformMergeProcessing void   )  [virtual]
 

This virtual function gets called to allow for the merging of ColourChange operations - this allows a multitude of sequential colour edits to be merged into a single undo stage.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from UndoableOperation.

Definition at line 3356 of file colormgr.cpp.

03357 {    
03358     // Obtain a pointer to the operation history for the operation's document
03359     OperationHistory* pOpHist = &GetWorkingDoc()->GetOpHistory();
03360     ERROR3IF(pOpHist == NULL, "There's no OpHistory!?");
03361 
03362     // Ensure that we are the last operation added to the operation history
03363     // Note cannot be an ERROR2 cos this function cannot fail. 
03364     ERROR3IF(pOpHist->FindLastOp() != this, "Last Op should be this op"); 
03365     
03366     // OK lets see if the operation performed before this was an OpNudge operation
03367     Operation* pPrevOp = pOpHist->FindPrevToLastOp();
03368 
03369     if (pPrevOp != NULL)   // Check if there was a previous op
03370     {   
03371         if (IS_A(pPrevOp, OpColourChange))
03372         {
03373             if (((OpColourChange *)pPrevOp)->RedoRecord == RedoRecord)
03374             {
03375                 // This op is a colour change for the same colour as the last op.
03376 
03377                 // We may need to change the 'IsVisible' flag for the ActionColourChange
03378                 // (if either change is 'visible', the overall change must be 'visible')
03379                 
03380                 ActionColourChange* pNewAction = (ActionColourChange *)
03381                     GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(ActionColourChange));
03382             
03383                 ERROR3IF(pNewAction == NULL, "This op should have an ActionColourChange");
03384 
03385                 // If the new action is visible, force the old one to be visible
03386                 if (pNewAction != NULL && !pNewAction->IsInvisible)
03387                 {
03388                     ActionColourChange* pOldAction = (ActionColourChange *)
03389                         ((OpColourChange *)pPrevOp)->GetUndoActionList()->
03390                                     FindActionOfClass(CC_RUNTIME_CLASS(ActionColourChange));
03391             
03392                     ERROR3IF(pOldAction == NULL, "This op should have an ActionColourChange");
03393 
03394                     if (pOldAction != NULL)
03395                         pOldAction->IsInvisible = FALSE;
03396                 }
03397 
03398                 // We have already overwritten the changed colour, so we just kill
03399                 // ourselves to remove the unneeded undo step (so undo will revert
03400                 // directly to the original state of the colour)
03401                 pOpHist->DeleteLastOp(); 
03402             }
03403         }
03404     }
03405 }

BOOL OpColourChange::Redo  )  [virtual]
 

Redoes whatever Undo() undid.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Reimplemented from Operation.

Definition at line 3331 of file colormgr.cpp.

03332 {
03333     return (Operation::Redo());
03334 }

BOOL OpColourChange::Undo  )  [virtual]
 

Undoes whatever Do() or Redo() did.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Reimplemented from Operation.

Definition at line 3311 of file colormgr.cpp.

03312 {
03313     return (Operation::Undo()); 
03314 }       


Member Data Documentation

IndexedColour* OpColourChange::RedoRecord [protected]
 

Definition at line 439 of file colormgr.h.

IndexedColour* OpColourChange::UndoRecord [protected]
 

Definition at line 438 of file colormgr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:57:45 2007 for Camelot by  doxygen 1.4.4