OpMoveToLyrInFront Class Reference

This class represents the move to layer in front operation. More...

#include <zordops.h>

Inheritance diagram for OpMoveToLyrInFront:

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

Public Member Functions

 OpMoveToLyrInFront ()
 OpMoveToLyrInFront constructor.
void Do (OpDescriptor *)
 Performs the MoveToLayerInFront operation. This moves those selected objects which are not on the highest visible layer to the lowest z-order position of the next visible layer in front.
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

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

Detailed Description

This class represents the move to layer in front operation.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/05/94
See also:
OpBringToFront

OpPutToBack

OpMoveForwards

OpMoveBackwards

OpMoveToLyrBehind Documentation: specs.doc

Definition at line 252 of file zordops.h.


Constructor & Destructor Documentation

OpMoveToLyrInFront::OpMoveToLyrInFront  ) 
 

OpMoveToLyrInFront constructor.

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

Errors: -

See also:
-

Definition at line 1994 of file zordops.cpp.

01994                                       : SelOperation()                              
01995 {                              
01996 }


Member Function Documentation

void OpMoveToLyrInFront::Do OpDescriptor  )  [virtual]
 

Performs the MoveToLayerInFront operation. This moves those selected objects which are not on the highest visible layer to the lowest z-order position of the next visible layer in front.

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

