OpApplyAttrInteractive Class Reference

More...

#include <attrappl.h>

Inheritance diagram for OpApplyAttrInteractive:

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

Public Member Functions

 OpApplyAttrInteractive ()
 OpApplyAttrInteractive constructor.
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.
virtual void DragFinished (DocCoord PointerPos, ClickModifiers ClickMods, Spread *pSpread, BOOL Success, BOOL bSolidDrag)
 Marks the end of the drag. It is at this point that all the transformations should be applied to the selection if everything worked. OpApplyAttrInteractive implements this just to pick up Escape handling through the Success flag.
virtual BOOL DoDragAttr (AttrValueChange *pNewValue)
 

virtual BOOL DragAttrChanged (AttrValueChange *pNewValue)
 

virtual BOOL DragAttrFinished (AttrValueChange *pNewValue, BOOL bSuccess=TRUE)
 

virtual void PerformMergeProcessing ()
 This virtual function gets called to allow for the merging of nudge operations.

Static Public Member Functions

static BOOL Init ()
 Declares a preference that allows you to clear memory in delete().
static OpState GetState (String_256 *, OpDescriptor *)
 For finding OpApplyAttrInteractive state.

Private Attributes

UINT32 m_UndoAttribStrID
List m_AttrGroupList
AttrTypeSet m_AttrTypes

Detailed Description

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005

Definition at line 205 of file attrappl.h.


Constructor & Destructor Documentation

OpApplyAttrInteractive::OpApplyAttrInteractive  ) 
 

OpApplyAttrInteractive constructor.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1749 of file attrappl.cpp.

01749                                               : OpApplyAttrib()                             
01750 {                              
01751 }


Member Function Documentation

BOOL OpApplyAttrInteractive::DoDragAttr AttrValueChange pNewValue  )  [virtual]
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1827 of file attrappl.cpp.

01828 {
01829     // ApplyAttribute without optimisations, without undo, get list of attributes affected and their initial values
01830     // Assume the value supplied is a "Mutator"
01831     AttrFillGeometry* pMutator = NULL;
01832     //BOOL MakeAttrCurrent = FALSE; // until we know better
01833     BOOL ApplyAttribute = FALSE;
01834 
01835     ERROR2IF(pNewValue==NULL, FALSE, "DoDragattr not given a decent attribute pointer");
01836     ERROR3IF(!pNewValue->IsAFillAttr(), "A Mutator must be a fill attribute");
01837     pMutator = (AttrFillGeometry*)pNewValue;
01838 
01839     SelRange* Sel = GetApplication()->FindSelection();
01840     ERROR3IF(Sel==NULL, "Can't find SelRange!");
01841     if (Sel==NULL) return FALSE;
01842 
01843     ApplyAttribute = AttributeManager::CanBeAppliedToSelection(pMutator, &m_AttrGroupList);
01844 
01845     if (ApplyAttribute)
01846     {
01847         // ------------------------------------------------------------------
01848         // Apply attributes without preamble and without optimisation or
01849         // localisation so that dragging starts up quickly.
01850         // Noe that the initial application is done undoably so that the intial
01851         // states of the attributes are recorded (see DragAttrFinished).
01852         //
01853         // Some Attributes require a second attribute to be changed as well,
01854         // which has to be done within this op.
01855         BOOL bMutateOther;
01856         NodeAttribute* pOtherAttrib = AttributeManager::GetOtherAttrToApply(pNewValue, &bMutateOther);
01857 
01858         // Apply attributes with undo - The undo info is used to record the initial states
01859         // of the attributes so that the drag can be abandoned correctly and finalised correctly
01860         DoApplyToSelection(this, pNewValue, TRUE, FALSE);       // Don't allow optimisations yet
01861 
01862         if (pOtherAttrib && !pNewValue->OtherAttrIsAppliedSelectively())
01863             DoApplyToSelection(this, pOtherAttrib, bMutateOther, FALSE);
01864 
01865         if (pOtherAttrib)
01866         {
01867             delete pOtherAttrib;
01868             pOtherAttrib = NULL;
01869         }
01870 
01871 //      StartDrag(DRAGTYPE_NOSCROLL);
01872         Operation::SetQuickRender(TRUE, this);
01873 
01874         // Quick redraw
01875         Sel->ForceRedrawView(GetWorkingDocView(), TRUE, TRUE, TRUE);
01876         GetWorkingDocView()->FlushRedraw();
01877         GetApplication()->ServiceRendering();
01878     }
01879 
01880     return ApplyAttribute;
01881 }

