ActionHideColours Class Reference

When executed, sets/clears an IndexedColour's 'deleted' flag, so that it becomes {un}hidden - this is then un/redoable by using a HideAction with the opposite 'HideFlag' value. More...

#include <colormgr.h>

Inheritance diagram for ActionHideColours:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ActionHideColours ()
 ActionHideColours constructor.
 ~ActionHideColours ()
 ActionHideColours destructor.
virtual void Slaughter (void)
 ActionHideColours Slaughter method. Cleans up any deleted colours associated with this action - once slaughtered, deleted colours can not come back (touch wood!) so are actually deleted from the document rather than just hidden.
virtual ActionCode Execute ()
 Executes the ActionHideColours (to hide/unhide an IndexedColour), creating an equal and opposite action to undo it with later.

Static Public Member Functions

static ActionCode Init (Operation *const pOp, ActionList *pActionList, UINT32 ActionSize, ColourList *ParentList, IndexedColour *Colour[], BOOL HideThem, Action **NewAction)
 To check that there is sufficient room for the action in the operation history, and if there is, then to add the action to the operations action list.

Private Attributes

ColourListParentList
IndexedColour ** ChangeColour
BOOL HideFlag

Detailed Description

When executed, sets/clears an IndexedColour's 'deleted' flag, so that it becomes {un}hidden - this is then un/redoable by using a HideAction with the opposite 'HideFlag' value.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/6/94
Scope: Private - for use only by the ColourManager

See also:
OpHideColours

Definition at line 356 of file colormgr.h.


Constructor & Destructor Documentation

ActionHideColours::ActionHideColours  ) 
 

ActionHideColours constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94

Definition at line 2853 of file colormgr.cpp.

02854 {
02855     ChangeColour = NULL;
02856     ParentList   = NULL;
02857 }

ActionHideColours::~ActionHideColours  ) 
 

ActionHideColours destructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94

Definition at line 2871 of file colormgr.cpp.

02872 {
02873     if (ChangeColour != NULL)
02874         delete [] ChangeColour;
02875 }


Member Function Documentation

ActionCode ActionHideColours::Execute  )  [virtual]
 

Executes the ActionHideColours (to hide/unhide an IndexedColour), creating an equal and opposite action to undo it with later.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/6/94
Parameters:
- [INPUTS]
ActionCode indicating if the action was successfully executed or not [OUTPUTS]
Returns:
-

Reimplemented from Action.

Definition at line 2949 of file colormgr.cpp.

02950 {
02951    ActionHideColours HideColAct;
02952    ActionCode ActCode;
02953 
02954     // Create an action to restore the changes we are about to make
02955     if ((ActCode = ActionHideColours::Init(pOperation,
02956                                             pOppositeActLst,
02957                                             sizeof(ActionHideColours),
02958                                             ParentList, ChangeColour,
02959                                             ((HideFlag) ? FALSE : TRUE),
02960                                             (Action**)(&HideColAct))) != AC_FAIL)
02961     {
02962         INT32 Index = 0;
02963 
02964         while (ChangeColour[Index] != NULL)     // Write all the 'deleted' flags
02965         {
02966             // Check that the caller only gave us named colours
02967             ERROR3IF(!ChangeColour[Index]->IsNamed(),
02968                 "You don't need to call (Un)HideColours for Local colours! Remove ASAP!");
02969 
02970             ChangeColour[Index]->SetDeleted(HideFlag);
02971             Index++;
02972         }
02973     }
02974 
02975     return (ActCode);
02976 }

ActionCode ActionHideColours::Init Operation *const   pOp,
ActionList pActionList,
UINT32  ActionSize,
ColourList TheParentList,
IndexedColour Colour[],
BOOL  HideThem,
Action **  NewAction
[static]
 

To check that there is sufficient room for the action in the operation history, and if there is, then to add the action to the operations action list.

Parameters:
pOp,: The operation to which the action should be added [INPUTS] pActionList: The action list in the operation object ActionSize: The size of the action in bytes. This should be the total size of the action (including any objects pointed to by the action). TheParentList: Points to the list containing the IndexedColours in Colour[] Colour[]: A NULL terminated list array of pointers to the IndexedColours which are to be hidden/unhidden HideThem: TRUE to Hide, FALSE to unhide the colours.
NewAction,: A pointer to the action if it could be allocated. [OUTPUTS]
Returns:
AC_FAIL: There was not enough room in the operation history for the action and the user did not wish to continue. Usually End() should be called in this situation.
AC_NORECORD: There was not enough room in the operation history for the action, but the user requested that he wished to continue without undo.

