OpDragRotateCentre Class Reference

Allows you to drag the selector tool's centre of rotattion around. More...

#include <selector.h>

Inheritance diagram for OpDragRotateCentre:

Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpDragRotateCentre ()
 Constructs an Operation that allows the user to drag around the centre of rotation blobby.
void StartDragCentreBlob (Spread *, const DocCoord &, ClickModifiers)
 Starts a drag of the rotation centre blobby.
virtual void DragPointerMove (DocCoord, ClickModifiers, Spread *, BOOL bSolidDrag)
 Called while the rotation centre blobby is being dragged around. Erases it from its old position and redraws it at its new position.
virtual void DragFinished (DocCoord, ClickModifiers, Spread *, BOOL, BOOL bSolidDrag)
 Moves the rotation centre to its final resting place (he he) and ends the drag.
virtual BOOL DragKeyPress (KeyPress *pKey, BOOL bSolidDrag)
 Checks for the constrain key going up or down, snapping the dragged rotation centre to the nearest bounds blob when it goes down, freeing it to follow the mouse when the key goes up.
void RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag)
 Draws the rotation centre blobby at the last-known position of the mouse during a drag.

Static Public Member Functions

static BOOL Declare ()
 Registers the rotation centre drag Operation.
static OpState GetState (String_256 *Description, OpDescriptor *)
 Controls whether the rotation-centre mouse drag operation is available or not. Currently, is always available (the internal logic of the selector tool & info-bar handle this really).
static DocRect CalcBlobClipRect (const DocCoord &dcPos)
 Constructs a rectangle that surrounds the given point during a mouse drag. Some rendering functions require a clipping rectangle that isn't always available (poor design or what) so this makes one up as necessary.

Private Member Functions

 CC_DECLARE_DYNCREATE (OpDragRotateCentre)
void GetNearestBlob (const DocCoord &dcPos, DocCoord *pPos, INT32 *pBlob) const
 Finds the nearest bounds blob to the given point.

Private Attributes

Spreadm_pStartSpread
DocCoord m_dcFirstPos
DocCoord m_dcLastPos
DocCoord m_dcLastMousePos

Detailed Description

Allows you to drag the selector tool's centre of rotattion around.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
several deadlines previous, I can assure you
See also:
-

Definition at line 175 of file selector.h.


Constructor & Destructor Documentation

OpDragRotateCentre::OpDragRotateCentre  ) 
 

Constructs an Operation that allows the user to drag around the centre of rotation blobby.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 5972 of file selector.cpp.

05973 {
05974     // Empty.
05975 }


Member Function Documentation

DocRect OpDragRotateCentre::CalcBlobClipRect const DocCoord dcPos  )  [static]
 

Constructs a rectangle that surrounds the given point during a mouse drag. Some rendering functions require a clipping rectangle that isn't always available (poor design or what) so this makes one up as necessary.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
dcPos the centre of the blob that the clipping rectangle will surround [INPUTS]
- [OUTPUTS]
Returns:
A clipping rectangle for use by RenderDragBlobs.

Errors: -

See also:
OpDragRotateCentre::RenderDragBlobs

Definition at line 6256 of file selector.cpp.

06257 {
06258     INT32 nSize = SelectorTool::pBlobManager->GetBlobSize() + 2;
06259     return DocRect(DocCoord(dcPos.x - nSize, dcPos.y - nSize),
06260                    DocCoord(dcPos.x + nSize, dcPos.y + nSize));
06261 }

OpDragRotateCentre::CC_DECLARE_DYNCREATE OpDragRotateCentre   )  [private]
 

BOOL OpDragRotateCentre::Declare  )  [static]
 

Registers the rotation centre drag Operation.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the op is correctly registered.

Errors: -

See also:
-

Definition at line 6209 of file selector.cpp.

06210 {
06211     return RegisterOpDescriptor(0, /* _R(IDS_DRAGROTATECENTREOP), */ 0,
06212                                 CC_RUNTIME_CLASS(OpDragRotateCentre),
06213                                 OPTOKEN_SELECTOR_DRAGCENTRE, GetState);
06214 }

void OpDragRotateCentre::DragFinished DocCoord  dcPos,
ClickModifiers  mods,
Spread pSpread,
BOOL  fDragOK,
BOOL  bSolidDrag
[virtual]
 

Moves the rotation centre to its final resting place (he he) and ends the drag.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
dcPos final position of the mouse [INPUTS] pSpread spread containing the mouse fDragOK whether the drag was cancelled or not
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 6120 of file selector.cpp.