BOOL OpApplyAttrInteractive::DragAttrChanged AttrValueChange pNewValue  )  [virtual]
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1901 of file attrappl.cpp.

01902 {
01903     // Change attrs in the list and update without optimisation, without undo
01904     SelRange* Sel = GetApplication()->FindSelection();
01905     ERROR3IF(Sel==NULL, "Can't find SelRange!");
01906     if (Sel==NULL) return FALSE;
01907 
01908     BOOL bMutateOther;
01909     NodeAttribute* pOtherAttrib = AttributeManager::GetOtherAttrToApply(pNewValue, &bMutateOther);
01910 
01911     DoApplyToSelection(NULL, pNewValue, TRUE, FALSE);       // Don't allow optimisations yet
01912 
01913     if (pOtherAttrib && !pNewValue->OtherAttrIsAppliedSelectively())
01914         DoApplyToSelection(NULL, pOtherAttrib, bMutateOther, FALSE);
01915 
01916     if (pOtherAttrib)
01917     {
01918         delete pOtherAttrib;
01919         pOtherAttrib = NULL;
01920     }
01921 
01922     // Quick redraw
01923     Sel->ForceRedrawView(GetWorkingDocView(), TRUE, TRUE, TRUE);
01924     GetWorkingDocView()->FlushRedraw();
01925     GetApplication()->ServiceRendering();
01926 
01927     return TRUE;
01928 }

BOOL OpApplyAttrInteractive::DragAttrFinished AttrValueChange pNewValue,
BOOL  bSuccess = TRUE
[virtual]
 

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1948 of file attrappl.cpp.

