OpCreateFill Class Reference

An operation to add a Linear Graduated Fill to the selected Object(s). More...

#include <opgrad.h>

Inheritance diagram for OpCreateFill:

Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpCreateFill ()
 Dummy Contrustor-Register this operation into the list of all operationsUsed for greying etc of an operation.Dummy Contrustor-Register this operation into the list of all operationsUsed for greying etc of an operation.Constructor for the action to undo fill modification 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. This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function This is the virtual function that is called when the action is executed by the Undo/Redo system. This is the function that actually undoes the ModifyFillCoords action by changing the attribute values, and records redo information from the current values. Constructor for the action to undo fill modification 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. This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function This is the virtual function that is called when the action is executed by the Undo/Redo system. This is the function that actually undoes the ModifyFillColours action by changing the attribute values, and records redo information from the current values. Dummy Constructor.
virtual void DoDrag (AttrFillGeometry *, Spread *pSpread, DocCoord Anchor)
 Starts the drag and records the initial position of the mouse etc. It also snaps the start position to the grid if it needs to.
virtual void DragPointerMove (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag)
 re-draws the drag blobs as the mouse moves about the document.
virtual void DragFinished (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag)
 Called when the drag ends. This function rubs out the drag blobs and then builds a new GradFill Node and adds it to the end of the tree.
virtual void RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag)
 Renders the EOR blobs during a drag. It can also get called from OnDraw().
virtual BOOL GetStatusLineText (String_256 *pText, Spread *pSpread, DocCoord DocPos, ClickModifiers ClickMods)
 Gets the status text during the creation of a fill.

Static Public Member Functions

static BOOL Init ()
 Declare the operations OpDescriptor.
static OpState GetState (String_256 *Description, OpDescriptor *)
 Finds out the operations current state for greying etc in menus.

Protected Attributes

AttrFillGeometryGradFill
SpreadStartSpread
DocCoord StartPoint
DocCoord LastMousePosition

Private Member Functions

 CC_DECLARE_DYNCREATE (OpCreateFill)
DocRect GetDragBlobRect ()
 This function finds the bounding rect that the parallelogram of the NodeGradFill we are using for EOR renderings parallelogram fits in.

Detailed Description

An operation to add a Linear Graduated Fill to the selected Object(s).

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94

Definition at line 155 of file opgrad.h.


Constructor & Destructor Documentation

OpCreateFill::OpCreateFill  ) 
 

Dummy Contrustor-Register this operation into the list of all operationsUsed for greying etc of an operation.Dummy Contrustor-Register this operation into the list of all operationsUsed for greying etc of an operation.Constructor for the action to undo fill modification 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. This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function This is the virtual function that is called when the action is executed by the Undo/Redo system. This is the function that actually undoes the ModifyFillCoords action by changing the attribute values, and records redo information from the current values. Constructor for the action to undo fill modification 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. This function initialises the array pointers in this action. Note that the variable NumElements is initialised in the Init function This is the virtual function that is called when the action is executed by the Undo/Redo system. This is the function that actually undoes the ModifyFillColours action by changing the attribute values, and records redo information from the current values. Dummy Constructor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94

Definition at line 2506 of file opgrad.cpp.

02507 {
02508     GradFill = NULL;
02509 }


Member Function Documentation

OpCreateFill::CC_DECLARE_DYNCREATE OpCreateFill   )  [private]
 

void OpCreateFill::DoDrag AttrFillGeometry Fill,
Spread pSpread,
DocCoord  Anchor
[virtual]
 

Starts the drag and records the initial position of the mouse etc. It also snaps the start position to the grid if it needs to.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
pSpread - The Spread the drag is starting on [INPUTS] Anchor - The coord of the start of the drag

Definition at line 2524 of file opgrad.cpp.

