#include <selector.h>
Inheritance diagram for OpDragRotateCentre:
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 | |
Spread * | m_pStartSpread |
DocCoord | m_dcFirstPos |
DocCoord | m_dcLastPos |
DocCoord | m_dcLastMousePos |
Definition at line 175 of file selector.h.
|
Constructs an Operation that allows the user to drag around the centre of rotation blobby.
Definition at line 5972 of file selector.cpp.
|
|
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.
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 }
|
|
|
|
Registers the rotation centre drag Operation.
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 }
|
|
Moves the rotation centre to its final resting place (he he) and ends the drag.
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 }
|
|
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.
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 }
|
|
Called while the rotation centre blobby is being dragged around. Erases it from its old position and redraws it at its new position.
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 }
|
|
Finds the nearest bounds blob to the given point.
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 }
|
|
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).
Definition at line 6233 of file selector.cpp. 06234 { 06235 OpState os; 06236 return os; 06237 }
|
|
Draws the rotation centre blobby at the last-known position of the mouse during a drag.
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 }
|
|
Starts a drag of the rotation centre blobby.
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 }
|
|
Definition at line 209 of file selector.h. |
|
Definition at line 211 of file selector.h. |
|
Definition at line 210 of file selector.h. |
|
Definition at line 208 of file selector.h. |