01949 {
01950     SelRange* Sel = GetApplication()->FindSelection();
01951     ERROR3IF(Sel==NULL, "Can't find SelRange!");
01952     if (Sel==NULL)
01953     {
01954         FailAndExecute();
01955         End();
01956         return FALSE;
01957     }
01958 
01959 //  bSuccess = EndDrag();
01960     Operation::SetQuickRender(FALSE, this);
01961 
01962     if (!bSuccess)
01963     {
01964         // Just restore back to how things were when the drag started
01965         BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED)); 
01966         FailAndExecute();
01967         End();
01968         return FALSE;
01969     }
01970 
01971     BeginSlowJob();
01972 
01973     // ---------------------------------------------------------------------
01974     // Before we record the real undo info
01975     // restore the original attributes by executing the undo info
01976     // recorded when the drag started.
01977     //
01978     // This is a bit low level but it leverages the existing undo system to
01979     // record the initial states of the attributes rather than writing
01980     // something new to do the same job.
01981     //
01982     FailAndExecute();
01983     KeepOnEnd();            // This ensures that this Op is not self-deleted inside End()!
01984     End();
01985 
01986     // -----------------------------------------------------------------
01987     m_AttrTypes.DeleteAll();
01988     AttributeManager::pLastNodeAppliedTo = NULL;
01989     ValueChangeType = pNewValue->GetRuntimeClass();
01990     BOOL RedrawBlobs = FALSE;
01991     NodeAttribute* pOtherAttrib = NULL;
01992 
01993     ObjChangeFlags cFlags;
01994     cFlags.Attribute = TRUE;
01995     ObjChangeParam ObjChange(OBJCHANGE_STARTING, cFlags, NULL, this);
01996 
01997     if (!Sel->AllowOp(&ObjChange))
01998     {
01999         FailAndExecute();
02000         goto EndOperation;
02001     }
02002 
02003     // Get a description of the attribute being applied so that we can use it to create the 
02004     // undo string. 
02005     m_UndoAttribStrID = pNewValue->GetAttrNameID();
02006 
02007     if (!DoStartSelOp(RedrawBlobs, RedrawBlobs, TRUE, TRUE))
02008     {
02009         FailAndExecute();
02010         goto EndOperation;
02011     }
02012 
02013     // Some Attributes require a second attribute to be changed as well,
02014     // which has to be done within this op.
02015     BOOL bMutateOther;
02016     pOtherAttrib = AttributeManager::GetOtherAttrToApply(pNewValue, &bMutateOther);
02017             
02018     // Before we apply the attribute to the selection we must localise all attributes
02019     // with the same type that we are going to apply. If we don't do this then the
02020     // tree will be left in an invalid state. 
02021     m_AttrTypes.AddToSet((pNewValue->GetAttributeType())); 
02022     if (pOtherAttrib)
02023         m_AttrTypes.AddToSet((pOtherAttrib->GetAttributeType())); 
02024     
02025     // Invalidate before
02026     if (!DoInvalidateRegions(Sel, 
02027                              pNewValue, 
02028                              TRUE,              // Always mutate new value attribute
02029                              pOtherAttrib,
02030                              bMutateOther))     // Mutators have to include bounds
02031     {
02032         FailAndExecute();
02033         goto EndOperation;
02034     }
02035 
02036     if (!DoLocaliseForAttrChange(Sel, &m_AttrTypes))
02037     {
02038         FailAndExecute();
02039         goto EndOperation;
02040     }
02041 
02042     // -----------------------------------------------------------------
02043     DoApplyToSelection(this, pNewValue, TRUE, TRUE);        // Now we can undo, Now we can optimise!
02044 
02045     if (pOtherAttrib && !pNewValue->OtherAttrIsAppliedSelectively())
02046         DoApplyToSelection(this, pOtherAttrib, bMutateOther, TRUE);
02047 
02048     if (pOtherAttrib)
02049     {
02050         delete pOtherAttrib;
02051         pOtherAttrib = NULL;
02052     }
02053 
02054     // -----------------------------------------------------------------
02055     // Invalidate after
02056     if (!DoInvalidateRegions(Sel,
02057                              pNewValue, 
02058                              TRUE,
02059                              pOtherAttrib,
02060                              bMutateOther))  //Mutators have to include bounds
02061     {
02062         FailAndExecute();
02063         goto EndOperation;
02064     }
02065 
02066     // Having applied the attributes, we  must now try and factor out the newly 
02067     // applied attributes
02068     if (!DoFactorOutAfterAttrChange(Sel, &m_AttrTypes))
02069     {
02070         FailAndExecute();
02071         goto EndOperation;
02072     }
02073 
02074     AttrFillGeometry::LastRenderedMesh = NULL;
02075 
02076     if (Document::GetSelected())
02077         Document::GetSelected()->SetModified(TRUE);
02078 
02079     cFlags.Attribute = TRUE;
02080     ObjChange.Define(OBJCHANGE_FINISHED, cFlags, NULL, this);
02081     if (!UpdateChangedNodes(&ObjChange))
02082         FailAndExecute();
02083 
02084     AttributeManager::LastAppliedBounds = Sel->GetBoundingRect();
02085 
02086     // -----------------------------------------------------------------
02087     AttributeManager::UpdateCurrentAppliedAttr(pNewValue, &m_AttrGroupList, TRUE, TRUE);
02088     AttributeManager::UpdateAfterAttrApplied(pNewValue);
02089 
02090 // ------------------------------------------
02091 EndOperation:           
02092     EndSlowJob();
02093 
02094     m_AttrTypes.DeleteAll();
02095     m_AttrGroupList.DeleteAll();
02096 
02097     End(); // End of operation
02098 
02099     Sel->BroadcastAnyPendingMessages();
02100 
02101     return TRUE;
02102 }

