OpGuideline Class Reference

Allows guidelines to be dragged around. More...

#include <guides.h>

Inheritance diagram for OpGuideline:

UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject OpDeleteAllGuidelines OpDeleteGuideline OpNewGuideline List of all members.

Public Member Functions

 OpGuideline ()
 Default constructor.
 ~OpGuideline ()
 Default destructor.
virtual void DoWithParam (OpDescriptor *pOpDesc, OpParam *pParam)
 This function is used to create a guideline in the selected spread. It calls DoAddNewGuideline() with pParam->Param1 specifying the guideline type.
virtual BOOL DragKeyPress (KeyPress *pKeyPress, BOOL bSolidDrag)
 Responds to a keypress during the drag.
virtual void DragPointerMove (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag)
 Responds to a mouse move during a drag of a guideline.
virtual void DragFinished (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag)
 Responds to the drag of a guideline ending.
virtual BOOL Undo ()
 Called when the op is undone. This broadcasts a 'Guidelines changed' layer message.
virtual BOOL Redo ()
 Called when the op is redone. This broadcasts a 'Guidelines changed' layer message.
void RenderMyDragBlobs ()
 Renders the blobs associated with the current drag.
void RenderDragBlobs (DocRect Rect, Spread *pSpread, BOOL bSolidDrag)
 Main routine for rendering the blobs associated with the current drag. This can be called from anywhere, e.g. when the view scrolls.
void GetOpName (String_256 *OpName)
 Returns a desc of the op. Mainly used to fill in the menu item for the undo/redo ops.

Static Public Member Functions

static BOOL Init ()
 Registers an op desc for this op.
static OpState GetState (String_256 *Description, OpDescriptor *)
 Func for determining the usability of this op.
static BOOL IsMouseOverRuler ()
 Test to see where the mouse pointer is. It will return TRUE if the mouse is over either ruler, or the origin gadget.

Protected Member Functions

void DoDrag (Spread *pSpread, DocCoord PointerPos)
 Starts a drag for a new or existing guideline.
void DoAddNewGuideline (Spread *pSpread, DocCoord PointerPos, GuidelineType Type)
 Starts a drag to add a new guideline to the document.
void DoMoveGuideline (Spread *pSpread, DocCoord PointerPos, NodeGuideline *pGuideline)
 Starts a drag to add a new guideline to the document.
BOOL DoTranslateGuideline (NodeGuideline *pGuideline, MILLIPOINT Ordinate, NodeGuideline **ppNewGuideline=NULL)
 Translates the given guideline to line up with Ordinate, undoably.
BOOL DoNewGuideline (Node *pContext, AttachNodeDirection AttachDir, GuidelineType Type, MILLIPOINT Ordinate, NodeGuideline **ppNewGuideline=NULL)
 Creates a new guideline to line up with Ordinate, undoably.
BOOL DoDeleteGuideline (NodeGuideline *pGuideline, BOOL TryToLeaveCopy=FALSE)
 Deletes the given guideline, undoably.
BOOL DoDeleteListOfGuidelines (NodeGuideline **pGuidelineList)
 Deletes the guidelines in the given list, undoably The list should be terminated by a NULL value.
LayerDoCreateGuideLayer ()
 This returns a ptr to the guide layer.
BOOL CanLeaveCopy ()
 Sees if the user wants to leave a copy behind.
void UpdateStatusLineAndPointer ()
 Makes sure the status line AND pointer are correct during a drag.
void BroadcastGuidelineChanges (NodeGuideline *pGuideline)
 Broadcasts a LayerMsg::LayerReason::GUIDELINES_CHANGED for the parent layer of pGuideline.
void BroadcastGuidelineChanges (Layer *pLayer)
 Broadcasts a LayerMsg::LayerReason::GUIDELINES_CHANGED for the given layer.
void SetOrdinate (DocCoord &PointerPos)
 This does everything required in creating a layer fit to be called the guide layer Sets the Ordinate member var to either the X or the Y value of PointerPos depending on the guideline type.

Protected Attributes

UINT32 UndoIDS

Private Member Functions

 CC_DECLARE_DYNCREATE (OpGuideline)

Private Attributes

OpGuidelineOpMethod OpMethod
SpreadpSpread
NodeGuidelinepDraggedGuideline
MILLIPOINT Ordinate
GuidelineType Type
BOOL LeaveCopy
CursorpCursor
UINT32 CurrentStatusHelp
INT32 CursorStackID
LayerpBroadcastLayer
BOOL RenderOn

