OpChangeFeatherProfile Class Reference

#include <opfeathr.h>

Inheritance diagram for OpChangeFeatherProfile:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpChangeFeatherProfile ()
virtual void Do (OpDescriptor *pOp)
 This function is called when the user clicks our linked profile button (yahoo!). This function does one of two things:.
virtual void DoWithParam (OpDescriptor *pOp, OpParam *pParam)
 Change all selected feather profiles Note: It's important that the basic logic of this function is the same as that in GetProfileFromSelection2.
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

static OpState GetState (String_256 *, OpDescriptor *)
 Return availability of OpChangeFeatherProfile.
static BOOL Init ()
 Declares a preference that allows you to clear memory in delete().

Protected Member Functions

virtual BOOL OnSelChangingMsg (SelChangingMsg::SelectionState State)
 Update the Profile dialog when the selection changes.

Private Member Functions

BOOL DoChangeFeatherProfile (FeatherAttrValue *pAttr, CProfileBiasGain &newProfile)
 Change one feather profile.

Static Private Member Functions

static SelRange::CommonAttribResult GetProfileFromSelection2 (BOOL bFastScan, CProfileBiasGain *pCommonProfile)
 See InformationBarOp::GetProfileFromSelection() for a description of this function. See BlendInfoBarOp::GetProfileFromSelection for multi-gadget eg.

Detailed Description

Definition at line 363 of file opfeathr.h.


Constructor & Destructor Documentation

OpChangeFeatherProfile::OpChangeFeatherProfile  )  [inline]
 

Definition at line 368 of file opfeathr.h.

00368 : UndoableOperation() {}


Member Function Documentation

void OpChangeFeatherProfile::Do OpDescriptor pOp  )  [virtual]
 

This function is called when the user clicks our linked profile button (yahoo!). This function does one of two things:.

Author:
Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/3/2000
1) Gets the current feathering profile (if there is one); and invokes the profile dialog with it. 2) Closes the profile dialog down.

See Also: InformationBarOp::GetProfileFromSelection() for tips of implementing the remainder of this function.

NOTE: At present one should NOT implement OpChangeFeatherProfile::DoWithParam ()

Reimplemented from Operation.

Definition at line 1603 of file opfeathr.cpp.

01604 {
01605     if (!(ChangeFeatherProfileOpDesc::m_BiasGainGadget.IsDialogOpen ()))
01606     {
01607         CBiasGainDlg* pDialog_m  =  new CBiasGainDlg();
01608         CProfileBiasGain CommonProfile;
01609         SelRange::CommonAttribResult status = GetProfileFromSelection2(FALSE, &CommonProfile);
01610 
01611         // I don't why this isn't working like the other profile gadgets do, BUT 
01612         // force the controlling button to stay down!
01613 
01614         // AUGH!!!!!!  why on earth do I get a divide by zero error from the dialog if I call 
01615         // SetBoolGadgetSelected?  well sod it, the button can damn well stay up!
01616 
01617         //pDlg->SetLongGadgetValue (FeatherProfile->GetUniqueGadgetID (), 1);
01618 
01619         //ChangeFeatherProfileOpDesc::m_BiasGainGadget.GetOwningBar ()->SetBoolGadgetSelected (_R(IDC_FEATHERPROFILE_GDGT), TRUE);
01620         
01621         //ChangeFeatherProfileOpDesc::SetBoolGadgetSelected (_R(IDC_FEATHERPROFILE_GDGT), TRUE);
01622         
01623         pDialog_m->InvokeVia(ChangeFeatherProfileOpDesc::m_BiasGainGadget, &CommonProfile, status==Range::ATTR_MANY);
01624     }
01625     else
01626     {
01627         //ChangeFeatherProfileOpDesc::m_BiasGainGadget.GetOwningBar ()->SetBoolGadgetSelected (_R(IDC_FEATHERPROFILE_GDGT), FALSE);
01628         ChangeFeatherProfileOpDesc::m_BiasGainGadget.CloseDialog();
01629         //ChangeFeatherProfileOpDesc::SetBoolGadgetSelected (_R(IDC_FEATHERPROFILE_GDGT), FALSE);
01630     }
01631 }

