#include <ops.h>
Inheritance diagram for ActionList:
Public Member Functions | |
ActionList () | |
~ActionList () | |
ActionList destructor, deletes the action list and all actions it contains. NOTE that REDO action lists must be deleted backwrds. | |
BOOL | ExecuteForwards (BOOL AllButLast) |
This method executes all actions in the action list forwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned. | |
BOOL | ExecuteBackwards (BOOL AllButLast, BOOL bIgnoreSelectActions=FALSE) |
This method executes all actions in the action list backwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned. | |
Action * | FindActionOfClass (CCRuntimeClass *ClassOfActionToFind, Action *LastAction=NULL) |
To search the action list for the first action with runtime class ClassOfActionToFind. |
Definition at line 196 of file ops.h.
|
|
|
ActionList destructor, deletes the action list and all actions it contains. NOTE that REDO action lists must be deleted backwrds.
Definition at line 219 of file ops.cpp. 00220 { 00221 /* 00222 ListItem* Current = GetHead(); // First action 00223 while (Current != NULL) // While there are more actions to delete 00224 { 00225 ((Action*)RemoveHead())->Slaughter(); // Delete the action 00226 Current = GetHead(); // Get next action 00227 ContinueSlowJob(); 00228 } 00229 */ 00230 ListItem* Current = GetTail(); // Last action 00231 while (Current != NULL) // While there are more actions to delete 00232 { 00233 ((Action*)RemoveTail())->Slaughter(); // Delete the action 00234 Current = GetTail(); // Get next action 00235 ContinueSlowJob(); 00236 } 00237 00238 }
|
|
This method executes all actions in the action list backwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned.
Definition at line 338 of file ops.cpp. 00339 { 00340 ListItem* CurrentAction = GetTail(); 00341 00342 if (AllButLast && (CurrentAction != NULL)) 00343 CurrentAction = CurrentAction->Previous; // Don't execute the last action 00344 00345 //TRACE( _T("Before Undo\n")); 00346 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST(); 00347 00348 BOOL Failed = FALSE; 00349 while ((CurrentAction != NULL) && (!Failed)) // For each action in the list 00350 { 00351 // Attempt to execute action 00352 if (!(bIgnoreSelectActions && 00353 CurrentAction->IsKindOf(CC_RUNTIME_CLASS(RestoreSelectionsAction))) 00354 ) 00355 Failed = (((Action*)CurrentAction)->Execute() == AC_FAIL); 00356 00357 //((Action*)CurrentAction)->Dump(); 00358 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST(); 00359 00360 // Get next action 00361 CurrentAction = CurrentAction->Previous; 00362 } 00363 00364 if (!Failed) 00365 { 00366 // Successfully executed action list so all actions are deleted. 00367 Action* HeadItem = (Action *) GetHead(); 00368 00369 Document *pDoc = HeadItem->GetWorkingDoc(); 00370 ERROR2IF(pDoc == NULL, FALSE, "No document attached to action in Action::ExecuteBackwards"); 00371 OperationHistory& OpHistory = pDoc->GetOpHistory(); 00372 00373 // Loop while there are still actions to delete 00374 while (HeadItem != NULL) 00375 { 00376 // Reduce the size of the operation history by the size of the action being deleted 00377 OpHistory.DecSize(((Action*)HeadItem)->GetSize()); 00378 00379 // Delete the action 00380 delete (RemoveItem(HeadItem)); 00381 00382 // Get next action 00383 HeadItem = (Action *) GetHead(); 00384 } 00385 00386 } 00387 00388 return (!Failed); 00389 }
|
|
This method executes all actions in the action list forwards. If there is no failure then all actions are deleted If an action fails whilst executing no actions are deleted and FALSE is returned.
Definition at line 265 of file ops.cpp. 00266 { 00267 ListItem* CurrentAction = GetHead(); 00268 ListItem* LastAction = GetTail(); 00269 00270 // If we are to execute all actions but the last then the last action to 00271 // execute is prev(tail) 00272 if ((LastAction != NULL) && (AllButLast)) 00273 LastAction = LastAction->Previous; 00274 00275 //TRACE( _T("Before Redo\n")); 00276 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST(); 00277 00278 BOOL Failed = FALSE; 00279 while ((CurrentAction != LastAction) && (!Failed)) // For each action in the list 00280 { 00281 // Execute the action 00282 Failed = (((Action*)CurrentAction)->Execute() == AC_FAIL); 00283 00284 //((Action*)CurrentAction)->Dump(); 00285 //((Action*)CurrentAction)->GetWorkingDoc()->FindFirstSpread()->DST(); 00286 00287 CurrentAction = CurrentAction->Next; 00288 } 00289 00290 if (!Failed) 00291 { 00292 // Successfully executed action list so all actions are deleted. 00293 Action* HeadItem = (Action *) GetHead(); 00294 00295 Document *pDoc = HeadItem->GetWorkingDoc(); 00296 ERROR2IF(pDoc == NULL, FALSE, "No document attached to action in Action::ExecuteForwards"); 00297 OperationHistory& OpHistory = pDoc->GetOpHistory(); 00298 00299 while (HeadItem != NULL) 00300 { 00301 // Reduce the size of the operation history by the size of the action 00302 // being deleted. 00303 OpHistory.DecSize(HeadItem->GetSize()); 00304 00305 // Remove the action from the action list 00306 delete (RemoveItem(HeadItem)); 00307 00308 // Get next action 00309 HeadItem = (Action *) GetHead(); 00310 } 00311 } 00312 00313 return (!Failed); 00314 }
|
|
To search the action list for the first action with runtime class ClassOfActionToFind. Action* ActionList::FindActionOfClass(CCRuntimeClass* ClassOfActionToFind, Action* LastAction = NULL);
Definition at line 418 of file ops.cpp. 00420 { 00421 Action* Current = LastAction; // Will be NULL if LastAction is not specified 00422 do 00423 { 00424 if (Current == NULL) 00425 { 00426 Current = (Action*)GetHead(); 00427 } 00428 else 00429 { 00430 Current = (Action*)GetNext(Current); 00431 } 00432 if ((Current != NULL) && (Current->GetRuntimeClass() == ClassOfActionToFind)) 00433 { 00434 return Current; 00435 } 00436 } while (Current != NULL); 00437 return NULL; 00438 }
|