Detailed Description

Allows guidelines to be dragged around.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/9/95

Definition at line 255 of file guides.h.


Constructor & Destructor Documentation

OpGuideline::OpGuideline  ) 
 

Default constructor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Definition at line 1160 of file guides.cpp.

01161 {
01162     pDraggedGuideline = NULL;
01163     pBroadcastLayer   = NULL;
01164     UndoIDS           = _R(IDS_MARKN_EMPTY);
01165     LeaveCopy         = FALSE;
01166     pCursor           = NULL;
01167     CurrentStatusHelp = _R(IDS_MARKN_EMPTY);
01168     CursorStackID     = GUIDE_CURSORID_UNSET;
01169     RenderOn          = TRUE;
01170 }

OpGuideline::~OpGuideline  ) 
 

Default destructor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Definition at line 1187 of file guides.cpp.

01188 {
01189     if (pCursor != NULL)
01190         delete pCursor;
01191 }


Member Function Documentation

void OpGuideline::BroadcastGuidelineChanges Layer pLayer  )  [protected]
 

Broadcasts a LayerMsg::LayerReason::GUIDELINES_CHANGED for the given layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
pLayer = ptr to layer [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
DoWithParams()

Definition at line 1228 of file guides.cpp.

01229 {
01230     if (pLayer != NULL)
01231     {
01232         BROADCAST_TO_ALL(LayerMsg(pLayer,LayerMsg::GUIDELINES_CHANGED));
01233     }
01234 
01235     pBroadcastLayer = pLayer;
01236 }

void OpGuideline::BroadcastGuidelineChanges NodeGuideline pGuideline  )  [protected]
 

Broadcasts a LayerMsg::LayerReason::GUIDELINES_CHANGED for the parent layer of pGuideline.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
pGuideline = ptr to guideline [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
DoWithParams()

Definition at line 1208 of file guides.cpp.

01209 {
01210     if (pGuideline != NULL)
01211         BroadcastGuidelineChanges((Layer*)pGuideline->FindParent(CC_RUNTIME_CLASS(Layer)));
01212 }

BOOL OpGuideline::CanLeaveCopy  )  [protected]
 

Sees if the user wants to leave a copy behind.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if user wants to leave a copy behind, FALSE otherwise
TRUE is returned if the ctrl is pressed, or Numpad + has been pressed an odd number of times during the drag

See also:
OpGuideline::DragFinished()

Definition at line 1832 of file guides.cpp.

01833 {
01834     return (LeaveCopy || KeyPress::IsConstrainPressed());
01835 }

OpGuideline::CC_DECLARE_DYNCREATE OpGuideline   )  [private]
 

void OpGuideline::DoAddNewGuideline Spread pSpread,
DocCoord  PointerPos,
GuidelineType  TheType
[protected]
 

Starts a drag to add a new guideline to the document.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
pThisSpread = ptr to spread drag started in [INPUTS] PointerPos = coord of point clicked TheType = The type of guideline
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Definition at line 1377 of file guides.cpp.

01378 {
01379     Type = TheType;
01380 
01381     DoDrag(pSpread,PointerPos);
01382 }

Layer * OpGuideline::DoCreateGuideLayer  )  [protected]
 

This returns a ptr to the guide layer.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Ptr to the guide layer, or NULL one couldn't be created.
If the guide layer already exists, a ptr to it is returned.

If there isn't a guide layer, it is created and inserted into the doc tree. If this fails the func returns NULL

See also:
OpGuideline::DoNewGuideline()

Definition at line 1887 of file guides.cpp.

01888 {
01889     Layer* pLayer = pSpread->FindFirstGuideLayer();
01890     if (pLayer != NULL)
01891         return pLayer;
01892 
01893     Layer* pNewLayer = Layer::CreateGuideLayer();
01894     if (pNewLayer != NULL)
01895     {
01896         // If we insert the new layer as the FIRSTCHILD then this will be behind the page.
01897         // If we insert as the last child then we will be at the front of
01898         // the stacking order. We need to insert ourselves as the node after the last page node
01899         // This used to take this approach before 4/4/97.
01900 //      Page *pLastPage = pSpread->FindLastPageInSpread();
01901         Layer *pLastLayer = pSpread->FindLastLayer();
01902         // If there is the sepcial background layer present then ensure that we insert after that
01903 //      Layer * pLayer = pSpread->FindFirstPageBackgroundLayer();
01904 //      Node * pInsertionPoint = pLastPage;
01905         Node * pInsertionPoint = pLastLayer;
01906 //      if (pLayer)
01907 //          pInsertionPoint = pLayer;
01908 
01909         // Insert the new layer as the next node after the last page.
01910         if (pLastLayer && DoInsertNewNode(pNewLayer,pInsertionPoint,NEXT,FALSE,FALSE,FALSE,FALSE))
01911         {
01912             pNewLayer->EnsureUniqueLayerID();
01913             BROADCAST_TO_ALL(SpreadMsg(pSpread,SpreadMsg::LAYERCHANGES));
01914         }
01915         else
01916         {
01917             delete pNewLayer;
01918             pNewLayer = NULL;
01919         }
01920     }
01921 
01922     return pNewLayer;
01923 }

