#include <opnudge.h>
Inheritance diagram for OpNudge:
Public Member Functions | |
double | GetXNudgeDisplacement () |
double | GetYNudgeDisplacement () |
double | GetXPixelDisplacement () |
double | GetYPixelDisplacement () |
virtual void | Do (OpDescriptor *pOpDesc) |
The nudge op's Do() function. | |
void | GetOpName (String_256 *OpName) |
The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies. | |
virtual void | PerformMergeProcessing () |
This virtual function gets called to allow for the merging of nudge operations. | |
BOOL | IsNudgeOK (BOOL dx, BOOL dy) |
A validity check function the tests to see if the nudge will send the nudge beyond the spread bounds. | |
void | ScrollToShow (DocCoord Coord) |
BOOL | DoesActionListHideNodes (Operation *pOp) |
To disallow the merging of nudge operations if a HideNodesAction was added to this nudge op, as this wouldn't then undo correctly. | |
Static Public Member Functions | |
static BOOL | Init () |
Declares a preference that allows you to clear memory in delete(). | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding OpNudge's state. | |
static void | SetNudgeStep (MILLIPOINT Step) |
static MILLIPOINT | GetNudgeStep () |
Protected Attributes | |
double | X_NudgeFactor |
double | Y_NudgeFactor |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpNudge) | |
Private Attributes | |
double | PixelNudge |
BOOL | flag |
Static Private Attributes | |
static MILLIPOINT | NudgeStep |
Definition at line 122 of file opnudge.h.
|
|
|
The nudge op's Do() function.
Reimplemented from Operation. Definition at line 275 of file opnudge.cpp. 00276 { 00277 // Determine the nudge factors based on the OpDescriptor used to invoke the nudge operation 00278 String OpToken = pOpDesc->Token; 00279 00280 //Get scaled pixel size 00281 FIXED16 ScaledPixelWidth, ScaledPixelHeight; 00282 GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ; 00283 PixelNudge=ScaledPixelWidth.MakeDouble() ; 00284 00285 00286 if (OpToken == String(OPTOKEN_NUDGEUP1)) { X_NudgeFactor = 0; Y_NudgeFactor = 1; flag=TRUE; } 00287 else if (OpToken == String(OPTOKEN_NUDGEUP5)) { X_NudgeFactor = 0; Y_NudgeFactor = 5; flag=TRUE; } 00288 else if (OpToken == String(OPTOKEN_NUDGEUP10)) { X_NudgeFactor = 0; Y_NudgeFactor = 10; flag=TRUE; } 00289 else if (OpToken == String(OPTOKEN_NUDGEUPFIFTH)) { X_NudgeFactor = 0; Y_NudgeFactor = 0.2; flag=TRUE; } 00290 else if (OpToken == String(OPTOKEN_NUDGEDOWN1)) { X_NudgeFactor = 0; Y_NudgeFactor = -1; flag=TRUE; } 00291 else if (OpToken == String(OPTOKEN_NUDGEDOWN5)) { X_NudgeFactor = 0; Y_NudgeFactor = -5; flag=TRUE; } 00292 else if (OpToken == String(OPTOKEN_NUDGEDOWN10)) { X_NudgeFactor = 0; Y_NudgeFactor = -10; flag=TRUE; } 00293 else if (OpToken == String(OPTOKEN_NUDGEDOWNFIFTH)) { X_NudgeFactor = 0; Y_NudgeFactor = -0.2; flag=TRUE; } 00294 else if (OpToken == String(OPTOKEN_NUDGELEFT1)) { X_NudgeFactor = -1; Y_NudgeFactor = 0; flag=TRUE; } 00295 else if (OpToken == String(OPTOKEN_NUDGELEFT5)) { X_NudgeFactor = -5; Y_NudgeFactor = 0; flag=TRUE; } 00296 else if (OpToken == String(OPTOKEN_NUDGELEFT10)) { X_NudgeFactor = -10; Y_NudgeFactor = 0; flag=TRUE; } 00297 else if (OpToken == String(OPTOKEN_NUDGELEFTFIFTH)) { X_NudgeFactor = -0.2; Y_NudgeFactor = 0; flag=TRUE; } 00298 else if (OpToken == String(OPTOKEN_NUDGERIGHT1)) { X_NudgeFactor = 1; Y_NudgeFactor = 0; flag=TRUE; } 00299 else if (OpToken == String(OPTOKEN_NUDGERIGHT5)) { X_NudgeFactor = 5; Y_NudgeFactor = 0; flag=TRUE; } 00300 else if (OpToken == String(OPTOKEN_NUDGERIGHT10)) { X_NudgeFactor = 10; Y_NudgeFactor = 0; flag=TRUE; } 00301 else if (OpToken == String(OPTOKEN_NUDGERIGHTFIFTH)) { X_NudgeFactor = 0.2; Y_NudgeFactor = 0; flag=TRUE; } 00302 00303 else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL1)) { X_NudgeFactor = 0; Y_NudgeFactor = 1; flag=FALSE; } 00304 else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL10)) { X_NudgeFactor = 0; Y_NudgeFactor = 10; flag=FALSE; } 00305 else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1)) { X_NudgeFactor = 0; Y_NudgeFactor = -1; flag=FALSE; } 00306 else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10)) { X_NudgeFactor = 0; Y_NudgeFactor = -10; flag=FALSE; } 00307 else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL1)) { X_NudgeFactor = -1; Y_NudgeFactor = 0; flag=FALSE; } 00308 else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL10)) { X_NudgeFactor = -10; Y_NudgeFactor = 0; flag=FALSE; } 00309 else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1)) { X_NudgeFactor = 1; Y_NudgeFactor = 0; flag=FALSE; } 00310 else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10)) { X_NudgeFactor = 10; Y_NudgeFactor = 0; flag=FALSE; } 00311 00312 else 00313 { 00314 ERROR3("Unknown type of nudge"); 00315 } 00316 00317 00318 00319 Range* Selection = GetApplication()->FindSelection(); 00320 RangeControl TransFlags = Selection->GetRangeControlFlags(); 00321 TransFlags.IgnoreNoneRenderable=TRUE; 00322 TransFlags.IgnoreInvisibleLayers = TRUE; 00323 Selection->SetRangeControl(TransFlags); 00324 SliceHelper::ModifySelectionToContainWholeButtonElements(); 00325 00326 00327 00328 // Setup the Offset DocCoord to contain the X and Y translation values 00329 DocCoord Offset; 00330 00331 if (flag) 00332 { 00333 (Offset.x) = (INT32) GetXNudgeDisplacement(); 00334 (Offset.y) = (INT32) GetYNudgeDisplacement(); 00335 } 00336 else if (!flag) 00337 { 00338 (Offset.x) = (INT32)GetXPixelDisplacement(); 00339 (Offset.y) = (INT32)GetYPixelDisplacement(); 00340 } 00341 00342 // Will the nudge send the selection beyond the spread bounds? 00343 // If so, fail and return now 00344 if (!IsNudgeOK(Offset.x,Offset.y)) 00345 { 00346 SliceHelper::RestoreSelection(); 00347 InformWarning(_R(IDS_NUDGE_OUTOFBOUNDS)); 00348 FailAndExecute(); 00349 End(); 00350 return; 00351 } 00352 00353 TransformData TransData; 00354 00355 // Set up the transform data 00356 TransData.CentreOfTrans.x = 0; 00357 TransData.CentreOfTrans.y = 0; 00358 TransData.StartBlob = 0; 00359 TransData.LockAspect = TRUE; 00360 TransData.LeaveCopy = FALSE; 00361 TransData.ScaleLines = FALSE; 00362 TransData.TransFills = TRUE; 00363 TransData.pRange = 0; 00364 00365 // Call OpTranslateTrans::DoWithParams() with a ptr to the transform data and a ptr to a DocCoord 00366 // that specs the X and Y offsets of the translation 00367 OpParam param( &TransData, &Offset ); 00368 DoWithParam( pOpDesc, ¶m ); 00369 00370 SliceHelper::RestoreSelection(); 00371 }
|
|
To disallow the merging of nudge operations if a HideNodesAction was added to this nudge op, as this wouldn't then undo correctly.
Definition at line 603 of file opnudge.cpp. 00604 { 00605 ActionList * pActions = pOp->GetUndoActionList(); 00606 ListItem* CurrentAction = pActions->GetHead(); 00607 00608 while (CurrentAction != NULL) // For each action in the list 00609 { 00610 if (IS_A(CurrentAction, HideNodeAction)) 00611 return TRUE; 00612 00613 // Get next action 00614 CurrentAction = pActions->GetNext(CurrentAction); 00615 } 00616 00617 return FALSE; 00618 }
|
|
Definition at line 133 of file opnudge.h. 00133 { return NudgeStep; }
|
|
The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.
Reimplemented from Operation. Definition at line 506 of file opnudge.cpp. 00507 { 00508 *OpName = String_256(_R(IDS_UNDO_NUDGE)); 00509 }
|
|
For finding OpNudge's state.
Reimplemented from TransOperation. Definition at line 248 of file opnudge.cpp. 00249 { 00250 OpState OpSt; 00251 00252 SelRange* pSelRange = GetApplication()->FindSelection(); 00253 if (pSelRange != NULL && pSelRange->FindFirst() != NULL) 00254 OpSt.Greyed = FALSE; 00255 else 00256 OpSt.Greyed = TRUE; 00257 00258 return (OpSt); 00259 }
|
|
Definition at line 140 of file opnudge.h. 00140 { return NudgeStep * X_NudgeFactor; }
|
|
Definition at line 142 of file opnudge.h. 00142 { return PixelNudge * X_NudgeFactor;}
|
|
Definition at line 141 of file opnudge.h. 00141 { return NudgeStep * Y_NudgeFactor; }
|
|
Definition at line 143 of file opnudge.h. 00143 { return PixelNudge * Y_NudgeFactor;}
|
|
Declares a preference that allows you to clear memory in delete().
Reimplemented from SimpleCCObject. Definition at line 195 of file opnudge.cpp. 00196 { 00197 REG_NUDGE_OP(NUDGEUP1); 00198 REG_NUDGE_OP(NUDGEUP5); 00199 REG_NUDGE_OP(NUDGEUP10); 00200 REG_NUDGE_OP(NUDGEUPFIFTH); 00201 REG_NUDGE_OP(NUDGEUPPIXEL1); 00202 REG_NUDGE_OP(NUDGEUPPIXEL10); 00203 00204 REG_NUDGE_OP(NUDGEDOWN1); 00205 REG_NUDGE_OP(NUDGEDOWN5); 00206 REG_NUDGE_OP(NUDGEDOWN10); 00207 REG_NUDGE_OP(NUDGEDOWNFIFTH); 00208 REG_NUDGE_OP(NUDGEDOWNPIXEL1); 00209 REG_NUDGE_OP(NUDGEDOWNPIXEL10); 00210 00211 REG_NUDGE_OP(NUDGELEFT1); 00212 REG_NUDGE_OP(NUDGELEFT5); 00213 REG_NUDGE_OP(NUDGELEFT10); 00214 REG_NUDGE_OP(NUDGELEFTFIFTH); 00215 REG_NUDGE_OP(NUDGELEFTPIXEL1); 00216 REG_NUDGE_OP(NUDGELEFTPIXEL10); 00217 00218 REG_NUDGE_OP(NUDGERIGHT1); 00219 REG_NUDGE_OP(NUDGERIGHT5); 00220 REG_NUDGE_OP(NUDGERIGHT10); 00221 REG_NUDGE_OP(NUDGERIGHTFIFTH); 00222 REG_NUDGE_OP(NUDGERIGHTPIXEL1); 00223 REG_NUDGE_OP(NUDGERIGHTPIXEL10); 00224 00225 //Camelot.DeclareSection(TEXT("Nudge"), 1); 00226 //Camelot.DeclarePref(TEXT("Nudge"), TEXT("StepSize"), (UINT32*)&OpNudge::NudgeStep, 0, UINT_MAX); 00227 00228 ERROR2IF(OpNudge::NudgeStep<0, FALSE, "Preference nudge step was negative"); 00229 00230 return (TRUE); 00231 }
|
|
A validity check function the tests to see if the nudge will send the nudge beyond the spread bounds.
Definition at line 390 of file opnudge.cpp. 00391 { 00392 // Get the selection 00393 SelRange* pSel = GetApplication()->FindSelection(); 00394 ERROR2IF(pSel == NULL,FALSE,"Awooga, NULL sel range"); 00395 00396 // Find out the bounding rectangle of the selection 00397 DocRect BoundingRect = pSel->GetBoundingRect(); 00398 00399 // Find out the Pasteboard rect 00400 DocRect PasteRect; 00401 Spread* pSpread = pOurDoc->GetSelectedSpread(); 00402 if (pSpread==NULL) 00403 PasteRect = BoundingRect; 00404 else 00405 { 00406 // Try to make the pasteboard grow if necessary to include the new object position 00407 // This is very quick if the pasteboard is large enough already. 00408 pSpread->ExpandPasteboardToInclude(BoundingRect); 00409 00410 // And re-read the bounding rectangle of the selection, as the pasteboard resize may have 00411 // caused the origin of our entire coordinate space to have moved! Argh! 00412 BoundingRect = pSel->GetBoundingRect(); 00413 // BoundingRect.Translate(dx,dy); 00414 00415 // This is in Document Coords, so we need to convert it 00416 PasteRect = pSpread->GetPasteboardRect(); 00417 pSpread->DocCoordToSpreadCoord(&PasteRect); 00418 } 00419 00420 // Assume the nudge will be OK. 00421 BOOL NudgeOK = TRUE; 00422 00423 if (PasteRect.ContainsRect(BoundingRect)) 00424 { 00425 // Untranslated bounds fit inside pasteboard rect, so we must complain if the bounds 00426 // do not fit *after* translation 00427 00428 // Translate the bounds by the nudge values 00429 BoundingRect.Translate(dx,dy); 00430 00431 // Do the translated bounds still fit entirely in the pasteboard rect? 00432 NudgeOK = PasteRect.ContainsRect(BoundingRect); 00433 } 00434 else 00435 { 00436 // The original bounds overlap the pasteboard rect, so we must complain if the user 00437 // nudges the bounds completely out of sight 00438 00439 if (PasteRect.IsIntersectedWith(BoundingRect)) 00440 { 00441 // The original bounds intersect with the pasteboard rect 00442 BoundingRect.Translate(dx,dy); 00443 00444 // Only allow the nudge if the translated bounds still overlap with the spread. 00445 NudgeOK = PasteRect.IsIntersectedWith(BoundingRect); 00446 } 00447 } 00448 00449 // If the nudge is OK, we may need to scroll the DocView? 00450 00451 /* Jim, 12/9/96 - removed this because we don't want to scroll to show opn nudges 00452 00453 if (NudgeOK) 00454 { 00455 DocCoord Coord(0,0); 00456 00457 // If nudging left or right, pick the min or max X coord 00458 if (dx != 0) 00459 { 00460 if (dx < 0) 00461 Coord.x = BoundingRect.lox; 00462 else 00463 Coord.x = BoundingRect.hix; 00464 } 00465 00466 // If nudging up or down, pick the max or min Y coord 00467 if (dy != 0) 00468 { 00469 if (dy < 0) 00470 Coord.y = BoundingRect.loy; 00471 else 00472 Coord.y = BoundingRect.hiy; 00473 } 00474 00475 // If we have picked a coord, ensure that this coord is visible in the selected spread 00476 // of the selected DocView 00477 if (Coord != DocCoord(0,0)) 00478 { 00479 DocView* pDocView = DocView::GetSelected(); 00480 if (pDocView != NULL) 00481 pDocView->ScrollToShow(&Coord); 00482 } 00483 } 00484 */ 00485 return NudgeOK; 00486 }
|
|
This virtual function gets called to allow for the merging of nudge operations.
Reimplemented from UndoableOperation. Definition at line 528 of file opnudge.cpp. 00529 { 00530 // Obtain a pointer to the operation history for the current document 00531 OperationHistory* pOpHist = &pOurDoc->GetOpHistory(); 00532 00533 // Ensure that we are the last operation added to the operation history 00534 // Note cannot be an ERROR2 cos this function cannot fail. 00535 ERROR3IF(pOpHist->FindLastOp() != this, "Last Op should be this op"); 00536 00537 // OK lets see if the operation performed before this was an OpNudge operation 00538 Operation* pPrevOp = pOpHist->FindPrevToLastOp(); 00539 00540 if (pPrevOp != NULL) // Check if there was a previous op 00541 { 00542 00543 if (IS_A(pPrevOp, OpNudge)) 00544 { 00545 // Yes it was 00546 // We can merge this op with pPrevOp if they both apply to the same set of objects 00547 // This will be TRUE is their SelectionStates are the same. 00548 RestoreSelectionsAction* pRestoreSelAct = (RestoreSelectionsAction*) 00549 GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(RestoreSelectionsAction)); 00550 ERROR3IF(pRestoreSelAct == NULL, "This op should have a RestoreSelectionsAction"); 00551 SelectionState* ThisOpsSelection = pRestoreSelAct->GetSelState(); 00552 00553 pRestoreSelAct = (RestoreSelectionsAction*) 00554 pPrevOp->GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(RestoreSelectionsAction)); 00555 ERROR3IF(pRestoreSelAct == NULL, "OpNudge op should have a RestoreSelectionsAction"); 00556 SelectionState* LastOpsSelection = pRestoreSelAct->GetSelState(); 00557 00558 if ((*ThisOpsSelection) == (*LastOpsSelection)) 00559 { 00560 00561 // scan to see if either of these ops hides a node 00562 // if either do then we cannot merge them together 00563 // this can happen if perhaps the extending definitions 00564 // were changed by the nudge (sjk 27-7-00) 00565 if (DoesActionListHideNodes(pPrevOp) || DoesActionListHideNodes(this) ) 00566 return; 00567 00568 // this op can be merged into the previous op, we simply need to combine the 00569 // TransformNodeActions 00570 TransformNodeAction* pTransNdAct = (TransformNodeAction*) 00571 GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(TransformNodeAction)); 00572 ERROR3IF(pTransNdAct == NULL, "This op should have a TransformNodeAction"); 00573 00574 TransformNodeAction* pLastOpsTransNdAct = (TransformNodeAction*) 00575 pPrevOp->GetUndoActionList()->FindActionOfClass(CC_RUNTIME_CLASS(TransformNodeAction)); 00576 ERROR3IF(pLastOpsTransNdAct == NULL,"OpNudgeOp should have a TransformNodeAction"); 00577 00578 pLastOpsTransNdAct->CombineWith(pTransNdAct); 00579 00580 // This op is no longer required, so let's vape it 00581 pOpHist->DeleteLastOp(); 00582 } 00583 } 00584 } 00585 return; 00586 }
|
|
|
|
Definition at line 132 of file opnudge.h. 00132 { NudgeStep = Step; }
|
|
|
|
|
|
|
|
|
|
|