02235 {  
02236     // Obtain the current selections 
02237     Range Sel(*(GetApplication()->FindSelection()));
02238     RangeControl rg = Sel.GetRangeControlFlags();
02239     rg.PromoteToParent = TRUE;
02240     Sel.Range::SetRangeControl(rg);
02241 
02242     // Find the first node which is selected 
02243     Node* FirstSelectedNode = Sel.FindFirst(); 
02244  
02245     // The first selected node should not ever be NULL
02246     ENSURE(FirstSelectedNode != NULL, "The OpMoveToLyrInFront's GetState fn has not done a very good job"); 
02247     
02248     if (FirstSelectedNode != NULL) 
02249     {
02250         if (!DoStartSelOp(FALSE,FALSE))  // Try to record the selection state , don't
02251                                          // render the blobs though 
02252         {
02253             goto EndOperation;  
02254         }
02255 
02256         // We need to invalidate the region
02257         if (!DoInvalidateNodesRegions(Sel, TRUE, FALSE, FALSE, FALSE))
02258         {
02259             goto EndOperation; 
02260         }
02261 
02262         Node*   CurrentNode         = FirstSelectedNode; 
02263         
02264 //      RangeControl LyrCntrl = { TRUE, FALSE, FALSE };  // Selected + don't cross layers  
02265         Range   LayerRange; 
02266         Layer*  NxtLyr              = NULL;
02267         Node*   NextNode            = NULL; 
02268         Node*   ThisLayer           = NULL;
02269         Node*   FirstSelectedNxtLyr = NULL;
02270         Node*   LastObjectMoved     = NULL; 
02271 
02272         BOOL    OldVisible          = FALSE;
02273         BOOL    OldLocked           = FALSE;
02274 
02275 #ifndef WEBSTER
02276         MODE PresentMode            = LAYER; 
02277 #endif
02278         // Loop for all layers
02279         // Current Node is the first selected object on the layer we are currently processing
02280         while (CurrentNode != NULL)
02281         {
02282             ENSURE(CurrentNode->IsAnObject(), "Non ink node in OpMoveToLyrInFront");
02283 
02284             ThisLayer = CurrentNode->FindParent(CC_RUNTIME_CLASS(Layer));
02285 
02286             if (ThisLayer != NULL)
02287                 ((Layer*)ThisLayer)->InvalidateBoundingRect();
02288 
02289 // WEBSTER - markn 2/2/97
02290 // Not needed in Webster
02291 // Neville 23/6/97 Now needed but must work in Frame mode in Webster
02292 // RanbirR - 28/10/97 - Changed for Camelot v2, Frame/Layer integration. 
02293 
02294 #ifdef WEBSTER
02295             // ----------------------------------------------------------------------------
02296             // Find the next visible frame
02297             NxtLyr = (Layer*)ThisLayer;
02298             do
02299             {
02300                 NxtLyr = NxtLyr->FindNextFrameLayer();
02301                 if (NxtLyr != NULL)
02302                 {
02303                     // Is the layer not a guide or a page background layer?
02304                     if (!NxtLyr->IsGuide() && !NxtLyr->IsPageBackground())
02305                     {
02306                         // found
02307                         break;
02308                     }
02309                 }
02310                 
02311             } while (NxtLyr != NULL); 
02312 
02313             if (NxtLyr != NULL)
02314             {
02315                 // Make the layer visible and editable so we don't loose the selection
02316                 // do it blatently as it will be fixed up properly latter
02317                 OldVisible = NxtLyr->IsVisible();
02318                 OldLocked = NxtLyr->IsLocked();
02319                 NxtLyr->SetVisible(TRUE);
02320                 NxtLyr->SetLocked(FALSE);
02321             }
02322             
02323 #else
02324             // ----------------------------------------------------------------------------
02325 
02326             // Determine the Document Mode.
02327             NxtLyr = (Layer*)ThisLayer;
02328             PresentMode = (MODE)NxtLyr->IsFrame();
02329             
02330             if(PresentMode == LAYER)
02331             {
02332                 do
02333                 {
02334                     NxtLyr = NxtLyr->FindNextLayer();
02335                     if (NxtLyr != NULL)
02336                     {
02337                         if (NxtLyr->IsVisible() && !NxtLyr->IsLocked() && !NxtLyr->IsGuide())
02338                         {
02339                             // found
02340                             break;
02341                         }
02342                     }
02343                     
02344                 } while (NxtLyr != NULL); 
02345 
02346                 if (NxtLyr != NULL)
02347                 {
02348                     // Make the layer visible and editable so we don't loose the selection
02349                     // do it blatently as it will be fixed up properly latter
02350                     OldVisible = NxtLyr->IsVisible();
02351                     OldLocked = NxtLyr->IsLocked();
02352                     NxtLyr->SetVisible(TRUE);
02353                     NxtLyr->SetLocked(FALSE);
02354                 }
02355             }
02356             else if (PresentMode == FRAME)
02357             {
02358                 // Find the next visible frame
02359                 do
02360                 {
02361                     NxtLyr = NxtLyr->FindNextFrameLayer();
02362                     if (NxtLyr != NULL)
02363                     {
02364                         // Is the layer not a guide or a page background layer?
02365                         if (!NxtLyr->IsGuide() && !NxtLyr->IsPageBackground())
02366                         {
02367                             // found
02368                             break;
02369                         }
02370                     }
02371                 
02372                 } while (NxtLyr != NULL); 
02373 
02374                 if (NxtLyr != NULL)
02375                 {
02376                     // Make the layer visible and editable so we don't loose the selection
02377                     // do it blatently as it will be fixed up properly latter
02378                     OldVisible = NxtLyr->IsVisible();
02379                     OldLocked = NxtLyr->IsLocked();
02380                     NxtLyr->SetVisible(TRUE);
02381                     NxtLyr->SetLocked(FALSE);
02382                 }
02383             }
02384             else
02385                 ERROR3("OpMoveToLyrInFront::Do - Bad mode!");
02386 #endif 
02387 
02388             if (NxtLyr == NULL)
02389             {
02390                 ENSURE(CurrentNode != FirstSelectedNode, "OpMoveToLyrInFront called with nothing to do"); 
02391                 
02392                 // There is no layer in front so the operation is complete
02393                 goto EndOperation;
02394             } 
02395 
02396             NxtLyr->InvalidateBoundingRect();
02397 
02398             // Create a range of selected nodes on this layer, we will move these to the layer
02399             // in front.
02400             Range temp(CurrentNode, 
02401                                NULL, 
02402                                RangeControl(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) );
02403             LayerRange = temp;
02404 //          LayerRange = Range(CurrentNode, 
02405 //                             NULL, 
02406 //                             RangeControl(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) );
02407             
02408             // Find the first selected node on the layer in front of the layer we are currently 
02409             // processing. 
02410 
02411             FirstSelectedNxtLyr = CurrentNode;
02412             
02413             do 
02414             {
02415                 if (FirstSelectedNxtLyr->FindParent(CC_RUNTIME_CLASS(Layer)) != ThisLayer)
02416                 {
02417                     break; // Found     
02418                 }
02419                 FirstSelectedNxtLyr = Sel.FindNext(FirstSelectedNxtLyr);
02420 
02421             } while (FirstSelectedNxtLyr != NULL);
02422             
02423             // We haven't moved any objects from this layer yet
02424             LastObjectMoved = NULL; 
02425 
02426             // Shift all selected nodes on this layer to the lowest z-order position on the layer in front
02427             // maintaining the objects relative order 
02428             do
02429             {
02430                 NextNode = LayerRange.FindNext(CurrentNode); // Hand over hand
02431 
02432                 if (LastObjectMoved == NULL)
02433                 {
02434                     // No previous objects have been copied from this layer to the NxtLayer, therefore
02435                     // Attach the node as a first child of the next layer
02436                     ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
02437                     if (!DoMoveNode(CurrentNode, NxtLyr, FIRSTCHILD)) 
02438                     {
02439                         goto EndOperation;
02440                     }
02441 
02442                     ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
02443                     CurrentNode->SetSelected(TRUE);
02444                 }
02445                 else
02446                 {
02447                     // Copy the rest of the objects after the first object
02448                     ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
02449                     if (!DoMoveNode(CurrentNode, LastObjectMoved, NEXT)) 
02450                     {
02451                         goto EndOperation;
02452                     }
02453 
02454                     ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
02455                     CurrentNode->SetSelected(TRUE);
02456                 }
02457 
02458                 LastObjectMoved = CurrentNode;  // Remember the node we have just moved
02459                 CurrentNode = NextNode; 
02460             
02461             } while (NextNode != NULL);
02462 
02463 //#ifdef WEBSTER    Included in Camelot2 for Frame/Layer integration - RanbirR 03/11/97 
02464 #ifdef WEBSTER
02465             if (NxtLyr != NULL)
02466 #else
02467             if (NxtLyr != NULL && PresentMode == FRAME)
02468 #endif
02469             {
02470                 // Put back the old states so we get the redraw correct
02471                 NxtLyr->SetVisible(OldVisible);
02472                 //NxtLyr->SetLocked(OldLocked);
02473             }
02474 //#endif    
02475             // Get the first selected node of the next layer
02476             CurrentNode = FirstSelectedNxtLyr; 
02477         } 
02478 
02479 //#ifdef WEBSTER    Included in Camelot2 for Frame/Layer integration - RanbirR 03/11/97 
02480 
02481         // Switch to viewing the destination layer
02482         // Otherwise, the user will see the objects dissappear and will be worried
02483         // Also, the range blows up as the destination is invisible
02484 #ifdef WEBSTER
02485         if (NxtLyr != NULL)
02486 #else
02487         if (NxtLyr != NULL && PresentMode == FRAME)
02488 #endif
02489         {
02490 PORTNOTETRACE("gallery", "Removed used of FrameSGallery from OpMoveToLyrInFront");
02491 #if !defined(EXCLUDE_FROM_XARALX)
02492             FrameSGallery::MakeActiveLayer(NxtLyr);
02493             BROADCAST_TO_ALL(LayerMsg(NxtLyr,LayerMsg::UPDATE_ACTIVE_LAYER));
02494 #endif
02495         }
02496 
02497 //#endif // WEBSTER     Included in Camelot2 for Frame/Layer integration - RanbirR 03/11/97 
02498         
02499         // We need to invalidate the region
02500         if (!DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE, FALSE, FALSE, FALSE))
02501         {
02502             goto EndOperation; 
02503         }
02504     
02505         // Invalidate the bounding rects
02506         if (FirstSelectedNode->IsBounded())
02507         {
02508             NodeRenderableBounded* pNodeRB = (NodeRenderableBounded*)FirstSelectedNode;
02509             pNodeRB->InvalidateBoundingRect();
02510         }
02511     }
02512 
02513     EndOperation:
02514 
02515     End(); // End of operation
02516 } 

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