BOOL OpGuideline::DoDeleteGuideline NodeGuideline pGuideline,
BOOL  TryToLeaveCopy = FALSE
[protected]
 

Deletes the given guideline, undoably.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pGuideline = ptr to an existing guideline [INPUTS] TryToLeaveCopy = TRUE to try and leave copy, FALSE means force delete
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
OpGuideline::DragFinished()

Definition at line 1788 of file guides.cpp.

01789 {
01790     BOOL ok = TRUE;
01791 
01792     if (TryToLeaveCopy && CanLeaveCopy())
01793     {
01794         // User is trying to copy the guideline, so just set up the correct undo string
01795         UndoIDS = _R(IDS_OPCOPYGUIDELINE);
01796     }
01797     else
01798     {
01799         ERROR2IF(pGuideline == NULL,FALSE,"pGuideline is NULL");
01800 
01801         pSpread = pGuideline->FindParentSpread();
01802         ERROR2IF_PF(pSpread == NULL,FALSE,("pGuideline (0x%x) has no parent spread",pGuideline));
01803 
01804         DocRect Rect = pGuideline->GetRenderRect(FALSE);
01805 
01806         if (ok) ok = DoInvalidateRegion(pSpread,Rect);
01807         if (ok) ok = DoHideNode(pGuideline,TRUE);
01808     }
01809 
01810     return ok;
01811 }

BOOL OpGuideline::DoDeleteListOfGuidelines NodeGuideline **  pGuidelineList  )  [protected]
 