BOOL OpChangeFeatherProfile::DoChangeFeatherProfile FeatherAttrValue pFeather,
CProfileBiasGain newProf
[private]
 

Change one feather profile.

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

Definition at line 2020 of file opfeathr.cpp.

02021 {
02022     CProfileBiasGain undoProf = pFeather->GetProfile();
02023 
02024     if (!pFeather->ChangeFeatherProfile(newProf))
02025     {
02026         // ChangeFeatherProfileAction doesn't need to alloc any memory so shouldn't ever fail
02027         return FALSE;
02028     }
02029 
02030     ChangeFeatherProfileAction* pAct = NULL;
02031 
02032     // Setup the action to undo this Operation
02033     if (!ChangeFeatherProfileAction::Init(  this, 
02034                                             &UndoActions,
02035                                             pFeather,
02036                                             undoProf,
02037                                             &pAct   ) == AC_OK )
02038     {
02039         return FALSE;
02040     }
02041 
02042     return TRUE;
02043 }

void OpChangeFeatherProfile::DoWithParam OpDescriptor pOp,
OpParam pParam
[virtual]
 

Change all selected feather profiles Note: It's important that the basic logic of this function is the same as that in GetProfileFromSelection2.

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

Reimplemented from Operation.

Definition at line 1788 of file opfeathr.cpp.