void OpApplyAttrInteractive::DragFinished DocCoord  PointerPos,
ClickModifiers  ClickMods,
Spread pSpread,
BOOL  Success,
BOOL  bSolidDrag
[virtual]
 

Marks the end of the drag. It is at this point that all the transformations should be applied to the selection if everything worked. OpApplyAttrInteractive implements this just to pick up Escape handling through the Success flag.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/08/2005
Parameters:
PointerPos - The position of the mouse at the end of the drag [INPUTS] ClickMods - the keyboard modifiers in place pSpread - the spread that was under the mouse Worked - TRUE if the drag was completed successfully

Reimplemented from Operation.

Definition at line 2243 of file attrappl.cpp.

02248 {
02249     DragAttrFinished(NULL, Success);
02250 }

void OpApplyAttrInteractive::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:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005
Parameters:
- [INPUTS]
The undo string for the operation [OUTPUTS]
Returns:

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 1803 of file attrappl.cpp.

01804 { 
01805     *OpName = String_256(m_UndoAttribStrID); 
01806     *OpName += String_256(_R(IDS_CHANGE)); 
01807 }  

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

For finding OpApplyAttrInteractive state.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/08/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpApplyAttrInteractive operation

Errors: -

See also:
-

Definition at line 1771 of file attrappl.cpp.

01772 {
01773     OpState OpSt;
01774 
01775     SelRange* Sel = GetApplication()->FindSelection();
01776     ERROR2IF(Sel==NULL,OpSt,"Can't find SelRange!");
01777 
01778     // The Operation is greyed if there are no nodes selected 
01779     OpSt.Greyed = ( (Sel->FindFirst() == NULL) );  
01780                                                 
01781     return OpSt;
01782 }

static BOOL OpApplyAttrInteractive::Init void   )  [static]
 

Declares a preference that allows you to clear memory in delete().

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/4/94
Returns:
TRUE if it worked OK, FALSE if not

Reimplemented from SimpleCCObject.

void OpApplyAttrInteractive::PerformMergeProcessing void   )  [virtual]
 

This virtual function gets called to allow for the merging of nudge operations.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
01/10/2005
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from UndoableOperation.

Definition at line 2122 of file attrappl.cpp.