02525 {
02526     DocView::SnapSelected(pSpread, &Anchor);
02527 
02528     // We had better take a note of the starting point of the drag
02529     StartSpread = pSpread;
02530     StartPoint = Anchor;
02531     
02532     // init the old and the new mouse position needed in drawing the rubber box
02533     LastMousePosition = Anchor;
02534 
02535     GradFill = Fill;
02536 
02537     GradFill->SetStartPoint(&Anchor);
02538     GradFill->SetEndPoint(&Anchor);
02539     
02540     if (GradFill->GetEndPoint2() != NULL)
02541         GradFill->SetEndPoint2(&Anchor);
02542 
02543     // Remove other fill meshs whilst we are dragging   
02544     BlobStyle MyBlobs;
02545     MyBlobs.Fill = TRUE;
02546     (Camelot.GetBlobManager())->RemoveInterest(MyBlobs);
02547 
02548     AttrFillGeometry::DraggedFill = GradFill;
02549 
02550     // And tell the Dragging system that we need drags to happen
02551 //  StartDrag( DRAGTYPE_AUTOSCROLL );
02552     StartDrag(DRAGTYPE_AUTOSCROLL, NULL, NULL, TRUE, TRUE);         // We support solid dragging
02553 }   

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

Called when the drag ends. This function rubs out the drag blobs and then builds a new GradFill Node and adds it to the end of the tree.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/6/94
Parameters:
PointerPos - The position of the mouse at the end of the drag [INPUTS] ClickModifiers - Not Used pSpread - The spread that the drag ended over Success - TRUE if the drag worked

Reimplemented from Operation.

Definition at line 2669 of file opgrad.cpp.

