UnApplyAction Class Reference

When executed this action will hide a node. It will also generate a ShowNodeAction action adding it to the opposite Action list. More...

#include <ops.h>

Inheritance diagram for UnApplyAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 UnApplyAction ()
 UnApplyAction constructor.
 ~UnApplyAction ()
virtual ActionCode Execute ()
 Executes the UnApplyAction which hides the node. It also creates a ShowNodeAction and adds it to the opposite ActionList.
void RecordTag (NodeAttribute *pAttr)

Static Public Member Functions

static ActionCode Init (Operation *const pOp, ActionList *pActionList, Node *pActionNode, NodeAttribute *pActionAttribute, BOOL IncludeSubtreeSize, Action **NewAction, BOOL TellSubtree=TRUE)
 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

Nodem_pApplyNode
NodeAttributem_pAttribute
TAG m_nAttrTag
BOOL IncludeSubtreeSize:1
BOOL TellSubtree:1

Friends

class OpApplyAttrInteractive

Detailed Description

When executed this action will hide a node. It will also generate a ShowNodeAction action adding it to the opposite Action list.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/07/2005
See also:
ShowNodeAction

Definition at line 938 of file ops.h.


Constructor & Destructor Documentation

UnApplyAction::UnApplyAction  ) 
 

UnApplyAction constructor.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/07/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 3779 of file ops.cpp.

03780 {
03781     m_pApplyNode = NULL;
03782     m_pAttribute = NULL;
03783     m_nAttrTag = 0;
03784     IncludeSubtreeSize = FALSE;
03785     TellSubtree = FALSE;
03786 }

UnApplyAction::~UnApplyAction  ) 
 

Definition at line 3788 of file ops.cpp.

03789 {
03790     if (m_pAttribute)
03791     {
03792         delete m_pAttribute;
03793         m_pAttribute = NULL;
03794     }
03795 }


Member Function Documentation

ActionCode UnApplyAction::Execute  )  [virtual]
 

Executes the UnApplyAction which hides the node. It also creates a ShowNodeAction and adds it to the opposite ActionList.

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

Errors: -

See also:
-

Reimplemented from Action.

Definition at line 3815 of file ops.cpp.

03816 {
03817     ApplyAction* pApplyAct;  
03818     ActionCode ActCode;  
03819 
03820 //  NodeHidden* HideNode = NULL;
03821 
03822     // Attempt to initialise the apply action which will re-apply the node that 
03823     // we are about to unapply.
03824     if ((ActCode = ApplyAction::Init(pOperation,
03825                                         pOppositeActLst,
03826                                         m_pApplyNode,
03827                                         m_pAttribute,
03828                                         IncludeSubtreeSize,
03829                                         ( Action**)(&pApplyAct),
03830                                         TellSubtree)) == AC_FAIL)
03831         return ActCode;
03832     
03833     // Tell our parent that we have changed so any cached info he has must be removed
03834     // (Deals with cases where DoInvalidateRegion has been used and so no other
03835     //  cache release calls have been made)
03836     if (m_pApplyNode->IsBounded())
03837         ((NodeRenderableBounded*)m_pApplyNode)->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
03838 
03839     // Determine which node needs hiding
03840     CCRuntimeClass* pClass = m_pAttribute->GetRuntimeClass();
03841 
03842     // We need to search the children of node to find the attribute
03843     // Note that if this action has recorded a Tag, that attribute should not have been
03844     // mutated before trying to execute this action. If it has then the mutated attribute
03845     // will have a new tag and will not be found. c.f. interactive dragging...
03846     Node* NodeToHide = m_pApplyNode->FindFirstChild();
03847     BOOL bLookingForEffect = m_pApplyNode->IsAnObject() && ((NodeRenderableInk*)m_pApplyNode)->IsValidEffectAttr(m_pAttribute);
03848     while (NodeToHide != NULL)
03849     {
03850         if (NodeToHide->GetRuntimeClass() == pClass &&
03851             (m_nAttrTag == 0 || m_nAttrTag == NodeToHide->GetTag()) &&
03852             (bLookingForEffect == (NodeToHide->IsAnAttribute() && ((NodeAttribute*)NodeToHide)->IsEffectAttribute()))
03853             )
03854             // We have found the attribute to hide
03855             break;
03856 
03857         NodeToHide = NodeToHide->FindNext();
03858     }
03859 
03860     if (NodeToHide != NULL)
03861     {
03862         // If the node being hidden is an attribute which will effect the bounds of it's parent
03863         // bounded object then we must invalidate the parents bounds
03864         if (m_pApplyNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)))
03865             ((NodeRenderableBounded*)m_pApplyNode)->InvalidateBoundingRect();   
03866             
03867         NodeToHide->CascadeDelete();
03868         delete NodeToHide;
03869         NodeToHide = NULL;
03870 
03871         // Mark the parent layer as edited as something has changed on it
03872         // Could use SetParentLayerAsEdited but only implemented for NodeRenderableInk at present
03873         Layer* pLayer = (Layer*) m_pApplyNode->FindParent(CC_RUNTIME_CLASS(Layer));
03874         if (pLayer)
03875             pLayer->SetEdited(TRUE);
03876 
03877     } 
03878 
03879     return ActCode;
03880 }    

