OpPenCreatePath Class Reference

This op is concerned with creating a new path in the tree. It is derived from OpPenEditPath, which handles all the dragging and redraw of a new path element. This op will use. More...

#include <penedit.h>

Inheritance diagram for OpPenCreatePath:

OpPenEditPath OpPenHandles Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpPenCreatePath ()
 OpPenCreatePath constructor.
void DoPenCreatePath (ControlPts *, DocCoord, Spread *, Path *)
 Creates a path element when the user clicks or drags at a particular point. The edit path will contain the necessary element when the operation has finished. If the operation is not a success, the edit path will contain nothing.
virtual void DragFinished (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL Success, BOOL bSolidDrag)
 This is called when a drag operation finishes.

Static Public Member Functions

static BOOL Init ()
 OpPenCreatePath initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the OpPenCreatePath's state.

Private Attributes

DocCoord Handle0
DocCoord Handle1

Detailed Description

This op is concerned with creating a new path in the tree. It is derived from OpPenEditPath, which handles all the dragging and redraw of a new path element. This op will use.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94

Definition at line 415 of file penedit.h.


Constructor & Destructor Documentation

OpPenCreatePath::OpPenCreatePath  ) 
 

OpPenCreatePath constructor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
See also:
-

Definition at line 1486 of file penedit.cpp.

01487 {
01488     // Dummy constructor
01489 }


Member Function Documentation

void OpPenCreatePath::DoPenCreatePath ControlPts pHandles,
DocCoord  ClickPoint,
Spread pClickSpread,
Path pPath
 

Creates a path element when the user clicks or drags at a particular point. The edit path will contain the necessary element when the operation has finished. If the operation is not a success, the edit path will contain nothing.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
Parameters:
pHandles = pointer to a handles block containing drag handle info [INPUTS] ClickPoint = the last mouse click position pClickSpread= pointer to spread where the click occured pEditPath = pointer to path to edit
pEditPath = Updated to contain a single path element, either [OUTPUTS] a curve or line dependent on whether the operation performs a drag.
Returns:
-

Errors: failandexecute will be called if the operation fails in some way, most likely when no memory is available.

Definition at line 1576 of file penedit.cpp.

01580 {   
01581     // ok, we always create a curve element in the path and descover whether
01582     // the points all lie in a straight line at the end of the drag. If so, we
01583     // will alter the path element back to a line at that stage.
01584 
01585     BOOL ok;
01586     
01587     pEditPath = pPath;
01588     
01589     Handle0 = pHandles->HndClick;
01590     Handle1 = pHandles->HndDrag;
01591 
01592     // make the new click point relative to our handle coordinates.
01593     if (pHandles->pHndSpread != pClickSpread)
01594         ClickPoint = MakeRelativeToSpread(pHandles->pHndSpread, pClickSpread, ClickPoint);
01595 
01596     // make sure we get the grid snapping involved
01597     DocCoord SnapPos = ClickPoint;
01598     DocView::SnapCurrent(pClickSpread,&SnapPos);
01599 
01600     // create the first element in the path
01601     ok = (pEditPath->InsertMoveTo(Handle0, NULL));
01602 
01603     if (ok)
01604     {
01605         DocCoord Cpt1 = Handle1;
01606         if (Handle0 == Handle1)
01607         {
01608             Cpt1.x = (2*Handle0.x + SnapPos.x)/3;
01609             Cpt1.y = (2*Handle0.y + SnapPos.y)/3;
01610         }
01611         DocCoord Cpt2;
01612         Cpt2.x = (Handle1.x + 2*SnapPos.x)/3;
01613         Cpt2.y = (Handle1.y + 2*SnapPos.y)/3;
01614 
01615         ok = InsertBezier(Cpt1, Cpt2, SnapPos);
01616     }
01617     
01618     if (ok)
01619     {
01620         // Set info about the click point and spread
01621         HandleFlags hFlags;
01622         SetDragHandles(hFlags, SnapPos, SnapPos, SnapPos, pClickSpread);
01623             
01624         // Set the edit control to tell the drag code which 
01625         // point to overwrite 
01626         WobbleFlags wFlags;
01627         SetWobbleIndex(wFlags, 3);
01628 
01629         // Render the first eor version on
01630         DocRect Rect = GetBoundingRect();
01631         RenderDragBlobs(Rect, StartSpread, FALSE);
01632         
01633         // Now start the drag op on this path
01634         ok = OpPenEditPath::DoPenDragPath();
01635     }
01636 
01637     if (!ok)
01638     {
01639         // failed to perform create so lets tidy up the path and exit
01640         pEditPath->ClearPath();
01641         FailAndExecute();
01642         End();
01643     }
01644 }   

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

This is called when a drag operation finishes.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/9/94
Parameters:
PointerPos - The position of the mouse at the end of the drag [INPUTS] ClickMods - the key modifiers being pressed Success - TRUE if the drag was terminated properly, FALSE if it was ended with the escape key being pressed
See also:
ClickModifiers

Reimplemented from OpPenEditPath.

Definition at line 1665 of file penedit.cpp.

01667 {
01668     // inform the base class to stop dragging
01669     OpPenEditPath::DragFinished( PointerPos, ClickMods, pSpread, Success, bSolidDrag);
01670 
01671     // Rub out the old EORed version of the path
01672     DocRect Rect = GetBoundingRect();
01673     RenderDragBlobs( Rect, StartSpread, bSolidDrag);
01674 
01675     if (Success)
01676     {
01677         if (!HasMouseMoved(StartMousePos,CurrentMousePos))
01678         {
01679             // nothing moved so check to see if we can convert to a line
01680             if (Handle0 == Handle1)
01681                 ConvertToLine(1);           // delete the curve element and create a line!
01682             else
01683                 RemoveRotateEnd(1);         // make sure the end has no smooth bits set
01684         }
01685     }
01686     else
01687         FailAndExecute();
01688 
01689     End();
01690 }

OpState OpPenCreatePath::GetState String_256 ,
OpDescriptor
[static]
 

For finding the OpPenCreatePath's state.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpPenCreatePath

Errors: -

See also:
-

Reimplemented from OpPenEditPath.

Definition at line 1541 of file penedit.cpp.

01542 {
01543     OpState OpSt;
01544     // Always enabled at the moment.
01545     return OpSt;
01546 }

BOOL OpPenCreatePath::Init void   )  [static]
 

OpPenCreatePath initialiser method.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/9/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from OpPenEditPath.

Definition at line 1510 of file penedit.cpp.

01511 {
01512     return (RegisterOpDescriptor(0,                                     // tool ID
01513                                 _R(IDS_PENCREATEPATHOP),                    // string resource ID
01514                                 CC_RUNTIME_CLASS(OpPenCreatePath),      // runtime class for Op
01515                                 OPTOKEN_PENCREATEPATH,                  // Ptr to token string
01516                                 OpPenCreatePath::GetState,              // GetState function
01517                                 0,                                      // help ID = 0
01518                                 _R(IDBBL_PENCREATEPATHOP),                  // bubble help ID = 0
01519                                 0                                       // resource ID = 0
01520                                 )); 
01521 
01522 }               


Member Data Documentation

DocCoord OpPenCreatePath::Handle0 [private]
 

Definition at line 428 of file penedit.h.

DocCoord OpPenCreatePath::Handle1 [private]
 

Definition at line 429 of file penedit.h.


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