OpEditLiveEffect Class Reference

Operation to apply Bitmap Effect to the selection. See also:. More...

#include <opliveeffects.h>

Inheritance diagram for OpEditLiveEffect:

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

Public Member Functions

virtual void GetOpName (String_256 *pstrOpName)
virtual BOOL DoEffectOp (ListRange *pLevelRange, OpLiveEffectParam *pLEOpParam)
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

static OpState GetParamState (String_256 *pstrDescription, OpDescriptor *pOpDesc, OpParam *pOpParam)
 Return state of the specified LiveEffect (name in pstrDescription) being applied to the selection (taking into account the current position in the LiveEffect Stack.

Protected Member Functions

virtual BOOL AllowEmptySelection () const

Private Member Functions

 CC_DECLARE_DYNCREATE (OpEditLiveEffect)

Detailed Description

Operation to apply Bitmap Effect to the selection. See also:.

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

Definition at line 395 of file opliveeffects.h.


Member Function Documentation

virtual BOOL OpEditLiveEffect::AllowEmptySelection  )  const [inline, protected, virtual]
 

Reimplemented from OpLiveEffect.

Definition at line 415 of file opliveeffects.h.

00415 { return TRUE; }

OpEditLiveEffect::CC_DECLARE_DYNCREATE OpEditLiveEffect   )  [private]
 

BOOL OpEditLiveEffect::DoEffectOp ListRange pLevelRange,
OpLiveEffectParam pLEOpParam
[virtual]
 

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

Errors: See also:

Reimplemented from OpLiveEffect.

Definition at line 3018 of file opliveeffects.cpp.