01789 {
01790     ObjChangeFlags cFlags;
01791     cFlags.Attribute = TRUE;
01792     DocRect InvalidRegion(0,0,0,0); // To prevent individual node redraws we union all bounding
01793                                     // rects of nodes which get feathered and then generate a
01794                                     // single redraw action (DoInvalidateNodeRegion)
01795     CProfileBiasGain NewProfile;
01796     ListRange* pLevelRange = NULL;
01797     AttrFeather* pAttr = NULL;
01798 
01799     if (pParam && IS_A(pParam, FeatherProfileOpParam))
01800     {
01801         FeatherProfileOpParam* pProfileParam = (FeatherProfileOpParam*)pParam;
01802         pLevelRange = pProfileParam->pLevelRange;
01803         NewProfile = pProfileParam->P;
01804     }
01805 
01806     if (pLevelRange==NULL)
01807     {
01808         SelRange* pSelRange = GetApplication()->FindSelection();
01809         pLevelRange = pSelRange->GetTopClassRange(CC_RUNTIME_CLASS(NodeFeatherEffect), FALSE, TRUE);
01810     }
01811 
01812     // Since the selection may change during this Op we must get a permanent copy of
01813     // the level range we are working on
01814     ListRange* pLocalRange = new ListRange(pLevelRange);
01815     if (pLocalRange==NULL)
01816     {
01817         FailAndExecute();
01818         End();
01819         return;
01820     }
01821 
01822     if (((ChangeFeatherProfileOpDesc*)pOp)->m_bProfileChanging)
01823     {
01824         // Prevent slow renderers from doing their stuff while we try to
01825         // show the results of the feather op interactively.
01826         Operation::SetQuickRender(TRUE, this);
01827     }
01828 
01829     DoInvalidateNodesRegions(*pLocalRange, TRUE, FALSE, FALSE, FALSE);
01830 
01831     Node* pNode = pLocalRange->FindFirst();
01832     while (pNode)
01833     {
01834 #ifdef FEATHER_EFFECT
01835         if (pNode->IsEffect() && ((NodeEffect*)pNode)->IsFeatherEffect())
01836         {
01837             // -------------------------------------------------------------------------
01838             // Feather effect case:
01839             NodeFeatherEffect* pEffect = (NodeFeatherEffect*)pNode;
01840             CProfileBiasGain undoProf = pEffect->GetProfile();
01841 
01842             // Setup the action to undo this Operation
01843             ChangeFeatherEffectProfileAction* pAct = NULL;
01844             if (ChangeFeatherEffectProfileAction::Init(this, 
01845                                                         &UndoActions,
01846                                                         pEffect,
01847                                                         undoProf,
01848                                                         &pAct   ) != AC_OK )
01849             {
01850                 FailAndExecute();
01851                 End();
01852                 return;
01853             }
01854 
01855             // Only set the new profile if the action was successfully allocated
01856             pEffect->SetProfile(NewProfile);
01857 
01858             // union feathered node bounding rect so only one redraw per feather op
01859             OpChangeFeatherSize::ReleaseFeatherCache(pEffect, InvalidRegion);
01860 
01861         }
01862         else
01863 #endif
01864         {
01865             // -------------------------------------------------------------------------
01866             // Feather attribute case:
01867             // Feather attributes don't get optimised so we know we should find it it in the child list of the selected item
01868             pAttr = (AttrFeather*)pNode->FindFirstChild(CC_RUNTIME_CLASS(AttrFeather));
01869 
01870 //          if (!pAttr)
01871 //          {
01872 //              // if there is no feather - see if the parent node is a compound; and if so,
01873 //              // see if it has been feathered ....
01874 //
01875 //              if (pNode->FindParent ()->IsController ())
01876 //              {
01877 //                  pAttr = pNode->FindParent ()->FindFirstChild(CC_RUNTIME_CLASS(AttrFeather));
01878 //              }
01879 //          }
01880 //
01881             if (pAttr)
01882             {
01883                 ObjChangeParam ObjChange(OBJCHANGE_STARTING, cFlags, pNode, this);
01884                 if (pNode->AllowOp(&ObjChange))
01885                 {
01886                     if (!DoChangeFeatherProfile(&pAttr->Value, NewProfile))
01887                     {
01888                         FailAndExecute();
01889                         End();
01890                         return;
01891                     }
01892 
01893                     // union feathered node bounding rect so only one redraw per feather op
01894                     if (pNode->IsAnObject())
01895                     {
01896                         OpChangeFeatherSize::ReleaseFeatherCache((NodeRenderableInk*)pNode, InvalidRegion);
01897                     }
01898 
01899                     // send the objchange message to trigger any OnChildChange messages
01900                     ObjChange.Define(OBJCHANGE_FINISHED, cFlags, pNode, this);
01901                     UpdateChangedNodes(&ObjChange);
01902                 }
01903             }
01904         }
01905 
01906         pNode = pLocalRange->FindNext(pNode);
01907     }
01908 
01909     delete pLocalRange;
01910     pLocalRange = NULL;
01911 
01912     // send through the redraw
01913     if (!(InvalidRegion.hi.x==0) || !(InvalidRegion.lo.x==0) || !(InvalidRegion.hi.y==0) || !(InvalidRegion.lo.y==0))
01914     {
01915         Document* SelectedDoc = Document::GetSelected();
01916         ENSURE(SelectedDoc,"No selected doc.");
01917         Spread* pSpread = SelectedDoc->GetSelectedSpread();
01918         ENSURE(pSpread,"No selected spread.");
01919 
01920         DoInvalidateRegion(pSpread,InvalidRegion);
01921     }
01922     else
01923     {
01924         // no nodes feathered
01925         SucceedAndDiscard();
01926     }
01927 
01928     if (!((ChangeFeatherProfileOpDesc*)pOp)->m_bProfileInitialChange)
01929     {
01930         // don't want op in op hist
01931         // nb Action::Init modifies the ophist size in anticipation of the op being added
01932         // to the history list. Hence modify the size
01933         SucceedAndDiscard();
01934     }
01935 
01936     if (((ChangeFeatherProfileOpDesc*)pOp)->m_bProfileChanging)
01937     {
01938         // Prevent slow renderers from doing their stuff while we try to
01939         // show the results of the feather op interactively.
01940         Operation::SetQuickRender(FALSE, this);
01941     }
01942 
01943     // bodge/hack alert!  I found it necessary to add some code to the selector tool to prevent
01944     // profile dilaogs from closing down when changing the selection.  Unfortunately, when you
01945     // change the profile within the feathers profile dialog - this same code is called; which
01946     // attempts to close down the dialog.  It must not do this!  I traced the offending call
01947     // (which invokes OpChangeFeatherProfile::OnSelChangingMsg ()) to being the following one
01948     // to End ().
01949     SelectorTool::SetNormalClick_CheckProfileDialog (TRUE);
01950     End();
01951     SelectorTool::SetNormalClick_CheckProfileDialog (FALSE);
01952 }