For finding OpMoveToLyrInFront's state.

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

Errors: -

See also:
-

Definition at line 2063 of file zordops.cpp.

02064 {
02065     OpState OpSt;
02066 
02067     String_256 DisableReason;
02068 
02069     SelRange Sel(*( GetApplication()->FindSelection()));
02070     RangeControl rg = Sel.GetRangeControlFlags();
02071     rg.PromoteToParent = TRUE;
02072     Sel.Range::SetRangeControl(rg);
02073 
02074 
02075     Node* pNode = Sel.FindFirst();
02076 
02077     while (pNode != NULL)
02078     {
02079         Node* pLayer = pNode->FindParent(CC_RUNTIME_CLASS(Layer));
02080         if (pLayer != NULL && ((Layer*)pLayer)->IsGuide())
02081         {
02082             *UIDescription = String_256(_R(IDS_CANT_MOVE_OFF_GUIDE_LAYER));
02083             OpSt.Greyed = TRUE;
02084             return OpSt;
02085         }
02086 
02087         pNode = Sel.FindNext(pNode);
02088     }
02089 
02090     // Find the first node which is selected 
02091     Node* FirstSelectedNode = Sel.FindFirst(); 
02092 
02093     // The operation is disabled if the first object which is selected is already on the highest
02094     // visible layer.
02095     BOOL HighestVisible = TRUE; 
02096     Layer* CurrentLayer = (Layer*) (FirstSelectedNode->FindParent(CC_RUNTIME_CLASS(Layer)));
02097     ERROR2IF(CurrentLayer == NULL, OpSt, "Cannot find layer of first selected object"); 
02098 // WEBSTER - markn 2/2/97
02099 // Not needed in Webster
02100 // Neville 23/6/97 Now needed but must work in Frame mode in Webster
02101 // RanbirR - 28/10/97 - Changed for Camelot v2, Frame/Layer integration. 
02102 
02103 #ifdef WEBSTER
02104     // Find the next frame layer
02105     do
02106     {
02107         CurrentLayer = CurrentLayer->FindNextFrameLayer();
02108         if (CurrentLayer != NULL)
02109         {
02110             // Is the layer not a guide or a page background layer?
02111             if (!CurrentLayer->IsGuide() && !CurrentLayer->IsPageBackground())
02112             {
02113                 HighestVisible = FALSE; // The first node selected is not on the highest visible layer
02114                                         // so the operation can be performed. 
02115                 break;
02116             }
02117         } 
02118     } while (CurrentLayer != NULL);   
02119 
02120 #else
02121     // Are we in frame or layer mode.
02122     MODE PresentMode = (MODE)CurrentLayer->IsFrame();
02123 
02124     if (PresentMode == FRAME)
02125     {
02126         do
02127         {
02128             CurrentLayer = CurrentLayer->FindNextFrameLayer();
02129             if (CurrentLayer != NULL)
02130             {
02131                 // Is the layer not a guide or a page background layer?
02132                 if (!CurrentLayer->IsGuide() && !CurrentLayer->IsPageBackground())
02133                 {
02134                     HighestVisible = FALSE; // The first node selected is not on the highest visible layer
02135                                             // so the operation can be performed. 
02136                     break;
02137                 }
02138             } 
02139         } while (CurrentLayer != NULL);   
02140     }
02141     else if (PresentMode == LAYER)
02142     {
02143         do
02144         {
02145             CurrentLayer = CurrentLayer->FindNextLayer();
02146             if (CurrentLayer != NULL)
02147             {
02148                 // Is the layer visible
02149                 if (CurrentLayer->IsVisible() && !CurrentLayer->IsLocked() && !CurrentLayer->IsGuide())
02150                 {
02151                     HighestVisible = FALSE; // The first node selected is not on the highest visible layer
02152                                             // so the operation can be performed. 
02153                     break;
02154                 }
02155             } 
02156         } while (CurrentLayer != NULL);   
02157     }
02158     else
02159         ERROR3("OpMoveToLyrInFront::GetState - Bad mode!");
02160 
02161 #endif // WEBSTER
02162 
02163     if (HighestVisible)
02164     {
02165         // The operation must be disabled
02166         OpSt.Greyed = TRUE;
02167 
02168         #ifdef WEBSTER
02169 
02170             if (Sel.FindNext(FirstSelectedNode) == NULL)
02171             {
02172                 // There is only a single selected node
02173                 DisableReason = String_256(_R(IDS_ALREADY_ON_TOP_FRMS)); 
02174             }
02175             else
02176             {
02177                 // There is more than one selected node
02178                 DisableReason = String_256(_R(IDS_ALREADY_ON_TOP_FRM)); 
02179             }
02180         #else
02181             if(PresentMode == LAYER)
02182             {
02183                 if (Sel.FindNext(FirstSelectedNode) == NULL)
02184                 {
02185                     // There is only a single selected node
02186                     DisableReason = String_256(_R(IDS_ALREADY_ON_TOP_LYRS)); 
02187                 }
02188                 else
02189                 {
02190                     // There is more than one selected node
02191                     DisableReason = String_256(_R(IDS_ALREADY_ON_TOP_LYRP)); 
02192                 }
02193             }
02194             else if(PresentMode == FRAME)
02195             {
02196                 if (Sel.FindNext(FirstSelectedNode) == NULL)
02197                 {
02198                     // There is only a single selected node
02199                     DisableReason = String_256(_R(IDS_ALREADY_ON_TOP_FRMS)); 
02200                 }
02201                 else
02202                 {
02203                     // There is more than one selected node
02204                     DisableReason = String_256(_R(IDS_ALREADY_ON_TOP_FRM)); 
02205                 }
02206             }
02207             else
02208                 ERROR3("OpMoveToLyrInFront::Do - Bad mode!");
02209         #endif
02210     }
02211 
02212     *UIDescription = DisableReason;  
02213 
02214     return(OpSt);   
02215 }