AC_OK : The action was successfully initialised and added to the operation.

The function calls the Action::Init function passing the runtime class of an ActionHideColours.

Returns:
Errors: -
See also:
Action::Init

Definition at line 3027 of file colormgr.cpp.

03034 {
03035     ActionCode Ac = (Action::Init(pOp,
03036                                     pActionList,
03037                                     ActionSize,
03038                                     CC_RUNTIME_CLASS(ActionHideColours), 
03039                                     NewAction));
03040     if (*NewAction != NULL)
03041     {
03042         INT32 Count = 0;
03043 
03044         while (Colour[Count] != NULL)                   // Count array size
03045             Count++;
03046 
03047         ActionHideColours *AHC = (ActionHideColours*) (*NewAction);
03048 
03049         ALLOC_WITH_FAIL(AHC->ChangeColour, new IndexedColourPtr[Count+1], pOp);
03050 
03051         if (AHC->ChangeColour == NULL)                  // Failed in Action Alloc
03052         {
03053             delete AHC;                                 // Delete the action
03054             *NewAction = NULL;                          // Ensure return NULL
03055             return(AC_FAIL);                            // And return 'failed'
03056         }
03057 
03058         Count = 0;
03059         while (Colour[Count] != NULL)                   // Copy Colour array
03060         {
03061             AHC->ChangeColour[Count] = Colour[Count];
03062             Count++;
03063         }
03064         AHC->ChangeColour[Count] = NULL;                // And NULL terminate
03065         
03066         AHC->ParentList = TheParentList;                // Copy the parentlist pointer
03067         AHC->HideFlag = HideThem;                       // Copy HideFlag
03068     }
03069 
03070     return (Ac);
03071 }

void ActionHideColours::Slaughter void   )  [virtual]
 

ActionHideColours Slaughter method. Cleans up any deleted colours associated with this action - once slaughtered, deleted colours can not come back (touch wood!) so are actually deleted from the document rather than just hidden.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/94
Notes: Only colours which are truly 'deleted' at this point in time are destructed, because this action both deletes (hides) and undeletes (unhides) colours, so our 'undo/redo' record may point at colours which are currently alive and in use. We also have to be careful about this, as there can be 2 undo records for the same colour (creation and deletion) in the list at once, and obviously, only one of them should attemp to destruct the colour!

Reimplemented from Action.

Definition at line 2899 of file colormgr.cpp.

02900 {
02901     // If we have some colour(s) and our last action was to hide them (thus they are
02902     // deleted colours rather than undeleted ones), then we are responsible for
02903     // slaughtering the now-unneeded colours.
02904     // NOTE: Remember that if we are a 'Hide' action, then the colour should currently
02905     // be in an UN-hidden state; thus, we delete ONLY if we are an UN-hide action.
02906 
02907     if (ChangeColour != NULL && !HideFlag)
02908     {
02909         INT32 Index = 0;
02910     
02911         // Delete each colour in turn from the ParentList ColourList
02912         while (ChangeColour[Index] != NULL)
02913         {
02914             // Remove from the list
02915             ParentList->RemoveItem(ChangeColour[Index]);
02916 
02917             // Ensure it has no children pointing at it
02918             ParentList->RemoveLinksToColour(ChangeColour[Index]);
02919 
02920             // Delink this colour from its parent, if any
02921             if (ChangeColour[Index]->FindLastLinkedParent() != NULL)
02922                 ChangeColour[Index]->SetLinkedParent(NULL, COLOURTYPE_NORMAL);
02923 
02924             // And finally, delete it
02925             delete ChangeColour[Index];
02926 
02927             Index++;
02928         }
02929     }
02930 
02931     Action::Slaughter();        // Call the base class Slaughter method to delete ourself
02932 }


Member Data Documentation

IndexedColour** ActionHideColours::ChangeColour [private]
 

Definition at line 378 of file colormgr.h.

BOOL ActionHideColours::HideFlag [private]
 

Definition at line 379 of file colormgr.h.

ColourList* ActionHideColours::ParentList [private]
 

Definition at line 377 of file colormgr.h.


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