SelRange::CommonAttribResult OpChangeFeatherProfile::GetProfileFromSelection2 BOOL  bFastScan,
CProfileBiasGain pCommonProfile
[static, private]
 

See InformationBarOp::GetProfileFromSelection() for a description of this function. See BlendInfoBarOp::GetProfileFromSelection for multi-gadget eg.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/04/2005
Parameters:
- [INPUTS]
Common profile if there is one [OUTPUTS]
Returns:
Enum indicating None, Common or Many Profiles

Definition at line 1677 of file opfeathr.cpp.

01679 {   
01680     // we must now examine all our nodes ....
01681     
01682     // If we have a specific context within which we should be operating
01683     // use that
01684     Range* pLevelRange = OpChangeFeatherSize::GetEditContext();
01685     if (pLevelRange==NULL)
01686     {
01687         // If not, go get a context from the current selection
01688         SelRange* pSelRange = GetApplication()->FindSelection();
01689         pLevelRange = pSelRange->GetTopClassRange(CC_RUNTIME_CLASS(NodeFeatherEffect), FALSE, TRUE);
01690     }
01691     if (pLevelRange==NULL)
01692         return Range::ATTR_NONE;
01693     
01694     BOOL bFoundFeather = FALSE;
01695     CProfileBiasGain FirstProfile;
01696     AttrFeather* pAttr = NULL;
01697     SelRange::CommonAttribResult status = Range::ATTR_NONE;
01698     MonotonicTime timer;
01699 
01700     Node* pNode = pLevelRange->FindFirst();
01701     while (pNode && !(bFastScan && timer.Elapsed(100)))
01702     {
01703 #ifdef FEATHER_EFFECT
01704         if (pNode->IsEffect() && ((NodeEffect*)pNode)->IsFeatherEffect())
01705         {
01706             // -------------------------------------------------------------------------
01707             // Feather effect case:
01708             NodeFeatherEffect* pEffect = (NodeFeatherEffect*)pNode;
01709             if (!bFoundFeather)
01710             {
01711                 bFoundFeather = TRUE;
01712                 FirstProfile = pEffect->GetProfile();
01713                 status = Range::ATTR_COMMON;
01714             }
01715             else
01716             {
01717                 if (!(FirstProfile == pEffect->GetProfile()))
01718                 break;
01719             }
01720         }
01721         else
01722 #endif
01723         {
01724             // -------------------------------------------------------------------------
01725             // Feather attribute case:
01726             // Feather attributes don't get optimised so we know we should find it it in the child list of the selected item
01727             pAttr = (AttrFeather*)pNode->FindFirstChild(CC_RUNTIME_CLASS(AttrFeather));
01728 
01729             if (pAttr)
01730             {
01731                 if (!bFoundFeather)
01732                 {
01733                     bFoundFeather = TRUE;
01734                     FirstProfile = pAttr->Value.GetProfile();
01735                     status = Range::ATTR_COMMON;
01736                 }
01737                 else
01738                 {
01739                     if (!(FirstProfile == pAttr->Value.GetProfile()))
01740                     break;
01741                 }
01742             }
01743             else
01744             {
01745                 // node is using default feather - got two cases to handle here
01746                 // Or may be INSIDE a feathered Node!!! So checking default value is pointless!
01747             }
01748         }
01749 
01750         pNode = pLevelRange->FindNext(pNode);
01751     }
01752 
01753     // If we exited the loop while there were still more nodes to process
01754     // We must have run out of time or aborted early because we detected the "many" case
01755     if (pNode)
01756     {
01757         status = Range::ATTR_MANY;
01758         if (pCommonProfile)
01759             *pCommonProfile = *(new CProfileBiasGain());        // Reset to defaults
01760     }
01761     else
01762     {
01763         if (pCommonProfile)
01764             *pCommonProfile = FirstProfile;
01765     }
01766 
01767     return status;
01768 }

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