BOOL OpMoveToLyrInFront::Init void   )  [static]
 

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

02017 {
02018 /*
02019     return (RegisterOpDescriptor(0,
02020                                 _R(IDS_MOVELAYERINFRONT),
02021                                 CC_RUNTIME_CLASS(OpMoveToLyrInFront),
02022                                 OPTOKEN_MOVELAYERINFRONT,
02023                                 OpMoveToLyrInFront::GetState,
02024                                 0,  
02025                                 _R(IDBBL_MOVELAYERINFRONT),
02026                                 _R(IDD_ANIMATIONBAR),               // resource ID
02027                                 _R(IDC_FRAME_MOVEUPAFRAME),         // control ID
02028                                 SYSTEMBAR_ANIMATION,            // Bar ID
02029                                 TRUE,                           // Receive messages
02030                                 FALSE,
02031                                 FALSE,
02032                                 0,
02033                                 (GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION)
02034 
02035                                 )); 
02036 */
02037     // Changed for Camelot2, Layer/Frame integration - RanbirR.
02038 
02039     FrameInFrontOpDescriptor* pOpDesc = new FrameInFrontOpDescriptor(OPTOKEN_MOVELAYERINFRONT, 
02040                                                                      CC_RUNTIME_CLASS(OpMoveToLyrInFront),
02041                                                                      OpMoveToLyrInFront::GetState);
02042     if(pOpDesc)
02043         return TRUE;
02044 
02045     return FALSE;
02046 }               

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

Reimplemented from SelOperation.

Definition at line 263 of file zordops.h.

00263 { 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