ShowNodeAction Class Reference

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

#include <ops.h>

Inheritance diagram for ShowNodeAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ShowNodeAction ()
 ShowNodeAction constructor.
virtual ~ShowNodeAction ()
virtual void Slaughter ()
 destructor which gets called when an operation is deleted
virtual ActionCode Execute ()
 Executes the ShowNodeAction which un-hides the node. It also creates a HideNodeAction and adds it to the opposite ActionList.

Static Public Member Functions

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

NodeHidden * node
BOOL IncludeSubtreeSize:1
BOOL TellSubtree:1

Detailed Description

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

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

Definition at line 898 of file ops.h.


Constructor & Destructor Documentation

ShowNodeAction::ShowNodeAction (   ) 
 

ShowNodeAction constructor.

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

Errors: -

See also:
-

Definition at line 3487 of file ops.cpp.

03488 {
03489 }

ShowNodeAction::~ShowNodeAction (   )  [virtual]
 

Definition at line 3491 of file ops.cpp.

03492 {
03493 }   


Member Function Documentation

ActionCode ShowNodeAction::Execute (   )  [virtual]
 

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

03560 {  
03561     HideNodeAction* HideNodeAct;  
03562     ActionCode ActCode;  
03563 
03564     // If the HideNodeAction is for a NodeAttribute then this node must have a parent before
03565     // we call the HideNodeAction's Init method. However because it is hidden it does not have one at
03566     // the moment. So we use the SetParentDangerous function to give it the parent of the NodeHidden.
03567     // This is horrible but it is the safest thing to do. If we call node->ShowNode before calling
03568     // HideNodeAction::Init then we are shafted if this function fails. (The action will not be atomic)
03569   
03570     node->HiddenNd->SetParentDangerous(node->FindParent()); 
03571 
03572      // Attempt to initialise the hide node action  
03573     if ((ActCode = HideNodeAction::Init(pOperation,                    
03574                                         pOppositeActLst, 
03575                                         node->HiddenNd, 
03576                                         IncludeSubtreeSize,  
03577                                         ( Action**)(&HideNodeAct),
03578                                         TellSubtree)) != AC_FAIL) 
03579     {                 
03580         Node* BackFromTheDead = node->ShowNode();
03581         Node* Parent = BackFromTheDead->FindParent(); 
03582 ERROR3IF(Parent->DiscardsAttributeChildren(), "ShowNodeAction Execute under Caret\n");
03583 
03584         // Urgh - we can only tell whether an attribute is an effect attr when it's in the tree
03585         // And we need to give the HideNodeAction the Tag of the attribute if it is an
03586         // Effect Attribute so that HideNodeExecute finds it correctly...
03587         if (HideNodeAct)
03588             HideNodeAct->RecordTag(BackFromTheDead);
03589 
03590         // Tell the node and it's subtree, we have re-shown it
03591         if (TellSubtree)
03592         {
03593             Node* pNode = BackFromTheDead->FindFirstDepthFirst();
03594             while (pNode!=NULL)
03595             {
03596                 if (!pNode->ShowingNode())
03597                     return AC_FAIL;
03598 
03599                 // And find the next node
03600                 pNode = pNode->FindNextDepthFirst(BackFromTheDead);
03601             }
03602         }
03603 
03604         if (BackFromTheDead->IsSelected())
03605         {
03606             // Update the selection range 
03607             Camelot.UpdateSelection();
03608         }
03609 
03610         // If the node being shown is a layer then people need to know about it
03611         Layer * pLayer = NULL;
03612         if (BackFromTheDead->GetRuntimeClass() == CC_RUNTIME_CLASS(Layer))
03613         {
03614             Spread* pSpread = (Spread*) BackFromTheDead->FindParent(CC_RUNTIME_CLASS(Spread)); 
03615             BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
03616             pLayer = (Layer*)BackFromTheDead;
03617         }
03618 
03619         // Mark the bounding rects as out of date
03620         if (BackFromTheDead->IsBounded())
03621         {
03622             // Since this nodes bounding rect may well be invalid while it was hidden, we
03623             // have to validate it to be sure the invalidation ripples up through the tree
03624             ((NodeRenderableBounded*)BackFromTheDead)->ValidateBoundingRect();
03625             ((NodeRenderableBounded*)BackFromTheDead)->InvalidateBoundingRect();
03626         }
03627         else if (BackFromTheDead->GetRuntimeClass() == CC_RUNTIME_CLASS(AttrLineWidth))
03628         {
03629             // If the node being shown is an attribute which will effect the bounds of it's parent
03630             // bounded object then we must invalidatate the parent's bounds
03631             if (Parent != NULL)
03632             {
03633                 if(Parent->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)))
03634                 { 
03635                     ((NodeRenderableBounded*)Parent)->InvalidateBoundingRect();     
03636                 }
03637             }
03638         }
03639 
03640         // New 31/7/97 Neville
03641         // Mark the parent layer as edited as something has changed on it
03642         // Could use SetParentLayerAsEdited but only implemented for NodeRenderableInk at present
03643         if (pLayer == NULL)
03644             pLayer = (Layer*) BackFromTheDead->FindParent(CC_RUNTIME_CLASS(Layer));
03645         if (pLayer)
03646         {
03647                 // Note that this layer has been edited
03648                 pLayer->SetEdited(TRUE);
03649 #ifdef _DEBUG
03650                 // Tell the frame gallery to update its display of the frame
03651                 BROADCAST_TO_ALL( LayerMsg(pLayer, LayerMsg::REDRAW_LAYER ) );
03652 #endif
03653 
03654     // Tell our parent that we have changed so any cached info he has must be removed
03655     // (Deals with cases where DoInvalidateRegion has been used and so no other
03656     //  cache release calls have been made)
03657     if (BackFromTheDead->IsBounded())
03658         ((NodeRenderableBounded*)BackFromTheDead)->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
03659     else if (Parent->IsBounded())
03660         ((NodeRenderableBounded*)Parent)->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
03661 
03662         }
03663     }
03664     else
03665     {
03666         node->HiddenNd->SetParentDangerous(NULL); // The node was never un-hidden so we must give it a NULL parent
03667 
03668     }                 
03669     return (ActCode);                   
03670 }     

