HideNodeAction 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 HideNodeAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 HideNodeAction ()
 HideNodeAction constructor.
virtual ActionCode Execute ()
 Executes the HideNodeAction which hides the node. It also creates a ShowNodeAction and adds it to the opposite ActionList.
CCRuntimeClassGetClassOfAttrNodeToHide () const
void RecordTag (Node *NodeToHide)

Static Public Member Functions

static ActionCode Init (Operation *const pOp, ActionList *pActionList, Node *NodeToHide, 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

Nodenode
CCRuntimeClassClassOfAttributeToHide
TAG m_nHiddenWixAttrTag
BOOL IncludeSubtreeSize:1
BOOL TellSubtree:1
BOOL m_bEffect:1

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:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/93
See also:
ShowNodeAction

Definition at line 827 of file ops.h.


Constructor & Destructor Documentation

HideNodeAction::HideNodeAction  ) 
 

HideNodeAction constructor.

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

Errors: -

See also:
-

Definition at line 3067 of file ops.cpp.

03068   : node(0),
03069     ClassOfAttributeToHide(0),
03070     m_nHiddenWixAttrTag(0),
03071     IncludeSubtreeSize(FALSE),
03072     TellSubtree(FALSE),
03073     m_bEffect(FALSE)
03074 {
03075     // Empty.
03076 }   


Member Function Documentation

ActionCode HideNodeAction::Execute  )  [virtual]
 

Executes the HideNodeAction which hides the node. It also creates a ShowNodeAction and adds it 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 3190 of file ops.cpp.

