OpApplyAttribToSelected Class Reference

This class represents the OpApplyAttribToSelected operation. It applies the specified attribute to all selected objects. More...

#include <attrappl.h>

Inheritance diagram for OpApplyAttribToSelected:

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

Public Member Functions

 OpApplyAttribToSelected ()
 OpApplyAttribToSelected constructor.
void DoWithParam (OpDescriptor *OpDesc, OpParam *pOpParam)
 Performs the OpApplyAttribToSelected operation. This function applies the NodeAttribute to all selected objects.
virtual void GetOpName (String_256 *OpName)
 The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.

Static Public Member Functions

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

Protected Member Functions

BOOL ApplyToSelection (NodeAttribute *Attrib, BOOL Mutate)

Protected Attributes

UINT32 UndoAttribStrID

Detailed Description

This class represents the OpApplyAttribToSelected operation. It applies the specified attribute to all selected objects.

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

Definition at line 173 of file attrappl.h.


Constructor & Destructor Documentation

OpApplyAttribToSelected::OpApplyAttribToSelected  ) 
 

OpApplyAttribToSelected constructor.

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

Errors: -

See also:
-

Definition at line 1207 of file attrappl.cpp.

01207                                                 : OpApplyAttrib()                               
01208 {                              
01209     ValueChangeType = NULL;
01210     MergeRepeats = FALSE;
01211     m_pAttr = NULL;
01212 }


Member Function Documentation

BOOL OpApplyAttribToSelected::ApplyToSelection NodeAttribute Attrib,
BOOL  Mutate
[protected]
 

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
5/4/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful FALSE if the operation should be aborted (TIDYUP THEN CALL End()!)

Errors: -

See also:
-

Definition at line 1427 of file attrappl.cpp.

01428 {
01429     return DoApplyToSelection(this, Attrib, Mutate, TRUE);              // Do undo and Do optimisations
01430 }

void OpApplyAttribToSelected::DoWithParam OpDescriptor OpDesc,
OpParam pOpParam
[virtual]
 

Performs the OpApplyAttribToSelected operation. This function applies the NodeAttribute to all selected objects.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/8/93
Parameters:
OpDescriptor [INPUTS]
pOpParam,: Param1 contains a pointer to the NodeAttribute to apply to the [OUTPUTS] currently selected nodes
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 1232 of file attrappl.cpp.

