oprshape.cpp

Go to the documentation of this file.
00001 // $Id: oprshape.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Implementation of the Regular Shape tool operations
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h"
00104 #include "oprshape.h"   
00105 
00106 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "attrmgr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 #include "blobs.h"
00109 #include "csrstack.h"
00110 //#include "cursor.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "lineattr.h"
00113 #include "noderect.h"
00114 #include "nodershp.h"
00115 //#include "peter.h"
00116 #include "progress.h"                              
00117 //#include "resource.h"
00118 //#include "rndrgn.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 #include "shapeops.h"
00120 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 //#include "trans2d.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 //#include "viewrc.h"
00123 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 
00125 DECLARE_SOURCE( "$Revision: 1282 $" );
00126 
00127 CC_IMPLEMENT_DYNCREATE(OpNewRegShape, SelOperation)
00128 
00129 #define new CAM_DEBUG_NEW     
00130 
00131 
00132 /********************************************************************************************
00133 
00134 >   OpNewRegShape::OpNewRegShape()
00135 
00136     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00137     Created:    22/11/94
00138     Purpose:    Constructor. This simply sets a few of the operation flags.
00139 
00140 ********************************************************************************************/
00141 
00142 OpNewRegShape::OpNewRegShape()
00143 {
00144     pCursor = NULL;
00145     IsShiftDown = FALSE;
00146 }
00147 
00148 
00149 
00150 /********************************************************************************************
00151 
00152 >   void OpNewRegShape::DoDrag( Spread* pSpread, DocCoord Anchor, INT32 NumSides, CreateMode DragMode
00153                                             BOOL Circular, BOOL Stellated, BOOL Curved)
00154 
00155     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00156     Created:    22/11/94
00157     Inputs:     pSpread - The spread that the drag was started on
00158                 Anchor - starting position of the drag
00159                 NumSides - the number of sides the new regular shape should have (0 implies an ellipse)
00160                 CreateMode - the way the drag and the new object should interact.  Either RADIUS,
00161                 DIAMETER or BOUNDS
00162                 Circular - TRUE to base the created shape on a circle, FALSE if it is a polygon
00163                 Curved - TRUE if the created shape has rounded corners.
00164     Purpose:    Starts dragging from the coordinate passed in.
00165                 For RADIUS mode you are dragging the major axes from a fixed centre point
00166                 For DIAMETER mode you are dragging the major axes, the centre point is the 
00167                 midpoint of the line between the start and current points.
00168                 For BOUNDS mode you are dragging a bounding box.  The major and minor axes
00169                 just touch the edge of the box.
00170 
00171 ********************************************************************************************/
00172 void OpNewRegShape::DoDrag( Spread* pSpread, DocCoord Anchor, INT32 NumSides, CreateMode DragMode, 
00173                                                 BOOL Circular, BOOL Stellated, BOOL Curved)
00174 {
00175     DocView::SnapCurrent(pSpread, &Anchor);
00176 
00177     // We had better take a note of the starting point of the drag.
00178     StartSpread = pSpread;
00179     StartPoint = Anchor;
00180     LastPoint = Anchor;
00181     CreationMode = DragMode;
00182     
00183     // Create the shape that is to be dragged around.
00184     NewShape = new (NodeRegularShape);
00185 
00186     if ((NewShape == NULL) || !NewShape->SetUpShape() )
00187     {
00188         InformError(_R(IDS_OUT_OF_MEMORY), _R(IDS_OK));
00189         return;
00190     }
00191 
00192     // And make sure it is filled in
00193     NewShape->SetNumSides(NumSides);
00194 
00195     const DocCoord Origin(0,0);
00196     NewShape->SetCentrePoint(Origin);
00197     NewShape->SetMajorAxes(Origin);
00198     NewShape->SetMinorAxes(Origin);
00199 
00200     NewShape->SetCircular(Circular);
00201     NewShape->SetStellated(Stellated);
00202     NewShape->SetPrimaryCurvature(Curved);
00203     NewShape->SetStellationCurvature(Curved);
00204 
00205     Matrix InitialMat(StartPoint.x, StartPoint.y);
00206     NewShape->SetTransformMatrix(&InitialMat);
00207 
00208     // Eor the rectangle on for the first time
00209     DocRect EditPathBBox = NewShape->GetBoundingRect();
00210     RenderDragBlobs(EditPathBBox, StartSpread, FALSE);
00211 
00212     // And tell the Dragging system that we need drags to happen
00213     StartDrag( DRAGTYPE_AUTOSCROLL, NULL, &Anchor, FALSE );
00214 }
00215 
00216 
00217 
00218 /********************************************************************************************
00219 
00220 >   void OpNewRegShape::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, 
00221                                    Spread* pSpread, BOOL bSolidDrag)
00222     
00223     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00224     Created:    21/11/94
00225     Inputs:     PointerPos - The current position of the mouse in Doc Coords
00226                 ClickMods - Which key modifiers are being pressed
00227                 pSpread - The spread that the mouse pointer is over
00228     Purpose:    Takes the pointer position of the corner of the shape being dragged
00229                 and redisplays the outline
00230     SeeAlso:    ClickModifiers
00231 
00232 ********************************************************************************************/
00233 
00234 void OpNewRegShape::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods, 
00235                                    Spread* pSpread, BOOL bSolidDrag)
00236 {
00237     // Rub out the old shape
00238     DocRect EditPathBBox = NewShape->GetBoundingRect();
00239     RenderDragBlobs(DocRect(0,0,0,0), StartSpread, bSolidDrag);
00240 
00241     // make sure the rect does not wrap around the edge of the spread
00242     if (pSpread != StartSpread)
00243         PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos);
00244 
00245     // If the SHIFT key is down then drop into RADIUS mode
00246     CreateMode TempCreationMode = CreationMode;
00247     if (ClickMods.Adjust && CreationMode == DIAMETER)
00248         TempCreationMode = RADIUS;
00249     if (ClickMods.Adjust && ClickMods.Constrain && CreationMode == BOUNDS)
00250         TempCreationMode = RADIUS;
00251 
00252     // Now see if we should constrain the point
00253     if (ClickMods.Constrain)
00254     {
00255         // If we are in bounds creation mode then we want to restrict to 45, 135 225, and 315 degrees
00256         // This stops thin shapes (ie zero wdith or height)
00257         if (TempCreationMode == BOUNDS)
00258         {
00259             double length = StartPoint.Distance(PointerPos);
00260         
00261             if (length != 0.0)
00262             {
00263                 DocCoord Offset = PointerPos - StartPoint; 
00264                 double rotangle = atan2((double)Offset.y, (double)Offset.x);
00265 
00266                 if ((rotangle >= 0) && (rotangle <= PI/2))
00267                     rotangle = PI/4;
00268                 if (rotangle > PI/2)
00269                     rotangle = 3*(PI/4);
00270                 if ((rotangle < 0) && (rotangle >= -PI/2))
00271                     rotangle = -PI/4;
00272                 if (rotangle < -PI/2)
00273                     rotangle = -3*(PI/4);
00274 
00275                 PointerPos.x = StartPoint.x + (INT32)length; 
00276                 PointerPos.y = StartPoint.y; 
00277 
00278                 Trans2DMatrix Trans(StartPoint, rotangle*(180/PI));
00279                 Trans.Transform(&PointerPos, 1);
00280             }
00281         }
00282         else
00283         {
00284             DocCoord Centre = NewShape->GetCentrePoint();
00285             if (TempCreationMode == DIAMETER)
00286                 Centre = StartPoint;
00287             DocView::ConstrainToAngle(Centre, &PointerPos);
00288         }
00289     }
00290 
00291     // snap to the grid too
00292     DocView::SnapCurrent(pSpread, &PointerPos);
00293 
00294     // Change our shape to fit the current mouse position
00295     switch (TempCreationMode)
00296     {
00297         case RADIUS:
00298         {   // The major axes point is the current mouse pos rotated around the centre point by  
00299             // 180 degrees.  The minor point is the same point rotated by a further 90 degrees
00300             DocCoord OldCentre = NewShape->GetCentrePoint();
00301             DocCoord NewMajor = PointerPos - OldCentre;
00302             DocCoord NewMinor = PointerPos - OldCentre;
00303             Trans2DMatrix Trans1(DocCoord(0,0), -180);
00304             Trans1.Transform(&NewMajor, 1);
00305             Trans2DMatrix Trans2(DocCoord(0,0), -270);
00306             Trans2.Transform(&NewMinor, 1);
00307             NewShape->SetMajorAxes(NewMajor);
00308             NewShape->SetMinorAxes(NewMinor);
00309             NewShape->SetCentrePoint(DocCoord(0,0));
00310             Matrix InitialMat(OldCentre.x, OldCentre.y);
00311             NewShape->SetTransformMatrix(&InitialMat);
00312             break;
00313         }
00314         case DIAMETER:
00315         {   // The centre point is the midpoint of the line from the start point to the current point.
00316             // The major axes is positioned so that a vertex is on the starting position.
00317             // The minor axes is the major axes rotated by -90 degrees.
00318             DocCoord NewCentre;
00319             NewCentre.x = (StartPoint.x + PointerPos.x) / 2;
00320             NewCentre.y = (StartPoint.y + PointerPos.y) / 2;
00321             NewShape->SetCentrePoint(DocCoord(0,0));
00322             DocCoord NewMajor = PointerPos - NewCentre;
00323             Trans2DMatrix Trans1(DocCoord(0,0), 180-(180.0/NewShape->GetNumSides()));
00324             Trans1.Transform(&NewMajor, 1);
00325             NewShape->SetMajorAxes(NewMajor);
00326             DocCoord NewMinor = NewMajor;
00327             Trans2DMatrix Trans2(DocCoord(0,0), -90);
00328             Trans2.Transform(&NewMinor, 1);
00329             NewShape->SetMinorAxes(NewMinor);
00330             Matrix InitialMat(NewCentre.x, NewCentre.y);
00331             NewShape->SetTransformMatrix(&InitialMat);
00332             break;
00333         }
00334         case BOUNDS:
00335         {   
00336             DocCoord NewCentre;
00337             DocCoord NewMajor;
00338             DocCoord NewMinor;
00339             // If SHIFT is down then we need to reposition the shape in a similar way to the old
00340             // rectangle tool
00341             if (ClickMods.Adjust)
00342             {
00343                 if (!IsShiftDown)
00344                 {
00345                     IsShiftDown = TRUE;
00346                     RecentrePoint.x = (StartPoint.x + PointerPos.x) / 2;
00347                     RecentrePoint.y = (StartPoint.y + PointerPos.y) / 2;
00348                 }
00349                 DocRect BoundsRect(RecentrePoint, RecentrePoint);
00350                 BoundsRect.IncludePoint(PointerPos);
00351                 BoundsRect.IncludePoint(RecentrePoint + (RecentrePoint - PointerPos));
00352                 InflateShape(&BoundsRect, &NewCentre, &NewMajor, &NewMinor);
00353             }
00354             else
00355             {
00356                 if (IsShiftDown)
00357                 {
00358                     IsShiftDown = FALSE;
00359                     StartPoint = RecentrePoint + (RecentrePoint - PointerPos);
00360                 }
00361 
00362                 DocRect BoundsRect(StartPoint, StartPoint);
00363                 BoundsRect.IncludePoint(PointerPos);
00364                 InflateShape(&BoundsRect, &NewCentre, &NewMajor, &NewMinor);
00365             }
00366 
00367             NewShape->SetCentrePoint(DocCoord(0,0));    
00368             NewShape->SetMajorAxes(NewMajor - NewCentre);    
00369             NewShape->SetMinorAxes(NewMinor - NewCentre);    
00370             Matrix InitialMat(NewCentre.x, NewCentre.y);
00371             NewShape->SetTransformMatrix(&InitialMat);
00372             break;
00373         }
00374         default:
00375             ERROR3("Unknown creation type");
00376     }
00377 
00378     // Put the Eor back on again for the new shape
00379     EditPathBBox = NewShape->GetBoundingRect();
00380     RenderDragBlobs(EditPathBBox, StartSpread, bSolidDrag);
00381 
00382     BROADCAST_TO_ALL(ShapeEditedMsg(NewShape, pSpread));
00383 
00384     LastPoint = PointerPos;
00385 }
00386 
00387 
00388 
00389 /********************************************************************************************
00390 
00391 >   void OpNewRegShape::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, 
00392                                 Spread* pSpread, BOOL Success, BOOL bSolidDrag)
00393 
00394     
00395     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00396     Created:    22/11/94
00397     Inputs:     PointerPos - The position of the mouse at the end of the drag
00398                 ClickMods - the key modifiers being pressed
00399                 pSpread - The spread that the drag finished on
00400                 Success - TRUE if the drag was terminated properly, FALSE if it
00401                 was ended with the escape key being pressed
00402     Purpose:    Ends the drag and creates a rectangle using the dimensions and position
00403                 of the outline rectangle produced by the dragging system. It also ends the
00404                 operation.
00405     SeeAlso:    ClickModifiers
00406 
00407 ********************************************************************************************/
00408 
00409 void OpNewRegShape::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods, 
00410                                 Spread* pSpread, BOOL Success, BOOL bSolidDrag)
00411 {
00412     // Start a slow job
00413     BeginSlowJob();
00414 
00415     // End the Drag                             
00416     EndDrag();
00417 
00418     // First Rub out the old box
00419     DocRect EditPathBBox = NewShape->GetBoundingRect();
00420     RenderDragBlobs(EditPathBBox, StartSpread, bSolidDrag);
00421         
00422     // If we should carry on, then do it
00423     BOOL Worked = FALSE;
00424     if ( Success && (StartPoint != PointerPos) ) 
00425         Worked = CompleteOperation();
00426 
00427     // if it did not work or the user pressed ESCAPE then fail
00428     if (!Worked)
00429     {
00430         // It did not work, so we had better recover
00431         NewShape->CascadeDelete();
00432         delete NewShape;
00433 
00434         FailAndExecute();
00435     }
00436 
00437     End();
00438 }
00439 
00440 
00441 
00442 
00443 /********************************************************************************************
00444 
00445 >   BOOL OpNewRegShape::CompleteOperation()
00446 
00447     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00448     Created:    22/11/94
00449     Returns:    TRUE if the operation worked, FALSE if not
00450     Purpose:    Does all the work in building the undo etc. It builds a shape and inserts it
00451                 into the tree.
00452 
00453 ********************************************************************************************/
00454 
00455 BOOL OpNewRegShape::CompleteOperation()
00456 {
00457     // We will only create the shape if it is bigger than a blob rect at the current scale
00458     DocRect temp;
00459     GetApplication()->GetBlobManager()->GetBlobRect(StartPoint, &temp);
00460     if (temp.ContainsCoord(LastPoint))
00461     {
00462         return FALSE;
00463     }
00464 
00465     // Find the document for this operation.
00466     Document* pDoc = GetWorkingDoc();
00467     if (pDoc==NULL)
00468     {
00469         TRACEALL( _T("OpNewRegShape::CompleteOperation has no working document.")); 
00470         return FALSE;
00471     }
00472 
00473     // Apply a few attributes
00474     if (!(pDoc->GetAttributeMgr().ApplyCurrentAttribsToNode((NodeRenderableInk*)NewShape)))
00475         return FALSE;
00476 
00477     // Delete any applied join attribute
00478     NodeAttribute* pAppliedJoin = NewShape->GetChildAttrOfType(CC_RUNTIME_CLASS(AttrJoinType));
00479     if (pAppliedJoin != NULL) 
00480     {
00481         pAppliedJoin->CascadeDelete();
00482         delete pAppliedJoin;
00483     }
00484 
00485     // Apparently all shapes should have mitre joins.
00486     AttrJoinType* pMitreJoin = new AttrJoinType(NewShape, LASTCHILD);
00487     if (pMitreJoin == NULL)
00488         return FALSE;
00489     pMitreJoin->Value.JoinType = MitreJoin;
00490 
00491     // Try and start the the operation
00492     if (!DoStartSelOp(FALSE))
00493         return FALSE;
00494 
00495     // Ok, add it in and invalidate the region
00496     if (!DoInsertNewNode(NewShape, StartSpread, TRUE))
00497         return FALSE;
00498 
00499     // Finally, make sure we haven't added the new object partially off the spread
00500     StartSpread->ExpandPasteboardToInclude(NewShape->GetBoundingRect());
00501 
00502     // all worked
00503     return TRUE;
00504 }
00505 
00506 
00507 
00508 /********************************************************************************************
00509 
00510 >   void OpNewRegShape::InflateShape(DocRect *Bounds, DocCoord* NewCentre, DocCoord* NewMajor, DocCoord* NewMinor)
00511 
00512     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00513     Created:    20/1/95
00514     Inputs:     Bounds - The bounding box of the initial shape
00515                 NewCenter - the centre point of the shape
00516                 NewMajor - the proposed new major point
00517                 NewMinor - the proposed new major point
00518     Outputs:    NewMajor and NewMinor may have been repositioned
00519     Returns:    -
00520     Purpose:    NewMajor and NewMinor are initially positioned half way along the top and
00521                 halfway down the righthand side of the Bounds rect respectivly,  Their
00522                 positions are then increased so that the shape path passes through their
00523                 previous positions.
00524 
00525 ********************************************************************************************/
00526 void OpNewRegShape::InflateShape(DocRect *Bounds, DocCoord* NewCentre, DocCoord* NewMajor, DocCoord* NewMinor)
00527 {
00528     // Set their initial positions
00529     NewCentre->x = (Bounds->lo.x + Bounds->hi.x) / 2;
00530     NewCentre->y = (Bounds->lo.y + Bounds->hi.y) / 2;
00531     NewMajor->x = (Bounds->lo.x + Bounds->hi.x) / 2;
00532     NewMajor->y = Bounds->hi.y;
00533     NewMinor->x = Bounds->hi.x;
00534     NewMinor->y = (Bounds->lo.y + Bounds->hi.y) / 2;
00535     
00536     // Move them if required
00537     if (!NewShape->IsCircular())
00538     {
00539         DocCoord MajorRender = *NewMajor;
00540         DocCoord MinorRender = *NewMinor;
00541         double radius = NewCentre->Distance(*NewMajor);
00542         double SideA = cos(PI/NewShape->GetNumSides())*radius;
00543         if (SideA != 0.0)
00544         {
00545             DocCoord Update = DocCoord::PositionPointFromRatio(*NewCentre, *NewMajor, radius/SideA);
00546             NewMajor->y = Update.y;
00547         }
00548 
00549         if ( ((NewShape->GetNumSides() % 2) == 0) && (((NewShape->GetNumSides()/2) % 2) == 0) )
00550         {
00551             radius = NewCentre->Distance(*NewMinor);
00552             SideA = cos(PI/NewShape->GetNumSides())*radius;
00553             if (SideA != 0.0)
00554             {
00555                 DocCoord Update = DocCoord::PositionPointFromRatio(*NewCentre, *NewMinor, radius/SideA);
00556                 NewMinor->x = Update.x;
00557             }
00558         }
00559     }
00560 }
00561 
00562 
00563 
00564 /********************************************************************************************
00565 
00566 >   virtual void OpNewRegShape::RenderDragBlobs( DocRect Rect, Spread* pSpread, BOOL bSolidDrag )
00567 
00568     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00569     Created:    22/11/94
00570     Inputs:     Rect - The region that needs the blobs to be drawn
00571                 pSpread - The spread that the drawing will happen on
00572     Purpose:    Draws an EORed version of the current shape
00573 
00574 ********************************************************************************************/
00575 
00576 void OpNewRegShape::RenderDragBlobs(DocRect Rect, Spread* pSpread, BOOL bSolidDrag)
00577 {
00578     // If being called from DocView::RenderView, then the spread could be wrong - so
00579     // convert the rectangle if necessary.
00580     if (pSpread != StartSpread)
00581     {
00582         Rect.lo = MakeRelativeToSpread(StartSpread, pSpread, Rect.lo);
00583         Rect.hi = MakeRelativeToSpread(StartSpread, pSpread, Rect.hi);
00584     }
00585 
00586     // start a rendering loop
00587     RenderRegion* pRegion = DocView::RenderOnTop(NULL, pSpread, ClippedEOR);
00588     while (pRegion)
00589     {
00590         // Set the line colour 
00591         pRegion -> SetFillColour(COLOUR_NONE);
00592         pRegion -> SetLineColour(COLOUR_XORNEW);
00593 
00594         // Draw the outline
00595         NewShape->RenderEorDrag(pRegion);
00596 
00597         // Get the Next render region
00598         pRegion = DocView::GetNextOnTop(NULL);
00599     }
00600 }
00601 
00602 
00603 
00604 /********************************************************************************************
00605 
00606 >   BOOL OpNewRegShape::Declare()
00607 
00608     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00609     Created:    16/11/94                                                                        
00610     Returns:    TRUE if all went OK, False otherwise
00611     Purpose:    Adds the operation to the list of all known operations
00612 
00613 ********************************************************************************************/
00614 BOOL OpNewRegShape::Declare()
00615 {
00616     return (RegisterOpDescriptor(
00617                                 0, 
00618                                 _R(IDS_NEWREGULARSHAPEOP),
00619                                 CC_RUNTIME_CLASS(OpNewRegShape), 
00620                                 OPTOKEN_NEWREGSHAPE,
00621                                 OpNewRegShape::GetState));
00622 
00623 }
00624 
00625 
00626 
00627 /********************************************************************************************
00628 
00629 >   OpState OpNewRegShape::GetState(String_256* Description, OpDescriptor*)
00630 
00631     Author:     Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
00632     Created:    16/11/94
00633     Outputs:    -
00634     Returns:    Ungreyed, Unticked
00635     Purpose:    Find out the state of the new regular shape at the specific time
00636 
00637 ********************************************************************************************/
00638 OpState OpNewRegShape::GetState(String_256* Description, OpDescriptor*)
00639 {
00640     OpState Blobby;
00641     
00642     return Blobby;
00643 }
00644 

Generated on Sat Nov 10 03:47:49 2007 for Camelot by  doxygen 1.4.4