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 #include "camtypes.h"
00104
00105
00106
00107 #ifndef WEBSTER
00108
00109
00110
00111
00112 #include "rulers.h"
00113
00114 #include "sprdmsg.h"
00115 #include "optsmsgs.h"
00116 #include "userrect.h"
00117 #include "grid.h"
00118 #include "appprefs.h"
00119 #include "layerprp.h"
00120 #include "camelot.h"
00121
00122 DECLARE_SOURCE("$Revision: 1535 $");
00123
00124 CC_IMPLEMENT_MEMDUMP(RulerPair, MessageHandler)
00125 CC_IMPLEMENT_MEMDUMP(RulerBase, CC_CLASS_MEMDUMP)
00126 CC_IMPLEMENT_MEMDUMP(HorizontalRuler, RulerBase)
00127 CC_IMPLEMENT_MEMDUMP(VerticalRuler, RulerBase)
00128 CC_IMPLEMENT_MEMDUMP(RulerContextMenu, ContextMenu)
00129 CC_IMPLEMENT_MEMDUMP(OriginContextMenu, ContextMenu)
00130
00131 #define new CAM_DEBUG_NEW
00132
00133 #define MAX_LEGEND_CHARS 12
00134 #define LABEL_SPACING_STRING _T("8888")
00135 #define ACCEPTIBLE_DEVIATION_FROM_INTEGER 1e-10
00136 #define NEAR_ENOUGH_INTEGER(a) ( fabs(fmod(a,1)) < ACCEPTIBLE_DEVIATION_FROM_INTEGER )
00137 #define MAKE_INTEGER(a) ( (INT32)( (a) + ACCEPTIBLE_DEVIATION_FROM_INTEGER*3 ) )
00138
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 RulerBase::RulerBase()
00151 {
00152 }
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 BOOL RulerBase::Redraw(OilRect* pUpdateOilRect)
00168 {
00169
00170 DocView* pDocView = pRulerPair->GetpDocView();
00171 RulerRedrawData* pRD = pRulerPair->GetpRedrawData();
00172 Spread* pSpread = pRulerPair->GetpSpread();
00173
00174
00175 if (pSpread==NULL)
00176 return TRUE;
00177
00178
00179 DocRect drect = pUpdateOilRect->ToDoc(pSpread,pDocView).ToSpread(pSpread,pDocView);
00180 UserRect UpdateRect = drect.ToUser(pSpread);
00181
00182
00183 UserCoord Offsets(0, 0);
00184 if (Tool::GetCurrent())
00185 Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00186
00187
00188 UpdateRect.lo.x -= Offsets.x;
00189 UpdateRect.lo.y -= Offsets.y;
00190 UpdateRect.hi.x -= Offsets.x;
00191 UpdateRect.hi.y -= Offsets.y;
00192
00193 MILLIPOINT LoLimit = GetOrd(pRD->PasteBoardUserRect.lo);
00194 MILLIPOINT HiLimit = GetOrd(pRD->PasteBoardUserRect.hi);
00195 if (GetOrd(UpdateRect.lo)<LoLimit) UpdateRect.lo=MakeCoord(LoLimit);
00196 if (GetOrd(UpdateRect.hi)>HiLimit) UpdateRect.hi=MakeCoord(HiLimit);
00197 if (GetOrd(UpdateRect.hi)<GetOrd(UpdateRect.lo))
00198 return TRUE;
00199
00200
00201 if (Tool::GetCurrent())
00202 Tool::GetCurrent()->RenderRulerBlobs(this, UpdateRect, TRUE);
00203
00204
00205 double Start = GetOrd(UpdateRect.lo)/pRD->GratStepSize;
00206 double End = GetOrd(UpdateRect.hi)/pRD->GratStepSize;
00207 INT32 FirstGrat = (INT32)floor(Start)*pRD->GratStep;
00208 INT32 LastGrat = (INT32)ceil(End)*pRD->GratStep;
00209
00210
00211 String_8 GratLabelText(_T(""));
00212 INT32 Grat=FirstGrat;
00213 while (Grat<=LastGrat)
00214 {
00215
00216 MILLIPOINT GratPos=(MILLIPOINT)(Grat*pRD->GratUnitSize + GetOrd(Offsets));
00217 OilCoord GratOilPos=MakeCoord(GratPos).ToSpread(pSpread).ToOil(pSpread,pDocView);
00218
00219
00220 ERROR3IF(!NEAR_ENOUGH_INTEGER(fabs(Grat*pRD->ScaleFactor)),"RulerBase::Redraw() - Grat label should be integer!");
00221 INT32 GratLabel=MAKE_INTEGER(fabs(Grat*pRD->ScaleFactor));
00222 Convert::LongToString(GratLabel,&GratLabelText);
00223 pOILRuler->DrawMajorGraticule(GratOilPos, (LPCTSTR)GratLabelText);
00224
00225
00226 INT32 MinorGrats = pRD->MinorGrats;
00227 INT32 MinorGrat = 1;
00228 MILLIPOINT MinorGratPos = 0;
00229 while (MinorGrat<MinorGrats)
00230 {
00231 INT32 Size=0;
00232 if (MinorGrat*2==MinorGrats) Size+=1;
00233 if (MinorGrats>5)
00234 if (MinorGrat*4==MinorGrats || MinorGrat*2==MinorGrats || MinorGrat*4==MinorGrats*3) Size+=2;
00235 MinorGratPos = (MILLIPOINT)(GratPos+pRD->MinorGratStepSize*MinorGrat);
00236 GratOilPos = MakeCoord(MinorGratPos).ToSpread(pSpread).ToOil(pSpread,pDocView);
00237 pOILRuler->DrawMinorGraticule(GratOilPos,Size);
00238 MinorGrat+=1;
00239 }
00240
00241
00242 Grat+=pRD->GratStep;
00243 }
00244
00245
00246 if (Tool::GetCurrent())
00247 Tool::GetCurrent()->RenderRulerBlobs(this, UpdateRect, FALSE);
00248
00249
00250 DocCoord LastPos = pRulerPair->GetMouseFollowerPosition();
00251 BOOL Visibility = pRulerPair->GetMouseFollowerVisibility();
00252
00253 if (Visibility==TRUE)
00254 {
00255 OilCoord LastOilPos = LastPos.ToOil(pSpread,pDocView);
00256 pOILRuler->PaintMouseFollower(LastOilPos, pDocView, RenderOn);
00257
00258 }
00259
00260 return TRUE;
00261 }
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 BOOL RulerBase::HighlightSection(MILLIPOINT ord_lo, MILLIPOINT ord_hi)
00276 {
00277 DocView* pDocView = pRulerPair->GetpDocView();
00278 Spread* pSpread = pRulerPair->GetpSpread();
00279
00280
00281 if (pSpread==NULL) return TRUE;
00282
00283
00284 UserCoord Offsets(0, 0);
00285 if (Tool::GetCurrent())
00286 Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00287 ord_lo += GetOrd(Offsets); ord_hi += GetOrd(Offsets);
00288
00289 OilCoord OilPosLo = MakeCoord(ord_lo).ToSpread(pSpread).ToOil(pSpread,pDocView);
00290 OilCoord OilPosHi = MakeCoord(ord_hi).ToSpread(pSpread).ToOil(pSpread,pDocView);
00291 return pOILRuler->HighlightSection(OilPosLo, OilPosHi);
00292 }
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 BOOL RulerBase::DrawBitmap(MILLIPOINT ord, ResourceID BitmapID)
00308 {
00309 DocView* pDocView = pRulerPair->GetpDocView();
00310 Spread* pSpread = pRulerPair->GetpSpread();
00311
00312
00313 if (pSpread==NULL) return TRUE;
00314
00315
00316 UserCoord Offsets(0, 0);
00317 if (Tool::GetCurrent())
00318 Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00319 ord += GetOrd(Offsets);
00320
00321 OilCoord OilPos = MakeCoord(ord).ToSpread(pSpread).ToOil(pSpread,pDocView);
00322 return pOILRuler->DrawBitmap(OilPos, BitmapID);
00323 }
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 BOOL RulerBase::OnRulerClick(OilCoord PointerPos, ClickType Click, ClickModifiers Mods)
00346 {
00347 ERROR3IF(pRulerPair==NULL, "pRulerPair unexpectedly NULL");
00348 ERROR3IF(pRulerPair->GetpSpread()==NULL, "pRulerPair->pSpread unexpectedly NULL");
00349 ERROR3IF(pRulerPair->GetpDocView()==NULL, "pRulerPair->pDocView unexpectedly NULL");
00350
00351
00352 if (CCamApp::IsDisabled())
00353 return FALSE;
00354
00355
00356
00357
00358
00359 Spread *pSpread = pRulerPair->GetpSpread();
00360
00361 if (pSpread == NULL)
00362 {
00363 ERROR3("Could not find Ruler pair spread");
00364 return FALSE;
00365 }
00366
00367
00368
00369
00370
00371
00372
00373 UserCoord UserPos = OilToToolCoords(PointerPos, pSpread);
00374 if (Tool::GetCurrent())
00375 return Tool::GetCurrent()->OnRulerClick(UserPos, Click, Mods, pSpread, this);
00376
00377 return FALSE;
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 UserCoord RulerBase::OilToToolCoords(OilCoord PointerPos, Spread* pSpread)
00393 {
00394 DocView* pDocView = pRulerPair->GetpDocView();
00395
00396
00397 DocCoord DocPos = PointerPos.ToDoc(pSpread, pDocView);
00398
00399
00400 pSpread->DocCoordToSpreadCoord(&DocPos);
00401 UserCoord UserPos = DocPos.ToUser(pSpread);
00402
00403
00404
00405 MILLIPOINT PixelSize = pDocView->GetScaledPixelWidth().MakeLong();
00406 if (IsHorizontal())
00407 UserPos.y = MILLIPOINT(PointerPos.y * PixelSize);
00408 else
00409 UserPos.x = MILLIPOINT(PointerPos.x * PixelSize);
00410
00411
00412 UserCoord Offsets(0, 0);
00413 if (Tool::GetCurrent())
00414 Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00415
00416
00417 if (IsHorizontal())
00418 UserPos.x -= Offsets.x;
00419 else
00420 UserPos.y -= Offsets.y;
00421 return UserPos;
00422 }
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 BOOL RulerBase::GetStatusLineText(String_256* pText, OilCoord PointerPos)
00438 {
00439 Spread *pSpread = pRulerPair->GetpSpread();
00440 UserCoord UserPos = OilToToolCoords(PointerPos, pSpread);
00441 return (Tool::GetCurrent()) ? Tool::GetCurrent()->GetRulerStatusLineText(pText, UserPos, pSpread, this) : FALSE;
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459 BOOL RulerBase::StartToolDrag(ClickModifiers Mods, UserCoord PointerPos,
00460 String_256* pOpToken, OpParam* pParam)
00461 {
00462
00463 Spread *pSpread = pRulerPair->GetpSpread();
00464 DocView *pDocView = pRulerPair->GetpDocView();
00465
00466
00467 UserCoord Offsets(0, 0);
00468 if (Tool::GetCurrent())
00469 Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00470 PointerPos.translate(Offsets.x, Offsets.y);
00471
00472 OilCoord OilPos = PointerPos.ToSpread(pSpread).ToOil(pSpread,pDocView);
00473 return pOILRuler->StartToolDrag(Mods, OilPos, pOpToken, pParam);
00474 }
00475
00476
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 HorizontalRuler::HorizontalRuler()
00489 {
00490 pOILRuler = NULL;
00491 pRulerPair = NULL;
00492 }
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 BOOL HorizontalRuler::Init(RulerPair* pRulers, OILHorizontalRuler* pHOILRuler)
00507 {
00508 ERROR2IF(pHOILRuler==NULL,FALSE,"HorizontalRuler::Init() - pVOILRuler==NULL");
00509 ERROR2IF( pRulers==NULL,FALSE,"HorizontalRuler::Init() - pRulers==NULL");
00510
00511 pOILRuler = pHOILRuler;
00512 pRulerPair = pRulers;
00513
00514 return TRUE;
00515 }
00516
00517
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529 VerticalRuler::VerticalRuler()
00530 {
00531 pOILRuler = NULL;
00532 pRulerPair = NULL;
00533 }
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 BOOL VerticalRuler::Init(RulerPair* pRulers, OILVerticalRuler* pVOILRuler)
00548 {
00549 ERROR2IF(pVOILRuler==NULL,FALSE,"VerticalRuler::Init() - pVOILRuler==NULL");
00550 ERROR2IF( pRulers==NULL,FALSE,"VerticalRuler::Init() - pRulers==NULL");
00551
00552 pOILRuler = pVOILRuler;
00553 pRulerPair = pRulers;
00554
00555 return TRUE;
00556 }
00557
00558
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570 RulerPair::RulerPair()
00571 {
00572 pSpread = NULL;
00573 pDocView = NULL;
00574
00575 MouseFollowerVisibility = FALSE;
00576 }
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593 BOOL RulerPair::Init(DocView* pDView, OILHorizontalRuler* pOILHRuler,
00594 OILVerticalRuler* pOILVRuler, OriginGadget* pOGadget)
00595 {
00596 ERROR2IF( pDView==NULL,FALSE,"RulerPair::Init() - pDocView==NULL");
00597 ERROR2IF(pOILHRuler==NULL,FALSE,"RulerPair::Init() - pOILHRuler==NULL");
00598 ERROR2IF(pOILVRuler==NULL,FALSE,"RulerPair::Init() - pOILVRuler==NULL");
00599 ERROR2IF( pOGadget==NULL,FALSE,"RulerPair::Init() - pOGadget==NULL");
00600
00601 HRuler.Init(this,pOILHRuler);
00602 VRuler.Init(this,pOILVRuler);
00603 pDocView = pDView;
00604 pOriginGadget = pOGadget;
00605
00606 return TRUE;
00607 }
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 extern BOOL SafeAppendString(StringBase*, const StringBase&, BOOL = TRUE);
00621
00622 BOOL RulerPair::UpdateRedrawData()
00623 {
00624 ERROR2IF( pSpread==NULL,FALSE,"RulerPair::UpdateRedrawData() - pSpread==NULL");
00625 ERROR2IF(pDocView==NULL,FALSE,"RulerPair::UpdateRedrawData() - pDocView==NULL");
00626
00627
00628 NodeGrid* pDefaultGrid=pSpread->FindFirstDefaultGridInSpread();
00629 ERROR2IF(pDefaultGrid==NULL,FALSE,"RulerPair::UpdateRedrawData() - pDefaultGrid==NULL");
00630
00631
00632 DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
00633 ERROR2IF(pDocUnitList==NULL,FALSE,"RulerPair::UpdateRedrawData() - pDocUnitList==NULL");
00634
00635
00636 OilRect MinGratSpacingOilRect;
00637 BOOL ok = OILRuler::GetMinGraticuleSpacing(&MinGratSpacingOilRect,pDocView);
00638 ERROR2IF(!ok,FALSE,"RulerPair::UpdateRedrawData() - OILRuler::GetMinGraticuleSpacing() failed");
00639 DocRect MinGratSpacingDocRect = MinGratSpacingOilRect.ToDoc(pSpread,pDocView);
00640 MILLIPOINT MinGratSpacing = max(MinGratSpacingDocRect.Width(),MinGratSpacingDocRect.Height());
00641
00642
00643 OilRect LabelSizeOilRect;
00644 ok = OILRuler::GetTextSize(&LabelSizeOilRect,LABEL_SPACING_STRING,pDocView);
00645 ERROR2IF(!ok,FALSE,"RulerPair::UpdateRedrawData() - OILRuler::GetTextSize() failed");
00646 DocRect LabelSizeDocRect = LabelSizeOilRect.ToDoc(pSpread,pDocView);
00647 MILLIPOINT MinLabelSpacing = max(LabelSizeDocRect.Width(),LabelSizeDocRect.Height());
00648
00649
00650 UnitType GridUnits = pDefaultGrid->GetUnits();
00651 INT32 GridSubDivisions = pDefaultGrid->GetSubdivisions();
00652 double GridStepSize = pDefaultGrid->GetMainStep();
00653 double GridStepSizeInUnits = pDefaultGrid->GetDivisions();
00654 double GridUnitSize = GridStepSize/GridStepSizeInUnits;
00655
00656
00657
00658
00659 double GratStepSize = GridStepSize;
00660 INT32 GratStep = 1;
00661 double GratUnitSize = GratStepSize;
00662 if (NEAR_ENOUGH_INTEGER(GridStepSizeInUnits))
00663 {
00664 GratStep = MAKE_INTEGER(GridStepSizeInUnits);
00665 GratUnitSize = GridUnitSize;
00666 }
00667
00668
00669 DocRect PasteSpreadRect = pSpread->GetPasteboardRect(FALSE, pDocView);
00670 pSpread->DocCoordToSpreadCoord(&PasteSpreadRect);
00671 UserRect PasteBoardUserRect = PasteSpreadRect.ToUser(pSpread);
00672
00673
00674 UserCoord Offsets(0, 0);
00675 Tool::GetCurrent()->GetRulerOrigin(pSpread, &Offsets);
00676 PasteBoardUserRect.Translate(-Offsets.x, -Offsets.y);
00677
00678
00679 double XStart = fabs(PasteBoardUserRect.lo.x/GratStepSize)*GratStep;
00680 double XEnd = fabs(PasteBoardUserRect.hi.x/GratStepSize)*GratStep;
00681 double YStart = fabs(PasteBoardUserRect.lo.y/GratStepSize)*GratStep;
00682 double YEnd = fabs(PasteBoardUserRect.hi.y/GratStepSize)*GratStep;
00683
00684
00685 double LogMax = log10(max(max(XStart,XEnd),max(YStart,YEnd)));
00686 INT32 MaxDP = (INT32)floor(LogMax);
00687 double ScaleFactor = (MaxDP<=2) ? 1 : 1/pow(10.0,MaxDP-2);
00688
00689
00690
00691
00692
00693
00694 INT32 GratFreq = (INT32)ceil(MinLabelSpacing/GratStepSize);
00695 INT32 Mult = 1;
00696 INT32 SafetyCount = 0;
00697 while (1)
00698 {
00699 if (GratFreq<=1*Mult && NEAR_ENOUGH_INTEGER(1*Mult*GratStep*ScaleFactor)) { GratFreq=1*Mult; break; }
00700 if (GratFreq<=2*Mult && NEAR_ENOUGH_INTEGER(2*Mult*GratStep*ScaleFactor)) { GratFreq=2*Mult; break; }
00701 if (GratFreq<=5*Mult && NEAR_ENOUGH_INTEGER(5*Mult*GratStep*ScaleFactor)) { GratFreq=5*Mult; break; }
00702 Mult *= 10;
00703 ERROR2IF(SafetyCount++>1000,FALSE,"RulerPair::UpdateRedrawData() - SafetyCount exceeded!");
00704 }
00705
00706
00707 double VisibleGratStepSize = GratStepSize*GratFreq;
00708 INT32 VisibleGratStep = GratStep *GratFreq;
00709
00710
00711 String_32 LegendUnitMultiplier(_T(""));
00712 if (GratStep*ScaleFactor!=GridStepSizeInUnits)
00713 {
00714 TCHAR mult[4]={' ',(TCHAR)0xD7,' ','\0'};
00715 LegendUnitMultiplier = mult;
00716 String_32 LegendUnitSize(_T(""));
00717 double GratUnit=GridStepSizeInUnits/GratStep;
00718 ok=Convert::DoubleToString(GratUnit/ScaleFactor,&LegendUnitSize);
00719 SafeAppendString(&LegendUnitMultiplier,LegendUnitSize,FALSE);
00720 }
00721
00722
00723 String_32 LegendStr = pDocUnitList->GetToken(GridUnits);
00724 if (LegendStr.Length()+LegendUnitMultiplier.Length() > MAX_LEGEND_CHARS)
00725 LegendStr = pDocUnitList->GetSpecifier(GridUnits);
00726 SafeAppendString(&LegendStr,LegendUnitMultiplier,FALSE);
00727
00728
00729 INT32 MinorGrats = GridSubDivisions;
00730 if (GratFreq>1)
00731 MinorGrats = GratFreq;
00732 double MinorGratStepSize = VisibleGratStepSize/MinorGrats;
00733
00734
00735 INT32 MinorGratFreq = 1;
00736 if (MinorGratStepSize<MinGratSpacing)
00737 {
00738
00739 MinorGratFreq = (INT32)ceil(MinGratSpacing/MinorGratStepSize);
00740 while (MinorGratFreq<MinorGrats && fmod((double)MinorGrats,(double)MinorGratFreq)!=0)
00741 MinorGratFreq+=1;
00742 if (MinorGratFreq>MinorGrats)
00743 MinorGratFreq=MinorGrats;
00744 }
00745 INT32 VisibleMinorGrats = MinorGrats/MinorGratFreq;
00746 double VisibleMinorGratStepSize = VisibleGratStepSize/VisibleMinorGrats;
00747
00748
00749 RedrawData.GratUnitSize = GratUnitSize;
00750 RedrawData.MinorGrats = VisibleMinorGrats;
00751 RedrawData.MinorGratStepSize = VisibleMinorGratStepSize;
00752 RedrawData.GratStep = VisibleGratStep;
00753 RedrawData.GratStepSize = VisibleGratStepSize;
00754 RedrawData.PasteBoardUserRect = PasteBoardUserRect;
00755 RedrawData.ScaleFactor = ScaleFactor;
00756 RedrawData.LegendStr = LegendStr;
00757
00758 return TRUE;
00759 }
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 MsgResult RulerPair::Message(Msg* pMsg)
00773 {
00774 ERROR2IF( pMsg==NULL,FAIL,"RulerPair::Message() - pMsg==NULL");
00775 if (pDocView==NULL)
00776 {
00777
00778 return OK;
00779 }
00780
00781 Document* pDoc=pDocView->GetDoc();
00782 ERROR2IF(pDoc==NULL,FAIL,"RulerPair::Message() - pDoc==NULL");
00783 BOOL ok=TRUE;
00784
00785
00786
00787 if ( MESSAGE_IS_A(pMsg,OptionsChangingMsg) && ((OptionsChangingMsg*)pMsg)->pScopeDoc==pDoc )
00788 {
00789 if ( ((OptionsChangingMsg*)pMsg)->State==OptionsChangingMsg::NEWDEFAULTGRID
00790 || ((OptionsChangingMsg*)pMsg)->State==OptionsChangingMsg::NEWPAGESIZE
00791 || ((OptionsChangingMsg*)pMsg)->State==OptionsChangingMsg::PAGESIZEHASCHANGED
00792 || ((OptionsChangingMsg*)pMsg)->State==OptionsChangingMsg::NEWUNITS )
00793 {
00794 ok=Update();
00795 }
00796 }
00797
00798
00799 if ( MESSAGE_IS_A(pMsg,DocChangingMsg) && ((DocChangingMsg*)pMsg)->pChangingDoc==pDoc
00800 && ((DocChangingMsg*)pMsg)->State==DocChangingMsg::BORNANDSTABLE )
00801 {
00802 pSpread=pDocView->GetVisibleSpread();
00803 ok=Update();
00804 }
00805
00806
00807
00808
00809 if ( MESSAGE_IS_A(pMsg,SpreadMsg) && ((SpreadMsg*)pMsg)->Reason==SpreadMsg::SELCHANGED
00810 && ((SpreadMsg*)pMsg)->pNewSpread!=NULL && ((SpreadMsg*)pMsg)->pNewSpread->FindOwnerDoc()==pDoc
00811 && pSpread!=((SpreadMsg*)pMsg)->pNewSpread )
00812 {
00813 pSpread=((SpreadMsg*)pMsg)->pNewSpread;
00814 ok=Update();
00815 }
00816
00817
00818 if ( MESSAGE_IS_A(pMsg,DocViewMsg) && ((DocViewMsg*)pMsg)->pDocView==pDocView )
00819 {
00820
00821
00822
00823
00824
00825
00826 if ( ((DocViewMsg*)pMsg)->State==DocViewMsg::NEWANDSTABLE )
00827 {
00828 pSpread=pDocView->GetVisibleSpread();
00829 ok=Update();
00830 }
00831 }
00832
00833
00834 if ( MESSAGE_IS_A(pMsg,DocViewMsg) && ((DocViewMsg*)pMsg)->State==DocViewMsg::SELCHANGED
00835 && ((DocViewMsg*)pMsg)->pOldDocView==pDocView )
00836 {
00837 UpdateMouseFollowers(NULL);
00838 }
00839
00840 return ok ? OK : FAIL;
00841 }
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853 BOOL RulerPair::Update()
00854 {
00855 if (pSpread!=NULL)
00856 UpdateRedrawData();
00857
00858 OILHorizontalRuler* pHOilRuler=(OILHorizontalRuler*)HRuler.GetpOILRuler();
00859 ERROR2IF(pHOilRuler==NULL,FALSE,"RulerPair::Update() - pHOilRuler==NULL");
00860 pHOilRuler->SetLegendText(&RedrawData.LegendStr);
00861 pHOilRuler->UpdateRuler();
00862
00863 OILVerticalRuler* pVOilRuler=(OILVerticalRuler*)VRuler.GetpOILRuler();
00864 ERROR2IF(pVOilRuler==NULL,FALSE,"RulerPair::Update() - pVOilRuler==NULL");
00865 pVOilRuler->UpdateRuler();
00866
00867 return TRUE;
00868 }
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882 BOOL RulerPair::UpdateMouseFollowers(DocCoord* pDocCoord)
00883 {
00884 ERROR2IF(pDocView==NULL,FALSE,"RulerPair::UpdateMouseFollowers() - pDocView==NULL");
00885 ERROR2IF( pSpread==NULL,FALSE,"RulerPair::UpdateMouseFollowers() - pSpread==NULL");
00886
00887
00888 BOOL NewVisibility = (pDocCoord!=NULL);
00889 DocCoord NewPos = pDocCoord!=NULL ? *pDocCoord : DocCoord(0,0);
00890 DocCoord OldPos = GetMouseFollowerPosition();
00891 BOOL OldVisibility = GetMouseFollowerVisibility();
00892
00893
00894 if (NewVisibility==FALSE && OldVisibility==FALSE)
00895 return TRUE;
00896 if (NewVisibility==TRUE && OldVisibility==TRUE && NewPos==OldPos)
00897 return TRUE;
00898
00899
00900 OILHorizontalRuler* pHOILRuler = (OILHorizontalRuler*)HRuler.GetpOILRuler();
00901 OILVerticalRuler* pVOILRuler = (OILVerticalRuler*)VRuler.GetpOILRuler();
00902 ERROR2IF(pHOILRuler==NULL,FALSE,"RulerPair::UpdateMouseFollowers() - pOILHRuler==NULL");
00903 ERROR2IF(pVOILRuler==NULL,FALSE,"RulerPair::UpdateMouseFollowers() - pOILVRuler==NULL");
00904
00905
00906 if (OldVisibility==TRUE)
00907 {
00908 OilCoord OldOilPos = OldPos.ToOil(pSpread,pDocView);
00909 pHOILRuler->PaintMouseFollower(OldOilPos, pDocView, RenderOff);
00910 pVOILRuler->PaintMouseFollower(OldOilPos, pDocView, RenderOff);
00911 }
00912
00913
00914 if (NewVisibility==TRUE)
00915 {
00916 OilCoord NewOilPos = NewPos.ToOil(pSpread,pDocView);
00917 pHOILRuler->PaintMouseFollower(NewOilPos, pDocView, RenderOn);
00918 pVOILRuler->PaintMouseFollower(NewOilPos, pDocView, RenderOn);
00919 }
00920
00921
00922 MouseFollowerVisibility = NewVisibility;
00923 MouseFollowerPosition = NewPos;
00924
00925 return TRUE;
00926 }
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941 BOOL RulerPair::GetStatusLineText(String_256* pText, WinCoord MousePos, CWindowID hWnd)
00942 {
00943 ERROR2IF(pText==NULL,FALSE,"RulerPair::GetStatusLineText() - pText==NULL");
00944
00945
00946 OriginGadget* pOriginGadget = GetpOriginGadget();
00947 OILVerticalRuler* pOilVRuler = (OILVerticalRuler*) GetpVerticalRuler()->GetpOILRuler();
00948 OILHorizontalRuler* pOilHRuler = (OILHorizontalRuler*)GetpHorizontalRuler()->GetpOILRuler();
00949 ERROR2IF(pOriginGadget==NULL,FALSE,"RulerPair::GetStatusLineText() - pOriginGadget==NULL");
00950 ERROR2IF( pOilVRuler==NULL,FALSE,"RulerPair::GetStatusLineText() - pOilVRuler==NULL");
00951 ERROR2IF( pOilHRuler==NULL,FALSE,"RulerPair::GetStatusLineText() - pOilHRuler==NULL");
00952
00953 LegendLabel* pLegendLabel = pOilHRuler->GetpLegendLabel();
00954 ERROR2IF(pLegendLabel==NULL,FALSE,"RulerPair::GetStatusLineText() - pLegendLabel==NULL");
00955
00956 BOOL valid=FALSE;
00957 if (!valid) valid = pOilVRuler->GetStatusLineText(pText, MousePos, hWnd);
00958 if (!valid) valid = pOilHRuler->GetStatusLineText(pText, MousePos, hWnd);
00959 if (!valid) valid = pLegendLabel->GetStatusLineText(pText, MousePos, hWnd);
00960 if (!valid) valid = pOriginGadget->GetStatusLineText(pText, MousePos, hWnd);
00961
00962 return valid;
00963 }
00964
00965
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978 BOOL RulerContextMenu::Build()
00979 {
00980 BOOL ok = TRUE;
00981 ok = ok && BuildCommand(OPTOKEN_DELETEALLGUIDELINES,TRUE);
00982 ok = ok && BuildCommand(OPTOKEN_NEWGUIDELINEPROPDLG);
00983 ok = ok && BuildCommand(OPTOKEN_GUIDEPROPERTIESDLG);
00984 ok = ok && BuildCommand(OPTOKEN_GRIDANDRULERSDLG);
00985
00986 return ok;
00987 }
00988
00989
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002 BOOL OriginContextMenu::Build()
01003 {
01004 BOOL ok = TRUE;
01005 ok = ok && BuildCommand(OPTOKEN_RESETSPREADORIGIN,TRUE);
01006 ok = ok && BuildCommand(OPTOKEN_GRIDANDRULERSDLG);
01007
01008 return ok;
01009 }
01010
01011 #endif // WEBSTER == 0