00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 #ifndef INC_SELECTOR
00101 #define INC_SELECTOR
00102
00103 #include "dragtool.h"
00104 #include "transop.h"
00105
00106 #include "blobs.h"
00107
00108
00109 #define OPTOKEN_SELECTOR_DRAGBOX _T("SelectorDragBox")
00110 #define OPTOKEN_SELECTOR_DRAGCENTRE _T("SelectorDragCentre")
00111
00112 class OpState;
00113 class Cursor;
00114 class Spread;
00115 class SelectorInfoBarOp;
00116 class SelChangingMsg;
00117 class DocViewMsg;
00118 class KeyPress;
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 class OpSelectorDragBox : public Operation
00133 {
00134 public:
00135
00136
00137 OpSelectorDragBox();
00138
00139
00140 void StartDragBox( Spread* pSpread, DocCoord Anchor, ClickModifiers);
00141 virtual BOOL SnappingDrag() { return FALSE; }
00142
00143
00144 virtual void DragPointerMove(DocCoord, ClickModifiers, Spread*, BOOL bSolidDrag);
00145 virtual void DragFinished(DocCoord, ClickModifiers, Spread*, BOOL, BOOL bSolidDrag);
00146
00147
00148 void RenderDragBlobs(DocRect, Spread*, BOOL bSolidDrag);
00149
00150
00151 static BOOL Declare();
00152 static OpState GetState(String_256* Description, OpDescriptor*);
00153
00154 private:
00155
00156 CC_DECLARE_DYNCREATE(OpSelectorDragBox);
00157
00158
00159 Spread* StartSpread;
00160 DocCoord StartPoint;
00161 DocCoord LastMousePosition;
00162 };
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 class OpDragRotateCentre : public Operation
00176 {
00177 public:
00178
00179
00180 OpDragRotateCentre();
00181
00182
00183 void StartDragCentreBlob(Spread*, const DocCoord&, ClickModifiers);
00184
00185
00186 virtual void DragPointerMove(DocCoord, ClickModifiers, Spread*, BOOL bSolidDrag);
00187 virtual void DragFinished(DocCoord, ClickModifiers, Spread*, BOOL, BOOL bSolidDrag);
00188 virtual BOOL DragKeyPress(KeyPress* pKey, BOOL bSolidDrag);
00189
00190
00191 void RenderDragBlobs(DocRect, Spread*, BOOL bSolidDrag);
00192
00193
00194 static BOOL Declare();
00195 static OpState GetState(String_256* Description, OpDescriptor*);
00196
00197
00198 static DocRect CalcBlobClipRect(const DocCoord& dcPos);
00199
00200 private:
00201
00202 CC_DECLARE_DYNCREATE(OpDragRotateCentre);
00203
00204
00205 void GetNearestBlob(const DocCoord& dcPos, DocCoord* pPos, INT32* pBlob) const;
00206
00207
00208 Spread* m_pStartSpread;
00209 DocCoord m_dcFirstPos;
00210 DocCoord m_dcLastPos;
00211 DocCoord m_dcLastMousePos;
00212 };
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 class CCAPI SelectorTool : public DragTool
00238 {
00239
00241
00242
00243 public:
00244
00245
00246 SelectorTool();
00247 virtual ~SelectorTool();
00248 BOOL Init();
00249
00250
00251 void Describe(void* InfoPtr);
00252 UINT32 GetID() { return TOOLID_SELECTOR; };
00253
00254
00255 virtual void SelectChange(BOOL);
00256 virtual void OnClick(DocCoord, ClickType, ClickModifiers, Spread*);
00257 virtual void OnMouseMove(DocCoord, Spread*, ClickModifiers);
00258 virtual BOOL OnKeyPress(KeyPress* pKey);
00259 virtual BOOL OnIdle();
00260 virtual void RenderToolBlobs(Spread* pSpread, DocRect* pClipRect);
00261
00262
00263 void DragMove(TransformBoundingData* pBoundingData);
00264
00265
00266
00267 virtual BOOL DragFinished(DragEndType det);
00268
00269
00270
00271 static void AllowIdleWork(BOOL fIsAllowed);
00272
00273 static BOOL IsSelectorCaching(){ return fSelectorIsCaching;};
00274
00275
00276
00277 static BOOL BeyondFixedRange(double fpFixedVal);
00278
00279 virtual BOOL AreToolBlobsRenderedOnSelection() {return TRUE;}
00280
00281
00282
00283 static BOOL GetNormalClick_CheckProfileDialog () { return (bNormalClickCheckProfileDialog); }
00284 static void SetNormalClick_CheckProfileDialog (BOOL newVal) { bNormalClickCheckProfileDialog = newVal; }
00285
00286 private:
00287
00288 BOOL fAllowIdleProcessing;
00289 BOOL fMouseHasMoved;
00290 static BOOL fSelectorIsCaching;
00291
00292
00293 static TCHAR* FamilyName;
00294 static TCHAR* ToolName;
00295 static TCHAR* Purpose;
00296 static TCHAR* Author;
00297
00298 static INT32 CursorStackID;
00299
00300
00301
00302 CC_DECLARE_MEMDUMP(SelectorTool);
00303
00304
00306
00307
00308 public:
00309
00310
00311 void SelectionHasChanged(BOOL DontUpdate =0);
00312 void AttributeHasChanged();
00313 void ViewChanged(const DocViewMsg& msg);
00314 BOOL UpdateSelectionInfo();
00315
00316
00317 Spread* GetSelectionSpread() const;
00318 const DocRect& GetSelectionBounds(BOOL WithNoAttrs = FALSE) const;
00319 const BOOL GetAreaDetails(BOOL WithNoAttrs, XLONG* pxlArea, XLONG* pxlPerim) const;
00320
00321 private:
00322
00323
00324 Spread* SelectionSpread;
00325 SelRange* SelectRange;
00326 DocRect SelectionRect;
00327 DocRect SelectionRectNoAttr;
00328
00329 XLONG xlSelectionArea;
00330 XLONG xlSelectionPerim;
00331
00332
00333 BOOL fIgnoreSelChange;
00334
00335
00337
00338
00339 public:
00340 static NodeRenderableInk* FindPreProcessClickNode(Spread* pSpread,
00341 DocCoord ClickPos,
00342 BOOL Interruptible = FALSE);
00343
00344 protected:
00345
00346
00347 virtual BOOL PreProcessClick();
00348 virtual BOOL ProcessObjectClick();
00349 virtual void PostProcessClick();
00350
00351
00352 virtual void HandleSingleClick();
00353 virtual void HandleDoubleClick();
00354 virtual void HandleDragClick();
00355 virtual void HandleButtonUp();
00356
00357
00358 virtual void HandleTabKey(BOOL fIsShifted);
00359
00360
00361
00362 struct IterateFlags
00363 {
00364 IterateFlags( BOOL IgInvisibleLayers = FALSE,
00365 BOOL IgLockedLayers = FALSE )
00366 {
00367 IgnoreInvisibleLayers = IgInvisibleLayers;
00368 IgnoreLockedLayers = IgLockedLayers;
00369 }
00370
00371 BOOL IgnoreInvisibleLayers :1;
00372 BOOL IgnoreLockedLayers :1;
00373 };
00374
00375
00376
00377 Layer* m_pIterStartLayer;
00378
00379
00380
00381 Node* IteratePreProcess(Node* pCurrent);
00382 NodeRenderableInk* IterateNextInk(Node* pCurrent, IterateFlags iterFlags);
00383 NodeRenderableInk* IteratePrevInk(Node* pCurrent, IterateFlags iterFlags);
00384 NodeRenderableInk* IteratePostProcessNext( Node* pCurrent, Node* pParent,
00385 IterateFlags iterFlags );
00386 NodeRenderableInk* IteratePostProcessPrev( Node* pCurrent, Node* pParent,
00387 IterateFlags iterFlags );
00388
00389 private:
00390
00391
00392 BOOL IsRotateCentreClicked(DocCoord ClickStart) const;
00393
00394
00395 BOOL IsTranslateShortcut(ClickModifiers cmods) const;
00396
00397
00398 BOOL IsClickModified(ClickModifiers cmods) const;
00399
00400
00401
00402 BOOL IsSelectUnderClick(ClickModifiers cmods) const;
00403
00404
00405 BOOL IsSelectMemberClick(ClickModifiers cmods) const;
00406
00407
00408 BOOL IsSelectLeafClick(ClickModifiers cmods) const;
00409
00410
00411
00412 NodeRenderableInk* FindFrom(NodeRenderableInk* pSimpleNode) const;
00413
00414
00415 NodeRenderableInk* EnsureInkNext(Range* range, Node* pNode) const;
00416 NodeRenderableInk* EnsureInkPrev(Range* range, Node* pNode) const;
00417
00418
00419 enum ClickActionCode {
00420 CLICKACTION_NONE,
00421 CLICKACTION_BOUNDTOPLEFT,
00422 CLICKACTION_BOUNDTOP,
00423 CLICKACTION_BOUNDTOPRIGHT,
00424 CLICKACTION_BOUNDLEFT,
00425 CLICKACTION_BOUNDRIGHT,
00426 CLICKACTION_BOUNDBOTTOMLEFT,
00427 CLICKACTION_BOUNDBOTTOM,
00428 CLICKACTION_BOUNDBOTTOMRIGHT,
00429 CLICKACTION_BOUNDTRANSFORMORIGIN,
00430 CLICKACTION_SELNONE,
00431 CLICKACTION_SELNODE,
00432 CLICKACTION_SELUNDER,
00433 CLICKACTION_SELUNDERCYCLE,
00434 CLICKACTION_SELUNDERFAIL,
00435 CLICKACTION_SELUNDERFAIL2,
00436 CLICKACTION_SELINSIDE,
00437 CLICKACTION_SELINSIDECYCLE,
00438 CLICKACTION_SELINSIDEFAIL,
00439 CLICKACTION_SELINSIDEFAIL2,
00440 CLICKACTION_SELLEAF
00441 };
00442
00443
00444 ClickActionCode DetermineClickAction(NodeRenderableInk** ppActionNode,
00445 NodeRenderableInk* pLastClickNode,
00446 NodeRenderableInk* pClickSimpleNode,
00447 NodeRenderableInk* pClickCompoundNode,
00448 Spread* pStartSpread,
00449 DocCoord ClickStart,
00450 ClickModifiers ClickMods);
00451 ClickActionCode CycleClickAction(NodeRenderableInk** ppActionNode,
00452 NodeRenderableInk* pClickCompoundNode,
00453 ClickActionCode foundAction,
00454 ClickActionCode cycleAction);
00455 BOOL ValidateLastClickUnder(NodeRenderableInk* pLastClickNode, Spread* pStartSpread, DocCoord ClickStart);
00456 BOOL ValidateLastClickInside(NodeRenderableInk* pLastClickNode, NodeRenderableInk* pClickSimpleNode);
00457
00458
00459 DocCoord ClickStart;
00460 Spread* StartSpread;
00461 ClickModifiers ClickMods;
00462 ClickType TypeOfClick;
00463 INT32 nClickedBoundsBlob;
00464 BOOL fPossibleToggleClick;
00465 BOOL fIsBlobDrag;
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475 NodeRenderableInk* pClickSimpleNode;
00476 NodeRenderableInk* pClickCompoundNode;
00477 NodeRenderableInk* pLastClickNode;
00478 NodeRenderableInk* pPreProcClickNode;
00479
00481
00482
00483 public:
00484
00485
00486 void RotationCentreDragged(const DocCoord& dcNewPos);
00487
00488
00489
00490 void InvalidateRotationCentre();
00491
00492 private:
00493
00494
00495 void GetUserParams();
00496
00497
00498 void DoScale();
00499 void DoSquash();
00500 void DoShear();
00501 void DoTranslate();
00502 void DoRotate();
00503
00504
00505 void DoDragBox();
00506 void DoDragRotateCentre();
00507
00508
00509 BOOL StartXformDrag(TransOperation* pXformDragOp, DragType dragtype);
00510 BOOL StartXformImmediate(const TCHAR* chOpToken, void* pvParam2);
00511
00512
00513 TransformData tdParams;
00514 DocCoord dcRotateCentre;
00515 BOOL fRotateCentreIsValid;
00516
00517
00518
00519 TransformBoundingData BoundingData;
00520
00521
00523
00524
00525 public:
00526
00527
00528 void SelectionBlobChange(BlobStyle ChangingBlobs);
00529 void BoundsButtonChange();
00530 void RotateButtonChange(BOOL fNewState);
00531 void FlipButtonChange(BOOL fIsVertical);
00532 void SetRotateCentre(INT32 nBlob);
00533
00534
00535 void DoTranslateImmediate(MILLIPOINT nXpos, MILLIPOINT nYpos);
00536 void DoScaleImmediate(MILLIPOINT nWinc, MILLIPOINT nHinc);
00537
00538 void DoScalePercentImmediate(double nWpercent, double nHpercent);
00539 void DoRotateImmediate(ANGLE nAngle);
00540 void DoShearImmediate(ANGLE nAngle);
00541
00542
00543
00544 void PublicDoTranslate();
00545
00546
00547
00548 void ResetDefaults();
00549
00550
00551 static void SetStatusText(UINT32 nStringID);
00552 static void SetStatusText(String_256* pStr);
00553 static void UnCacheInfoBar(BOOL = FALSE);
00554
00555
00556 virtual BOOL GetStatusLineText(String_256* ptext, Spread* pSpread,
00557 DocCoord DocPos, ClickModifiers cmods);
00558
00559 void FigureUserFeedback(Spread* pSpread,
00560 DocCoord dcMousePos,
00561 ClickModifiers cmods,
00562 BOOL DoSlowTests,
00563 String_256* pStr,
00564 Cursor** ppPointerShape);
00565 BOOL Append(String_256* pStr, UINT32 StringID);
00566 BOOL Append(String_256* pStr, String_256 String);
00567 BOOL Append(String_256* pStr, ClickModifiers cmods,
00568 UINT32 SelectID,
00569 UINT32 AddID,
00570 UINT32 RemoveID,
00571 NodeRenderableInk* pActionNode = NULL);
00572 BOOL Append(String_256* pStr, ClickModifiers cmods,
00573 String_256 SelectTemplate,
00574 String_256 AddTemplate,
00575 String_256 RemoveTemplate,
00576 NodeRenderableInk* pActionNode = NULL);
00577
00578 private:
00579
00580
00581 static BOOL ReadPrefs();
00582
00583
00584 static SelectorInfoBarOp* pInfoBarOp;
00585
00586
00587 friend class SelectorInfoBarOp;
00588
00589
00590
00592
00593
00594 public:
00595
00596
00597
00598 enum BlobType
00599 {
00600 NO_BLOBS,
00601 BOUNDS_BLOBS,
00602 ROTATE_BLOBS
00603 };
00604
00605
00606 BlobStyle GetBlobStyle() const;
00607 BlobType GetCurrentToolBlobType() const;
00608
00609
00610
00611
00612 static INT32 GetBlobBorderSize(void);
00613 static void InflateByBlobBorder(DocRect* pdrRect);
00614
00615 static void AllowGuidelineScan (BOOL newVal = TRUE) { bGlineSAllowed = newVal; }
00616
00617 private:
00618
00619
00620 void RenderBoundBlobs(Spread*, DocRect*, const DocRect&);
00621 void RenderRotateBlobs(Spread*, DocRect*, const DocRect&);
00622 void RenderRotateCentre(RenderRegion*, const DocCoord&);
00623
00624
00625 DocRect InflatedSelRect() const;
00626 DocCoord GetBoundsBlobPos(INT32 nBlob) const;
00627 DocCoord GetSelPosNearBlob(INT32 nBlob) const;
00628
00629
00630 INT32 BoundsBlobHitTest(const DocCoord& dcMousePos) const;
00631 static BOOL IsNearBlob(const DocCoord& dcBlobOrigin, const DocCoord& dcTestPoint);
00632
00633
00634 void ChangeCursorAndText(INT32 nBlobID, String_256* pStr, Cursor** pPointerShape);
00635
00636
00637 void SetKeyDownCursor(ClickModifiers cmods);
00638 void ResetCursorNow();
00639
00640
00641
00642 void RenderOtherToolBlobs();
00643
00644
00645 static BlobManager* pBlobManager;
00646 BlobStyle bsBlobStyle;
00647 BlobType eCurrentBlobs;
00648 BOOL fShowToolBlobs;
00649
00650 INT32 nLastSelectedBlob;
00651 BOOL fValidSelectedBlob;
00652 BOOL m_bComputeAreaDetails;
00653
00654
00655
00656
00657
00658
00659
00660 Cursor* pNormalCursor;
00661 Cursor* pAdjustCursor;
00662 Cursor* pUnderCursor;
00663 Cursor* pInsideCursor;
00664 Cursor* pUnderAdjustCursor;
00665 Cursor* pInsideAdjustCursor;
00666 Cursor* pLeafCursor;
00667 Cursor* pLeafAdjustCursor;
00668
00669 Cursor* pALLCursor;
00670 Cursor* pNWSECursor;
00671 Cursor* pNESWCursor;
00672 Cursor* pNSCursor;
00673 Cursor* pWECursor;
00674 Cursor* pGradFillCursor;
00675 Cursor* pDragRotateCursor;
00676 Cursor* pHorzGuideCursor;
00677 Cursor* pVertGuideCursor;
00678
00679
00680
00681 static INT32 nBlobBorder;
00682 static unsigned fBlobPref;
00683 static BOOL fAllowCorelToggleClick;
00684 static BOOL fSelectUnderLikeArtWorks;
00685
00686
00687
00688
00689
00690 static BOOL bNormalClickCheckProfileDialog;
00691
00692
00693
00694
00695 static BOOL bGlineSAllowed;
00696
00697 protected:
00698
00699 static BOOL fSlaveLineWidthToButton;
00700 static BOOL fConsiderLineWidths;
00701 static BOOL fUseScalingFix;
00702 static BOOL bPageDoubleClickOpenFile;
00703
00704
00705 friend class OpDragRotateCentre;
00706 };
00707
00708 #endif // INC_SELECTOR