RestoreSelectionsAction Class Reference

When executed this action will restore the selection state of the document. It will also spawn another identical RestoreSelectionsAction adding and add it to the opposite action list. More...

#include <ops.h>

Inheritance diagram for RestoreSelectionsAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 RestoreSelectionsAction ()
 RestoreSelectionsAction constructor.
 ~RestoreSelectionsAction ()
void Slaughter ()
 All RestoreSelections actions have a pointer to a selection state. This selection state is passed on to the actions twin, and therefore should not be deleted in the actions destructor. The slaughter method is responsible for deleting the SelState.
virtual ActionCode Execute ()
 Executes the RestoreSelectionsAction which restores the selection state. It also creates another identical RestoreSelectionsAction and adds this to the opposite ActionList.
SelectionStateGetSelState ()

Static Public Member Functions

static ActionCode Init (Operation *const pOp, ActionList *pActionList, SelectionState *SelState, BOOL Toggle, BOOL ToggleStatus, BOOL SelStateShared, BOOL RenderStartBlobs, BOOL RenderEndBlobs, BOOL StartRestore, 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

SelectionStateSelState
BOOL toggle:1
BOOL toggleStatus:1
BOOL SelStateShared:1
BOOL RenderStartBlobs:1
BOOL RenderEndBlobs:1
BOOL StartRestore:1

Detailed Description

When executed this action will restore the selection state of the document. It will also spawn another identical RestoreSelectionsAction adding and add it to the opposite action list.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/93
See also:
-

Definition at line 1037 of file ops.h.


Constructor & Destructor Documentation

RestoreSelectionsAction::RestoreSelectionsAction  ) 
 

RestoreSelectionsAction constructor.

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

Errors: -

See also:
-

Definition at line 4178 of file ops.cpp.

04179 {
04180 }

RestoreSelectionsAction::~RestoreSelectionsAction  ) 
 

Definition at line 4182 of file ops.cpp.

04183 { 
04184     // Note that the SelectionState object is not deleted in the destructor. This is because 
04185     // it will be used by the spawned RestoreSelectionAction generated in the Execute method.
04186 }   


Member Function Documentation

ActionCode RestoreSelectionsAction::Execute  )  [virtual]
 

Executes the RestoreSelectionsAction which restores the selection state. It also creates another identical RestoreSelectionsAction and adds this to the opposite ActionList.

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

Errors: -

See also:
-

Reimplemented from Action.

Definition at line 4248 of file ops.cpp.

04249 {  
04250     RestoreSelectionsAction* RestoreAct;  
04251     ActionCode ActCode;  
04252     // Attempt to initialise the action    
04253     if ((ActCode = RestoreSelectionsAction::Init(pOperation,                    
04254                                                  pOppositeActLst,  
04255                                                  SelState, 
04256                                                  toggle, 
04257                                                  !toggleStatus,   // Toggle it
04258                                                  SelStateShared, 
04259                                                  RenderStartBlobs,
04260                                                  RenderEndBlobs,
04261                                                  !StartRestore,   // Will become the last restore !
04262                                                  ( Action**)(&RestoreAct))) != AC_FAIL) 
04263     {   
04264         // The action was successfully initialised. If this is a toggle 
04265         // action then only restore the selection state when the toggleStatus is
04266         // true. 
04267         if ((!toggle) || (toggleStatus))  // Determine if we have to do anything 
04268         {   
04269             // Only render the blobs if StartRestore is FALSE and either
04270             // a. RenderStartBlobs is TRUE and this action is an undo action 
04271             // b. RenderEndBlobs is TRUE and this is a redo action
04272 
04273             BOOL RenderBlobs = FALSE;
04274                              
04275             if (!StartRestore)
04276             {
04277                 if  (pOppositeActLst == pOperation->GetUndoActionList())
04278                 {
04279                     // This action is a redo action
04280                     RenderBlobs = RenderEndBlobs;
04281                 }
04282 
04283                 else
04284                 {
04285                     // This action is an undo action
04286                     RenderBlobs = RenderStartBlobs;
04287                 }
04288             }
04289 
04290             // Turn blob rendering on if this is the last restore
04291             //if (!StartRestore)
04292             //{
04293             //  Camelot.GetBlobManager()->BlobRenderingOn(FALSE); 
04294             //}
04295 
04296             // Always remove the selection blobs when StartRestore is TRUE           
04297             SelState->Restore(RenderBlobs, StartRestore); // Restore selections   
04298             
04299             // Turn blob rendering off if this is the first restore
04300             //if (StartRestore)
04301             //{
04302             //  Camelot.GetBlobManager()->BlobRenderingOff(FALSE); 
04303             //}
04304  
04305         }
04306     }             
04307     return (ActCode);                
04308 }     

SelectionState* RestoreSelectionsAction::GetSelState  )  [inline]
 

Definition at line 1057 of file ops.h.

01059 { return SelState; };      