02670 {
02671     // Put the hour glass up as we have to
02672     BeginSlowJob();
02673 
02674     DocRect DragRect;
02675 
02676     // First Rub out the old Drag blobs
02677     DocRect BoundingRect = GetDragBlobRect();
02678     RenderDragBlobs(BoundingRect, StartSpread, bSolidDrag);
02679 
02680     // Get the scaled pixel size for the view
02681     FIXED16 ScaledPixelWidth,
02682             ScaledPixelHeight;
02683     GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight);
02684 
02685     INT32 PixWidth  = ScaledPixelWidth.MakeLong();
02686     INT32 PixHeight = ScaledPixelHeight.MakeLong();
02687 
02688     // Flag to say if everything has worked
02689     BOOL IsOk = FALSE;
02690 
02691     // End the Drag                             
02692     if (!EndDrag())
02693         goto EndOperation;
02694 
02695     if (PointerPos == StartPoint)
02696         goto EndOperation;
02697 
02698     if (*GradFill->GetStartPoint() == *GradFill->GetEndPoint())
02699         goto EndOperation;
02700 
02701     DragRect.IncludePoint(StartPoint);
02702     DragRect.IncludePoint(PointerPos);
02703 
02704     if (DragRect.Width() < PixWidth*2 && DragRect.Height() < PixHeight*2)
02705     {
02706         TRACEUSER( "Will", _T("Drag rect too small\n"));
02707         goto EndOperation;
02708     }
02709 
02710     // if the drag was a sucess then make a grad fill
02711     if (Success && (!DragRect.IsEmpty()))
02712     {
02713         if (GradFill != NULL)
02714         {               
02715              CCRuntimeClass* CurrentAttribGroup = 
02716                 Tool::GetCurrent()->Parent->m_ToolInfo.CurrentAttributeGroup;
02717 
02718             Document* CurrentDoc = Document::GetSelected();
02719 
02720             AttrFillGeometry* CurrentAttr = (AttrFillGeometry*)(CurrentDoc->GetAttributeMgr()
02721                     .GetCurrentAttribute(CurrentAttribGroup, GradFill->GetAttributeType()));
02722 
02723             // Is there a current attribute of this type ?
02724             if (CurrentAttr != NULL)
02725             {
02726                 BOOL Locked = ((FillGeometryAttribute*)GradFill->GetAttributeValue())->IsAspectLocked();
02727                 
02728                 // Use the current Attributes Colours
02729                 *((FillGeometryAttribute*)GradFill->GetAttributeValue()) = 
02730                             *((FillGeometryAttribute*)CurrentAttr->GetAttributeValue());
02731 
02732                 ((FillGeometryAttribute*)GradFill->GetAttributeValue())->SetAspectLock(Locked);
02733 
02734                 DocCoord Start  = StartPoint;
02735                 DocCoord End    = LastMousePosition;
02736                 DocCoord End2   = MakeLineAtAngle(StartPoint, LastMousePosition);
02737 
02738                 // Ensure the Aspect ratio is correct for a new
02739                 // bitmap fill
02740                 if (GradFill->GetBitmap() != NULL)
02741                 {
02742                     BitmapInfo Info;
02743                     KernelBitmap* Bmp = GradFill->GetBitmap();
02744 
02745                     AttrFillGeometry* Attr = AttrFillGeometry::FindFirstSelectedAttr(GradFill->GetAttributeType());
02746 
02747                     while (Attr != NULL)
02748                     {
02749                         if (Attr->GetBitmap() != NULL)
02750                         {
02751                             Bmp = Attr->GetBitmap();
02752                             break; 
02753                         }
02754                 
02755                         Attr = AttrFillGeometry::FindNextSelectedAttr(GradFill->GetAttributeType());
02756                     }
02757 
02758                     // if possible we base our default size on the bitmaps preferred size
02759                     if (Bmp && Bmp->ActualBitmap)
02760                     {
02761                         if (Bmp->ActualBitmap->GetInfo( &Info ))
02762                         {
02763                             INT32 BitmapWidth  = Info.RecommendedWidth;
02764                             INT32 BitmapHeight = Info.RecommendedHeight;
02765 
02766                             // Calculate the spect ratio of the bitmap
02767                             double Ratio = double(BitmapHeight)/double(BitmapWidth);
02768 
02769                             End2 = MakeLineAtAngle(Start, End, 90, INT32(Start.Distance(End) * Ratio));
02770                         }
02771                     }
02772                 }
02773 
02774                 if (GradFill->IsKindOf(CC_RUNTIME_CLASS(AttrBitmapFill)))
02775                 {
02776                     // Get the Real Control Points
02777                     // (The user only sees the virtual points)
02778                     GetBitmapRealPoints(Start, End, End2,
02779                                         &Start, &End, &End2);
02780                 }
02781 
02782                 // Set the new fills points
02783                 GradFill->SetStartPoint(&Start);
02784                 GradFill->SetEndPoint(&End);
02785 
02786                 if (GradFill->GetEndPoint2() != NULL)
02787                     GradFill->SetEndPoint2(&End2);
02788             }
02789             else
02790             {
02791                 // No current fill so use default colours
02792                 *GradFill->GetStartColour() = DocColour(COLOUR_WHITE);
02793                 *GradFill->GetEndColour()   = DocColour(COLOUR_BLACK);
02794             }
02795 
02796             if (GradFill->GetAttributeType() == CC_RUNTIME_CLASS(AttrTranspFillGeometry))
02797             {
02798                 UINT32 Start = 0;
02799                 UINT32 End = 255;
02800     
02801                 GradFill->SetStartTransp(&Start);
02802                 GradFill->SetEndTransp(&End);
02803             }
02804 
02805             SelRange *Selection = Camelot.FindSelection();
02806             DocRect Bounds;
02807             if (Selection != NULL && Selection->Count()>0)
02808                 Bounds = Selection->GetBoundingRect();
02809             else
02810                 Bounds = GetDragBlobRect();
02811 
02812             // Give the attribute a bounding rect
02813             GradFill->SetBoundingRect(Bounds);
02814 
02815             GradFill->SelectBlob(FILLCONTROL_ENDPOINT);
02816 
02817             // And pass it to the attribute manager to sort the rest out
02818             AttributeManager::SendMessages = FALSE;
02819             AttributeManager::AttributeSelected(GradFill); 
02820             AttributeManager::SendMessages = TRUE;
02821 
02822             IsOk = TRUE;
02823         }
02824     }
02825 
02826 EndOperation:
02827     // If something went wrong, then fail
02828     if (!IsOk)
02829     {
02830         delete GradFill;
02831         FailAndExecute();
02832     }
02833 
02834     AttrFillGeometry::DraggedFill = NULL;
02835 
02836     // Turn the fill meshes back on
02837     BlobStyle MyBlobs;
02838     MyBlobs.Fill = TRUE;
02839     (Camelot.GetBlobManager())->AddInterest(MyBlobs);
02840 
02841     AttrFillGeometry::SelectionCount = AttrFillGeometry::CountSelectionControlPoints();
02842     // We've probably changed a Colour
02843     BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::COLOURATTCHANGED)); 
02844     // and the Attrib may have changed shape or summit. Who knows ?
02845     BROADCAST_TO_ALL(SelChangingMsg(SelChangingMsg::NONCOLOURATTCHANGED)); 
02846 
02847     // always call end
02848     End();
02849 }