06122 {
06123     // Put the hourglass up
06124     BeginSlowJob();
06125 
06126     // Act on the termination status of the drag operation.
06127     if (fDragOK)
06128     {
06129         // Treat the drag finish as a mouse move to gett he right snapping behaviour...
06130         DragPointerMove(dcPos,mods,pSpread, bSolidDrag);
06131 
06132         // Tell the selector tool that the rotation centre has moved.
06133         ((SelectorTool*) Tool::GetCurrent())->RotationCentreDragged(m_dcLastPos);   
06134 
06135         // Reenable the tool's idle processing.
06136         SelectorTool::AllowIdleWork(TRUE);
06137 
06138         // End the Drag
06139         if (!EndDrag()) FailAndExecute();
06140     }
06141     else
06142     {
06143         // Remove the last drawn rotation centre blob.
06144         RenderDragBlobs(CalcBlobClipRect(m_dcLastPos), m_pStartSpread, bSolidDrag);
06145 
06146         // Redraw it at its original position.
06147         RenderDragBlobs(CalcBlobClipRect(m_dcLastPos = m_dcFirstPos), m_pStartSpread, bSolidDrag);
06148 
06149         // Reenable the tool's idle processing.
06150         SelectorTool::AllowIdleWork(TRUE);
06151 
06152         // Set up the flags that say it all went wrong.
06153         EndDrag();
06154         FailAndExecute();
06155     }
06156 
06157     // Finished.
06158     End();
06159 }

BOOL OpDragRotateCentre::DragKeyPress KeyPress pKey,
BOOL  bSolidDrag
[virtual]
 

