OpMoveToLyrBehind Class Reference

This class represents the move to layer behind operation. More...

#include <zordops.h>

Inheritance diagram for OpMoveToLyrBehind:

SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpMoveToLyrBehind ()
 OpMoveToLyrBehind constructor.
void Do (OpDescriptor *)
 Performs the OpMoveToLyrBehind operation. This moves all selected nodes (which are not on the lowest visible layer) to the highest z-order position on the next visible layer behind.
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

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

Detailed Description

This class represents the move to layer behind operation.

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

OpPutToBack

OpMoveForwards

OpMoveBackwards

OpMoveToLyrInFront Documentation: specs.doc

Definition at line 284 of file zordops.h.


Constructor & Destructor Documentation

OpMoveToLyrBehind::OpMoveToLyrBehind  ) 
 

OpMoveToLyrBehind constructor.

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

Errors: -

See also:
-

Definition at line 2539 of file zordops.cpp.

02539                                     : SelOperation()                                
02540 {                              
02541 }


Member Function Documentation

void OpMoveToLyrBehind::Do OpDescriptor  )  [virtual]
 

Performs the OpMoveToLyrBehind operation. This moves all selected nodes (which are not on the lowest visible layer) to the highest z-order position on the next visible layer behind.

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 2794 of file zordops.cpp.