void OpCreateFill::DragPointerMove DocCoord  PointerPos,
ClickModifiers  ClickMods,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

re-draws the drag blobs as the mouse moves about the document.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
PointerPos - The current mouse position [INPUTS] ClickMods - Which modifier keys were being pressed at the time pSpread - The Spread that the mouse is over now

Reimplemented from Operation.

Definition at line 2569 of file opgrad.cpp.

02570 {
02571     // Snap the actual mouse position to the grid if needed
02572     DocView::SnapSelected(pSpread, &PointerPos);
02573 
02574     // if we need to constrain the drag, then make our GradFill into a circle
02575     if (ClickMods.Constrain)
02576         DocView::ConstrainToAngle(StartPoint, PI/4, &PointerPos);
02577 
02578     // If the mouse is in a different position then do something
02579     if (PointerPos != LastMousePosition)
02580     {
02581         // First Rub out the old Drag blobs
02582         DocRect BoundingRect = GetDragBlobRect();
02583         RenderDragBlobs(BoundingRect, StartSpread, bSolidDrag);
02584 
02585         // Make sure that the coords are relative to the coorect spread
02586         if (pSpread != StartSpread)
02587             PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos);
02588 
02589         // Update the last mouse position and re-calc the bounding rect
02590         LastMousePosition = PointerPos;
02591 
02592         DocCoord Start  = StartPoint;
02593         DocCoord End    = PointerPos;
02594         DocCoord End2   = MakeLineAtAngle(StartPoint, PointerPos);
02595 
02596         // If we are creating a Bitmap Fill, then try to create it 
02597         // with the correct aspect ratio 
02598         if (GradFill->GetBitmap() != NULL)
02599         {
02600             BitmapInfo Info;
02601             KernelBitmap* Bmp = GradFill->GetBitmap();
02602 
02603             AttrFillGeometry* Attr = AttrFillGeometry::FindFirstSelectedAttr(GradFill->GetAttributeType());
02604 
02605             while (Attr != NULL)
02606             {
02607                 if (Attr->GetBitmap() != NULL)
02608                 {
02609                     Bmp = Attr->GetBitmap();
02610                     break; 
02611                 }
02612                 
02613                 Attr = AttrFillGeometry::FindNextSelectedAttr(GradFill->GetAttributeType());
02614             }
02615 
02616             // if possible we base our default size on the bitmaps preferred size
02617             if (Bmp && Bmp->ActualBitmap)
02618             {
02619                 if (Bmp->ActualBitmap->GetInfo( &Info ))
02620                 {
02621                     INT32 BitmapWidth  = Info.RecommendedWidth;
02622                     INT32 BitmapHeight = Info.RecommendedHeight;
02623 
02624                     // Calculate the spect ratio of the bitmap
02625                     double Ratio = double(BitmapHeight)/double(BitmapWidth);
02626 
02627                     End2 = MakeLineAtAngle(Start, End, 90, INT32(Start.Distance(End) * Ratio));
02628                 }
02629             }
02630         }
02631 
02632         if (GradFill->IsKindOf(CC_RUNTIME_CLASS(AttrBitmapFill)))
02633         {
02634             // Get the Real Control Points
02635             // (The user only sees the virtual points)
02636             GetBitmapRealPoints(Start, End, End2,
02637                                 &Start, &End, &End2);
02638         }
02639 
02640         // Update the new Fill's points
02641         GradFill->SetStartPoint(&Start);
02642         GradFill->SetEndPoint(&End);
02643         if (GradFill->GetEndPoint2() != NULL)
02644             GradFill->SetEndPoint2(&End2);
02645 
02646         BoundingRect = GetDragBlobRect();
02647 
02648         // Draw the Fill Mesh
02649         RenderDragBlobs(BoundingRect, StartSpread, bSolidDrag);
02650     }
02651 }