Deletes the guidelines in the given list, undoably The list should be terminated by a NULL value.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pGuidelineList = ptr to a list of existing guidelines [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
OpGuideline::DragFinished()

Definition at line 1852 of file guides.cpp.

01853 {
01854     ERROR2IF(pGuidelineList == NULL,FALSE,"pGuidelineList is NULL");
01855 
01856     BOOL ok= TRUE;
01857 
01858     while (*pGuidelineList != NULL && ok)
01859     {
01860         ok = DoDeleteGuideline(*pGuidelineList);
01861         pGuidelineList++;
01862     }
01863 
01864     return ok;
01865 }

void OpGuideline::DoDrag Spread pThisSpread,
DocCoord  PointerPos
[protected]
 

Starts a drag for a new or existing guideline.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
pThisSpread = ptr to spread drag started in (NULL means get selected spread) [INPUTS] PointerPos = coord of point clicked
- [OUTPUTS]
Returns:
-
See also:
DoMoveGuideline(), DoAddNewGuideline()

Definition at line 1424 of file guides.cpp.

01425 {
01426     pSpread = pThisSpread;
01427 
01428     if (pSpread == NULL)
01429         pSpread = Document::GetSelectedSpread();
01430 
01431     ERROR3IF(pSpread == NULL,"pSpread == NULL");
01432     if (pSpread == NULL)
01433     {
01434         End();
01435         return;
01436     }
01437 
01438     SetOrdinate(PointerPos);
01439 
01440     RenderMyDragBlobs();
01441 
01442     LeaveCopy = KeyPress::IsKeyPressed(CAMKEY(ADD));
01443 
01444     if (pCursor == NULL)
01445     {
01446         ToolListItem* pItem = Tool::Find(TOOLID_SELECTOR);
01447 
01448         if (pItem != NULL)
01449         {
01450             Tool* pTool = pItem->m_pTool;
01451 
01452             if (pTool != NULL)
01453             {
01454                 if (Type == GUIDELINE_HORZ)
01455                     pCursor = new Cursor(pTool,_R(IDCSR_SEL_HGUIDE));
01456                 else
01457                     pCursor = new Cursor(pTool,_R(IDCSR_SEL_VGUIDE));
01458 
01459                 if (pCursor != NULL)
01460                     CursorStackID = CursorStack::GPush(pCursor);
01461             }
01462         }
01463     }
01464 
01465     UpdateStatusLineAndPointer();
01466 
01467     // Tell the Dragging system that we need drags to happen
01468     StartDrag( DRAGTYPE_DEFERSCROLL );
01469 }

void OpGuideline::DoMoveGuideline Spread pSpread,
DocCoord  PointerPos,
NodeGuideline pGuideline
[protected]
 

Starts a drag to add a new guideline to the document.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
pThisSpread = ptr to spread drag started in [INPUTS] PointerPos = coord of point clicked pGuideline = the guideline to move
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Definition at line 1400 of file guides.cpp.

01401 {
01402     pDraggedGuideline = pGuideline;
01403     Type              = pDraggedGuideline->GetType();
01404 
01405     DoDrag(pSpread,PointerPos);
01406 }

BOOL OpGuideline::DoNewGuideline Node pContext,
AttachNodeDirection  AttachDir,
GuidelineType  Type,
MILLIPOINT  Ordinate,
NodeGuideline **  ppNewGuideline = NULL
[protected]
 

Creates a new guideline to line up with Ordinate, undoably.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pContext = ptr to context node (Can be NULL) [INPUTS] AttachDir = how the new guideline should be attached to the context node Type = type of guideline to create Ordinate = position of new guideline ppNewGuideline = place to put ptr of new guideline (Can be NULL)
*ppNewGuideline = ptr to new guideline (NULL if function fails) [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
OpGuideline::DragFinished()

Definition at line 1736 of file guides.cpp.

01737 {
01738     if (pContext == NULL)
01739     {
01740         pContext = DoCreateGuideLayer();
01741         AttachDir = LASTCHILD;
01742     }
01743 
01744     ERROR2IF(pContext == NULL,FALSE,"pContext is NULL");
01745 
01746     BOOL ok = TRUE;
01747 
01748     NodeGuideline* pNewGuideline = new NodeGuideline;
01749     ok = (pNewGuideline != NULL);
01750     if (ok)
01751     {
01752         pNewGuideline->SetType(Type);
01753         pNewGuideline->SetOrdinate(Ordinate);
01754 
01755         DocRect Rect = pNewGuideline->GetRenderRect(FALSE);
01756 
01757         if (ok) ok = DoInsertNewNode(pNewGuideline,pContext,AttachDir,FALSE,FALSE,FALSE,FALSE);
01758         if (ok) ok = DoInvalidateRegion(pSpread,Rect);
01759     }
01760 
01761     if (!ok && pNewGuideline != NULL)
01762     {
01763         delete pNewGuideline;
01764         pNewGuideline = NULL;
01765     }
01766 
01767     if (ppNewGuideline != NULL)
01768         *ppNewGuideline = pNewGuideline;
01769 
01770     return ok;
01771 }

BOOL OpGuideline::DoTranslateGuideline NodeGuideline pGuideline,
MILLIPOINT  Ordinate,
NodeGuideline **  ppNewGuideline = NULL
[protected]
 

Translates the given guideline to line up with Ordinate, undoably.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
pGuideline = ptr to an existing guideline [INPUTS] Ordinate = Absolute position to translate to ppNewGuideline = place to put ptr of translated guideline (Can be NULL)
*ppNewGuideline = ptr to translated guideline (NULL if function fails) [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise
See also:
OpGuideline::DragFinished()

Definition at line 1702 of file guides.cpp.

01703 {
01704     ERROR2IF(pGuideline == NULL,FALSE,"pGuideline is NULL");
01705 
01706     Type = pGuideline->GetType();
01707 
01708     BOOL ok = TRUE;
01709 
01710     if (ok) ok = DoNewGuideline(pGuideline,NEXT,Type,Ordinate,ppNewGuideline);
01711     if (ok) ok = DoDeleteGuideline(pGuideline,TRUE);
01712 
01713     return ok;
01714 }

void OpGuideline::DoWithParam OpDescriptor pOpDesc,
OpParam pParam
[virtual]
 

This function is used to create a guideline in the selected spread. It calls DoAddNewGuideline() with pParam->Param1 specifying the guideline type.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/9/95
Parameters:
pOpDesc = ptr op desc [INPUTS] pOpParam = param block to use
- [OUTPUTS]
Returns:
-
See also:
DoAddNewGuideline(), OilRuler::OnLButtonDown()

Reimplemented from Operation.

Definition at line 1254 of file guides.cpp.

01255 {
01256     ERROR3IF(pParam == NULL,"pParam is NULL");
01257 
01258     if (pParam != NULL)
01259     {
01260         OpGuidelineParam* pGuidelineParam = (OpGuidelineParam*)pParam;
01261         NodeGuideline* pGuideline = pGuidelineParam->pGuideline;
01262 
01263         OpMethod = pGuidelineParam->Method;
01264 
01265         switch (OpMethod)
01266         {
01267             //-----------------------------------
01268             case GUIDELINEOPMETHOD_MOVE_DRAG:
01269             {
01270                 ERROR3IF(pGuideline == NULL,"pGuideline is NULL");
01271 
01272                 if (pGuideline != NULL)
01273                 {
01274                     DocCoord PointerPos(pGuideline->GetOrdinate(),pGuideline->GetOrdinate());
01275                     DoMoveGuideline(NULL,PointerPos,pGuideline);
01276                 }
01277             }
01278             UndoIDS = _R(IDS_OPMOVEGUIDELINE);
01279             break;
01280 
01281             //-----------------------------------
01282             case GUIDELINEOPMETHOD_MOVE_IMMEDIATE:
01283             {
01284                 ERROR3IF(pGuideline == NULL,"pGuideline is NULL");
01285 
01286                 pSpread = Document::GetSelectedSpread();
01287 
01288                 if (pGuideline != NULL && !DoTranslateGuideline(pGuideline,pGuidelineParam->NewOrdinate))
01289                     FailAndExecute();
01290                 else
01291                     BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01292 
01293                 End();
01294             }
01295             UndoIDS = _R(IDS_OPMOVEGUIDELINE);
01296             break;
01297 
01298             //-----------------------------------
01299             case GUIDELINEOPMETHOD_NEW_DRAG:
01300             {
01301                 DocCoord PointerPos(-5000,-5000);
01302                 DoAddNewGuideline(NULL,PointerPos,pGuidelineParam->Type);
01303             }
01304             UndoIDS = _R(IDS_OPNEWGUIDELINE);
01305             break;
01306 
01307             //-----------------------------------
01308             case GUIDELINEOPMETHOD_NEW_IMMEDIATE:
01309             {
01310                 pSpread = Document::GetSelectedSpread();
01311 
01312                 if (!DoNewGuideline(NULL,NEXT,pGuidelineParam->Type,pGuidelineParam->NewOrdinate))
01313                     FailAndExecute();
01314                 else
01315                     BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01316 
01317                 End();
01318             }
01319             UndoIDS = _R(IDS_OPNEWGUIDELINE);
01320             break;
01321 
01322             //-----------------------------------
01323             case GUIDELINEOPMETHOD_CREATE_GUIDE_LAYER:
01324             {
01325                 pSpread = Document::GetSelectedSpread();
01326                 Layer* pGuideLayer = DoCreateGuideLayer();
01327 
01328                 if (pGuideLayer == NULL)
01329                     FailAndExecute();
01330                 else
01331                     BroadcastGuidelineChanges(pGuideLayer);
01332 
01333                 End();
01334             }
01335             UndoIDS = _R(IDS_OPCREATEGUIDELAYER);
01336             break;
01337 
01338             //-----------------------------------
01339             case GUIDELINEOPMETHOD_DELETE:
01340             {
01341                 pSpread = Document::GetSelectedSpread();
01342 
01343                 if (!DoDeleteListOfGuidelines(pGuidelineParam->pGuidelineList))
01344                     FailAndExecute();
01345                 else
01346                     BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01347 
01348                 End();
01349 
01350             }
01351             UndoIDS = _R(IDS_OPDELETESELECTEDGUIDELINES);       // ********* NEW RESOURCE STRING!!!!!!
01352             break;
01353             //-----------------------------------
01354             default:
01355                 ERROR3_PF(("Unknown OpGuideline method : %d",pGuidelineParam->Method));
01356                 break;
01357         }
01358     }
01359 }

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

Responds to the drag of a guideline ending.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
PointerPos = coord of the pointer [INPUTS] ClickMods = info on the click modifiers pSpread = ptr to spread (not used) Success = TRUE if drag ended successfully, FALSE if drag terminated (usu. by pressing Escape)
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Reimplemented from Operation.

Definition at line 1520 of file guides.cpp.

01521 {
01522     // First Rub out the old boxes
01523     RenderMyDragBlobs();
01524 
01525     if (Success)
01526     {
01527         DocView::SnapCurrent(pSpread,&PointerPos);
01528         SetOrdinate(PointerPos);
01529 
01530         if (pDraggedGuideline != NULL)
01531         {
01532             if (IsMouseOverRuler())
01533             {
01534                 UndoIDS = _R(IDS_OPDELETEGUIDELINE);
01535                 Success = DoDeleteGuideline(pDraggedGuideline);
01536             }
01537             else
01538                 Success = DoTranslateGuideline(pDraggedGuideline,Ordinate);
01539         }
01540         else
01541             Success = !IsMouseOverRuler() && DoNewGuideline(NULL,NEXT,Type,Ordinate);
01542     }
01543 
01544     // End the Drag
01545     EndDrag();
01546 
01547     // Restore cursor
01548     if (CursorStackID != GUIDE_CURSORID_UNSET)
01549     {
01550         CursorStack::GPop(CursorStackID);
01551         CursorStackID = GUIDE_CURSORID_UNSET;
01552     }
01553 
01554     if (pCursor != NULL)
01555     {
01556         delete pCursor;
01557         pCursor = NULL;
01558     }
01559 
01560     if (!Success)
01561         FailAndExecute();
01562     else
01563         BroadcastGuidelineChanges(pSpread->FindFirstGuideLayer());
01564     // End the op
01565     End();
01566 }

BOOL OpGuideline::DragKeyPress KeyPress pKeyPress,
BOOL  bSolidDrag
[virtual]
 

Responds to a keypress during the drag.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/10/95
Parameters:
pKeyPress = ptr to keypress object [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
DragFinished

Reimplemented from Operation.

Definition at line 1635 of file guides.cpp.

01636 {
01637     BOOL Processed = FALSE;
01638     switch (pKeyPress->GetVirtKey())
01639     {
01640         case CAMKEY(ADD):
01641             if (!pKeyPress->IsModified() && pKeyPress->IsPress() && !pKeyPress->IsRepeat())
01642             {
01643                 LeaveCopy = !LeaveCopy;
01644                 UpdateStatusLineAndPointer();
01645                 Processed = TRUE;
01646             }
01647             break;
01648 
01649         case CAMKEY(CONTROL):
01650             UpdateStatusLineAndPointer();
01651             Processed = TRUE;
01652             break;
01653     }
01654     return Processed;
01655 }

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

Responds to a mouse move during a drag of a guideline.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
PointerPos = coord of the pointer [INPUTS] ClickMods = info on the click modifiers pSpread = ptr to spread
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Reimplemented from Operation.

Definition at line 1487 of file guides.cpp.

01488 {
01489     // First Rub out the old box
01490     RenderMyDragBlobs();
01491 
01492     DocView::SnapCurrent(pSpread,&PointerPos);
01493 
01494     SetOrdinate(PointerPos);
01495 
01496     // Render the new drag box
01497     RenderMyDragBlobs();
01498 
01499     UpdateStatusLineAndPointer();
01500 }

void OpGuideline::GetOpName String_256 OpName  )  [virtual]
 

Returns a desc of the op. Mainly used to fill in the menu item for the undo/redo ops.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
OpName = ptr to string [INPUTS]
OpName contains a description of the op [OUTPUTS]
Returns:
-
See also:
-

Reimplemented from Operation.

Definition at line 2219 of file guides.cpp.

02220 {
02221     *OpName = String_256(UndoIDS);
02222 }

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

Func for determining the usability of this op.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
Description = ptr to place description of why this op can't happen [INPUTS] pOpDesc = ptr to the Op Desc associated with this op
- [OUTPUTS]
Returns:
An OpState object
See also:
-

Reimplemented in OpDeleteGuideline, OpDeleteAllGuidelines, and OpNewGuideline.

Definition at line 2199 of file guides.cpp.

02200 {
02201     OpState State;
02202     return State;
02203 }

BOOL OpGuideline::Init void   )  [static]
 

Registers an op desc for this op.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if op successfully declared, FALSE otherwise
See also:
-

Reimplemented from SimpleCCObject.

Reimplemented in OpNewGuideline.

Definition at line 2140 of file guides.cpp.

02141 {
02142     return (GuidelinePropDlg::Init()    && 
02143             OpNewGuideline::Init()      &&
02144             OpSpreadOrigin::Init()      && 
02145             OpResetSpreadOrigin::Init() &&
02146 #ifndef STANDALONE
02147             OpChangeLayerColour::Init() &&
02148 #endif
02149             RegisterOpDescriptor(
02150                                 0, 
02151                                 0,
02152                                 CC_RUNTIME_CLASS(OpGuideline), 
02153                                 OPTOKEN_GUIDELINE ,
02154                                 OpGuideline::GetState,
02155                                 0,  /* help ID */
02156                                 0,  /* bubble ID */
02157                                 0   /* bitmap ID */
02158                                 ) &&
02159 
02160             RegisterOpDescriptor(
02161                                 0, 
02162                                 _R(IDS_DELETEALLGUIDELINES),
02163                                 CC_RUNTIME_CLASS(OpDeleteAllGuidelines), 
02164                                 OPTOKEN_DELETEALLGUIDELINES ,
02165                                 OpDeleteAllGuidelines::GetState,
02166                                 0,  /* help ID */
02167                                 0,  /* bubble ID */
02168                                 0   /* bitmap ID */
02169                                 ) &&
02170 
02171             RegisterOpDescriptor(
02172                                 0, 
02173                                 _R(IDS_DELETEGUIDELINE),
02174                                 CC_RUNTIME_CLASS(OpDeleteGuideline), 
02175                                 OPTOKEN_DELETEGUIDELINE ,
02176                                 OpDeleteGuideline::GetState,
02177                                 0,  /* help ID */
02178                                 0,  /* bubble ID */
02179                                 0   /* bitmap ID */
02180                                 )                               
02181             );
02182 }

BOOL OpGuideline::IsMouseOverRuler  )  [static]
 

Test to see where the mouse pointer is. It will return TRUE if the mouse is over either ruler, or the origin gadget.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if mouse is over a ruler, FALSE otherwise
See also:
OpGuideline::DragFinished()

Definition at line 1673 of file guides.cpp.

01674 {
01675     DocView* pDocView = DocView::GetSelected();
01676     if (pDocView != NULL)
01677     {
01678         CCamView* pCCamView = pDocView->GetConnectionToOilView();
01679         return (pCCamView->IsMouseOverRuler() != OVER_NO_RULERS);
01680     }
01681 
01682     return FALSE;
01683 }

BOOL OpGuideline::Redo  )  [virtual]
 