Return availability of OpChangeFeatherProfile.

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

Definition at line 1564 of file opfeathr.cpp.

01565 {
01566     OpState OpSt;
01567 
01568     SelRange::CommonAttribResult status = GetProfileFromSelection2(TRUE, NULL);
01569     if (status == Range::ATTR_NONE)
01570     {
01571         OpSt.Greyed = TRUE;
01572         String_256 DisableReason(_R(IDS_NO_FEATHERED_OBJECTS));
01573         *UIDescription = DisableReason;            
01574     }
01575 
01576     return OpSt;
01577 }

BOOL OpChangeFeatherProfile::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.

Definition at line 1530 of file opfeathr.cpp.

01531 {
01532     OpDescriptor* OpDesc = new ChangeFeatherProfileOpDesc(0,
01533                                              _R(IDS_FEATHERPROFILEOP),
01534                                              CC_RUNTIME_CLASS(OpChangeFeatherProfile),
01535                                              OPTOKEN_FEATHERPROFILE,
01536                                              OpChangeFeatherProfile::GetState,          // NB Operations GetState
01537                                              0,
01538                                              _R(IDBBL_FEATHERPROFILEOP),
01539                                              SYSTEMBAR_FEATHER,
01540                                              _R(IDC_FEATHERPROFILE_GDGT),
01541                                              TRUE,
01542                                              FALSE,
01543                                              FALSE,
01544                                              (GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION | DONT_GREY_WHEN_SELECT_INSIDE ) );
01545 
01546     ERRORIF(!OpDesc, FALSE, _R(IDE_NOMORE_MEMORY));
01547 
01548     return TRUE;
01549 }

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

Reimplemented from UndoableOperation.

Definition at line 375 of file opfeathr.h.

00375 { return FALSE; }

BOOL OpChangeFeatherProfile::OnSelChangingMsg SelChangingMsg::SelectionState  State  )  [protected, virtual]
 

Update the Profile dialog when the selection changes.

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

Reimplemented from MessageHandler.

Definition at line 1970 of file opfeathr.cpp.

01971 {
01972     if (ChangeFeatherProfileOpDesc::m_BiasGainGadget.IsDialogOpen ())
01973     {   
01974         CProfileBiasGain CommonProfile;
01975         SelRange::CommonAttribResult status = GetProfileFromSelection2(FALSE, &CommonProfile);
01976         if (status == Range::ATTR_MANY)
01977         {
01978             // handles case where we click on another blend
01979             ChangeFeatherProfileOpDesc::m_BiasGainGadget.ReInitialiseDialog(&CommonProfile, TRUE);
01980         }
01981         else if (status == Range::ATTR_COMMON)
01982         {   
01983             // handles case where we click on another blend
01984             ChangeFeatherProfileOpDesc::m_BiasGainGadget.ReInitialiseDialog(&CommonProfile, FALSE);
01985         }
01986         else
01987         {
01988             // CGS:  wo there!  when selecting another object, everything is deselected - and then just that node
01989             // selected.  This is a problem, since if we proceed regardless, the profile dialog closes (when it
01990             // possibly shouldn't have).  As such, I now check for this occurring ....
01991             if (!SelectorTool::GetNormalClick_CheckProfileDialog())
01992             {
01993                 // user click on no object at all - close the profile dialog ....
01994                 ChangeFeatherProfileOpDesc::m_BiasGainGadget.CloseDialog();
01995             }
01996             else
01997                 ChangeFeatherProfileOpDesc::m_BiasGainGadget.ReInitialiseDialog(&CommonProfile, FALSE);
01998         }
01999     }
02000     
02001     return (TRUE);
02002 }


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