DocRect OpCreateFill::GetDragBlobRect  )  [private]
 

This function finds the bounding rect that the parallelogram of the NodeGradFill we are using for EOR renderings parallelogram fits in.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Returns:
The bounding rect of the NodeGradFill parallelogram

Definition at line 2898 of file opgrad.cpp.

02899 {
02900     return GradFill->GetBlobBoundingRect();
02901 }

OpState OpCreateFill::GetState String_256 Description,
OpDescriptor
[static]
 

Finds out the operations current state for greying etc in menus.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
Description - The Description of the operation [INPUTS]

Definition at line 2937 of file opgrad.cpp.

02938 {
02939     OpState Blobby;
02940     
02941     return Blobby;
02942 }

BOOL OpCreateFill::GetStatusLineText String_256 pText,
Spread pSpread,
DocCoord  DocPos,
ClickModifiers  ClickMods
[virtual]
 

Gets the status text during the creation of a fill.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/1/95
Parameters:
pSpread - pioter to spread mouse is over [INPUTS] DocPos - position of mouse in doc Mods - click modifiers
pText - buffer for StatusLine text [OUTPUTS]
Returns:
FALSE if fails

Reimplemented from Operation.

Definition at line 2959 of file opgrad.cpp.

02961 {
02962     if (GradFill == NULL)
02963     {
02964         *pText="";      // We don't seem to be doing anything at the moment !
02965         return TRUE;
02966     }
02967 
02968     pText->Load(_R(IDS_K_OPGRAD_CREATENEW));
02969 
02970     String_256 FillName;
02971     if (FillName.Load(GradFill->GetAttrNameID()))
02972     {
02973         // Add the description of the attribute onto the base string
02974         *pText += FillName;
02975 
02976         return TRUE;
02977     }
02978 
02979     return FALSE;
02980 }

BOOL OpCreateFill::Init void   )  [static]
 

Declare the operations OpDescriptor.

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Returns:
TRUE if the operation was initialised sucessfully

Reimplemented from SimpleCCObject.

Definition at line 2914 of file opgrad.cpp.

02915 {
02916     return (RegisterOpDescriptor(   0, 
02917                                     _R(IDS_CREATEFILLOP),
02918                                     CC_RUNTIME_CLASS(OpCreateFill), 
02919                                     OPTOKEN_GRADFILL,
02920                                     OpCreateFill::GetState,
02921                                     0,  /* help ID */
02922                                     0,
02923                                     0   /* bitmap ID */));
02924 }

void OpCreateFill::RenderDragBlobs DocRect  Rect,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Renders the EOR blobs during a drag. It can also get called from OnDraw().

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
Rect - The rectangle that needs to be redrawn [INPUTS] pSpread - the spread that it should be drawn on

Reimplemented from Operation.

Definition at line 2863 of file opgrad.cpp.

02864 {
02865     // If being called from DocView::RenderView, then the spread could be wrong - so
02866     // convert the rectangle if necessary.
02867     if (pSpread != StartSpread)
02868     {
02869         Rect.lo = MakeRelativeToSpread(StartSpread, pSpread, Rect.lo);
02870         Rect.hi = MakeRelativeToSpread(StartSpread, pSpread, Rect.hi);
02871     }
02872 
02873     RenderRegion* pRegion = DocView::RenderOnTop(&Rect, StartSpread, UnclippedEOR);
02874     while (pRegion)
02875     {
02876         GradFill->RenderFillBlobs(pRegion);
02877 
02878         // Get the Next render region
02879         pRegion = DocView::GetNextOnTop(&Rect);
02880     }
02881 
02882     // Bodge to stop fill meshes EOR each other out.
02883     AttrFillGeometry::LastRenderedMesh = NULL;
02884 }


Member Data Documentation

AttrFillGeometry* OpCreateFill::GradFill [protected]
 

Definition at line 187 of file opgrad.h.

DocCoord OpCreateFill::LastMousePosition [protected]
 

Definition at line 192 of file opgrad.h.

DocCoord OpCreateFill::StartPoint [protected]
 

Definition at line 191 of file opgrad.h.

Spread* OpCreateFill::StartSpread [protected]
 

Definition at line 188 of file opgrad.h.


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