02123 {    
02124     // Obtain a pointer to the operation history for the current document
02125     OperationHistory* pOpHist = &pOurDoc->GetOpHistory();
02126 
02127     // Ensure that we are the last operation added to the operation history
02128     // Note cannot be an ERROR2 cos this function cannot fail. 
02129     ERROR3IF(pOpHist->FindLastOp() != this, "Last Op should be this op"); 
02130     if (pOpHist->FindLastOp() != this)
02131         return;
02132     
02133     // OK lets see if the operation performed before this was an OpNudge operation
02134     Operation* pPrevOp = pOpHist->FindPrevToLastOp();
02135     if (pPrevOp == NULL)   // Check if there was a previous op
02136         return;
02137     
02138     if (!IS_A(pPrevOp, OpApplyAttrInteractive))
02139         return;
02140 
02141     // Yes it was
02142     // We can merge this op with pPrevOp if they both apply to the same set of objects
02143     // This will be TRUE is their SelectionStates are the same. 
02144     RestoreSelectionsAction* pRestoreSelAct = (RestoreSelectionsAction*)
02145         GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(RestoreSelectionsAction));  
02146     ERROR3IF(pRestoreSelAct == NULL, "This op should have a RestoreSelectionsAction");
02147     SelectionState* ThisOpsSelection = pRestoreSelAct->GetSelState();
02148 
02149     pRestoreSelAct = (RestoreSelectionsAction*)
02150         pPrevOp->GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(RestoreSelectionsAction));     
02151     ERROR3IF(pRestoreSelAct == NULL, "OpNudge op should have a RestoreSelectionsAction");
02152     SelectionState* LastOpsSelection = pRestoreSelAct->GetSelState();
02153 
02154     if (! ((*ThisOpsSelection) == (*LastOpsSelection)))
02155         return;
02156 
02157     ActionList* pPrevList = pPrevOp->GetUndoActionList();
02158     ActionList* pThisList = this->GetUndoActionList();
02159     if (pPrevList->GetCount()!=pThisList->GetCount())
02160         return;
02161 
02162     // Check that all actions are the same before we go any further...
02163     Action* pPrevAct = (Action*)pPrevList->GetHead();
02164     Action* pThisAct = (Action*)pThisList->GetHead();
02165     while (pPrevAct && pThisAct)
02166     {
02167         if (pPrevAct->GetRuntimeClass() != pThisAct->GetRuntimeClass())
02168             return;
02169 
02170         if (pPrevAct->IsKindOf(CC_RUNTIME_CLASS(UnApplyAction)))
02171         {
02172             UnApplyAction* pPrevApplyAct = (UnApplyAction*)pPrevAct;
02173             UnApplyAction* pThisApplyAct = (UnApplyAction*)pThisAct;
02174             if (pPrevApplyAct->m_pApplyNode != pThisApplyAct->m_pApplyNode)
02175                 return;
02176         }
02177 
02178         pPrevAct = (Action*)pPrevList->GetNext(pPrevAct);
02179         pThisAct = (Action*)pThisList->GetNext(pThisAct);
02180     }
02181 
02182     // Now we know all actions are the same, we can go ahead and transfer
02183     // The attribute information from this action list to the previous
02184     // action list...
02185     pPrevAct = (Action*)pPrevList->GetHead();
02186     pThisAct = (Action*)pThisList->GetHead();
02187     while (pPrevAct && pThisAct)
02188     {
02189         ERROR3IF(pPrevAct->GetRuntimeClass() != pThisAct->GetRuntimeClass(), "This can't happen!");
02190         if (pPrevAct->GetRuntimeClass() != pThisAct->GetRuntimeClass())
02191             return;
02192 
02193         if (pPrevAct->IsKindOf(CC_RUNTIME_CLASS(UnApplyAction)))
02194         {
02195             UnApplyAction* pPrevApplyAct = (UnApplyAction*)pPrevAct;
02196             UnApplyAction* pThisApplyAct = (UnApplyAction*)pThisAct;
02197             ERROR3IF(pPrevApplyAct->m_pApplyNode != pThisApplyAct->m_pApplyNode, "This can't happen!");
02198             if (pPrevApplyAct->m_pApplyNode != pThisApplyAct->m_pApplyNode)
02199                 return;
02200 
02201             // Update the previous UnApply action to hold the latest
02202             // attribute value from this Operation
02203             if (pPrevApplyAct->m_pAttribute)
02204                 delete pPrevApplyAct->m_pAttribute;
02205 
02206             pPrevApplyAct->m_pAttribute = pThisApplyAct->m_pAttribute;
02207 
02208             pThisApplyAct->m_pAttribute = NULL;
02209         }
02210 
02211         pPrevAct = (Action*)pPrevList->GetNext(pPrevAct);
02212         pThisAct = (Action*)pThisList->GetNext(pThisAct);
02213     }
02214 
02215     // This op is no longer required, so let's vape it
02216     pOpHist->DeleteLastOp();
02217 }


Member Data Documentation

List OpApplyAttrInteractive::m_AttrGroupList [private]
 

Definition at line 228 of file attrappl.h.

AttrTypeSet OpApplyAttrInteractive::m_AttrTypes [private]
 

Definition at line 229 of file attrappl.h.

UINT32 OpApplyAttrInteractive::m_UndoAttribStrID [private]
 

Definition at line 227 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