03191 {
03192     ShowNodeAction* ShwNodeAct;  
03193     ActionCode ActCode;  
03194 
03195     NodeHidden* HideNode; 
03196 
03197     // Tell our parent that we have changed so any cached info he has must be removed
03198     // (Deals with cases where DoInvalidateRegion has been used and so no other
03199     //  cache release calls have been made)
03200     if (node->IsBounded())
03201         ((NodeRenderableBounded*)node)->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
03202 
03203     // Determine which node needs hiding
03204     Node* NodeToHide = NULL;
03205     if (ClassOfAttributeToHide != NULL) // An attribute is being hidden
03206     {
03207 ERROR3IF(node->DiscardsAttributeChildren(), "HideNodeAction Execute under Caret\n");
03208         // We need to search the children of node to find the attribute
03209         Node* CurrentChild = node->FindFirstChild();
03210         while (CurrentChild != NULL)
03211         {
03212             if (CurrentChild->GetRuntimeClass() == ClassOfAttributeToHide)
03213             {
03214 #ifdef _HIDENODE_DETECTEFFECTS
03215                 if ((m_bEffect!=0) == ((NodeAttribute*)CurrentChild)->IsEffectAttribute() &&
03216                     (m_nHiddenWixAttrTag == 0 || m_nHiddenWixAttrTag == CurrentChild->GetTag()))
03217 #else
03218                 if ((m_nHiddenWixAttrTag == 0 || m_nHiddenWixAttrTag == CurrentChild->GetTag()))
03219 #endif
03220                 {
03221                     // We have found the attribute to hide
03222                     NodeToHide = CurrentChild;
03223                     break;
03224                 }
03225             }
03226             CurrentChild = CurrentChild->FindNext();
03227         }
03228 
03229         // This bit is v. scary
03230         if (NodeToHide == NULL)
03231         {
03232             // The attribute isnot where we left it last time. This could be due to a 
03233             // bitmap being deleted.
03234             ERROR3("Could not find attribute node to hide (Press continue for a fix :-)");
03235             return (ExtremeTerror(ClassOfAttributeToHide, node, 
03236                                   pOperation, pOppositeActLst, 
03237                                   TellSubtree, IncludeSubtreeSize)); 
03238         } 
03239     }
03240     else
03241     {
03242         NodeToHide = node; 
03243     }
03244 
03245     // Tell the node it's subtree, we are about to hide it
03246     if (TellSubtree)
03247     {
03248         Node* pNode = NodeToHide->FindFirstDepthFirst();
03249         while (pNode!=NULL)
03250         {
03251             if (!pNode->HidingNode())
03252                 return AC_FAIL;
03253 
03254             // And find the next node
03255             pNode = pNode->FindNextDepthFirst(NodeToHide);
03256         }
03257     }
03258 
03259     // The bounding rect of the parents to the node may well be changing
03260     if (NodeToHide->IsBounded())
03261     {
03262         ((NodeRenderableBounded*)NodeToHide)->InvalidateBoundingRect();
03263     }
03264     else if (NodeToHide->GetRuntimeClass() == CC_RUNTIME_CLASS(AttrLineWidth))
03265     {
03266         // If the node being hidden is an attribute which will effect the bounds of it's parent
03267         // bounded object then we must invalidatate the parents bounds
03268         Node* Parent = NodeToHide->FindParent(); 
03269         if (Parent != NULL)
03270         {
03271             if(Parent->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)))
03272             { 
03273                 ((NodeRenderableBounded*)Parent)->InvalidateBoundingRect();     
03274             }
03275         }
03276     }                 
03277         
03278     // Attempt to hide the node 
03279     ALLOC_WITH_FAIL(HideNode, new NodeHidden(NodeToHide),pOperation); 
03280 
03281     if (HideNode == NULL)
03282     {
03283         // We were unable to hide the node so fail 
03284         return AC_FAIL;         
03285     }
03286 
03287     if (NodeToHide->IsSelected())
03288     {
03289         // Update the selection range 
03290         Camelot.UpdateSelection();
03291     }
03292 
03293     Spread* ParentOfNode = NULL;
03294 
03295     Layer * pLayer = NULL;
03296     if (NodeToHide->GetRuntimeClass() == CC_RUNTIME_CLASS(Layer))
03297     {
03298         ParentOfNode = (Spread*) HideNode->FindParent(CC_RUNTIME_CLASS(Spread));
03299         pLayer = (Layer*)NodeToHide;
03300     }
03301 
03302     // New 31/7/97 Neville
03303     // Mark the parent layer as edited as something has changed on it
03304     // Could use SetParentLayerAsEdited but only implemented for NodeRenderableInk at present
03305     if (pLayer == NULL)
03306         pLayer = (Layer*) HideNode->FindParent(CC_RUNTIME_CLASS(Layer));
03307     if (pLayer)
03308     {
03309             // Note that this layer has been edited
03310             pLayer->SetEdited(TRUE);
03311 #ifdef _DEBUG
03312             // Tell the frame gallery to update its display of the frame
03313             BROADCAST_TO_ALL( LayerMsg(pLayer, LayerMsg::REDRAW_LAYER ) );
03314 #endif
03315     }
03316 
03317     // Attempt to initialise the show node action which will show the node that 
03318     // we have just hidden. 
03319     if ((ActCode = ShowNodeAction::Init(pOperation,                    
03320                                         pOppositeActLst,  
03321                                         HideNode, 
03322                                         IncludeSubtreeSize, 
03323                                         ( Action**)(&ShwNodeAct),
03324                                         TellSubtree)) == AC_FAIL) 
03325     { 
03326         // Show the node 
03327         HideNode->ShowNode();                   
03328     }   
03329     
03330     // If the node being hidden is a layer then people need to know about it
03331     if (ParentOfNode)
03332     {
03333         BROADCAST_TO_ALL(SpreadMsg(ParentOfNode,SpreadMsg::LAYERCHANGES));
03334     }
03335           
03336     return (ActCode);                        
03337 }    

CCRuntimeClass* HideNodeAction::GetClassOfAttrNodeToHide  )  const [inline]
 

Definition at line 841 of file ops.h.

00844         { return ClassOfAttributeToHide; }

ActionCode HideNodeAction::Init Operation *const   pOp,
ActionList pActionList,
Node NodeToHide,
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:
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

NodeToHide: The node to hide

IncludeSubtreeSize: The size of a HideNodeAction is always sizeof(HideNodeAction), 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 HideNodeAction.

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

Definition at line 3386 of file ops.cpp.

