ChangeContourWidthAction Class Reference

Forces a regeneration of the bevel in all nodes in the list Used by NodeBevelcontroller::OnChildChange to force redraws in undos/redos. More...

#include <opcntr.h>

Inheritance diagram for ChangeContourWidthAction:

Action ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ChangeContourWidthAction ()
 Constructor for the action.
 ~ChangeContourWidthAction ()
virtual ActionCode Execute ()
 Executes the action. Causes a regen of all bevels nodes in the action's list.

Static Public Member Functions

static ActionCode Init (Operation *pOp, ActionList *pActionList, List *pNodes, MILLIPOINT NewWidth, BOOL bKeepDirection, ChangeContourWidthAction **NewAction)
 This is the function which creates an instance of this action. If there is no room in the undo buffer (which is determined by the base class Init function called within) the function will either return AC_NO_RECORD which means the operation can continue, but no undo information needs to be stored, or AC_OK which means the operation should continue AND record undo information. If the function returns AC_FAIL, there was not enough memory to record the undo information, and the user has decided not to continue with the operation.

Protected Attributes

List m_Nodes
List m_WidthList

Detailed Description

Forces a regeneration of the bevel in all nodes in the list Used by NodeBevelcontroller::OnChildChange to force redraws in undos/redos.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/3/99

Definition at line 331 of file opcntr.h.


Constructor & Destructor Documentation

ChangeContourWidthAction::ChangeContourWidthAction  ) 
 

Constructor for the action.

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

Errors: -

See also:
-

Definition at line 1493 of file opcntr.cpp.

01494 {
01495 
01496 }

ChangeContourWidthAction::~ChangeContourWidthAction  ) 
 

Definition at line 1718 of file opcntr.cpp.

01719 {
01720     m_Nodes.DeleteAll();
01721     m_WidthList.DeleteAll();
01722 }


Member Function Documentation

ActionCode ChangeContourWidthAction::Execute  )  [virtual]
 

Executes the action. Causes a regen of all bevels nodes in the action's list.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/3/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 1661 of file opcntr.cpp.

01662 {
01663     ChangeContourWidthAction * pNewAction = NULL;
01664 
01665     // first, initialise an action to restore all the current widths in my list
01666     ActionCode Ac = ChangeContourWidthAction::Init(pOperation,
01667                                                    pOppositeActLst,
01668                                                    &m_Nodes,
01669                                                    0, // tell the action not to regen - I'm 
01670                                                    FALSE,  // going to do that
01671                                                    &pNewAction);
01672 
01673     NodeListItem * pItem = NULL;
01674     NodeContourController * pContour = NULL;
01675     ContourWidthListItem * pWidthItem = NULL;
01676 
01677     Document * pDoc = Document::GetCurrent();
01678 
01679     if (Ac == AC_OK)
01680     {
01681         // run through my lists resetting the original widths back to what they were
01682         pItem = (NodeListItem *)m_Nodes.GetHead();
01683         pWidthItem = (ContourWidthListItem *)m_WidthList.GetHead();
01684 
01685         while (pItem && pWidthItem)
01686         {
01687             pContour = (NodeContourController *)pItem->pNode;
01688 
01689             // invalidate the old rect
01690             if (pDoc)
01691             {
01692                 pDoc->ForceRedraw(pContour->FindParentSpread(), 
01693                     pContour->GetBoundingRect(FALSE, FALSE),
01694                     FALSE, pContour);
01695             }
01696 
01697             // restore the width of the node, and regenerate
01698             pContour->SetWidth(pWidthItem->m_Width);
01699 
01700             pContour->RegenerateNode(NULL, FALSE);
01701 
01702             // invalidate the new rect
01703             if (pDoc)
01704             {
01705                 pDoc->ForceRedraw(pContour->FindParentSpread(), 
01706                     pContour->GetBoundingRect(FALSE, FALSE),
01707                     FALSE, pContour);
01708             }
01709 
01710             pItem = (NodeListItem *)m_Nodes.GetNext(pItem);
01711             pWidthItem = (ContourWidthListItem *)m_WidthList.GetNext(pWidthItem);
01712         }
01713     }
01714     
01715     return Ac;
01716 }

ActionCode ChangeContourWidthAction::Init Operation pOp,
ActionList pActionList,
List pNodes,
MILLIPOINT  NewWidth,
BOOL  bKeepDirection,
ChangeContourWidthAction **  ppNewAction
[static]
 