ActionCode UnApplyAction::Init Operation *const   pOp,
ActionList pActionList,
Node pActionApplyNode,
NodeAttribute pActionAttribute,
BOOL  IncludeSubtreeSize,
Action **  NewAction,
BOOL  TellSubtree = TRUE
[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:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/07/2005
Parameters:
pOp,: The operation to which the action should be added [INPUTS]
pActionList: The action list in the operation object

NodeToHide: The node to hide

IncludeSubtreeSize: The size of a UnApplyAction is always sizeof(UnApplyAction), however the IncludeSubtreeSize flag is required by the twin ShowNodeAction.

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 UnApplyAction.

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

Definition at line 3929 of file ops.cpp.

03937 {  
03938     ActionCode Ac = (Action::Init(pOp,
03939                      pActionList,
03940                      sizeof(UnApplyAction) + sizeof(pActionAttribute),
03941                      CC_RUNTIME_CLASS(UnApplyAction), 
03942                      NewAction)); 
03943 
03944     if (*NewAction != NULL) 
03945     {
03946         UnApplyAction* pAction = (UnApplyAction*)(*NewAction);
03947 
03948         // Store the runtime class of the attribute so that we can find it
03949         pAction->m_pApplyNode = pActionApplyNode;
03950         pAction->m_pAttribute = (NodeAttribute*)pActionAttribute->SimpleCopy();
03951         pAction->IncludeSubtreeSize = IncludeSubtreeSize; 
03952         pAction->TellSubtree = TellSubtree; 
03953         pAction->RecordTag(pActionAttribute);
03954     }
03955                   
03956     return (Ac); 
03957 }

void UnApplyAction::RecordTag NodeAttribute pAttr  ) 
 

Definition at line 3959 of file ops.cpp.

03960 {
03961     // If it's also a Wix attribute then store its tag so it can be uniquely identified
03962     // when the attribute must be hidden again.
03963 //  if (pAttr->IS_KIND_OF(TemplateAttribute) || pAttr->IsEffectAttribute())
03964     if (pAttr->IS_KIND_OF(TemplateAttribute))
03965         m_nAttrTag = pAttr->GetTag();
03966     else
03967         m_nAttrTag = 0;
03968 }


Friends And Related Function Documentation

friend class OpApplyAttrInteractive [friend]
 

Definition at line 942 of file ops.h.


Member Data Documentation

BOOL UnApplyAction::IncludeSubtreeSize [private]
 

Definition at line 973 of file ops.h.

TAG UnApplyAction::m_nAttrTag [private]
 

Definition at line 964 of file ops.h.

Node* UnApplyAction::m_pApplyNode [private]
 

Definition at line 962 of file ops.h.

NodeAttribute* UnApplyAction::m_pAttribute [private]
 

Definition at line 963 of file ops.h.

BOOL UnApplyAction::TellSubtree [private]
 

Definition at line 974 of file ops.h.


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