Called when the op is redone. This broadcasts a 'Guidelines changed' layer message.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successfull, FALSE otherwise
See also:
-

Reimplemented from Operation.

Definition at line 2115 of file guides.cpp.

02116 {
02117     if (UndoableOperation::Redo())
02118     {
02119         BroadcastGuidelineChanges(pBroadcastLayer);
02120         return TRUE;
02121     }
02122 
02123     return FALSE;
02124 }

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

Main routine for rendering the blobs associated with the current drag. This can be called from anywhere, e.g. when the view scrolls.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
Rect = region of doc being updated (NOT USED!) [INPUTS] pSpread = ptr to the spread being redrawn
- [OUTPUTS]
Returns:
-
See also:
-

Reimplemented from Operation.

Definition at line 2030 of file guides.cpp.

02031 {
02032     static DocRect RenderRect;
02033 
02034     RenderRegion* pRender = DocView::RenderOnTop( NULL, pSpread, UnclippedEOR );
02035 
02036     while (pRender != NULL)
02037     {
02038         // Set line colour for dashed line
02039         pRender->SetLineColour(COLOUR_BLACK);
02040 
02041         DocCoord StartPoint(Ordinate,Ordinate);
02042         DocCoord EndPoint(Ordinate,Ordinate);
02043 
02044         if (RenderOn)
02045         {
02046             View* pView = pRender->GetRenderView();
02047             if (pView != NULL)
02048             {
02049                 RenderRect = pView->GetDocViewRect(pSpread);
02050                 RenderRect = RenderRect.ToSpread(pSpread,pView);
02051             }
02052             RenderRect.Inflate(pRender->GetScaledPixelWidth());
02053         }
02054 
02055         if (Type == GUIDELINE_HORZ)
02056         {
02057             StartPoint.x = RenderRect.lo.x;
02058             EndPoint.x   = RenderRect.hi.x;
02059         }
02060         else
02061         {
02062             StartPoint.y = RenderRect.lo.y;
02063             EndPoint.y   = RenderRect.hi.y;
02064         }
02065 
02066         pRender->DrawDashLine(StartPoint,EndPoint);
02067 
02068         // Get the Next render region
02069         pRender = DocView::GetNextOnTop(NULL);
02070     }   
02071 }