This is the function which creates an instance of this action. If there is no room in the undo buffer (which is determined by the base class Init function called within) the function will either return AC_NO_RECORD which means the operation can continue, but no undo information needs to be stored, or AC_OK which means the operation should continue AND record undo information. If the function returns AC_FAIL, there was not enough memory to record the undo information, and the user has decided not to continue with the operation.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/3/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 pNodes = ptr to node list containing the NodeBevel nodes to be addressed NewWidth = the new width to set all nodes in the list to bKeepDirection = Whether to keep the direction (either inner or outer) when setting the widths, or just to take the width as passed in
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 1532 of file opcntr.cpp.

01538 {
01539     if (bKeepDirection && NewWidth < 0)
01540     {
01541         ERROR3("Can't keep the direction when the width is < 0");
01542         return AC_FAIL;
01543     }
01544     
01545     UINT32 ActSize = sizeof(ChangeContourWidthAction);
01546     
01547     ActionCode Ac = Action::Init(pOp,pActionList,ActSize,CC_RUNTIME_CLASS(ChangeContourWidthAction),(Action**)ppNewAction);
01548 
01549     NodeListItem * pItem = NULL;
01550     NodeListItem * pNewItem = NULL;
01551 
01552     ContourWidthListItem * pNewWidthItem = NULL;
01553 
01554     Document * pDoc = Document::GetCurrent();
01555 
01556     NodeContourController * pContour = NULL;
01557 
01558     MILLIPOINT MaxWidth = 0;
01559 
01560     if (Ac == AC_OK)
01561     {
01562         // make a copy of the node list
01563         pItem = (NodeListItem *)pNodes->GetHead();
01564 
01565         while (pItem)
01566         {
01567             // store the node, and its old width value
01568             pContour = (NodeContourController *)pItem->pNode;
01569 
01570             ALLOC_WITH_FAIL(pNewItem, new NodeListItem(pContour), pOp);
01571             ALLOC_WITH_FAIL(pNewWidthItem, new ContourWidthListItem(pContour->GetWidth()), pOp);
01572 
01573             // invalidate the old rect
01574             if (pDoc)
01575             {
01576                 pDoc->ForceRedraw(pContour->FindParentSpread(), pContour->GetBoundingRect(FALSE, FALSE),
01577                     FALSE, pContour);
01578             }
01579 
01580             // regenerate the node
01581             if (NewWidth != 0)
01582             {
01583                 // set the contour controller's new width
01584                 if (!bKeepDirection)
01585                 {
01586                     if (NewWidth > 0)
01587                     {
01588                         MaxWidth = ContourNodePathProcessor::GetMaxInnerContourWidth(pContour);
01589 
01590                         if (NewWidth > MaxWidth)
01591                         {
01592                             pContour->SetWidth(MaxWidth);
01593                         }
01594                         else
01595                         {
01596                             pContour->SetWidth(NewWidth);
01597                         }
01598                     }
01599                     else
01600                     {
01601                         pContour->SetWidth(NewWidth);
01602                     }                   
01603                 }
01604                 else
01605                 {
01606                     if (pContour->GetWidth() < 0)
01607                     {
01608                         pContour->SetWidth(-NewWidth);
01609                     }
01610                     else
01611                     {
01612                         MaxWidth = ContourNodePathProcessor::GetMaxInnerContourWidth(pContour);
01613 
01614                         if (NewWidth > MaxWidth)
01615                         {
01616                             pContour->SetWidth(MaxWidth);
01617                         }
01618                         else
01619                         {
01620                             pContour->SetWidth(NewWidth);
01621                         }
01622                     }
01623                 }
01624 
01625                 pContour->RegenerateNode(NULL, FALSE);
01626             }
01627 
01628             // invalidate the new rect
01629             if (pDoc)
01630             {
01631                 pDoc->ForceRedraw(pContour->FindParentSpread(), pContour->GetBoundingRect(FALSE, FALSE),
01632                     FALSE, pContour);
01633             }
01634 
01635             // add the items to the lists
01636             (*ppNewAction)->m_Nodes.AddTail(pNewItem);
01637             (*ppNewAction)->m_WidthList.AddTail(pNewWidthItem);
01638 
01639             pItem = (NodeListItem *)pNodes->GetNext(pItem);
01640         }
01641     }
01642     
01643     return Ac;
01644 }


Member Data Documentation

List ChangeContourWidthAction::m_Nodes [protected]
 

Definition at line 347 of file opcntr.h.

List ChangeContourWidthAction::m_WidthList [protected]
 

Definition at line 348 of file opcntr.h.


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