01233 {   
01234 #ifndef STANDALONE
01235 
01236     AttrTypeSet AttrTypes; 
01237 
01238     Range SelRng(*(GetApplication()->FindSelection()));
01239 
01240  
01241     ERROR3IF(pOpParam == NULL, "The OpApplyAttribToSelected operation requires an attribute parameter"); 
01242 
01243     BeginSlowJob();
01244     AttributeManager::pLastNodeAppliedTo = NULL;
01245 
01246     // Obtain a pointer to the attribute which we will need to apply to all selected nodes 
01247     NodeAttribute* Attrib = (NodeAttribute*)(void *)pOpParam->Param1;
01248     m_pAttr = Attrib;
01249 
01250     // DMc - make sure that the change type is set
01251     if (Attrib)
01252     {
01253         ValueChangeType = Attrib->GetRuntimeClass();
01254     }
01255 
01256     NodeAttribute* pAppliedAttrib; 
01257 
01258     BOOL Mutate = FALSE;
01259     BOOL RedrawBlobs = FALSE;
01260     NodeAttribute* OldAttr = NULL;
01261 
01262     if (Attrib == NULL)
01263     {
01264         // If the first param is NULL then we are doing a mutation
01265         Attrib = (NodeAttribute*)(void *)pOpParam->Param2;
01266         m_pAttr = Attrib;
01267 
01268         // DMc - make sure that the change type is set
01269         if (Attrib)
01270         {
01271             ValueChangeType = Attrib->GetRuntimeClass();
01272         }
01273     
01274         Mutate = TRUE;
01275 
01276         ValueChangeType = Attrib->GetRuntimeClass();
01277 
01278         if( ValueChangeType == CC_RUNTIME_CLASS(AttrTranspChange)
01279             || ValueChangeType == CC_RUNTIME_CLASS(FillGeometryNudger)
01280             )
01281         {
01282             MergeRepeats = TRUE;
01283         }
01284     }   
01285     else
01286     {
01287         // Someone has specified a Particular Attribute that we should replace
01288         // and ignore all others.
01289         OldAttr = (NodeAttribute*)(void *)pOpParam->Param2;
01290         RedrawBlobs = Attrib->EffectsParentBounds();
01291     }
01292 
01293     SelRange* Sel;
01294     ObjChangeFlags cFlags;
01295     cFlags.Attribute = TRUE;
01296     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
01297 
01298     Sel = GetApplication()->FindSelection(); 
01299 
01300     if (!Sel->AllowOp(&ObjChange))
01301     {
01302         FailAndExecute();
01303         goto EndOperation;
01304     }
01305 
01306     // Get a description of the attribute being applied so that we can use it to create the 
01307     // undo string. 
01308     UndoAttribStrID = Attrib->GetAttrNameID();
01309 
01310     if (!DoStartSelOp(RedrawBlobs, RedrawBlobs, TRUE,TRUE))
01311     {
01312         goto EndOperation;  
01313     }
01314 
01315     NodeAttribute* OtherAttrib;
01316 
01317     // Some Attributes require a second attribute to be changed as well,
01318     // which has to be done within this op.
01319 
01320     BOOL IsMutate;
01321     OtherAttrib = AttributeManager::GetOtherAttrToApply(Attrib, &IsMutate);
01322             
01323     // Before we apply the attribute to the selection we must localise all attributes
01324     // with the same type that we are going to apply. If we don't do this then the
01325     // tree will be left in an invalid state. 
01326 
01327     AttrTypes.AddToSet((Attrib->GetAttributeType())); 
01328     if (OtherAttrib != NULL)
01329     {
01330         AttrTypes.AddToSet((OtherAttrib->GetAttributeType())); 
01331     }
01332     
01333     // Invalidate before
01334     if (!DoInvalidateRegions(&SelRng, 
01335                              Attrib, 
01336                              Mutate,
01337                              OtherAttrib,
01338                              IsMutate))  //Mutators have to include bounds
01339     {
01340         goto EndOperation;
01341     }
01342 
01343         
01344     if (!DoLocaliseForAttrChange(&SelRng, &AttrTypes))
01345     {
01346         goto EndOperation;
01347     }
01348 
01349     if (!ApplyToSelection(Attrib, Mutate))
01350     {
01351         goto EndOperation;
01352     }
01353     
01354     pAppliedAttrib = Attrib;    
01355     Attrib = OtherAttrib;
01356 
01357     // Karim 26/06/2000
01358     // Some attributes (only AttrLineWidth at the mo') need to *selectively*
01359     // apply the second attribute - hence it must *not* be applied here.
01360     if (Attrib != NULL && !pAppliedAttrib->OtherAttrIsAppliedSelectively())
01361     {
01362         if (!ApplyToSelection(Attrib, IsMutate))
01363         {
01364             delete Attrib;
01365             goto EndOperation;
01366         }
01367     }
01368     
01369     // Invalidate after
01370     if (!DoInvalidateRegions(&SelRng, 
01371                              pAppliedAttrib, 
01372                              Mutate,
01373                              OtherAttrib,
01374                              IsMutate))  //Mutators have to include bounds
01375     {
01376         delete Attrib;
01377         goto EndOperation; 
01378     }
01379 
01380     delete Attrib;
01381     
01382     // Having applied the attributes, we  must now try and factor out the newly 
01383     // applied attributes
01384     if (!DoFactorOutAfterAttrChange(&SelRng, &AttrTypes))
01385     {
01386         goto EndOperation;
01387     }
01388 
01389     AttrFillGeometry::LastRenderedMesh = NULL;
01390 
01391     if (Document::GetSelected())
01392         Document::GetSelected()->SetModified(TRUE);
01393 
01394     ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
01395     if (!UpdateChangedNodes(&ObjChange))
01396         FailAndExecute();
01397 
01398     AttributeManager::LastAppliedBounds = Sel->GetBoundingRect();
01399 
01400     EndOperation:           
01401     EndSlowJob();
01402 
01403     AttrTypes.DeleteAll();
01404 
01405 #endif
01406     End(); // End of operation
01407 } 

