OpLayerChange Class Reference

This class represents the LayerChange operation which is created by the LayerManager to make changes to the layers of the current spread. More...

#include <layermgr.h>

Inheritance diagram for OpLayerChange:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpLayerChange ()
 OpLayerChange constructor (Creates an undoable operation).
void Do (OpDescriptor *)
 Performs the layer change operation this operation reads the layer details list of the current documents layer manager, and changes the document tree to reflect any changes which have been made.
virtual BOOL Undo ()
 The overloaded Undo operation refreshes the layer details in the layer manager.
virtual BOOL Redo ()
 The overloaded Redo operation refreshes the layer details in the layer manager.

Static Public Member Functions

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

Private Member Functions

 CC_DECLARE_DYNCREATE (OpLayerChange)

Detailed Description

This class represents the LayerChange operation which is created by the LayerManager to make changes to the layers of the current spread.

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

Definition at line 236 of file layermgr.h.


Constructor & Destructor Documentation

OpLayerChange::OpLayerChange  ) 
 

OpLayerChange constructor (Creates an undoable operation).

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

Errors: -

See also:
-

Definition at line 635 of file layermgr.cpp.

00635                             : UndoableOperation()                               
00636 {                              
00637 }


Member Function Documentation

OpLayerChange::CC_DECLARE_DYNCREATE OpLayerChange   )  [private]
 

void OpLayerChange::Do OpDescriptor  )  [virtual]
 

Performs the layer change operation this operation reads the layer details list of the current documents layer manager, and changes the document tree to reflect any changes which have been made.

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

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 716 of file layermgr.cpp.

00717 {   
00718     ENSURE(FALSE,"This shouldn't have been called");
00719 /*
00720     Spread* pSpread = Document::GetCurrent()->GetLayerMgr().GetCurrentSpread(); 
00721     // Find the first layer on the spread. All siblings of the first layer node should
00722     // be layer nodes
00723     Node* CurrentTreeLayer = pSpread->FindFirstLayer(); // skips over page nodes 
00724 
00725     ENSURE(CurrentTreeLayer->GetRuntimeClass() == CC_RUNTIME_CLASS(Layer), 
00726             "A next sibling of a layer node is not a layer"); 
00727 
00728 
00729     // Get the first layer details record 
00730     LyrDetails* CurLyrDet = (LyrDetails*)
00731         (Document::GetCurrent()->GetLayerMgr()).LyrDetList.GetHead(); 
00732     
00733     BOOL InvalidateLayersRgn; // Flag used to decide if we should invalidate
00734                               // a layers region
00735     BOOL RemoveSelections;    // Flag used to indicate if we should remove all
00736                               // selections from the layer 
00737 
00738     // loop while there are more changes to be made 
00739     while (CurLyrDet != NULL) 
00740     {
00741         InvalidateLayersRgn = FALSE;
00742         RemoveSelections = FALSE; 
00743 
00744         // We can ignore all new layers which have been deleted 
00745         if (!((CurLyrDet->New) && (CurLyrDet->Deleted)))
00746         {
00747             // Is the layer a new layer ? 
00748             if (CurLyrDet->New)
00749             {
00750                 // Attempt to create a new layer node 
00751                 Layer* NewLyr; 
00752                 ALLOC_WITH_FAIL(NewLyr, (new Layer()), this);         
00753                 if (NewLyr == NULL)
00754                 {
00755                     goto EndOperation; // We were unable to create a new layer so 
00756                                        // abort the operation 
00757                 }
00758                 // Set the new layer's status  
00759                 NewLyr->SetLayerStatus(CurLyrDet->Status); 
00760            
00761                 // Create a hide node action to hide the new node when we undo/redo
00762                 HideNodeAction* UndoHideNodeAction; 
00763                 // ** Change !!!    
00764                 if (!HideNodeAction::Init(this,                    
00765                                           &UndoActions,
00766                                           NewLyr, 
00767                                           TRUE, 
00768                                           ( Action**)(&UndoHideNodeAction))      
00769                                           != AC_FAIL)
00770                 {
00771                     delete NewLyr;     // We won't be needing this 
00772                     goto EndOperation;      
00773                 }
00774                 // All is well 
00775                 if (CurrentTreeLayer != NULL)
00776                 {
00777                     // Add the new layer to the tree as a previous sibling of 
00778                     // the CurrentTreeLayer 
00779                     NewLyr->AttachNode(CurrentTreeLayer, PREV); 
00780                 }
00781                 else 
00782                 {
00783                     // Add the new layer as a last child of the spread 
00784                     NewLyr->AttachNode(Document::GetCurrent()->
00785                         GetLayerMgr().GetCurrentSpread(), LASTCHILD); 
00786                 }
00787             }
00788 
00789             // Has the layer been deleted 
00790             else if (CurLyrDet->Deleted)
00791             {
00792                 if ( CurLyrDet->Layer == CurrentTreeLayer )
00793                 {
00794                     // We are about to hide the CurrentTreeLayer so we need to find the 
00795                     // next layer before we do this 
00796                     CurrentTreeLayer = ((Layer*)CurrentTreeLayer)->FindNextLayer(); 
00797                 }
00798                 
00799                 // If a layer has been deleted then we ignore all attribute changes 
00800                 // which may have been made prior to the layer being deleted. 
00801                 // Change 
00802                 if (!DoHideNode(CurLyrDet->Layer, 
00803                                 TRUE                // Include subtree size 
00804                                 )) // Hide the node 
00805                     goto EndOperation; 
00806                 InvalidateLayersRgn = TRUE; // We will need to invalidate the hidden 
00807                                             // layers bounding region. 
00808                 RemoveSelections = TRUE;    
00809             }
00810             else 
00811             {
00812                 // Have the attributes of the layer changed 
00813                 if ( !(CurLyrDet->Status == CurLyrDet->Layer->GetLayerStatus()) )   
00814                 {
00815         
00816                     // Determine if the attribute changes mean that the layer's 
00817                     // bounding rectangle must be invalidated. 
00818                     LayerStatus Old = CurLyrDet->Layer->GetLayerStatus(); 
00819                     LayerStatus New = CurLyrDet->Status; 
00820                     if (
00821                          (New.Flags.Visible != Old.Flags.Visible) || 
00822                          (New.LayerQualityLevel != Old.LayerQualityLevel)  
00823                        )  
00824                     {
00825                         InvalidateLayersRgn = TRUE; 
00826                     } 
00827 
00828                     // Determine if the attribute changes mean that we should remove
00829                     // the selections on the layer 
00830                     if ( 
00831                         ((New.Flags.Visible != Old.Flags.Visible) && 
00832                          (!New.Flags.Visible)
00833                         ) || 
00834                         ((New.Flags.Locked != Old.Flags.Locked) && 
00835                          (New.Flags.Locked)
00836                         )
00837                        )
00838                     {
00839                         RemoveSelections = TRUE;  
00840                     } 
00841             
00842                     // Try to create an action to restore the attribute changes we 
00843                     // are about to make 
00844                     ChangeLyrAttribAction* UndoAttribChngAction;                          
00845 
00846                     if ( ChangeLyrAttribAction::Init(this,                    
00847                                                   &UndoActions,
00848                                                   sizeof(InvalidateRegionAction),  
00849                                                   CurLyrDet->Layer->GetLayerStatus(),
00850                                                   CurLyrDet->Layer, 
00851                                                   ( Action**)(&UndoAttribChngAction))
00852                                                   != AC_FAIL) 
00853                     {
00854                         // Change the layer's attributes 
00855                         CurLyrDet->Layer->SetLayerStatus(CurLyrDet->Status);    
00856                     }
00857                     else 
00858                         goto EndOperation; // We have failed 
00859             
00860                 }
00861                 // Has the current layers z-position changed ? 
00862                 if (CurLyrDet->Layer != CurrentTreeLayer)
00863                 {
00864                     // I don't think the CurrentTreeLayer can ever be NULL in this situation !
00865                     ENSURE(CurrentTreeLayer != NULL, "The current tree layer is NULL"); 
00866                     // Move the node to its correct tree position 
00867                     // *** Change 
00868                     if(!DoMoveNode(CurLyrDet->Layer, 
00869                                    CurrentTreeLayer, 
00870                                    PREV               // The correct tree position 
00871                                    ))
00872                     {
00873                         goto EndOperation; 
00874                     }                 
00875                 }
00876                 else // The layer is in the correct position in the tree
00877                 {
00878                     CurrentTreeLayer = ((Layer*)CurrentTreeLayer)->FindNextLayer(); 
00879                 }
00880             }
00881             // Do we want to remove the layer's selections 
00882             if (RemoveSelections)
00883             {
00884                 NodeRenderableInk::DeselectAllOnLayer(CurLyrDet->Layer); 
00885             }
00886 
00887             // Do we want to invalidate the bounding rectangle of the layer ? 
00888             if (InvalidateLayersRgn) 
00889             {
00890                 DocRect Bounds = CurLyrDet->Layer->GetBoundingRect();
00891                 // Don't bother if the bounding rectangle is empty 
00892                 if (!Bounds.IsEmpty())
00893                 {                                                     
00894                     // Create an InvalidateRegionAction  
00895                     if (!DoInvalidateNodeRegion(CurLyrDet->Layer, FALSE))
00896                     {
00897                         goto EndOperation; 
00898                     }
00899                 }
00900             }
00901         }
00902         // Process the next layer 
00903         CurLyrDet = (LyrDetails*)
00904             (Document::GetCurrent()->GetLayerMgr()).LyrDetList.GetNext(CurLyrDet); 
00905     }
00906     EndOperation:
00907 */
00908     End(); 
00909 }

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