03393 {  
03394     ActionCode Ac = (Action::Init(pOp,
03395                      pActionList,
03396                      sizeof(HideNodeAction), 
03397                      CC_RUNTIME_CLASS(HideNodeAction), 
03398                      NewAction)); 
03399 
03400     if (*NewAction != NULL) 
03401     {
03402         // Only used for attributes
03403         ((HideNodeAction*) (*NewAction))->ClassOfAttributeToHide = 0;
03404 
03405         // Do special things if the node to be hidden is an attribute
03406         if (NodeToHide->IsAnAttribute())
03407         {
03408             // Find the parent of the attribute node
03409             Node* AttributeParent = NodeToHide->FindParent();
03410 
03411             // We store the attribute's parent
03412             ((HideNodeAction*)(*NewAction))->node = AttributeParent; 
03413             ERROR2IF(AttributeParent == NULL, AC_FAIL, "Attribute has no parent"); 
03414 
03415             // It is bad if the attributes parent is an attribute, attributes are not safe anchors
03416             // they can be deleted. 
03417             ERROR2IF(AttributeParent->IsAnAttribute(), AC_FAIL, "Attribute's parent is an attribute");  
03418 
03419             // Store the runtime class of the attribute so that we can find it
03420             ((HideNodeAction*)(*NewAction))->ClassOfAttributeToHide = NodeToHide->GetRuntimeClass(); 
03421 
03422             // If it's also a Wix attribute then store its tag so it can be uniquely identified
03423             // when the attribute must be hidden again.
03424 #ifdef _HIDENODE_DETECTEFFECTS
03425             if (NodeToHide->IS_KIND_OF(TemplateAttribute))
03426 #else
03427             if (NodeToHide->IS_KIND_OF(TemplateAttribute) || ((NodeAttribute*)NodeToHide)->IsEffectAttribute())
03428 #endif
03429                 ((HideNodeAction*) (*NewAction))->m_nHiddenWixAttrTag = NodeToHide->GetTag();
03430             else
03431                 ((HideNodeAction*) (*NewAction))->m_nHiddenWixAttrTag = 0;
03432 
03433             ((HideNodeAction*) (*NewAction))->m_bEffect = ((NodeAttribute*)NodeToHide)->IsEffectAttribute();
03434         }
03435         else
03436         {
03437             ((HideNodeAction*)(*NewAction))->node = NodeToHide;
03438         }
03439 
03440         ((HideNodeAction*)(*NewAction))->IncludeSubtreeSize = IncludeSubtreeSize; 
03441         ((HideNodeAction*)(*NewAction))->TellSubtree = TellSubtree; 
03442     }
03443                   
03444     return (Ac); 
03445 }

void HideNodeAction::RecordTag Node NodeToHide  ) 
 

Definition at line 3447 of file ops.cpp.

03448 {
03449     if (NodeToHide->IsAnAttribute())
03450     {
03451         // Find the parent of the attribute node
03452 //      Node* AttributeParent = NodeToHide->FindParent();
03453 
03454         // If it's also a Wix attribute then store its tag so it can be uniquely identified
03455         // when the attribute must be hidden again.
03456 #ifdef _HIDENODE_DETECTEFFECTS
03457         if (NodeToHide->IS_KIND_OF(TemplateAttribute))
03458 #else
03459         if (NodeToHide->IS_KIND_OF(TemplateAttribute) || ((NodeAttribute*)NodeToHide)->IsEffectAttribute())
03460 #endif
03461             m_nHiddenWixAttrTag = NodeToHide->GetTag();
03462         else
03463             m_nHiddenWixAttrTag = 0;
03464 
03465         m_bEffect = ((NodeAttribute*)NodeToHide)->IsEffectAttribute();
03466     }
03467 }


Member Data Documentation

CCRuntimeClass* HideNodeAction::ClassOfAttributeToHide [private]
 

Definition at line 862 of file ops.h.

BOOL HideNodeAction::IncludeSubtreeSize [private]
 

Definition at line 879 of file ops.h.

BOOL HideNodeAction::m_bEffect [private]
 

Definition at line 881 of file ops.h.

TAG HideNodeAction::m_nHiddenWixAttrTag [private]
 

Definition at line 870 of file ops.h.

Node* HideNodeAction::node [private]
 

Definition at line 858 of file ops.h.

BOOL HideNodeAction::TellSubtree [private]
 

Definition at line 880 of file ops.h.


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