02795 {
02796     // Obtain the current selections 
02797     Range Sel(*(GetApplication()->FindSelection()));
02798     RangeControl rg = Sel.GetRangeControlFlags();
02799     rg.PromoteToParent = TRUE;
02800     Sel.Range::SetRangeControl(rg);
02801 
02802 
02803     // Find the first node which is selected 
02804     Node* FirstSelectedNode = Sel.FindFirst(); 
02805  
02806     // The first selected node should not ever be NULL
02807     ENSURE(FirstSelectedNode != NULL, 
02808         "The OpMoveToLyrInFront's GetState fn has not done a very good job"); 
02809     
02810     if (FirstSelectedNode != NULL) 
02811     {
02812         if (!DoStartSelOp(FALSE,FALSE))  // Try to record the selection state , don't
02813                                          // render the blobs though 
02814         {
02815             goto EndOperation;  
02816         }
02817 
02818         // We need to invalidate the region
02819         if (!DoInvalidateNodesRegions(Sel, TRUE, FALSE, FALSE, FALSE))
02820         {
02821             goto EndOperation; 
02822         }
02823 
02824         Node*   CurrentNode             = FirstSelectedNode; 
02825         
02826 //      RangeControl LyrCntrl = { TRUE, FALSE, FALSE };  // Selected + don't cross layers  
02827         Range   LayerRange; 
02828 
02829         Node*   Destination             = NULL; // Pointer to the last child of the previous layer.
02830                                                 // We move all nodes to be next siblings of this node
02831         Node*   ThisLayer               = NULL;
02832         Layer*  PrevLayer               = NULL;
02833         Node*   LastSelectedThisLayer   = NULL;
02834         Node*   NextNode                = NULL;
02835 
02836         BOOL    OldVisible              = FALSE;
02837         BOOL    OldLocked               = FALSE;
02838 
02839 #ifndef WEBSTER
02840         MODE PresentMode                = LAYER;
02841 #endif
02842         // Loop for all layers
02843         while (CurrentNode != NULL)
02844         {
02845             ENSURE(CurrentNode->IsAnObject(), "Non ink node in OpMoveToLyrBehind");
02846 
02847             // Create a range of selected nodes on this layer
02848             Range temp(CurrentNode, 
02849                                NULL, 
02850                                RangeControl(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) );
02851             LayerRange = temp;
02852 //          LayerRange = Range(CurrentNode, 
02853 //                             NULL, 
02854 //                             RangeControl(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) );
02855 
02856             // -----------------------------------------------------------------------------
02857             // Find the last child object of the previous visible layer, which is the destination for all
02858             // nodes moved from this layer.
02859             // - there may not be a previous layer
02860             // - there may not be any children on the previous layer
02861             Destination = NULL;
02862 
02863             ThisLayer = CurrentNode->FindParent(CC_RUNTIME_CLASS(Layer));
02864 
02865             if (ThisLayer != NULL)
02866                 ((Layer*)ThisLayer)->InvalidateBoundingRect();
02867                         
02868 // WEBSTER - markn 2/2/97
02869 // Not needed in Webster.
02870 // Neville 23/6/97 Now needed but must work in Frame mode in Webster
02871 // RanbirR - 28/10/97 - Changed for Camelot v2, Frame/Layer integration. 
02872 
02873 #ifdef WEBSTER
02874             // ----------------------------------------------------------------------------
02875             // Find the previous frame
02876             PrevLayer = (Layer*)ThisLayer;
02877             do
02878             {
02879                 PrevLayer = PrevLayer->FindPrevFrameLayer();
02880                 if (PrevLayer != NULL)
02881                 {
02882                     // Is the layer not a guide or a page background layer?
02883                     if (!PrevLayer->IsGuide() && !PrevLayer->IsPageBackground())
02884                     {
02885                         // found
02886                         break;
02887                     }
02888                 }
02889                 
02890             } while (PrevLayer != NULL); 
02891 
02892             if (PrevLayer != NULL)
02893             {
02894                 // Make the layer visible and editable so we don't loose the selection
02895                 // do it blatently as it will be fixed up properly latter
02896                 OldVisible = PrevLayer->IsVisible();
02897                 OldLocked = PrevLayer->IsLocked();
02898                 PrevLayer->SetVisible(TRUE);
02899                 PrevLayer->SetLocked(FALSE);
02900             }
02901 
02902 #else
02903             // -----------------------------------------------------------------------------
02904 
02905             // Determine the document mode.
02906             PrevLayer = (Layer*)ThisLayer;
02907             PresentMode = (MODE)PrevLayer->IsFrame();
02908 
02909             if(PresentMode == LAYER)
02910             {
02911                 do
02912                 {
02913                     PrevLayer = (Layer*)(PrevLayer->FindPrevious(CC_RUNTIME_CLASS(Layer)));
02914                     if (PrevLayer != NULL)
02915                     {
02916                         if (PrevLayer->IsVisible() && !PrevLayer->IsLocked() && !PrevLayer->IsGuide())
02917                         {
02918                             // found
02919                             break;
02920                         }
02921                     }
02922                     
02923                 } while (PrevLayer != NULL); 
02924 
02925                 if (PrevLayer != NULL)
02926                 {
02927                     // Make the layer visible and editable so we don't loose the selection
02928                     // do it blatently as it will be fixed up properly latter
02929                     OldVisible = PrevLayer->IsVisible();
02930                     OldLocked = PrevLayer->IsLocked();
02931                     PrevLayer->SetVisible(TRUE);
02932                     PrevLayer->SetLocked(FALSE);
02933                 }
02934             }
02935             else if (PresentMode == FRAME)
02936             {
02937                 // Find the previous visible layer
02938                 do
02939                 {
02940                     PrevLayer = PrevLayer->FindPrevFrameLayer();
02941                     if (PrevLayer != NULL)
02942                     {
02943                         // Is the layer not a guide or a page background layer?
02944                         if (!PrevLayer->IsGuide() && !PrevLayer->IsPageBackground())
02945                         {
02946                             // found
02947                             break;
02948                         }
02949                     }
02950                 
02951                 } while (PrevLayer != NULL); 
02952 
02953                 if (PrevLayer != NULL)
02954                 {
02955                     // Make the layer visible and editable so we don't loose the selection
02956                     // do it blatently as it will be fixed up properly latter
02957                     OldVisible = PrevLayer->IsVisible();
02958                     OldLocked = PrevLayer->IsLocked();
02959                     PrevLayer->SetVisible(TRUE);
02960                     PrevLayer->SetLocked(FALSE);
02961                 }
02962             }
02963             else
02964                 ERROR3("OpMoveToLyrBehind::Do - Bad mode");
02965 #endif
02966             if (PrevLayer != NULL)
02967             {
02968                 PrevLayer->InvalidateBoundingRect();
02969 
02970                 Destination = PrevLayer->FindLastChild();
02971                 
02972                 if (Destination != NULL)  // It will be NULL if there are no objects on the
02973                                                // previous layer
02974                 {
02975                     // The Destination node could be an Insertion node, we certainly don't want to insert
02976                     // after that
02977                     if (!(Destination->IsAnObject()))
02978                     {
02979                         Destination = Destination->FindPrevious(CC_RUNTIME_CLASS(NodeRenderableInk));   
02980                     }
02981 
02982                 }
02983             } 
02984 
02985             // If there is a previous layer then shift all selected nodes 
02986             // on this layer to the layer behind.
02987             do
02988             {
02989                 NextNode = LayerRange.FindNext(CurrentNode); // Hand over hand
02990 
02991                 if (PrevLayer != NULL)   
02992                 {
02993                     if (Destination == NULL)
02994                     {
02995                         // The destination is NULL which means that the layer
02996                         // has no existing objects
02997                         ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
02998                         if (!DoMoveNode(CurrentNode, PrevLayer, FIRSTCHILD)) 
02999                         {
03000                             goto EndOperation;
03001                         }
03002 
03003                         ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
03004                         CurrentNode->SetSelected(TRUE);
03005                     }
03006                     else
03007                     {
03008                         ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
03009                         if (!DoMoveNode(CurrentNode, Destination, NEXT)) 
03010                         {
03011                             goto EndOperation;
03012                         }
03013 
03014                         ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
03015                         CurrentNode->SetSelected(TRUE);
03016                     }
03017                     Destination = CurrentNode; 
03018                 } 
03019 
03020 
03021                 LastSelectedThisLayer = CurrentNode;  // Used to find first 
03022                                                       // selected on next layer
03023 
03024                 CurrentNode = NextNode; 
03025             
03026             } while (CurrentNode != NULL);
03027 
03028 // #ifdef WEBSTER //  Include in Camelot2 for Frame/Layer integration - RanbirR 03/11/97
03029 #ifdef WEBSTER
03030             if (PrevLayer != NULL)
03031 #else
03032             if (PrevLayer != NULL && PresentMode == FRAME)
03033 #endif
03034             {
03035                 // Put back the old states so we get the redraw correct
03036                 PrevLayer->SetVisible(OldVisible);
03037                 //PrevLayer->SetLocked(OldLocked);
03038             }
03039 
03040 //#endif    
03041             // Obtain the first selected node of the next layer
03042             CurrentNode = Sel.FindNext(LastSelectedThisLayer); 
03043         } 
03044         
03045 //#ifdef WEBSTER    Include in Camelot2 for Frame/Layer integration - RanbirR 03/11/97  
03046 
03047         // Switch to viewing the destination layer
03048         // Otherwise, the user will see the objects dissappear and will be worried
03049         // Also, the range blows up as the destination is invisible
03050 #ifdef WEBSTER //  Include in Camelot2 for Frame/Layer integration - RanbirR 03/11/97
03051         if (PrevLayer != NULL)
03052 #else
03053         if (PrevLayer != NULL && PresentMode == FRAME)
03054 #endif
03055         {
03056 PORTNOTETRACE("gallery", "Removed used of FrameSGallery from OpMoveToLyrBehind");
03057 #if !defined(EXCLUDE_FROM_XARALX)
03058             FrameSGallery::MakeActiveLayer(PrevLayer);
03059             BROADCAST_TO_ALL(LayerMsg(PrevLayer,LayerMsg::UPDATE_ACTIVE_LAYER));
03060 #endif
03061         }
03062 
03063 //#endif // WEBSTER     
03064         
03065         // We need to invalidate the region
03066         if (!DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE))
03067         {
03068             goto EndOperation; 
03069         }
03070 
03071         // Call ChangeBounds() on the first node to ensure all parent node bounds contain
03072         // the newly moved nodes bounds
03073         if (FirstSelectedNode->IsBounded())
03074         {
03075             NodeRenderableBounded* pNodeRB = (NodeRenderableBounded*)FirstSelectedNode;
03076             pNodeRB->InvalidateBoundingRect();
03077         }
03078     }
03079 
03080 EndOperation:
03081     GetApplication()->UpdateSelection();
03082 
03083     End(); // End of operation  
03084 
03085 } 

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