ActionCode RestoreSelectionsAction::Init Operation *const   pOp,
ActionList pActionList,
SelectionState SelState,
BOOL  Toggle,
BOOL  ToggleStatus,
BOOL  SelStateShared,
BOOL  RenderStartBlobs,
BOOL  RenderEndBlobs,
BOOL  StartRestore,
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.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/9/93
Parameters:
pOp,: The operation to which the action should be added [INPUTS]
pActionList: The action list in the operation object

SelState: Pointer to a selection State - this gets destroyed in the actions slaughter method.

Toggle: When TRUE this flag indicates that the selection state should only be restored when the ToggleStatus is TRUE. The ToggleStatus of the actions twin = !ToggleStatus. This mechanism allows two RestoreSelectionActions to be created for an operation, only one of which does anything. Usually an operation creates two RestoreSelectionsActions one at the head and one at the tail of the operations action list. When undoing it is desirable that the tail RestoreSelectionsAction restores the selection state and that the head RestoreSelectionsAction does nothing (except create a twin). when redoing the RestoreSelectionsAction which was originally at the head of the undo action list is now at the tail of the redo list and so it needs to restore the selections.Likewise the RestoreSelectionsAction which was at the tail of the undo action list will be at the head of the redo action list and so it is this actions turn to do nothing.

ToggleStatus: The initial toggle status

SelStateShared: This flag indicates that the SelState is shared by a pair of RestoreSelActions. If this flag is set then the Toggle flag must also be set.

RenderStartBlobs: Should the selection blobs be rendered for the start selection state ?

RenderEndBlobs: Should the selection blobs be rendered for the end selection state ?

StartRestore: TRUE indicates that this is the first restore action executed when the operation is undone.

Parameters:
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 a RestoreSelectionsAction.

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

Definition at line 4394 of file ops.cpp.

04404 {    
04405     // If the SelState is shared then Toggle must be TRUE. This is so that we know when
04406     // to delete the SelState. 
04407     ENSURE( (!SelStateShared || Toggle), "Invalid flags passed to RestoreSelectionsAction"); 
04408     
04409     // Try to allocate memory for the action 
04410     ActionCode Ac = (Action::Init(pOp,
04411                      pActionList,
04412                      sizeof(RestoreSelectionsAction) + SelState->GetSize(),
04413                      CC_RUNTIME_CLASS(RestoreSelectionsAction), 
04414                      NewAction));    
04415     if (*NewAction != NULL) 
04416     {
04417         ((RestoreSelectionsAction*)(*NewAction))->SelState = SelState;
04418         ((RestoreSelectionsAction*)(*NewAction))->toggle = Toggle; 
04419         ((RestoreSelectionsAction*)(*NewAction))->toggleStatus = ToggleStatus; 
04420         ((RestoreSelectionsAction*)(*NewAction))->SelStateShared = SelStateShared; 
04421         ((RestoreSelectionsAction*)(*NewAction))->RenderStartBlobs = RenderStartBlobs; 
04422         ((RestoreSelectionsAction*)(*NewAction))->RenderEndBlobs = RenderEndBlobs; 
04423         ((RestoreSelectionsAction*)(*NewAction))->StartRestore = StartRestore; 
04424 
04425     }
04426     return (Ac); 
04427 }

void RestoreSelectionsAction::Slaughter void   )  [virtual]
 

All RestoreSelections actions have a pointer to a selection state. This selection state is passed on to the actions twin, and therefore should not be deleted in the actions destructor. The slaughter method is responsible for deleting the SelState.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
If this is a togling action, and ToggleStatus = FALSE then the SelState is not deleted, it will be deleted by the other RestoreSelectionsAction with ToggleStatus = TRUE.

Returns:
Errors: -
See also:
Action::Slaughter

Reimplemented from Action.

Definition at line 4211 of file ops.cpp.

04212 {   
04213     // Determine if the SelState should be deleted here or in another RestoreSelectionsAction
04214     if (SelStateShared)
04215     {
04216         ENSURE(toggle, "If the SelState is shared then the toggle flag should be set"); 
04217         if (toggleStatus)
04218         {
04219             ENSURE (SelState != NULL, "Trying to delete a NULL SelectionState"); 
04220             delete SelState; 
04221         }
04222     } 
04223     else // The SelState is not shared so we can safely delete the selection state
04224     {
04225         delete SelState; 
04226     }
04227     Action::Slaughter(); 
04228 }   


Member Data Documentation

BOOL RestoreSelectionsAction::RenderEndBlobs [private]
 

Definition at line 1071 of file ops.h.

BOOL RestoreSelectionsAction::RenderStartBlobs [private]
 

Definition at line 1070 of file ops.h.

SelectionState* RestoreSelectionsAction::SelState [private]
 

Definition at line 1057 of file ops.h.

BOOL RestoreSelectionsAction::SelStateShared [private]
 

Definition at line 1067 of file ops.h.

BOOL RestoreSelectionsAction::StartRestore [private]
 

Definition at line 1073 of file ops.h.

BOOL RestoreSelectionsAction::toggle [private]
 

Definition at line 1065 of file ops.h.

BOOL RestoreSelectionsAction::toggleStatus [private]
 

Definition at line 1066 of file ops.h.


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