OpBringToFront Class Reference

This class represents the BringToFront operation. More...

#include <zordops.h>

Inheritance diagram for OpBringToFront:

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

Public Member Functions

 OpBringToFront ()
 OpBringToFront constructor.
void Do (OpDescriptor *)
 Performs the BringToFront operation, this moves all selected objects to the front of their layers.

Static Public Member Functions

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

Detailed Description

This class represents the BringToFront operation.

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

OpMoveForwards

OpMoveBackwards Documentation: specs.doc

Definition at line 131 of file zordops.h.


Constructor & Destructor Documentation

OpBringToFront::OpBringToFront  ) 
 

OpBringToFront constructor.

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

Errors: -

See also:
-

Definition at line 247 of file zordops.cpp.

00247                               : SelOperation()                              
00248 {                              
00249 }


Member Function Documentation

void OpBringToFront::Do OpDescriptor  )  [virtual]
 

Performs the BringToFront operation, this moves all selected objects to the front of their layers.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> (rewritten by Markn for WEBSTER - 2/2/97)
Date:
16/8/93
Parameters:
OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-
See note at the top of file about WEBSTER z-order ops
Returns:
Errors: -
See also:
-

Reimplemented from Operation.

Definition at line 498 of file zordops.cpp.

00499 {  
00500 #ifdef WEBSTER
00501     OpState OpSt;
00502     String_256 DisableReason; 
00503 
00504     SelRange Sel (*( GetApplication()->FindSelection());
00505     RangeControl rg = Sel.GetRangeControlFlags();
00506     rg.PromoteToParent = TRUE;
00507     Sel.Range::SetRangeControl(rg);
00508 
00509     Node* pSelNode = Sel.FindLast();
00510 
00511     // If there are selected objects, record undo stuff about the selection
00512     if (pSelNode != NULL)
00513     {
00514         // Try to record the selection state , don't render the blobs though
00515         // the invalidate will take care of this. 
00516         if (!DoStartSelOp(FALSE,FALSE))
00517             goto EndOperation;  
00518 
00519         // We need to invalidate the region
00520         if (!DoInvalidateNodesRegions(*Sel, TRUE))
00521             goto EndOperation; 
00522     }
00523 
00524     while (pSelNode != NULL)
00525     {
00526         Node* pContextNode = NULL;
00527 
00528         Node* pNode = pSelNode;
00529         while (pNode != NULL)
00530         {
00531             Node* pOldNode = pNode;     // Remember this node
00532 
00533             if (pNode != NULL)
00534                 pNode = pNode->FindNext();  // Get the node after this node
00535 
00536             // If the next node is an unselected object, then we can move this object to the front
00537             if (pNode != NULL && pNode->IsAnObject() && !pNode->IsSelected())
00538                 pContextNode = pNode;
00539 
00540             if (pNode == NULL)
00541             {
00542                 // Find the parent layer
00543                 Layer* pLayer = (Layer*)pOldNode->FindParent(CC_RUNTIME_CLASS(Layer));
00544 
00545                 // Find the last object on the first editable layer we can find that follows this layer
00546                 do
00547                 {
00548                     pLayer = pLayer->FindNextLayer(TRUE);
00549                     pNode = FindFirstObject(pLayer);
00550 
00551                 } while (pLayer != NULL && pNode == NULL);
00552 
00553                 // If the next node is an unselected object, then we can move this object to the front
00554                 if (pNode != NULL && pNode->IsAnObject() && !pNode->IsSelected())
00555                     pContextNode = pNode;
00556             }
00557         } 
00558 
00559         pNode = pSelNode;
00560         // Try the next selected node.
00561         pSelNode = Sel.FindPrev(pSelNode);
00562 
00563         if (pContextNode != NULL)
00564         {
00565             if (!DoMoveNode(pNode, pContextNode, NEXT))
00566                 goto EndOperation;
00567 
00568             pNode->SetSelected(TRUE);
00569         }
00570     }
00571 
00572     EndOperation:    
00573     End(); // End of operation
00574 
00575 #else
00576 // WEBSTER - markn 2/2/97
00577 // Original code
00578 
00579     // Obtain the current selections
00580     // Copy SelRange into a range so that it cannot change during the operation
00581     // Note: the cache is freshened by this 
00582     Range Sel(*(GetApplication()->FindSelection()));
00583     RangeControl rg = Sel.GetRangeControlFlags();
00584     rg.PromoteToParent = TRUE;
00585     Sel.Range::SetRangeControl(rg);
00586 
00587 
00588     // Find the first node which is selected 
00589     Node* FirstSelectedNode = Sel.FindFirst(); 
00590  
00591     // The first selected node should not ever be NULL. The GetState fn should have seen
00592     // to this.
00593     ENSURE(FirstSelectedNode != NULL, 
00594         "The OpBringToFront's GetState fn has not done a very good job"); 
00595     
00596     // lets be defensive about it anyway
00597     if (FirstSelectedNode != NULL) 
00598     {
00599         if (!DoStartSelOp(FALSE,FALSE))  // Try to record the selection state 
00600         {
00601             goto EndOperation;  
00602         }
00603 
00604         // We need to invalidate the region
00605         if (!DoInvalidateNodesRegions(Sel, TRUE, FALSE, FALSE, FALSE))
00606         {
00607             goto EndOperation; 
00608         }
00609         
00610         Spread* pSpread; 
00611         Node* Tail;
00612         Node* NextSelNode;  
00613 
00614         // We will need to scan the layers one at a time so create a Range control to
00615         // acheive this. 
00616 //      RangeControl LyrCntrl = { TRUE, FALSE, FALSE };  // Selected + don't cross layers  
00617         Range LayerRange; 
00618         
00619         // Find the spread that the selection lies on
00620         pSpread = FirstSelectedNode->FindParentSpread();
00621         
00622         Node* CurrentNode = FirstSelectedNode;     
00623         Node* LastNodeOnLayer;
00624 
00625         // Loop for all layers
00626         while(CurrentNode != NULL)
00627         {
00628 
00629             // Create a range of selected nodes on this layer
00630             Range temp(CurrentNode, 
00631                                NULL, 
00632                                RangeControl(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) );
00633             LayerRange = temp;
00634 //          LayerRange = Range(CurrentNode, 
00635 //                             NULL,
00636 //                             RangeControl(TRUE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,TRUE) );
00637 
00638             FirstSelectedNode = CurrentNode; 
00639             
00640             // Find the last ink object on this layer
00641             LastNodeOnLayer = CurrentNode->FindParent(CC_RUNTIME_CLASS(Layer))->FindLastChild();
00642             if (LastNodeOnLayer->IsAnObject())
00643             {
00644                 Tail = LastNodeOnLayer;
00645             }
00646             else
00647             {
00648                 Tail = LastNodeOnLayer->FindPrevious(CC_RUNTIME_CLASS(NodeRenderableInk));
00649             }
00650                 
00651             // If the first node selected is already at the front then we don't really want
00652             // to move it. In this situation we know that there can be no other selected nodes 
00653             // so we need not do anything                    
00654             if (FirstSelectedNode != Tail)
00655             {    
00656                 do 
00657                 {   
00658                     ENSURE (CurrentNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)), 
00659                     "Selected node not a NodeRenderableBounded");
00660                 
00661                     // Find the next selected node on the current layer
00662                     NextSelNode = LayerRange.FindNext(CurrentNode); 
00663             
00664                     ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
00665                     if (!DoMoveNode(CurrentNode, Tail, NEXT)) 
00666                     {
00667                         goto EndOperation;
00668                     }
00669 
00670                     ((NodeRenderableBounded*)CurrentNode)->ReleaseCached(TRUE, FALSE, FALSE, TRUE);
00671                     CurrentNode->SetSelected(TRUE);
00672                      
00673                     Tail = CurrentNode; 
00674                     CurrentNode = NextSelNode;     
00675             
00676                     // Stop when we hit the first node which was moved. 
00677                     // or when there are no more selected nodes (This can only happen if there is only
00678                     // one node selected). 
00679                 } while ((CurrentNode != FirstSelectedNode) && (CurrentNode != NULL)); 
00680          
00681             } 
00682             // Get the first selected node of the next layer
00683             CurrentNode = Sel.FindNext(Tail); 
00684             ENSURE(LayerRange.FindNext(Tail) == NULL, 
00685                 "Current Node is not the last selected node on the layer"); 
00686         } 
00687         // We need to invalidate the region
00688         if (!DoInvalidateNodesRegions(*(GetApplication()->FindSelection()), TRUE, FALSE, FALSE, FALSE))
00689         {
00690             goto EndOperation; 
00691         }
00692     }
00693 
00694     EndOperation:
00695     GetApplication()->UpdateSelection();
00696     
00697     End(); // End of operation
00698 
00699 #endif // WEBSTER
00700 } 

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