03019 {
03020     m_pLERange = new ListRange(pLevelRange);    // Grab ownership of returned list by copying it
03021     BOOL ok = FALSE;
03022 
03023     // Find out whether the user is trying to edit a destructive effect...
03024     {
03025         Node* pNode = m_pLERange->FindFirst();
03026         INT32 count=0;
03027         BOOL bDestructive = FALSE;
03028         BOOL bLocked = FALSE;
03029         while (pNode)
03030         {
03031             if (pNode->IsBitmapEffect() && ((NodeBitmapEffect*)pNode)->IsLockedEffect())
03032             {
03033                 bLocked = TRUE;
03034                 if (!((NodeLockedEffect*)pNode)->CanBeUnlocked())
03035                     bDestructive = TRUE;
03036             }
03037 
03038             count++;
03039             pNode = m_pLERange->FindNext(pNode);
03040         }
03041         if (bDestructive)
03042         {
03043             ENSURE(count==1, "Shouldn't allow user to edit more than one destructive effects at a time - greying should prevent this");
03044 
03045             INT32 butt = AskQuestion(_R(IDS_LE_DESTRUCTIVE_EDIT), _R(IDS_LE_RECREATEEFFECT), _R(IDS_CANCEL));
03046             if (butt==2)
03047             {
03048                 FailAndExecute();
03049                 End();
03050                 return FALSE;
03051             }
03052 
03053             // We need to abandon this edit, delete the destructive effects and go re-apply new ones
03054             // by calling OpApplyLiveEffect
03055             //
03056             // Record list of nodes under this effect list before we delete it
03057             ListRange* pRangeUnderDeletedEffect = new ListRange();
03058             if (pRangeUnderDeletedEffect==NULL)
03059             {
03060                 FailAndExecute();
03061                 End();
03062                 return FALSE;
03063             }
03064             Node* pNode = m_pLERange->FindFirst();
03065             while (pNode)
03066             {
03067                 if (pNode->IsBitmapEffect())
03068                 {
03069                     Node* pChild = ((NodeBitmapEffect*)pNode)->GetInkNodeFromController();
03070                     if (pChild) pRangeUnderDeletedEffect->AddNode(pChild);
03071                 }
03072                 else
03073                     ERROR3("Something's gone horribly wrong - non bitmap effect foudn in list of locked effects to be deleted\n");
03074 
03075                 pNode = m_pLERange->FindNext(pNode);
03076             }
03077             if (pRangeUnderDeletedEffect->IsEmpty())
03078             {
03079                 ERROR3("List of nodes under locked effect unexpectedly empty\n");
03080                 FailAndExecute();
03081                 End();
03082                 return FALSE;
03083             }
03084 
03085             // Get rid of this edit list before calling XPE
03086             ok = OpLiveEffect::DoDeletePostProcessor(this, m_pLERange);
03087             if (ok)
03088             {
03089                 // OK, now insret new effects in place fo the ones we just deleted
03090                 // (Leave m_iStackPos alone because it must, by definition, remain the same)
03091                 delete m_pLERange;
03092                 m_pLERange = DoApplyLockedEffect(pRangeUnderDeletedEffect, pLEOpParam->strOpUnique, pLEOpParam->strMenuText, NodeBitmapEffect::DefaultLockedPixelsPerInch);
03093                 m_bAppliedNewEffects = (m_pLERange!=NULL);
03094             }
03095             else
03096             {
03097                 FailAndExecute();
03098                 End();
03099                 return FALSE;
03100             }
03101             if (pRangeUnderDeletedEffect)
03102             {
03103                 delete pRangeUnderDeletedEffect;
03104                 pRangeUnderDeletedEffect = NULL;
03105             }
03106         }
03107         else
03108         {
03109             // Record the current state of this edit list before calling XPE
03110             // Mark this point in the LiveEffect's life ("on my mark") so that it can be undone
03111             // back to this point
03112             ActionCode ac = MarkEditListAction::DoMarkEditList(this, &UndoActions, pLEOpParam->pPPStack, pLEOpParam->StackPosition);
03113         }
03114     }
03115 
03116     // Mark all LiveEffects as untouched at this stage for change detection later on...
03117     SetChanged(FALSE);
03118 
03119     // Make sure we've got all the bitmaps we need to proceed
03120     ok = EnsureLiveEffectOriginalBitmaps();
03121     if (!ok)
03122     {
03123         FailAndExecute();
03124         End();
03125         return FALSE;
03126     }
03127     
03128     // OK, LiveEffects nodes are in the tree and have the original bitmaps that we need
03129     //
03130     // Now decide which bitmap to pass to XPE
03131     NodeBitmapEffect* pLE = NULL;
03132     if (m_pLERange)
03133     {
03134         Node* pNode = m_pLERange->FindLast();
03135         while (pNode && !(pNode->IsBitmapEffect() && ((NodeBitmapEffect*)pNode)->CanGenerateBitmap()))
03136             pNode = m_pLERange->FindPrev(pNode);
03137 
03138         if (pNode==NULL)
03139         {
03140             FailAndExecute();
03141             End();
03142             return FALSE;
03143         }
03144 
03145         pLE = (NodeBitmapEffect*)pNode;
03146     }
03147 
03148     // ----------------------------------------------
03149     // This is the important bit!
03150     //
03151     // Pass the sample bitmap to the XPE for editing
03152     // REMEMBER! This is only starting an edit - the results won't be known until later
03153     //
03154     ok = XPEHost::EditLiveEffect(this, pLE, pLEOpParam->strOpUnique, pLEOpParam->bReUseEditor);
03155     if (!ok)
03156     {
03157         FailAndExecute();
03158         End();
03159         return FALSE;
03160     }
03161 
03162     GetApplication()->FindSelection()->Update();
03163 
03164     // DON'T end the operation!
03165     // Someone will call DoEndEdit
03166     return FALSE;
03167 }

void OpEditLiveEffect::GetOpName String_256 pstrOpName  )  [virtual]
 

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

Errors: See also:

Reimplemented from Operation.

Definition at line 2996 of file opliveeffects.cpp.

02997 {
02998     *pstrOpName = String_256(_R(IDS_LE_OPEDIT));
02999 }

OpState OpEditLiveEffect::GetParamState String_256 pstrDescription,
OpDescriptor pOpDesc,
OpParam pOpParam
[static]
 

Return state of the specified LiveEffect (name in pstrDescription) being applied to the selection (taking into account the current position in the LiveEffect Stack.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/09/2004
Parameters:
[INPUTS] 
[OUTPUTS] 
Returns:

Errors: See also:

Definition at line 2928 of file opliveeffects.cpp.

02929 {
02930     // default is an unticked, *GREYED*, on-menu state.
02931     OpState OpSt;
02932     OpSt.Greyed = FALSE;
02933 
02934 /*  if (XPEHost::IsEditSessionRunning())
02935     {
02936         OpSt.Greyed = TRUE;
02937         *pstrDescription = String_256(_R(IDS_LE_EDIT_RUNNING));
02938     }
02939     else*/ if (GetApplication()->FindSelection()->FindFirst()==NULL)
02940     {
02941         OpSt.Greyed = TRUE;
02942         *pstrDescription = String_256(_R(IDS_LE_NOTHING_SELECTED));
02943     }
02944 
02945     return OpSt;
02946 }

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

Reimplemented from SelOperation.

Definition at line 412 of file opliveeffects.h.

00412 { return TRUE; }


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