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
00101
00102
00103
00104
00105
00106
00107 #ifndef INC_DOCVIEW
00108 #define INC_DOCVIEW
00109
00110 #include "view.h"
00111 #include "ccmaths.h"
00112 #include "rect.h"
00113 #include "doccoord.h"
00114 #include "binds.h"
00115 #include "clikmods.h"
00116 #include "ops.h"
00117 #include "monotime.h"
00118 #include "oilcoord.h"
00119 #include "quality.h"
00120 #include "docvmsg.h"
00121 #include "dragtrgt.h"
00122 #include "cursor.h"
00123 #include "snap.h"
00124
00125 #define OPTOKEN_TOGGLESOLIDDRAG TEXT("ToggleSolidDrag")
00126
00127 class ImportPosition;
00128
00129
00130
00131 class CCamView;
00132 class ViewState;
00133 class CursorStack;
00134 class Document;
00135 class Node;
00136 class Chapter;
00137 class RenderRegion;
00138 class WorkRect;
00139 class OilRect;
00140 class CSnap;
00141 class RulerPair;
00142 class AttrUser;
00143 class NodeRenderableInk;
00144 class DragInformation;
00145 class ViewDragTarget;
00146
00147
00148 enum OnTopCode
00149 {
00150 Normal = 0,
00151 UnclippedEOR = 1,
00152 UnclippedXOR = 1,
00153 ClippedEOR = 2,
00154 ClippedXOR = 2,
00155 CLICKBITMAP,
00156 COLOURBITMAP
00157 };
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 class PendingRedraws : public List
00175 {
00176 CC_DECLARE_MEMDUMP(PendingRedraws);
00177
00178 public:
00179 PendingRedraws();
00180 ~PendingRedraws();
00181
00182 BOOL AddInvalidRegion(Spread*, DocRect, Node* pInvalidNode);
00183 void FlushRedraw(DocView*);
00184 void HandleNodeDeletion(Node* pNode);
00185 };
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228 class CCAPI DocView : public View
00229 {
00230 friend class Document;
00231
00233
00234
00235 private:
00236 CC_DECLARE_DYNAMIC(DocView);
00237
00238 public:
00239 DocView(Document*);
00240 virtual ~DocView();
00241 BOOL Init();
00242 static BOOL DeclarePreferences();
00243
00244
00246
00247
00248 public:
00249 void OnNewView();
00250 void OnLoadedView();
00251
00253
00254
00255 private:
00256 static DocView* Selected;
00257 BOOL IsViewDying;
00258
00259 public:
00260 static DocView* GetCurrent();
00261 BOOL SetCurrent();
00262 static void SetNoCurrent();
00263 virtual void SetViewPixelSize();
00264
00265 static DocView* GetSelected();
00266
00267
00268
00269
00270
00271
00272 static CNativeWnd *GetCurrentRenderWindow();
00273 virtual CNativeWnd *GetRenderWindow();
00274
00275 protected:
00276 static void SetSelectedInternal(DocView *NewSelected);
00277 static void SendSelectedMessage(DocView *OldSelected, DocView *NewSelected);
00278
00279
00281
00282
00283 private:
00284 INT32 PushToolCursorID;
00285 Cursor m_PushCursor;
00286
00288
00289
00290 private:
00291 DocCoord StartDragPos;
00292 DocCoord OldDragPos;
00293 WorkCoord LastWorkClick;
00294 Operation* pCurrentDragOp;
00295 DocCoord DragPos;
00296 BOOL m_bSolidDragSupported;
00297
00298
00299 public:
00300 BOOL StartDrag( Operation*,
00301 DragType,
00302 DocRect* pMoveBBox,
00303 DocCoord* StartPos,
00304 BOOL KeepAccuracy,
00305 BOOL bSolidDragSupported = FALSE);
00306 BOOL EndDrag(Operation*);
00307 BOOL ChangeDragType(DragType Type);
00308
00309 void DragPointerMove(Operation*, OilCoord, ClickModifiers);
00310 void DragPointerIdle(Operation*, OilCoord, ClickModifiers);
00311 void DragFinished(Operation*, OilCoord, ClickModifiers, BOOL);
00312
00313 BOOL IsSingleClickReallyTriple() const;
00314 BOOL IsSingleClickReallyQuad() const;
00315
00316 void OnMouseMove(OilCoord, ClickModifiers);
00317 void OnClick(OilCoord, ClickType, ClickModifiers);
00318 void RenderSelectBlobs(DocRect Rect, Spread *pSpread);
00319
00320 BOOL IsMouseMoved();
00321
00322 WorkCoord GetClickWorkCoord();
00323
00324
00325
00326 static BOOL GetCurrentMousePos(Spread** ppSpread, DocCoord* pdcMousePos);
00327
00328 ObjectDragTarget IsPointerOverNode(NodeRenderableInk** ThisNode, INT32 Range, BOOL Interrupt = TRUE,
00329 BOOL bColourDrag = FALSE);
00330
00331 BOOL DM_DragFinished(DragInformation* DragInfo, ViewDragTarget* pDragTarget);
00332
00333 void SetSolidDragState(BOOL bNewState) {m_bSolidDrag = bNewState;}
00334
00335 BOOL GetCurrentSolidDragAbility() {return m_bSolidDragSupported;}
00336 BOOL GetCurrentSolidDragState() {return m_bSolidDrag;}
00337 void ClearClickState();
00338
00339
00341
00342
00343 public:
00344 virtual BOOL HandleKeyPress(KeyPress* pKeyPress);
00345
00346
00347
00348
00349
00350 void ResetRenderingStartTime() { StartTime.Sample(); }
00351
00353
00354
00355 private:
00356 struct CCAPI
00357 {
00358 BOOL BackgroundRender : 1;
00359 BOOL GridShow : 1;
00360 BOOL GridSnap : 1;
00361 BOOL ObjectsSnap : 1;
00362 BOOL MagObjectsSnap : 1;
00363 BOOL PrintBorderShow : 1;
00364 BOOL LogicalView : 1;
00365 BOOL WorkClickCached : 1;
00366 BOOL Dragging : 1;
00367 BOOL GuidesSnap : 1;
00368 BOOL GuidesShow : 1;
00369 } ViewFlags;
00370
00371
00372
00373 friend class CCamView;
00374
00375 MonotonicTime StartTime;
00376
00377
00378 RenderRegion* NewRenderRegion(DocRect, Matrix&, CNativeDC*, Spread*, RenderType);
00379
00380 void RenderView(RenderRegion* pRegion, Matrix& mxTxform, Spread* pSpread,
00381 BOOL fRenderPaper, BOOL fDeleteRegionAfter = TRUE,
00382 BOOL bForceImmediate = FALSE);
00383
00384 CNativeDC* GetRenderDC();
00385
00386 public:
00387 BOOL GetShowPrintBorders() { return (ViewFlags.PrintBorderShow != 0); }
00388 void SetShowPrintBorders(BOOL State) { ViewFlags.PrintBorderShow = State; }
00389
00390 public:
00391 Spread* FindEnclosingSpread(OilCoord);
00392 Spread* OilToSpreadCoord(OilCoord, DocCoord*);
00393
00394 public:
00395 virtual BOOL RenderPageMarks(RenderRegion*, Matrix&, DocRect&, Spread*);
00396
00397 public:
00398 void ContinueRenderView(RenderRegion* pRegion, Spread* pSpread,
00399 BOOL fRenderPaper = TRUE,
00400 BOOL fDeleteRegionAfter = TRUE,
00401 BOOL bForceImmediate = FALSE);
00402
00403 void RenderEntireView(RenderRegion* pRender, Spread* pSpread);
00404
00405 virtual BOOL GetForeBackMode();
00406 virtual void SetForeBackMode(BOOL);
00407
00408
00409 void ForceRedraw(BOOL ForcePaper = FALSE);
00410
00411
00412 void ForceRedraw(WorkRect&);
00413
00414
00415 void ForceRedraw(Spread*, DocRect, BOOL Accumulate = FALSE, Node* pInvalidNode = NULL);
00416 void FlushRedraw();
00417
00418 void HandleNodeDeletion(Node* pNode);
00419
00420 static BOOL BackgroundRendering;
00421 static BOOL SolidDragging;
00422 static UINT32 IdleDragDelay;
00423 static UINT32 IdleDragDelay2;
00424 static BOOL OriginOutlineShowNonOverlap;
00425 static BOOL OriginOutlineShowAlways;
00426 static UINT32 SolidDragTimeLimit;
00427 static BOOL OutlineShowBounds;
00428
00429 private:
00430 PendingRedraws PendingRedrawList;
00431
00433
00434
00435 private:
00436 static OnTopCode OnTopReason;
00437 static Spread* OnTopSpread;
00438 static RenderRegion* OnTopRenderRegion;
00439 static INT32 OnTopCount;
00440
00441 public:
00442 static RenderRegion* RenderOnTop(DocRect* Rect, Spread *pSpread, OnTopCode Reason);
00443 static RenderRegion* GetNextOnTop(DocRect*);
00444
00445 RenderRegion* GetFirstRenderRegion(DocRect&, Spread*, OnTopCode Reason);
00446 RenderRegion* GetNextRenderRegion(DocRect&, Spread*, OnTopCode Reason);
00447
00448
00450
00451
00452 private:
00453 static UINT32 ScrollToShowMargin;
00454 void ScrollToShowAux(DocCoord* pCoord, DocCoord Margin);
00455 public:
00456 void ShowViewScrollers(BOOL fIsVisible);
00457 void ShowViewRulers(BOOL fIsVisible);
00458 BOOL AreRulersVisible();
00459 BOOL AreScrollersVisible();
00460
00461 BOOL SetViewScale(FIXED16 NewScale);
00462 BOOL SetScrollOffsets(WorkCoord NewTopLeft, BOOL RedrawNeeded);
00463
00464
00465 void ScrollToShow(DocCoord* pCoord);
00466 void ScrollToShow(DocRect *RectToShow);
00467 void ScrollToShow(DocRect* pBoundingBox, DocCoord Direction);
00468 void ScrollToShowWithMargin(DocCoord* pCoord);
00469 void ScrollToShowWithMargin(DocRect *RectToShow);
00470 void ScrollToShowWithMargin(DocRect* pBoundingBox, DocCoord Direction);
00471
00472 BOOL ViewStateChanged();
00473
00474 DocRect GetDocViewRect(Spread*);
00475 void SetExtent(DocCoord, DocCoord);
00476 WorkRect GetViewRect();
00477
00478
00479
00480
00481
00483
00484
00485 private:
00486 INT32 ZoomTableIndex;
00487 INT32 PrevIndex;
00488 FIXED16 PrevScale;
00489 WorkCoord PrevOffset;
00490
00491 public:
00492 INT32 GetZoomTableIndex() const;
00493 void SetZoomTableIndex(INT32 nIndex);
00494
00495 INT32 GetPrevZoomIndex() const;
00496 void SetPrevZoomIndex(INT32 nIndex);
00497
00498 FIXED16 GetPrevZoomScale() const;
00499 void SetPrevZoomScale(FIXED16 fxScale);
00500
00501 WorkCoord GetPrevZoomOffset() const;
00502 void SetPrevZoomOffset(const WorkCoord& wcOffset);
00503
00504
00506
00507
00508 public:
00509
00510 BOOL Snap(Spread* pSpread, DocCoord* pDocCoord,
00511 BOOL TryMagSnap = TRUE,
00512 BOOL TryGridSnap = TRUE);
00513 BOOL Snap(Spread* pSpread, DocRect* pDocRect,
00514 const DocCoord& PrevCoord, const DocCoord& CurCoord);
00515
00516
00517 static BOOL SnapSelected(Spread* pSpread, DocCoord* pDocCoord,
00518 BOOL TryMagSnap = TRUE,
00519 BOOL TryGridSnap = TRUE);
00520 static BOOL SnapSelected(Spread* pSpread, DocRect* pDocRect,
00521 const DocCoord& PrevCoord, const DocCoord& CurCoord);
00522
00523 static BOOL SnapCurrent(Spread* pSpread, DocCoord* pDocCoord,
00524 BOOL TryMagSnap = TRUE,
00525 BOOL TryGridSnap = TRUE);
00526 static BOOL SnapCurrent(Spread* pSpread, DocRect* pDocRect,
00527 const DocCoord& PrevCoord, const DocCoord& CurCoord);
00528
00529 static BOOL SnapToMagneticNode(Spread* pSpread, Node* pNode, DocCoord* pDocCoord);
00530 static BOOL ForceSnapToGrid(Spread* pSpread, DocCoord* pDocCoord);
00531 static BOOL ForceSnapToGuides(Spread* pSpread, DocCoord* pDocCoord, GuidelineType Type);
00532
00533
00534 BOOL GetSnapToGridState();
00535 void SetSnapToGridState(BOOL SnapToGrid);
00536
00537 BOOL GetShowGridState();
00538 void SetShowGridState(BOOL ShowGrid);
00539
00540 BOOL GetSnapToObjectsState();
00541 void SetSnapToObjectsState(BOOL SnapToObjects);
00542
00543 BOOL GetSnapToMagObjectsState();
00544 void SetSnapToMagObjectsState(BOOL SnapToMagObjects);
00545
00546 BOOL GetSnapToGuidesState() { return (ViewFlags.GuidesSnap != 0); }
00547 void SetSnapToGuidesState(BOOL State) { ViewFlags.GuidesSnap = State; }
00548
00549 BOOL GetShowGuidesState() { return (ViewFlags.GuidesShow != 0); }
00550 void SetShowGuidesState(BOOL State) { ViewFlags.GuidesShow = State; }
00551
00552 private:
00553 CSnap* pCSnap;
00554
00556
00557
00558 public:
00559 static void ConstrainToAngle(DocCoord&, DocCoord*, double Constrain=0.0);
00560 static void ConstrainToAngle(DocCoord&, double, DocCoord*);
00561 static double DefaultConstrainAngle;
00562
00563 static void ConstrainToAspect(DocCoord& FixedPoint, FIXED16& AspectLock, DocCoord* CurCoord);
00564
00565
00566
00568
00569
00570 public:
00571
00572 Spread* GetVisibleSpread();
00573 Spread* GetFirstSelectedSpread();
00574
00576
00577
00578 public:
00579 RulerPair* GetpRulerPair() { return pRulerPair; }
00580
00581 protected:
00582 RulerPair* pRulerPair;
00583
00585
00586
00587 public:
00588 DocCoord GetCentreCoord();
00589 ImportPosition GetCentreImportPosition();
00590
00591 DocCoord GetTopLeftCoord();
00592 ImportPosition GetTopLeftImportPosition();
00593
00595
00596
00597 public:
00598 double GetZoomFactor();
00599
00600 private:
00601
00603
00604
00605 public:
00606 void SetPreventRenderView(BOOL Value);
00607 BOOL GetPreventRenderView();
00608
00609 private:
00610 BOOL m_bPreventRenderView;
00611
00612
00614 public:
00615 void NotifyBoundsChanged(BOOL bNewValue = TRUE) {m_bBoundsChanged = (m_bBoundsChanged || bNewValue);}
00616
00617 private:
00618 BOOL m_bBoundsChanged;
00619 };
00620
00621
00622
00623
00624
00625
00626
00627 #define OPTOKEN_TOGGLEFORE TEXT("ToggleForeBack")
00628 #define OPTOKEN_TOGGLESCROLL TEXT("ToggleScrollBars")
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 class OpToggleFore: public Operation
00646 {
00647 CC_DECLARE_DYNCREATE( OpToggleFore )
00648
00649 public:
00650 OpToggleFore();
00651 ~OpToggleFore();
00652
00653 static BOOL Init();
00654 void Do(OpDescriptor*);
00655 static OpState GetState(String_256*, OpDescriptor*);
00656 };
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674 class OpToggleScroll: public Operation
00675 {
00676 CC_DECLARE_DYNCREATE( OpToggleScroll )
00677
00678 public:
00679 OpToggleScroll();
00680 ~OpToggleScroll();
00681
00682 static BOOL Init();
00683 void Do(OpDescriptor*);
00684 static OpState GetState(String_256*, OpDescriptor*);
00685 };
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 class OpToggleSolidDrag: public Operation
00702 {
00703 CC_DECLARE_DYNCREATE( OpToggleSolidDrag )
00704
00705 public:
00706 OpToggleSolidDrag();
00707 ~OpToggleSolidDrag();
00708
00709 static BOOL Init();
00710 void Do(OpDescriptor*);
00711 static OpState GetState(String_256*, OpDescriptor*);
00712 };
00713
00714
00715
00716 #endif // INC_DOCVIEW