void OpGuideline::RenderMyDragBlobs  ) 
 

Renders the blobs associated with the current drag.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/9/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
RenderDragBlobs()

Definition at line 2007 of file guides.cpp.

02008 {
02009     DocRect Rect;
02010     RenderDragBlobs(Rect,pSpread, FALSE);
02011     RenderOn = !RenderOn;
02012 }

void OpGuideline::SetOrdinate DocCoord PointerPos  )  [protected]
 

This does everything required in creating a layer fit to be called the guide layer Sets the Ordinate member var to either the X or the Y value of PointerPos depending on the guideline type.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/95
Parameters:
PointerPos = pos of mouse pointer [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1985 of file guides.cpp.

01986 {
01987     if (Type == GUIDELINE_HORZ)
01988         Ordinate = PointerPos.y;
01989     else
01990         Ordinate = PointerPos.x;
01991 }

BOOL OpGuideline::Undo  )  [virtual]
 

Called when the op is undone. This broadcasts a 'Guidelines changed' layer message.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successfull, FALSE otherwise
See also:
-

Reimplemented from Operation.

Definition at line 2089 of file guides.cpp.

02090 {
02091     if (UndoableOperation::Undo())
02092     {
02093         BroadcastGuidelineChanges(pBroadcastLayer);
02094         return TRUE;
02095     }
02096 
02097     return FALSE;
02098 }