Checks for the constrain key going up or down, snapping the dragged rotation centre to the nearest bounds blob when it goes down, freeing it to follow the mouse when the key goes up.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/94
Parameters:
pKey pointer to the KeyPress object representing a key event [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the key-press was handled, FALSE otherwise.

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 6082 of file selector.cpp.

06083 {
06084     // Is this the constrain key going down or up?  Note that we have to explicitly compare
06085     // against the virtual key-code as the keypress stuff has a bug in it - it won't have the
06086     // constrain bit set when the release bit is set as well (ie. it doesn't send CTRL key-up
06087     // events).
06088     if (pKey->GetVirtKey() == CAMKEY(CC_MOD_CONSTRAIN))
06089     {
06090         // Treat the keypress as it was a mouse move to get the right snapping behaviour...
06091         DragPointerMove(m_dcLastMousePos,ClickModifiers::GetClickModifiers(),m_pStartSpread, FALSE);
06092         
06093         // Yes, we did process this one.
06094         return TRUE;
06095     }
06096 
06097     // Nope, didn't process it.
06098     return FALSE;
06099 }

void OpDragRotateCentre::DragPointerMove DocCoord  dcPos,
ClickModifiers  mods,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Called while the rotation centre blobby is being dragged around. Erases it from its old position and redraws it at its new position.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
dcPos the current mouse position [INPUTS] pSpread the spread containing the mouse
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 6027 of file selector.cpp.

06028 {   
06029     // If the mouse has moved outside the spread the drag was started on then we must
06030     // account for this.
06031     if (pSpread != m_pStartSpread)
06032     {
06033         // Convert from one spread's coordinates to another's.
06034         dcPos = MakeRelativeToSpread(m_pStartSpread, pSpread, dcPos);
06035     }
06036 
06037     // Now remember this mouse position.
06038     m_dcLastMousePos = dcPos;
06039 
06040     // If the constrain key is down then "snap" to the nearest blob position (as if the
06041     // "telephone keypad" had been clicked).
06042     if (mods.Constrain)
06043     {
06044         // Find the current nearest blob.
06045         DocCoord dcNearest;
06046         GetNearestBlob(dcPos, &dcNearest, NULL);
06047 
06048         // If it is the same as the last snapped position do nothing, otherwise update
06049         // our records.
06050         if (dcNearest == m_dcLastPos) return;
06051         dcPos = dcNearest;
06052     }
06053     else
06054     {
06055         // If the constrain key ISN'T down then we will snap to the grid, if appropriate.
06056         DocView::SnapCurrent(pSpread, &dcPos);
06057     }
06058 
06059     // Erase the old centre blob and draw the new one.
06060     RenderDragBlobs(CalcBlobClipRect(m_dcLastPos), m_pStartSpread, bSolidDrag);
06061     m_dcLastPos = dcPos;
06062     RenderDragBlobs(CalcBlobClipRect(m_dcLastPos), m_pStartSpread, bSolidDrag);
06063 }

void OpDragRotateCentre::GetNearestBlob const DocCoord dcPos,
DocCoord pPos,
INT32 *  pBlob
const [private]
 

Finds the nearest bounds blob to the given point.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/11/94
Parameters:
dcPos the point for which the nearest blob is to be found [INPUTS]
pPos if not NULL then is set to the position of the nearest blob [OUTPUTS] pBlob if not NULL then is set to the blob ID of the nearest blob
Returns:
-

Errors: -

See also:
OpDragRotateCentre::DragKeyPress; OpDragRotateCentre::DragPointerMove

Definition at line 6281 of file selector.cpp.

06282 {
06283     // Find out the nearest blob position to dcPos.
06284     SelectorTool* pTool = (SelectorTool*) Tool::GetCurrent();
06285     DocCoord dcNearestBlob(0,0);
06286 
06287     // This needs to be done a little carefully, as INT32_MAX itself is not big enough.
06288     XLONG nNearestDistance = XLONG(INT32_MAX);
06289     nNearestDistance *= nNearestDistance;           // square it to be safe
06290 
06291     // Compare against every blob.
06292     INT32 i;
06293     for (i = 0; i < 9; i++)
06294     {
06295         // Find out the square of the distance, in millipoints, to the i'th blob.
06296         DocCoord dcBlob = pTool->GetSelPosNearBlob(i);
06297         XLONG dx  = XLONG(dcPos.x) - XLONG(dcBlob.x);
06298         XLONG dy  = XLONG(dcPos.y) - XLONG(dcBlob.y);
06299         XLONG dz2 = (dx * dx) + (dy * dy);
06300 
06301         // If it's nearer remember it.
06302         if (dz2 < nNearestDistance)
06303         {
06304             nNearestDistance = dz2;
06305             dcNearestBlob = dcBlob;
06306         }
06307     }
06308 
06309     // Set the output paramaters accordingly.
06310     if (pPos  != NULL) *pPos  = dcNearestBlob;
06311     if (pBlob != NULL) *pBlob = i;
06312 }

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

Controls whether the rotation-centre mouse drag operation is available or not. Currently, is always available (the internal logic of the selector tool & info-bar handle this really).

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Returns a default OpState.

Errors: -

See also:
-

Definition at line 6233 of file selector.cpp.

06234 {
06235     OpState os;
06236     return os;
06237 }

void OpDragRotateCentre::RenderDragBlobs DocRect  drClip,
Spread pSpread,
BOOL  bSolidDrag
[virtual]
 

Draws the rotation centre blobby at the last-known position of the mouse during a drag.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
drClip clipping rectangle for output [INPUTS] pSpread the spread to render into
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 6178 of file selector.cpp.

06179 {
06180     RenderRegion* pRegion = DocView::RenderOnTop(&drClip, pSpread, ClippedEOR);
06181     while (pRegion != NULL)
06182     {
06183         // Set the line colour 
06184         pRegion->SetLineColour(COLOUR_XORSELECT);
06185         
06186         // Draw the rotation centre at the given position.
06187         ((SelectorTool*) Tool::GetCurrent())->RenderRotateCentre(pRegion, m_dcLastPos);
06188 
06189         // Get the next render region.
06190         pRegion = DocView::GetNextOnTop(&drClip);
06191     }
06192 }

void OpDragRotateCentre::StartDragCentreBlob Spread pSpread,
const DocCoord dcPos,
ClickModifiers 
 

Starts a drag of the rotation centre blobby.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/8/94
Parameters:
pSpread the spread containing the rotation centre blob [INPUTS] dcPos the initial position of the blob
The ClickModifiers argument is currently unused.
Parameters:
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 5996 of file selector.cpp.

05998 {
05999     // Put some helpful text in the status bar and prevent the selector tool overwriting
06000     // it until we are done.
06001     SelectorTool::AllowIdleWork(FALSE);
06002     SelectorTool::SetStatusText(_R(IDS_SEL_DRAGROTCENTRE));
06003 
06004     // Remember the starting positions etc and initiate a drag.
06005     m_pStartSpread = pSpread;
06006     m_dcLastMousePos = m_dcLastPos = m_dcFirstPos = dcPos;
06007     StartDrag(DRAGTYPE_AUTOSCROLL);
06008 }


Member Data Documentation

DocCoord OpDragRotateCentre::m_dcFirstPos [private]
 

Definition at line 209 of file selector.h.

DocCoord OpDragRotateCentre::m_dcLastMousePos [private]
 

Definition at line 211 of file selector.h.

DocCoord OpDragRotateCentre::m_dcLastPos [private]
 

Definition at line 210 of file selector.h.

Spread* OpDragRotateCentre::m_pStartSpread [private]
 

Definition at line 208 of file selector.h.


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