void OpApplyAttribToSelected::GetOpName String_256 OpName  )  [virtual]
 

The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/2/94
Parameters:
- [INPUTS]
The undo string for the operation [OUTPUTS]
Returns:

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 1717 of file attrappl.cpp.

01718 { 
01719     
01720     *OpName = String_256(UndoAttribStrID); 
01721     *OpName += String_256(_R(IDS_CHANGE)); 
01722 }  

OpState OpApplyAttribToSelected::GetState String_256 ,
OpDescriptor OpDesc
[static]
 

For finding OpApplyAttribToSelected state.

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

Errors: -

See also:
-

Reimplemented in OpEditFill.

Definition at line 1686 of file attrappl.cpp.

01687 {
01688     OpState OpSt;
01689 
01690     SelRange* Sel = GetApplication()->FindSelection();
01691     ERROR2IF(Sel==NULL,OpSt,"Can't find SelRange!");
01692 
01693     // The Operation is greyed if there are no nodes selected 
01694     OpSt.Greyed = ( (Sel->FindFirst() == NULL) );  
01695                                                 
01696     return(OpSt);   
01697 }

BOOL OpApplyAttribToSelected::Init void   )  [static]
 

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

Reimplemented in OpEditFill.

Definition at line 1632 of file attrappl.cpp.

01633 {
01634     // Register the opdescriptors for the OpApplyAttribToSelected operation
01635     OpDescriptor* OpDesc = new OpDescriptor(
01636                                             0,
01637                                             _R(IDS_APPLYATTRIBOP),              
01638                                             CC_RUNTIME_CLASS(OpApplyAttribToSelected),
01639                                             OPTOKEN_APPLYATTRIB,
01640                                             OpApplyAttribToSelected::GetState); 
01641     ERRORIF(!OpDesc, _R(IDE_NOMORE_MEMORY), FALSE);
01642 
01643     OpDesc = new OpDescriptor(
01644                                             0,
01645                                             _R(IDS_APPLYATTR_INTERACTIVE),
01646                                             CC_RUNTIME_CLASS(OpApplyAttrInteractive),
01647                                             OPTOKEN_APPLYATTRINTERACTIVE,
01648                                             OpApplyAttrInteractive::GetState);
01649     ERRORIF(!OpDesc, _R(IDE_NOMORE_MEMORY), FALSE);
01650 
01651 
01652         // Bodge this needs to use faby Macro technology so that the op is attached to
01653         // a system bar.
01654     OpDesc = new OpChangeLineWidthOpDesc(0,
01655                                          _R(IDS_CHANGELINEWIDTH),
01656                                          CC_RUNTIME_CLASS(OpApplyAttribToSelected),
01657                                          OPTOKEN_CHANGELINEWIDTH,
01658                                          OpChangeLineWidthOpDesc::GetState,
01659                                          0,
01660                                          _R(IDBBL_CHANGELINEWIDTH),
01661                                          _R(IDCB_LINEWIDTH_COMBO_BOX),
01662                                          _R(IDCB_LINEWIDTH_COMBO_BOX));
01663     ERRORIF(!OpDesc, _R(IDE_NOMORE_MEMORY), FALSE);
01664 
01665     if (!OpRepeatApplyAttribToSelected::Init())
01666         return FALSE;   
01667     
01668     return TRUE;
01669 }               


Member Data Documentation

UINT32 OpApplyAttribToSelected::UndoAttribStrID [protected]
 

Definition at line 188 of file attrappl.h.


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