void OpGuideline::UpdateStatusLineAndPointer  )  [protected]
 

Makes sure the status line AND pointer are correct during a drag.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
UndoableOperation

Definition at line 1582 of file guides.cpp.

01583 {
01584 //  if (pCursor != NULL && CursorStackID != GUIDE_CURSORID_UNSET)
01585 //      CursorStack::GSetTop(pCursor,CursorStackID);
01586 
01587     // Which status help should we display?
01588     UINT32 IDS = _R(IDS_DRAGDELETEGUIDE);
01589 
01590     if (!IsMouseOverRuler())
01591     {
01592         if (CanLeaveCopy())
01593         {
01594             if (Type == GUIDELINE_HORZ)
01595                 IDS = _R(IDS_DRAGCOPYHORZGUIDE);
01596             else
01597                 IDS = _R(IDS_DRAGCOPYVERTGUIDE);
01598         }
01599         else
01600         {
01601             if (Type == GUIDELINE_HORZ)
01602                 IDS = _R(IDS_SELHORZGUIDE);
01603             else
01604                 IDS = _R(IDS_SELVERTGUIDE);
01605         }
01606     }
01607 
01608     if (IDS != CurrentStatusHelp)
01609     {
01610         // put up some status line help
01611 
01612         CurrentStatusHelp = IDS;
01613         String_256 Str(IDS);
01614 
01615         StatusLine* pStatusLine=GetApplication()->GetpStatusLine();
01616         if (pStatusLine!=NULL)
01617             pStatusLine->UpdateText(&Str,STATUSLINE_SELDESC_STATBAR);
01618     }
01619 }


Member Data Documentation

UINT32 OpGuideline::CurrentStatusHelp [private]
 

Definition at line 325 of file guides.h.

INT32 OpGuideline::CursorStackID [private]
 

Definition at line 326 of file guides.h.

BOOL OpGuideline::LeaveCopy [private]
 

Definition at line 323 of file guides.h.

OpGuidelineOpMethod OpGuideline::OpMethod [private]
 

Definition at line 316 of file guides.h.

MILLIPOINT OpGuideline::Ordinate [private]
 

Definition at line 321 of file guides.h.

Layer* OpGuideline::pBroadcastLayer [private]
 

Definition at line 329 of file guides.h.

Cursor* OpGuideline::pCursor [private]
 

Definition at line 324 of file guides.h.

NodeGuideline* OpGuideline::pDraggedGuideline [private]
 

Definition at line 320 of file guides.h.

Spread* OpGuideline::pSpread [private]
 

Definition at line 319 of file guides.h.

BOOL OpGuideline::RenderOn [private]
 

Definition at line 331 of file guides.h.

GuidelineType OpGuideline::Type [private]
 

Definition at line 322 of file guides.h.

UINT32 OpGuideline::UndoIDS [protected]
 

Definition at line 335 of file guides.h.


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