For finding OpMoveToLyrBehind's state.

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

Errors: -

See also:
-

Definition at line 2608 of file zordops.cpp.

02609 {
02610     OpState OpSt;
02611 
02612     // In Camelot, work as before in layer mode
02613     // In Webster, work only on frame layers
02614     // This should never go off in Webster but we will leave it in just in case
02615     String_256 DisableReason;
02616 
02617     SelRange Sel(*(GetApplication()->FindSelection()));
02618     RangeControl rg = Sel.GetRangeControlFlags();
02619     rg.PromoteToParent = TRUE;
02620     Sel.Range::SetRangeControl(rg);
02621 
02622     Node* pNode = Sel.FindFirst();
02623     while (pNode != NULL)
02624     {
02625         Node* pLayer = pNode->FindParent(CC_RUNTIME_CLASS(Layer));
02626         if (pLayer != NULL && ((Layer*)pLayer)->IsGuide())
02627         {
02628             *UIDescription = String_256(_R(IDS_CANT_MOVE_OFF_GUIDE_LAYER));
02629             OpSt.Greyed = TRUE;
02630             return OpSt;
02631         }
02632 
02633         pNode = Sel.FindNext(pNode);
02634     }
02635 
02636 // WEBSTER - markn 2/2/97
02637 // Not needed in Webster. Now required but must be frame orientated
02638 // RanbirR - 28/10/97 - Changed for Camelot v2, Frame/Layer integration. 
02639 
02640 #ifdef WEBSTER
02641     // We need to work in Frame mode in Webster
02642 
02643     // The operation is disabled if there does not exist a selected node on a layer 
02644     // which is not the bottom-most layer.
02645     
02646     // Find the first node which is selected 
02647     Node* pLastSelectedNode = Sel.FindLast(); 
02648          
02649     // The operation is disabled if the last selected object is already on the lowest
02650     // visible layer.
02651     BOOL LowestVisible = TRUE; 
02652     Layer* pCurrentLayer = (Layer*) (pLastSelectedNode->FindParent(CC_RUNTIME_CLASS(Layer)));
02653     ERROR2IF(pCurrentLayer == NULL, OpSt, "Cannot find layer of first selected object"); 
02654     do
02655     {
02656         pCurrentLayer = pCurrentLayer->FindPrevFrameLayer();
02657         if (pCurrentLayer != NULL)
02658         {
02659             // Is the layer not a guide or a page background layer?
02660             if (!pCurrentLayer->IsGuide() && !pCurrentLayer->IsPageBackground())
02661             {
02662                 LowestVisible = FALSE; // The last node selected is not on the lowest visible frame
02663                                        // so the operation can be performed. 
02664                 break;
02665             }
02666         } 
02667     } while (pCurrentLayer != NULL);   
02668 
02669 #else
02670 
02671     // Find the first node which is selected 
02672     Node* pLastSelectedNode = Sel.FindLast();
02673     
02674     // Karim 18/04/2000 - spot-check! - any NULL pointers??
02675     if (pLastSelectedNode == NULL)
02676     {
02677         // fail in the same way as the layer check below, but we'll only complaing in debug.
02678         ERROR3("OpMoveToLyrBehind::GetState; NULL returned as last node in Selection!");
02679         return OpSt;
02680     }
02681 
02682     // The operation is disabled if the last selected object is already on the lowest
02683     // visible layer.
02684     BOOL LowestVisible = TRUE; 
02685     Layer* pCurrentLayer = (Layer*) (pLastSelectedNode->FindParent(CC_RUNTIME_CLASS(Layer)));
02686     ERROR2IF(pCurrentLayer == NULL, OpSt, "Cannot find layer of first selected object"); 
02687 
02688     // Determine the Document mode. 
02689     MODE PresentMode = (MODE)pCurrentLayer->IsFrame();
02690     if (PresentMode == LAYER)
02691     {
02692         do
02693         {
02694             pCurrentLayer = pCurrentLayer->FindPrevLayer();
02695             if (pCurrentLayer != NULL)
02696             {
02697                 // Is the layer visible
02698                 if (pCurrentLayer->IsVisible() && !pCurrentLayer->IsLocked() && !pCurrentLayer->IsGuide())
02699                 {
02700                         LowestVisible = FALSE; // The last node selected is not on the lowest visible layer
02701                                         // so the operation can be performed. 
02702                     break;
02703                 }
02704             } 
02705         } while (pCurrentLayer != NULL);   
02706     }
02707     else if (PresentMode == FRAME)
02708     {
02709         do
02710         {
02711             pCurrentLayer = pCurrentLayer->FindPrevFrameLayer();
02712             if (pCurrentLayer != NULL)
02713             {
02714                 // Is the layer not a guide or a page background layer?
02715                 if (!pCurrentLayer->IsGuide() && !pCurrentLayer->IsPageBackground())
02716                 {
02717                     LowestVisible = FALSE; // The last node selected is not on the lowest visible frame
02718                                            // so the operation can be performed. 
02719                     break;
02720                 }
02721             } 
02722         } while (pCurrentLayer != NULL);   
02723     }
02724     else
02725         ERROR3("OpMoveToLyrInFront::GetState - Bad mode!");
02726 #endif // WEBSTER
02727 
02728     if (LowestVisible)
02729     {
02730         // The operation must be disabled
02731         OpSt.Greyed = TRUE;
02732 
02733 
02734         if (Sel.FindFirst() == pLastSelectedNode)
02735         {
02736             #ifdef WEBSTER
02737                 // There is only a single selected node
02738                 DisableReason = String_256(_R(IDS_ALREADY_ON_BOTTOM_FRMS));                 
02739             #else
02740                 if(PresentMode == FRAME)
02741                     DisableReason = String_256(_R(IDS_ALREADY_ON_BOTTOM_FRMS));                 
02742                 else if(PresentMode == LAYER)
02743                     DisableReason = String_256(_R(IDS_ALREADY_ON_BOTTOM_LYRS)); 
02744                 else
02745                     ERROR3("OpMoveToLyrInBehind::GetState - Bad mode!");
02746             #endif
02747         }
02748         else
02749         {
02750             #ifdef WEBSTER
02751                 // There is more than one selected node
02752                 DisableReason = String_256(_R(IDS_ALREADY_ON_BOTTOM_FRM));  
02753             #else
02754                 if(PresentMode == FRAME)
02755                 {
02756                     // There is more than one selected node
02757                     DisableReason = String_256(_R(IDS_ALREADY_ON_BOTTOM_FRM));                      
02758                 }
02759                 else if (PresentMode == LAYER)
02760                 {
02761                     // There is more than one selected node
02762                     DisableReason = String_256(_R(IDS_ALREADY_ON_BOTTOM_LYRP)); 
02763                 }
02764                 else
02765                     ERROR3("OpMoveToLyrInFront::GetState - Bad mode!");
02766             #endif
02767         }
02768     }
02769     
02770     *UIDescription = DisableReason;  
02771 
02772     return(OpSt);   
02773 }

