DeactivateBrushDefAction Class Reference

Does most of the dirty work for the above operation. More...

#include <brushop.h>

Inheritance diagram for DeactivateBrushDefAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

virtual ActionCode Execute ()
 Executes the action. This will reset the brush variables to their old values.

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, BrushHandle Handle, DeactivateBrushDefAction **NewAction)
 To de/reactivate a brush definition in an undoable way.

Public Attributes

BrushHandle m_Handle

Private Member Functions

 DeactivateBrushDefAction ()

Detailed Description

Does most of the dirty work for the above operation.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/3/2000
See also:
OpDeactivateBrush

Definition at line 320 of file brushop.h.


Constructor & Destructor Documentation

DeactivateBrushDefAction::DeactivateBrushDefAction  )  [inline, private]
 

Definition at line 324 of file brushop.h.


Member Function Documentation

ActionCode DeactivateBrushDefAction::Execute  )  [virtual]
 

Executes the action. This will reset the brush variables to their old values.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/99
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL

Errors: -

See also:
Action::Init()

Reimplemented from Action.

Definition at line 1942 of file brushop.cpp.

01943 {
01944     ActionCode Act;
01945     DeactivateBrushDefAction* pAction;
01946     Act = DeactivateBrushDefAction::Init(pOperation,pOppositeActLst,m_Handle,&pAction);
01947 
01948     return Act;
01949 }

ActionCode DeactivateBrushDefAction::Init Operation pOp,
ActionList pActionList,
BrushHandle  Handle,
DeactivateBrushDefAction **  ppNewAction
[static]
 

To de/reactivate a brush definition in an undoable way.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/99
Parameters:
pOp = ptr to the operation to which this action belongs [INPUTS] pActionList = ptr to action list to which this action should be added Handle - handle to the definition to (de)activate
ppNewAction = ptr to a ptr to an action, allowing the function to return [OUTPUTS] a pointer to the created action
Returns:
ActionCode, one of AC_OK, AC_NO_RECORD or AC_FAIL

Errors: -

See also:
Action::Init()

Definition at line 1831 of file brushop.cpp.

01835 {
01836     // get the brush component from the document
01837     Document* pDoc = Document::GetCurrent();
01838     ERROR2IF(pDoc == NULL, AC_FAIL, "Wheres the document?");
01839     BrushComponent* pBrushComp = (BrushComponent*)pDoc->GetDocComponent(CC_RUNTIME_CLASS(BrushComponent));
01840     ERROR2IF(pBrushComp == NULL, AC_FAIL, "No brush component");
01841 
01842     BrushDefinition* pDef = pBrushComp->FindBrushDefinition(Handle);
01843     ERROR2IF(pDef == NULL, AC_FAIL, "Invalid handle passed to DeactivateBrushDefAction::Init");
01844     
01845     // make the new action
01846     UINT32 ActSize = sizeof(DeactivateBrushDefAction);
01847     DeactivateBrushDefAction* pNewAction;
01848     ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(DeactivateBrushDefAction),(Action**)&pNewAction);
01849     *ppNewAction = pNewAction;
01850 
01851     pNewAction->m_Handle = Handle;
01852     
01853     // get the line gallery
01854     LineGallery* pGallery = LineGallery::GetInstance();
01855     ERROR2IF(pGallery == NULL, AC_FAIL, "Unable to get line gallery in DeactivateBrushDefAction::Init");
01856 
01857     // get the freehand tool
01858     ToolListItem* pToolItem = Tool::Find(TOOLID_FREEHAND);
01859     ERROR2IF(pToolItem == NULL, AC_FAIL, "Unable to get tool item in DeactivateBrushDefAction::Init");
01860 
01861     FreeHandTool* pTool = (FreeHandTool*)pToolItem->m_pTool;
01862     ERROR2IF(pTool == NULL, AC_FAIL, "Unable to get tool in DeactivateBrushDefAction::Init");
01863 
01864     if (pDef->IsActivated())
01865     {
01866         // we are deactivating, we need to delete from the line gallery and freehandinfo bar
01867         pDef->SetActivated(FALSE);
01868         
01869         pGallery->DeleteBrushItem(Handle);
01870 
01871         pTool->BrushDeleted(Handle);
01872 
01873     }
01874     else
01875     {
01876         // we are activating:
01877         pDef->SetActivated(TRUE);
01878         
01879         // make a new atttibute to add to the line gallery
01880         PathProcessorBrush* pNewPathProc = new PathProcessorBrush;
01881         if (pNewPathProc == NULL)
01882         {
01883             ERROR3("Failed to allocate path processor");
01884             return AC_FAIL;
01885         }
01886 
01887         // tell it which brush definition to use
01888         pNewPathProc->SetBrushDefinition(Handle);
01889 
01890         // transfer all the data
01891         pDef->CopyDataToProcessor(pNewPathProc);
01892 
01893         // make a new attribute value for use by the line gallery
01894         BrushAttrValue* pVal = new BrushAttrValue(pNewPathProc);
01895         if (pVal == NULL)
01896         {
01897             ERROR3("Unable to allocate new BrushAttrVal");
01898             return AC_FAIL;
01899         }
01900     
01901         // add it to the line gallery
01902         LineGallery::AddNewBrushItem(pVal); 
01903 
01904         
01905         // get the infobar
01906         FreeHandInfoBarOp* pInfoBar = ((FreeHandTool*)pTool)->GetInfoBar();
01907         ERROR2IF(pInfoBar == NULL, AC_FAIL, "Unable to get InfoBar in DeactivateBrushDefAction::Init");
01908 
01909         // add to the freehand infobar
01910         pInfoBar->AddBrush(Handle);
01911     }
01912     
01913     // force a redraw of the document
01914     if (pDoc != NULL)
01915     {
01916         CBitmapCache* pBC = Camelot.GetBitmapCache();
01917         if (pBC) pBC->DeInitialise();
01918         pDoc->ForceRedraw();
01919     }
01920 
01921     return Ac;
01922 }


Member Data Documentation

BrushHandle DeactivateBrushDefAction::m_Handle
 

Definition at line 334 of file brushop.h.


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