ActionCode ShowNodeAction::Init (  Operation *const   pOp,
ActionList *  pActionList,
NodeHidden *  HiddenToShow,
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

HiddenToShow: The hidden node to show when the action is executed

IncludeSubtreeSize: This flag should be set if the action size should include the size of the subtree which is hidden.

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

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

Definition at line 3719 of file ops.cpp.

03725 { 
03726     // Determine the size of the action 
03727     UINT32 ActionSize; 
03728 
03729     ActionSize = sizeof(ShowNodeAction); 
03730     
03731     // If the subtree being hidden is to be considered to belong to the operation history 
03732     // then the ActionSize must include the size of the hidden subtree. 
03733 
03734     if (IncludeSubtreeSize)
03735     {
03736         ActionSize += ( HiddenToShow->HiddenNd->GetSubtreeSize());
03737         //if (IsUserName("Simon"))
03738         //  TRACE( _T("ShowNodeActionSize = %lu"), ActionSize);  
03739         
03740     }
03741 
03742     ActionCode Ac = (Action::Init(pOp,
03743                      pActionList,
03744                      ActionSize,
03745                      CC_RUNTIME_CLASS(ShowNodeAction), 
03746                      NewAction));
03747     if (*NewAction != NULL) 
03748     {
03749         ((ShowNodeAction*)(*NewAction))->node = HiddenToShow;
03750         ((ShowNodeAction*)(*NewAction))->IncludeSubtreeSize = IncludeSubtreeSize; 
03751         ((ShowNodeAction*)(*NewAction))->TellSubtree = TellSubtree; 
03752     }
03753 
03754     return (Ac); 
03755 } 

void ShowNodeAction::Slaughter (  void   )  [virtual]
 

destructor which gets called when an operation is deleted

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

Errors: -

See also:
Action::Slaughter

Reimplemented from Action.

Definition at line 3510 of file ops.cpp.

03511 {               
03512     // If the node which the NodeHidden hides has no parent and the node is not refferenced 
03513     // by any other NodeHidden nodes, then the node can safely be deleted.  
03514 
03515     // On the other-hand if the node which the NodeHidden hides has a parent, then it must not
03516     // be deleted. This situation arises when we have moved a node and the NodeHidden is simply
03517     // used as a place holder for when we undo/redo.  
03518                       
03519     // First delete the NodeHidden                                              
03520     Node* Hidden = node->HiddenNd; // Remember the node which it hides !
03521     node->CascadeDelete(); // Simply unlinks the node from the tree, node should 
03522                            // never have any children because it's a NodeHidden.  
03523     delete (node);  
03524     
03525     Hidden->DecHiddenCnt(); // Decrement the number of refferences to the hidden node.            
03526                       
03527     if (Hidden->FindParent() == NULL)
03528     {
03529         // The node which is hidden has no parent but it could be reffered to by other 
03530         // hidden nodes which as yet have not been deleted.                              
03531         
03532         if (Hidden->GetHiddenCnt() == 0) // The node is not hidden by any NodeHidden nodes.    
03533         {
03534             Hidden->CascadeDelete(); // Delete the children of the hidden node.
03535             delete (Hidden);         // Delete the hidden node itself 
03536         }
03537         
03538     } 
03539     Action::Slaughter(); // Call base class to destroy this 
03540 }   


Member Data Documentation

BOOL ShowNodeAction::IncludeSubtreeSize [private]
 

Definition at line 918 of file ops.h.

NodeHidden* ShowNodeAction::node [private]
 

Definition at line 914 of file ops.h.

BOOL ShowNodeAction::TellSubtree [private]
 

Definition at line 919 of file ops.h.


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