BOOL OpMoveToLyrBehind::Init void   )  [static]
 

OpMoveToLyrBehind 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 2561 of file zordops.cpp.

02562 {
02563 /*
02564     return (RegisterOpDescriptor(0,
02565                                 _R(IDS_MOVELAYERBEHIND),
02566                                 CC_RUNTIME_CLASS(OpMoveToLyrBehind),
02567                                 OPTOKEN_MOVELAYERBEHIND,
02568                                 OpMoveToLyrBehind::GetState,
02569                                 0,  // help ID
02570                                 _R(IDBBL_MOVELAYERBEHIND),
02571                                 _R(IDD_ANIMATIONBAR),               // resource ID
02572                                 _R(IDC_FRAME_MOVEDOWNAFRAME),       // control ID
02573                                 SYSTEMBAR_ANIMATION,            // Bar ID
02574                                 TRUE,                           // Receive messages
02575                                 FALSE,
02576                                 FALSE,
02577                                 0,
02578                                 (GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION)
02579 
02580                                 ));
02581 */
02582 
02583     FrameBehindOpDescriptor* pOpDesc = new FrameBehindOpDescriptor(OPTOKEN_MOVELAYERBEHIND, 
02584                                                                    CC_RUNTIME_CLASS(OpMoveToLyrBehind),
02585                                                                    OpMoveToLyrBehind::GetState);
02586 
02587     if(pOpDesc)
02588         return TRUE;
02589     
02590     return FALSE;
02591 }               

virtual BOOL OpMoveToLyrBehind::MayChangeNodeBounds  )  const [inline, virtual]
 

Reimplemented from SelOperation.

Definition at line 295 of file zordops.h.

00295 { return FALSE; }


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