For finding the OpLayerChange's state.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/9/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpLayerChange operation

Errors: -

See also:
-

Definition at line 685 of file layermgr.cpp.

00686 {
00687     OpState OpSt;  
00688     return(OpSt);   
00689 }

BOOL OpLayerChange::Init void   )  [static]
 

OpLayerChange initialiser method.

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

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 657 of file layermgr.cpp.

00658 {
00659     return (RegisterOpDescriptor(
00660                                 0,
00661                                 _R(IDS_LAYERCHANGEOP),
00662                                 CC_RUNTIME_CLASS(OpLayerChange),
00663                                 OPTOKEN_LYRCHNG,
00664                                 OpLayerChange::GetState,
00665                                 0,  /* help ID */
00666                                 _R(IDBBL_LAYERCHANGEOP),
00667                                 0   /* bitmap ID */));
00668 }               

BOOL OpLayerChange::Redo  )  [virtual]
 

The overloaded Redo operation refreshes the layer details in the layer manager.

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

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 954 of file layermgr.cpp.

00955 {
00956     BOOL Result = Operation::Redo(); 
00957     if (Result)
00958     {
00959         //Document::GetCurrent()->GetLayerMgr().RefreshLayerDetails(); 
00960     }
00961     return (Result); 
00962 }

BOOL OpLayerChange::Undo  )  [virtual]
 

The overloaded Undo operation refreshes the layer details in the layer manager.

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

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 927 of file layermgr.cpp.

00928 {
00929     BOOL Result = Operation::Undo(); 
00930     if (Result)
00931     {
00932         //Document::GetCurrent()->GetLayerMgr().RefreshLayerDetails(); 
00933     }
00934     return (Result); 
00935  
00936 }       


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