#include <tracedlg.h>
Inheritance diagram for TraceOp:
Public Member Functions | |
TraceOp () | |
TraceOp constructor. | |
void | DoWithParam (OpDescriptor *pOp, OpParam *pParam) |
Performs the TraceOp for the first time. | |
BOOL | FindCentreInsertionPosition (Spread **Spread, DocCoord *Position) |
Finds the centre insertion position for clipboard objects. | |
Static Public Member Functions | |
static BOOL | Init () |
BlobyOp initialiser method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding the TraceOp's state. |
Definition at line 161 of file tracedlg.h.
|
TraceOp constructor.
Definition at line 1469 of file tracedlg.cpp. 01469 : SelOperation() 01470 { 01471 }
|
|
Performs the TraceOp for the first time.
Reimplemented from Operation. Definition at line 1542 of file tracedlg.cpp. 01543 { 01544 DocCoord DropPos; 01545 Spread * pSpread; 01546 01547 if (!GetWorkingDoc()) return; 01548 01549 if (!FindCentreInsertionPosition(&pSpread, &DropPos)) 01550 { 01551 InformError(); 01552 FailAndExecute(); 01553 End(); 01554 return; 01555 } 01556 01557 // Put up a progress display/hourglass (FALSE => no delay, show it NOW!) 01558 BeginSlowJob(100, FALSE); 01559 TraceControl * pTraceControl = (((TraceOpParam *)(pParam))->pTraceControl); 01560 if (!pTraceControl) return; // we've done. 01561 01562 KernelBitmap * pKB = NULL; 01563 Node * pXNode = pTraceControl->GetPaths(); 01564 if (!pXNode || !pXNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded))) return; // nothing to trace 01565 NodeRenderableBounded *pNodeRenderableBounded = (NodeRenderableBounded *)pXNode; 01566 01567 if (!pTraceControl->GetBitmaps(&pKB, NULL, NULL)) 01568 { 01569 InformError(); 01570 FailAndExecute(); 01571 End(); 01572 return; 01573 } 01574 01575 if (!pKB) 01576 { 01577 ERROR2RAW("Where did that DropPos go then?"); 01578 InformError(); 01579 FailAndExecute(); 01580 End(); 01581 return; 01582 } 01583 01584 // First, set the rectangle to the right size for the bitmap... 01585 BitmapInfo BMInfo; 01586 pKB->ActualBitmap->GetInfo(&BMInfo); 01587 01588 DocRect BoundsRect; 01589 BoundsRect.lo.x = DropPos.x - (BMInfo.RecommendedWidth/2); 01590 BoundsRect.lo.y = DropPos.y - (BMInfo.RecommendedHeight/2); 01591 BoundsRect.hi.x = BoundsRect.lo.x + BMInfo.RecommendedWidth; 01592 BoundsRect.hi.y = BoundsRect.lo.y + BMInfo.RecommendedHeight; 01593 DocCoord Point1 = DocCoord(BoundsRect.hi.x, BoundsRect.lo.y); 01594 DocCoord Point2 = DocCoord(BoundsRect.lo.x, BoundsRect.hi.y); 01595 01596 pTraceControl->RemoveTree(FALSE); // Don't delete it 01597 pTraceControl->InitBitmap(); // to get us some room back 01598 01599 Matrix tMatrix(Div32By32(Point1.x-BoundsRect.lo.x,BMInfo.PixelWidth<<8), 01600 Div32By32(Point2.x-BoundsRect.lo.x,BMInfo.PixelWidth<<8), 01601 Div32By32(Point1.y-BoundsRect.lo.y,BMInfo.PixelHeight<<8), 01602 Div32By32(Point2.y-BoundsRect.lo.y,BMInfo.PixelHeight<<8), 01603 BoundsRect.lo.x,BoundsRect.lo.y); 01604 Trans2DMatrix Trans(tMatrix); 01605 01606 pNodeRenderableBounded->Transform(Trans); 01607 01608 // Insert the node, but don't invalidate its region 01609 if (!DoInsertNewNode(pNodeRenderableBounded, pSpread, TRUE)) 01610 { 01611 Node * pFirstChild = pNodeRenderableBounded->FindFirstChild(); 01612 if (pFirstChild) pNodeRenderableBounded->DeleteChildren(pFirstChild); 01613 delete pNodeRenderableBounded; 01614 01615 EndSlowJob(); 01616 FailAndExecute(); 01617 InformError(); 01618 End(); 01619 return; 01620 } 01621 01622 // All ok 01623 EndSlowJob(); 01624 End(); 01625 return; 01626 01627 }
|
|
Finds the centre insertion position for clipboard objects.
Definition at line 1646 of file tracedlg.cpp. 01647 { 01648 // --------------------------------------------------------------------------------- 01649 // Find out which spread is in the centre of the view 01650 // this is the spread that the pasted objects will be placed on 01651 01652 ERROR2IF((!Spread)||(!Position),FALSE,"Invalid call to FindCentreInsertionPoint()"); 01653 // Obtain the current DocView 01654 DocView* CurDocView = GetWorkingDocView(); 01655 01656 ERROR2IF(!CurDocView, FALSE, "The current DocView is NULL"); 01657 01658 WorkRect WrkViewRect = CurDocView->GetViewRect(); 01659 01660 ERROR2IF((WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) ), FALSE, "Invalid WorkRect"); 01661 01662 // Determine the centre of the view 01663 WorkCoord WrkCentreOfView; 01664 WrkCentreOfView.x = WrkViewRect.lo.x + (WrkViewRect.Width()/2); 01665 WrkCentreOfView.y = WrkViewRect.lo.y + (WrkViewRect.Height()/2); 01666 01667 // FindEnclosing spread requires an OilCoord 01668 OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets()); 01669 01670 // Find out which spread to insert the pasteboard objects onto 01671 (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView); 01672 ERROR2IF(!(*Spread), FALSE, "No spread?!"); 01673 01674 // Phew 01675 // --------------------------------------------------------------------------------- 01676 // Now lets find the spread coordinate of the centre of the view 01677 DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread); 01678 01679 ERROR2IF( ( (DocViewRect.IsEmpty()) || !(DocViewRect.IsValid())), FALSE, "DocViewRect is invalid" ); 01680 01681 // Find the centre of the DocViewRect 01682 DocCoord DocCentreOfView; 01683 DocCentreOfView.x = DocViewRect.lo.x + (DocViewRect.Width()/2); 01684 DocCentreOfView.y = DocViewRect.lo.y + (DocViewRect.Height()/2); 01685 01686 // Now convert from DocCoords to spread coords 01687 (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView); 01688 01689 // Finally, fill in the return value 01690 *Position = DocCentreOfView; 01691 01692 return TRUE; 01693 }
|
|
For finding the TraceOp's state.
Definition at line 1519 of file tracedlg.cpp. 01520 { 01521 OpState OpSt; 01522 return(OpSt); 01523 }
|
|
BlobyOp initialiser method.
Reimplemented from SimpleCCObject. Definition at line 1491 of file tracedlg.cpp. 01492 { 01493 return (SelOperation::RegisterOpDescriptor( 01494 0, 01495 _R(IDS_TRACEOP), 01496 CC_RUNTIME_CLASS(TraceOp), 01497 OPTOKEN_TRACEOP, 01498 TraceOp::GetState, 01499 0, /* help ID */ 01500 0, /* bubble help ID */ 01501 0 /* bitmap ID */)); 01502 }
|