For finding OpBringToFront's state.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com> (rewritten by Markn for WEBSTER - 2/2/97)
Date:
28/9/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpBringToFront operation
See note at the top of file about WEBSTER z-order ops
Returns:
Errors: -
See also:
-

Definition at line 308 of file zordops.cpp.

00309 {
00310 #ifdef WEBSTER
00311     OpState OpSt;
00312     String_256 DisableReason; 
00313 
00314     // DMc changed for select inside on bevels etc
00315     
00316     SelRange Sel(*( GetApplication()->FindSelection());
00317     RangeControl rg = Sel.GetRangeControlFlags();
00318     rg.PromoteToParent = TRUE;
00319     Sel.Range::SetRangeControl(rg);
00320 
00321     Node* pSelNode = Sel.FindFirst();
00322     while (pSelNode != NULL)
00323     {
00324         Node* pNode = pSelNode;
00325         while (pNode != NULL)
00326         {
00327             Node* pOldNode = pNode;     // Remember this node
00328 
00329             if (pNode != NULL)
00330                 pNode = pNode->FindNext();  // Get the node after this node
00331 
00332             // If the next node is an unselected object, then we can move this object to the front
00333             if (pNode != NULL && pNode->IsAnObject() && !pNode->IsSelected())
00334                 goto End;
00335 
00336             if (pNode == NULL)
00337             {
00338                 // Find the parent layer
00339                 Layer* pLayer = (Layer*)pOldNode->FindParent(CC_RUNTIME_CLASS(Layer));
00340 
00341                 // Find the last object on the first editable layer we can find that follows this layer
00342                 do
00343                 {
00344                     pLayer = pLayer->FindNextLayer(TRUE);
00345                     pNode = FindFirstObject(pLayer);
00346 
00347                 } while (pLayer != NULL && pNode == NULL);
00348 
00349                 // If the next node is an unselected object, then we can move this object to the front
00350                 if (pNode != NULL && pNode->IsAnObject() && !pNode->IsSelected())
00351                     goto End;
00352             }
00353         } 
00354 
00355         // Try the next selected node.
00356         pSelNode = Sel.FindNext(pSelNode);
00357     }
00358 
00359     OpSt.Greyed = TRUE;
00360  
00361     // Determine which reason string to return
00362     if (Sel.Count() > 1)
00363     {
00364         DisableReason = String_256(_R(IDS_ALREADY_AT_FRONTP)); // A plural description
00365     }
00366     else
00367     {
00368         DisableReason = String_256(_R(IDS_ALREADY_AT_FRONTS));
00369     }
00370     *UIDescription = DisableReason;                                       
00371 
00372     End:                                                 
00373     return(OpSt);
00374 
00375 #else
00376 // WEBSTER - markn 2/2/97
00377 // Original code
00378 
00379     OpState OpSt;
00380     String_256 DisableReason;
00381 
00382     // DMc changed for select inside on bevels etc
00383     SelRange Sel (*(GetApplication()->FindSelection()));
00384     RangeControl rg = Sel.GetRangeControlFlags();
00385     rg.PromoteToParent = TRUE;
00386     Sel.Range::SetRangeControl(rg);
00387 
00388     // If all selected objects are already at the front of their layers then the operation should be
00389     // disabled. 
00390     Node* Current = Sel.FindFirst(); 
00391     Node* LastCurrent;
00392     MODE PresentMode = FRAME; // In case Current is NULL
00393 
00394     // Determine the correct document mode.
00395     if(Current)
00396     {
00397         Layer* CurrentLayer = (Layer*) (Current->FindParent(CC_RUNTIME_CLASS(Layer)));
00398         ERROR2IF(CurrentLayer == NULL, OpSt, "Cannot find layer of first selected object"); 
00399 
00400         // The mode of this document - Frame/Layer.
00401         PresentMode = (MODE)CurrentLayer->IsFrame();
00402     }
00403 
00404     BOOL bSelected = FALSE;
00405     
00406     while(Current != NULL) // Loop for all layers
00407     {   
00408         // If an unselected object is found on this layer with a higher z-order position than
00409         // Current then the operation can be performed.
00410         do
00411         {
00412             // DMc revision 4/6/99
00413             if (Current->ShouldITransformWithChildren())
00414             {
00415                 // check to see if any of its children are selected
00416                 RangeControl rg(TRUE, FALSE);
00417                 Range rng(Current, Current, rg);
00418 
00419                 if (rng.IsEmpty())
00420                 {
00421                     bSelected = FALSE;
00422                 }
00423                 else
00424                 {
00425                     bSelected = TRUE;
00426                 }
00427             }
00428             else
00429             {
00430                 bSelected = Current->IsSelected();
00431             }
00432             
00433             if ((Current->IsAnObject()) && (!(bSelected)))
00434             {
00435                 goto End; // The operation can be performed
00436             }
00437             LastCurrent = Current;
00438             Current = Current->FindNext(); 
00439         } while (Current != NULL);
00440         // Obtain the next selected object (on the next layer)
00441         Current = Sel.FindNext(LastCurrent); 
00442     }
00443     // All selected objects are already at the front of their layers
00444     OpSt.Greyed = TRUE; 
00445 
00446     if(PresentMode == FRAME)
00447     {
00448         // Determine which reason string to return
00449         if (Sel.Count() > 1)
00450         {
00451             DisableReason = String_256(_R(IDS_ALREADY_AT_FRONTP_FRAME)); // A plural description
00452         }
00453         else
00454         {
00455             DisableReason = String_256(_R(IDS_ALREADY_AT_FRONTS_FRAME));
00456         }
00457     }
00458     else if (PresentMode == LAYER)
00459     {
00460         // Determine which reason string to return
00461         if (Sel.Count() > 1)
00462         {
00463             DisableReason = String_256(_R(IDS_ALREADY_AT_FRONTP)); // A plural description
00464         }
00465         else
00466         {
00467             DisableReason = String_256(_R(IDS_ALREADY_AT_FRONTS));
00468         }
00469     }
00470     else
00471         ERROR3("OpBringToFront::GetState - Bad mode!");
00472 
00473     *UIDescription = DisableReason;                                       
00474     End:                                                 
00475     return(OpSt);   
00476 
00477 #endif // WEBSTER
00478 }

BOOL OpBringToFront::Init void   )  [static]
 

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

00270 {
00271     return (RegisterOpDescriptor(0,
00272                                 _R(IDS_BRINGTOFRONTOP),
00273                                 CC_RUNTIME_CLASS(OpBringToFront),
00274                                 OPTOKEN_BRINGTOFRONT,
00275                                 OpBringToFront::GetState,
00276                                 0,  /* help ID */
00277                                 _R(IDBBL_BRINGTOFRONTOP),
00278                                 0,  
00279                                 0,
00280                                 SYSTEMBAR_ILLEGAL,          // For now !
00281                                 TRUE,                       // Receive messages
00282                                 FALSE,
00283                                 FALSE,
00284                                 0,
00285                                 (GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION)
00286 
00287                                 )); 
00288 
00289 }               


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