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 #include "csrstack.h"
00106 #include "camelot.h"
00107 #include "statline.h"
00108
00109 #include "optsmsgs.h"
00110
00111
00112
00113
00114
00115
00116 #include "ccolbar.h"
00117
00118 #include "basebar.h"
00119 #include "colpick.h"
00120 #include "rulers.h"
00121
00122
00123
00124
00125
00126
00127
00128 #include "colcontx.h"
00129 #include "colormgr.h"
00130 #include "opimgset.h"
00131 #include "camview.h"
00132 #include "prncamvw.h"
00133
00134 DECLARE_SOURCE("$Revision: 1404 $");
00135
00136 CC_IMPLEMENT_DYNCREATE(StatusLine, StandardBar);
00137
00138 #define new CAM_DEBUG_NEW
00139
00140
00141 const String_8 SelDescSuffix(_T(":: "));
00142 const String_8 TruncChar(_T(";"));
00143 const INT32 TextDelay =1000;
00144 const INT32 RenderDelay=200;
00145
00146
00147
00148 String_256 StatusLine::m_strPrefix(_T(""));
00149 BOOL StatusLine::restrictStatusLineFunctionsToColourPicker = FALSE;
00150 BOOL StatusLine::DoControlHelp = TRUE;
00151 StatusLine * StatusLine::s_pStatusLine = NULL;
00152
00153
00154 static UINT32 RenderAnimation[] = { _R(IDB_SL_REND1), _R(IDB_SL_REND2), _R(IDB_SL_REND3) };
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 StatusLine::StatusLine() : m_Timer(this)
00209 {
00210
00211 OldMemory=0;
00212 MousePosDP=2;
00213 TextTimer.Sample();
00214 RenderTimer.Sample();
00215 RenderAnimationState=0;
00216 MousePosNeedsUpdatingFlag=TRUE;
00217 MousePosPaneNeedsResizing=TRUE;
00218
00219
00220
00221 pSnappedCursor = new Cursor(_R(IDCSR_SNAPPED));
00222 SnappedCursorID = 0;
00223
00224 JobDescription=NULL;
00225 CurrentPercent=-1;
00226 ProgressShown=FALSE;
00227
00228 GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_LOW, this);
00229 }
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 StatusLine::~StatusLine()
00241 {
00242 if (pSnappedCursor != NULL)
00243 {
00244 delete pSnappedCursor;
00245 pSnappedCursor = NULL;
00246 }
00247
00248 if (JobDescription != NULL)
00249 {
00250 delete JobDescription;
00251 JobDescription = NULL;
00252 }
00253
00254 if (this == s_pStatusLine)
00255 {
00256
00257
00258 s_pStatusLine = NULL;
00259 }
00260
00261 GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_LOW, this);
00262 }
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 BOOL StatusLine::OnIdleEvent()
00282 {
00283 if (PrintMonitor::IsPrintingNow())
00284 return FALSE;
00285
00286
00287 if (!m_Timer.IsRunning())
00288 {
00289
00290
00291
00292 if (DocView::GetSelected() == NULL)
00293 return FALSE;
00294
00295
00296 #ifndef STANDALONE
00297
00298 if (MousePosPaneNeedsResizing)
00299 {
00300 MousePosPaneNeedsResizing=FALSE;
00301 Spread* pSpread=Document::GetSelectedSpread();
00302 if (pSpread)
00303 {
00304 SetMousePosPaneWidth(pSpread);
00305 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
00306 #ifndef EXCLUDE_FROM_XARALX
00307 if (pCCStatusBar->PaneState(_R(IDS_SL_MOUSEPOS),Enable)==Fail)
00308 ReturnValue=FALSE;
00309 #endif
00310 }
00311 }
00312 #endif
00313
00314 RefreshHelpText();
00315
00316 #ifdef _STATUSLINE_MEMORYPANE
00317
00318 MEMORYSTATUS MemState;
00319 MemState.dwLength=sizeof(MEMORYSTATUS);
00320 GlobalMemoryStatus(&MemState);
00321 INT32 Memory=MemState.dwAvailPhys;
00322 BOOL MemoryChanged=(OldMemory!=Memory);
00323 OldMemory=Memory;
00324
00325 if (MemoryChanged)
00326 {
00327
00328
00329 String_256 StrBuf(TEXT(""));
00330 camSnprintf(StrBuf, 256, TEXT("%dK"), Memory / 1024);
00331 if (StrBuf.Length()>4)
00332 StrBuf.Insert(&String_8(TEXT(",")),StrBuf.Length()-4);
00333 BOOL ok = SetStringGadgetValue(_R(IDS_SL_MEMORY),StrBuf);
00334 if (ok)
00335 PaintGadgetNow(_R(IDS_SL_MEMORY))
00336 else
00337 ReturnValue=FALSE;
00338 }
00339 #endif // _STATUSLINE_MEMORYPANE
00340
00341
00342 SetNeedsUpdate();
00343 }
00344
00345
00346 return FALSE;
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 void StatusLine::SetNeedsUpdate(BOOL Immediate )
00361 {
00362 if (Immediate)
00363 {
00364
00365 m_Timer.Stop();
00366 OnTimer();
00367 return;
00368 }
00369
00370 m_Timer.Start(1000, TRUE);
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 BOOL StatusLine::RefreshHelpText()
00386 {
00387
00388 if (Operation::GetCurrentDragOp())
00389 return TRUE;
00390
00391 BOOL ReturnValue=TRUE;
00392 BOOL PrefixSelDesc=STATUSLINE_SELDESC_DEFAULT;
00393 String_256 text(_T(""));
00394 BOOL TextValid=FALSE;
00395
00396
00397
00398
00399 if (IsRestrictedAccessToColourPicker () == TRUE)
00400 {
00401 return (TRUE);
00402 }
00403
00404 if (!TextValid)
00405 {
00406 TextValid=BaseBar::GetStatusLineText(&text);
00407 if (TextValid)
00408 PrefixSelDesc=STATUSLINE_SELDESC_BARDRAG;
00409 }
00410
00411 WinCoord WndPos(0,0);
00412 CWindowID WinID=DialogManager::GetWindowUnderPointer(&WndPos);
00413 DocView* pDocView=NULL;
00414 Spread* pSpread=NULL;
00415 DocCoord DocPos(0,0);
00416
00417
00418
00419 if (!TextValid && Document::GetCurrent()!=NULL)
00420 {
00421
00422 if (WinID != NULL)
00423 pDocView=CCamView::GetDocViewFromWindowID(WinID);
00424
00425 if (pDocView != NULL)
00426 {
00427 OilCoord OilPos = WndPos.ToOil(pDocView, TRUE);
00428 pSpread = pDocView->OilToSpreadCoord(OilPos, &DocPos);
00429 }
00430 }
00431
00432
00433 if (!TextValid)
00434 {
00435 Operation* pDragOp=Operation::GetCurrentDragOp();
00436 if (pDragOp)
00437 {
00438 TextValid=pDragOp->GetStatusLineText(&text,pSpread,DocPos,ClickModifiers::GetClickModifiers());
00439 ERROR3IF(!TextValid,"StatusLine::RefreshHelpText() - pDragOp->GetStatusLineText() failed");
00440 PrefixSelDesc=STATUSLINE_SELDESC_DRAGOPS;
00441
00442 if (!TextValid)
00443 {
00444 text=_T("");
00445 TextValid=TRUE;
00446 }
00447 }
00448 }
00449
00450
00451 if (!TextValid)
00452 {
00453 BOOL OverSelectedDoc=FALSE;
00454 if (pDocView)
00455 {
00456 if (pDocView==DocView::GetSelected())
00457 {
00458 OverSelectedDoc=TRUE;
00459 Tool* pTool=Tool::GetCurrent();
00460 ERROR3IF(pTool==NULL,"StatusLine::RefreshHelpText() - no selected tool");
00461 if (pTool)
00462 {
00463 TextValid=pTool->GetStatusLineText(&text,pSpread,DocPos,ClickModifiers::GetClickModifiers());
00464 if (TextValid)
00465 PrefixSelDesc=STATUSLINE_SELDESC_SELDOC;
00466 }
00467 else
00468 ReturnValue=FALSE;
00469 }
00470 else
00471 {
00472 TextValid=text.Load(_R(IDS_CLICKHERETOSELECTDOC));
00473 if (!TextValid)
00474 ReturnValue=FALSE;
00475 else
00476 PrefixSelDesc=STATUSLINE_SELDESC_OTHERDOC;
00477 }
00478 }
00479
00480 PORTNOTE("statline", "Removed use of ControlHelper")
00481 #if !defined(EXCLUDE_FROM_XARALX)
00482 if (!TextValid)
00483 {
00484 TextValid=ControlHelper::GetStatusLineText(&text,WinID);
00485 if (TextValid)
00486 PrefixSelDesc=STATUSLINE_SELDESC_BUTTONS;
00487 }
00488 #endif
00489
00490 if (!TextValid)
00491 {
00492 TextValid=DialogManager::GetStatusLineText(&text,NULL);
00493 if (TextValid)
00494 PrefixSelDesc=STATUSLINE_SELDESC_BUTTONS;
00495 }
00496
00497 #ifndef STANDALONE
00498 if (!TextValid)
00499 {
00500 TextValid=CColourBar::GetStatusLineText(&text);
00501 if (TextValid)
00502 PrefixSelDesc=STATUSLINE_SELDESC_COLBAR;
00503 }
00504
00505 if (!TextValid)
00506 {
00507 TextValid=ColourPicker::GetStatusLineText(&text);
00508 if (TextValid)
00509 PrefixSelDesc=STATUSLINE_SELDESC_COLBAR;
00510 }
00511
00512 #endif //STANDALONE
00513
00514 PORTNOTE("StatusLine", "Removed use of PreviewDlg")
00515 #ifndef EXCLUDE_FROM_XARALX
00516 if (!TextValid)
00517 {
00518 TextValid=PreviewDialog::GetStatusLineText(&text);
00519 if (TextValid)
00520 PrefixSelDesc=STATUSLINE_SELDESC_PREVIEWDLG;
00521 }
00522 #endif
00523
00524
00525
00526 PORTNOTE("StatusLine", "Removed use of Rulers")
00527 #ifndef EXCLUDE_FROM_XARALX
00528 #ifndef WEBSTER
00529 if (!TextValid)
00530 {
00531 DocView* pDocView = DocView::GetSelected();
00532 RulerPair* pRulerPair = NULL;
00533 if (pDocView!=NULL)
00534 pRulerPair = pDocView->GetpRulerPair();
00535 if (pRulerPair!=NULL)
00536 TextValid = pRulerPair->GetStatusLineText(&text,WndPos,WinID);
00537 if (TextValid)
00538 PrefixSelDesc=STATUSLINE_SELDESC_STATBAR;
00539 }
00540 #endif // WEBSTER
00541 #endif
00542
00543 PORTNOTE("StatusLine", "Removed use of Galleries")
00544 #ifndef EXCLUDE_FROM_XARALX
00545 #ifndef EXCLUDE_GALS
00546 if (!TextValid && WinID!=NULL)
00547 {
00548
00549
00550 CWindowID ParentWnd = ::GetParent(WinID);
00551 if (ParentWnd != NULL)
00552 {
00553 DialogBarOp* pBar = DialogBarOp::FindDialogBarOp((UINT32)ParentWnd);
00554 if (pBar != NULL && pBar->IS_KIND_OF(SuperGallery))
00555 {
00556 CRect TargetRect;
00557 ::GetWindowRect(WinID, &TargetRect);
00558
00559
00560 INT32 DPI = 96;
00561 HDC ScreenDC = CreateCompatibleDC(NULL);
00562 if (ScreenDC == NULL)
00563 ERROR2(FALSE, "Unable to create screen DC");
00564 DPI = GetDeviceCaps(ScreenDC, LOGPIXELSY);
00565 DeleteDC(ScreenDC);
00566
00567 INT32 WindowHeight = TargetRect.Height();
00568
00569 DocCoord KernelMousePos;
00570 KernelMousePos.x = ((WndPos.x) * 72000) / DPI;
00571 KernelMousePos.y = ((WindowHeight - WndPos.y) * 72000) / DPI;
00572
00573 TextValid = ((SuperGallery*)pBar)->GetStatusLineHelp(&KernelMousePos, &text);
00574 if (TextValid)
00575 PrefixSelDesc=STATUSLINE_SELDESC_STATBAR;
00576 }
00577 }
00578 }
00579 #endif
00580 #endif
00581
00582 #ifndef STANDALONE
00583
00584 if (!OverSelectedDoc)
00585 if (UpdateMousePosAndSnap(NULL,NULL,pDocView,FALSE)==FALSE)
00586 ReturnValue=FALSE;
00587 #endif
00588 }
00589
00590
00591 if (!TextValid)
00592 text=_T("");
00593 if (!UpdateText(&text,PrefixSelDesc))
00594 ReturnValue=FALSE;
00595
00596 return ReturnValue;
00597 }
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614 void StatusLine::SetPrefix(const StringBase& str)
00615 {
00616 m_strPrefix = str;
00617 }
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630 void StatusLine::SetDefaultPrefix()
00631 {
00632 m_strPrefix.Empty();
00633 }
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646 INT32 StatusLine::GetPrefixWidth()
00647 {
00648 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
00649 #ifndef EXCLUDE_FROM_XARALX
00650 CCStatusBar* pb = GetApplication()->GetpCCStatusBar();
00651 return pb && !m_strPrefix.IsEmpty() ? 4 + pb->GetTextWidth(&m_strPrefix, TRUE) : 0;
00652 #else
00653 return 0;
00654 #endif
00655 }
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670 BOOL StatusLine::RestrictStatusLineFunctionsToColourPicker (CWindowID colourPicker)
00671 {
00672
00673
00674 PORTNOTE("StatusLine", "Removed use of ColourPicker")
00675 #ifndef EXCLUDE_FROM_XARALX
00676 String_256 ClassNameStr;
00677
00678
00679 GetClassName (colourPicker, (TCHAR*) ClassNameStr, 255);
00680
00681 if (ClassNameStr == String_8(TEXT("cc_colPicker")))
00682 {
00683
00684
00685 restrictStatusLineFunctionsToColourPicker = TRUE;
00686 return (TRUE);
00687
00688 }
00689
00690 ENSURE(FALSE, "RestrictStatusLineFunctionsToColourPicker called for invalid colour picker control");
00691 #endif
00692 return (FALSE);
00693 }
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708 BOOL StatusLine::RestoreStatusLineFunctions (CWindowID colourPicker)
00709 {
00710
00711
00712 PORTNOTE("StatusLine", "Removed use of ColourPicker")
00713 #ifndef EXCLUDE_FROM_XARALX
00714 String_256 ClassNameStr;
00715
00716
00717 GetClassName (colourPicker, (TCHAR*) ClassNameStr, 255);
00718
00719 if (ClassNameStr == String_8(TEXT("cc_colPicker")))
00720 {
00721
00722
00723 restrictStatusLineFunctionsToColourPicker = FALSE;
00724 return (TRUE);
00725
00726 }
00727
00728 ENSURE(FALSE, "RestoreStatusLineFunctions called for invalid colour picker control");
00729 #endif
00730 return (FALSE);
00731 }
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753 extern BOOL SafeAppendString(StringBase*, const StringBase&, BOOL = TRUE);
00754
00755 BOOL StatusLine::UpdateText(String_256* pText, BOOL PrefixSelDesc)
00756 {
00757
00758
00759 #ifdef STANDALONE
00760 PrefixSelDesc = FALSE;
00761 #endif
00762
00763
00764 String_256 text("");
00765 SelRange* pSelection = 0;
00766
00767 if (m_strPrefix.IsEmpty())
00768 {
00769 if (PrefixSelDesc)
00770 {
00771
00772
00773
00774
00775 pSelection = GetApplication()->FindSelection();
00776
00777 if (pSelection) text = pSelection->Describe(STATUS_BAR);
00778 }
00779 }
00780 else
00781 {
00782
00783 text = m_strPrefix;
00784 }
00785
00786 if (text.Length()>0) SafeAppendString(&text, SelDescSuffix, FALSE);
00787 if (pText) SafeAppendString(&text, *pText, FALSE);
00788
00789
00790 TextTimer.Sample();
00791
00792 if ((IsRestrictedAccessToColourPicker () == FALSE) && (DoControlHelp == TRUE))
00793 {
00794 return SetStatusText(text);
00795 }
00796 else
00797 {
00798 return (TRUE);
00799 }
00800
00801 return FALSE;
00802 }
00803
00804 BOOL StatusLine::UpdateTextForColourPicker(String_256* pText, BOOL PrefixSelDesc)
00805 {
00806
00807
00808 #ifdef STANDALONE
00809 PrefixSelDesc = FALSE;
00810 #endif
00811
00812 ERROR2IF(restrictStatusLineFunctionsToColourPicker==FALSE,FALSE,"StatusLine::UpdateColourPickerText() - require TRUE to use this function!");
00813
00814
00815 String_256 text("");
00816 SelRange* pSelection = 0;
00817
00818 RangeControl rg;
00819
00820 if (m_strPrefix.IsEmpty())
00821 {
00822 if (PrefixSelDesc)
00823 {
00824
00825
00826
00827
00828 pSelection = GetApplication()->FindSelection();
00829
00830 if (pSelection) text = pSelection->Describe(STATUS_BAR);
00831 }
00832 }
00833 else
00834 {
00835
00836 text = m_strPrefix;
00837 }
00838
00839 if (text.Length()>0) SafeAppendString(&text, SelDescSuffix, FALSE);
00840 if (pText) SafeAppendString(&text, *pText, FALSE);
00841
00842
00843 TextTimer.Sample();
00844
00845 return SetStatusText(text);
00846 }
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865 BOOL StatusLine::TruncateTextToWidth(String_256* pText, INT32 width)
00866 {
00867 ERROR2IF( pText==NULL,FALSE,"StatusLine::TruncateTextToPane() - pText==NULL");
00868
00869
00870
00871 INT32 LastTruncPoint=pText->Length();
00872 String_256 text("");
00873
00874 INT32 TruncPoint=pText->Sub(SelDescSuffix);
00875 if (TruncPoint==-1)
00876 TruncPoint=pText->Length();
00877 else
00878 TruncPoint+=SelDescSuffix.Length();
00879 pText->Left(&text,TruncPoint);
00880
00881 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
00882 #ifndef EXCLUDE_FROM_XARALX
00883 INT32 TextWidth=0;
00884 while ((TextWidth=pCCStatusBar->GetTextWidth(&text))<=width)
00885 {
00886 ERROR2IF(TextWidth==-1,FALSE,"StatusLine::TruncateTextToPane() - pCCStatusBar->GetTextWidth() failed");
00887 LastTruncPoint=TruncPoint;
00888 if (LastTruncPoint==pText->Length())
00889 break;
00890 TruncPoint=pText->Sub(TruncChar,LastTruncPoint+1);
00891 if (TruncPoint==-1)
00892 TruncPoint=pText->Length();
00893 pText->Left(&text,TruncPoint);
00894 }
00895 #endif
00896
00897 pText->Left(pText,LastTruncPoint);
00898
00899 return TRUE;
00900 }
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918 BOOL StatusLine::GetMousePosText(String_256* pText, DocCoord MousePos, Spread* pSpread, INT32 dp)
00919 {
00920 ERROR2IF( pText==NULL,FALSE,"StatusLine::GetMousePosText() - pText==NULL");
00921 ERROR2IF( pSpread==NULL,FALSE,"StatusLine::GetMousePosText() - pSpread==NULL");
00922
00923 if (dp == -1)
00924 dp = MousePosDP;
00925
00926 String_256 yPos("");
00927 if (pSpread->SpreadCoordToText(pText,&yPos,MousePos,FALSE,TRUE,dp)==FALSE)
00928 return FALSE;
00929
00930 *pText+=String_64(_R(IDS_K_STATLINE_POSITIONSEP));
00931 *pText+=yPos;
00932 return TRUE;
00933 }
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954 BOOL StatusLine::SetMousePosPaneWidth(Spread* pSpread)
00955 {
00956 ERROR2IF( pSpread==NULL,FALSE,"StatusLine::SetMousePosPaneWidth() - pSpread==NULL");
00957
00958
00959 INT32 dp=2;
00960 INT32 ReturnValue=TRUE;
00961 if (pSpread->GetDecimalPlacesForPixelResolution(DocView::GetSelected(), &dp))
00962 MousePosDP=dp;
00963 else
00964 ReturnValue=FALSE;
00965
00966
00967 DocRect PasteRect=pSpread->GetPasteboardRect();
00968 DocCoord PasteSize(PasteRect.Width(),PasteRect.Height());
00969
00970
00971 String_256 MousePosText("");
00972 if (GetMousePosText(&MousePosText,DocCoord(0,0),pSpread,0)==FALSE)
00973 return FALSE;
00974
00975 String_256 DPSChar(_R(IDS_CONVERT_DP_CHAR));
00976
00977 String_256 ZeroChar(_R(IDS_CONVERT_ZERO_CHAR));
00978
00979 INT32 i;
00980 for (i=0;i<dp;i++)
00981 {
00982 MousePosText += ZeroChar;
00983 MousePosText += ZeroChar;
00984
00985 }
00986
00987 MousePosText += DPSChar;
00988 MousePosText += DPSChar;
00989
00990 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
00991 #ifndef EXCLUDE_FROM_XARALX
00992 INT32 MinCoordTextWidth=pCCStatusBar->GetTextWidth(&MousePosText);
00993 #else
00994 INT32 MinCoordTextWidth=100;
00995 #endif
00996
00997 if (MinCoordTextWidth==-1)
00998 return FALSE;
00999
01000
01001 if (GetMousePosText(&MousePosText,PasteSize,pSpread,0)==FALSE)
01002 return FALSE;
01003
01004 for (i=0;i<dp;i++)
01005 {
01006 MousePosText += ZeroChar;
01007 MousePosText += ZeroChar;
01008 }
01009
01010 MousePosText += DPSChar;
01011 MousePosText += DPSChar;
01012
01013 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
01014 #ifndef EXCLUDE_FROM_XARALX
01015 INT32 MaxCoordTextWidth=pCCStatusBar->GetTextWidth(&MousePosText) ;
01016 #else
01017 INT32 MaxCoordTextWidth=100;
01018 #endif
01019
01020 if (MaxCoordTextWidth==-1)
01021 return FALSE;
01022
01023
01024 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
01025 #ifndef EXCLUDE_FROM_XARALX
01026 INT32 TextWidth = max(MaxCoordTextWidth,MinCoordTextWidth);
01027 if (pCCStatusBar->SetPaneWidth(TextWidth,_R(IDS_SL_MOUSEPOS))==FALSE)
01028 return FALSE;
01029 #endif
01030 return ReturnValue;
01031 }
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044 MsgResult StatusLine::Message(Msg* pMsg)
01045 {
01046
01047 ERROR2IF( pMsg==NULL,FAIL,"StatusLine::Message() - pMsg==NULL");
01048
01049 if (IS_OUR_DIALOG_MSG(pMsg))
01050 {
01051 DialogMsg* Msg = (DialogMsg*)pMsg;
01052
01053 switch(Msg->DlgMsg)
01054 {
01055 case DIM_CREATE:
01056 {
01057 if (s_pStatusLine)
01058 {
01059 ERROR3("Two status lines - that isn't meant to happen");
01060 delete s_pStatusLine;
01061 }
01062 s_pStatusLine = this;
01063 SetGadgetBitmap(_R(IDB_SL_SNAP), _R(IDB_SL_SNAPN));
01064 nobreak;
01065 }
01066 case DIM_DLG_RESIZED:
01067 {
01068 if (!ProgressShown)
01069 {
01070
01071 HideGadget(_R(IDC_SL_PROGRESSGAUGE), FALSE);
01072 HideGadget(_R(IDC_SL_PROGRESSPERCENT), FALSE);
01073 Layout();
01074 HideGadget(_R(IDC_SL_PROGRESSGAUGE), !ProgressShown);
01075 HideGadget(_R(IDC_SL_PROGRESSPERCENT), !ProgressShown);
01076 }
01077 break;
01078 }
01079 default:
01080 break;
01081
01082 }
01083
01084 }
01085
01086
01087
01088
01089 if (MESSAGE_IS_A(pMsg,OptionsChangingMsg)
01090 || MESSAGE_IS_A(pMsg,DocChangingMsg) && ((DocChangingMsg*)pMsg)->State==DocChangingMsg::SELCHANGED
01091 || MESSAGE_IS_A(pMsg,DocViewMsg) && ((DocViewMsg*)pMsg)->State==DocViewMsg::SCALECHANGED)
01092 MousePosPaneNeedsResizing=TRUE;
01093
01094
01095 if (MESSAGE_IS_A(pMsg,DocChangingMsg) && ((DocChangingMsg*)pMsg)->State==DocChangingMsg::SELCHANGED)
01096 {
01097
01098 MousePosPaneNeedsResizing=TRUE;
01099 }
01100
01101 if (MESSAGE_IS_A(pMsg, DocViewMsg) && ((DocViewMsg*)pMsg)->State==DocViewMsg::SELCHANGED)
01102 {
01103 CCamFrame* pMainFrame = GetMainFrame();
01104 if (pMainFrame)
01105 {
01106 DocView* pView = ((DocViewMsg*)pMsg)->pNewDocView;
01107 BOOL bState = TRUE;
01108 String_256 sPlateName;
01109 if (pView)
01110 {
01111 ColourPlateType PlateType = COLOURPLATE_NONE;
01112 ColourContext *cc = pView->GetColourContext(COLOURMODEL_RGBT);
01113 if (cc && cc->GetColourPlate())
01114 {
01115 PlateType = cc->GetColourPlate()->GetType();
01116 }
01117
01118 switch (PlateType)
01119 {
01120 case COLOURPLATE_CYAN:
01121 sPlateName.Load(_R(IDS_PLATENAME_CYAN));
01122 break;
01123
01124 case COLOURPLATE_MAGENTA:
01125 sPlateName.Load(_R(IDS_PLATENAME_MAGENTA));
01126 break;
01127
01128 case COLOURPLATE_YELLOW:
01129 sPlateName.Load(_R(IDS_PLATENAME_YELLOW));
01130 break;
01131
01132 case COLOURPLATE_KEY:
01133 sPlateName.Load(_R(IDS_PLATENAME_KEY));
01134 break;
01135
01136 case COLOURPLATE_COMPOSITE:
01137 sPlateName.Load(_R(IDS_PLATENAME_COMPOSITE));
01138 break;
01139
01140 case COLOURPLATE_SPOT:
01141 {
01142 IndexedColour* pSpotColour = cc->GetColourPlate()->GetSpotColour();
01143 if (pSpotColour)
01144 sPlateName = *(pSpotColour->GetName());
01145 }
01146 break;
01147
01148 default:
01149 bState = FALSE;
01150 break;
01151 }
01152 }
01153 else
01154 {
01155 bState = FALSE;
01156 }
01157 PORTNOTE("printing", "Removed SetPrinterColourStatus");
01158 #ifndef EXCLUDE_FROM_XARALX
01159 pMainFrame->SetPrinterColourStatus(bState, &sPlateName);
01160 #endif
01161 }
01162
01163 }
01164
01165 return StandardBar::Message(pMsg);
01166 }
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183 BOOL StatusLine::UpdateMousePosAndSnap(DocCoord* pDocCoord, Spread* pSpread,
01184 DocView* pDocView, BOOL Snapped)
01185 {
01186 #ifndef STANDALONE
01187
01188 if (MousePosPaneNeedsResizing)
01189 return TRUE;
01190
01191 BOOL Blank = (pDocCoord==NULL && pSpread==NULL && Snapped==FALSE);
01192 if (!Blank)
01193 {
01194 ERROR2IF( pSpread==NULL,FALSE,"StatusLine::UpdateMousePosAndSnap() - pSpread==NULL");
01195 ERROR2IF( pDocCoord==NULL,FALSE,"StatusLine::UpdateMousePosAndSnap() - pDocCoord==NULL");
01196 }
01197
01198 BOOL ReturnValue=TRUE;
01199
01200
01201 String_256 MousePosText("");
01202 if (!Blank && GetMousePosText(&MousePosText,*pDocCoord,pSpread)==FALSE)
01203 ReturnValue=FALSE;
01204
01205 if (MousePosText != m_MousePosText)
01206 {
01207 m_MousePosText= MousePosText;
01208
01209 ReturnValue &=SetStringGadgetValue(_R(IDC_SL_MOUSEPOS), MousePosText);
01210
01211 }
01212
01213
01214
01215 #ifndef WEBSTER
01216
01217 DocView* pView = DocView::GetSelected();
01218 if (pView!=NULL)
01219 {
01220 RulerPair* pRulerPair = pView->GetpRulerPair();
01221 if (pRulerPair!=NULL)
01222 ReturnValue = pRulerPair->UpdateMouseFollowers(pDocCoord);
01223 }
01224 #endif // WEBSTER
01225
01226
01227 #ifndef WEBSTER
01228
01229 if (Snapped && (GetGadgetBitmap(_R(IDB_SL_SNAP)) != _R(IDB_SL_SNAP)))
01230 {
01231 SetGadgetBitmap(_R(IDB_SL_SNAP), _R(IDB_SL_SNAP));
01232 PaintGadgetNow(_R(IDB_SL_SNAP));
01233 }
01234 if (!Snapped && (GetGadgetBitmap(_R(IDB_SL_SNAP)) != _R(IDB_SL_SNAPN)))
01235 {
01236 SetGadgetBitmap(_R(IDB_SL_SNAP), _R(IDB_SL_SNAPN));
01237 PaintGadgetNow(_R(IDB_SL_SNAP));
01238 }
01239 #endif
01240
01241
01242
01243 Operation* pDragOp = Operation::GetCurrentDragOp();
01244 if (Snapped && pDragOp!=NULL && pDragOp->SnappingDrag())
01245 {
01246
01247 if (SnappedCursorID==0)
01248 {
01249 SnappedCursorID = CursorStack::GPush(pSnappedCursor);
01250 }
01251 }
01252 else
01253 {
01254
01255 if (SnappedCursorID!=0)
01256 {
01257 CursorStack::GPop(SnappedCursorID);
01258 SnappedCursorID = 0;
01259 }
01260 }
01261
01262
01263 MousePosNeedsUpdatingFlag=FALSE;
01264 return ReturnValue;
01265
01266 #else
01267 return TRUE;
01268 #endif
01269 }
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283 BOOL StatusLine::UpdateSolidDragIndicator(BOOL bSolidAllowed, BOOL bSolid)
01284 {
01285
01286
01287
01288 BOOL ReturnValue=TRUE;
01289
01290
01291 PORTNOTE("StatusLine", "Removed use of CCStatusBar")
01292 #ifndef EXCLUDE_FROM_XARALX
01293 FlagState DragState = pCCStatusBar->PaneState(_R(IDS_SL_SDRAG));
01294 if (bSolid && DragState==Disable)
01295 {
01296 if (pCCStatusBar->PaneState(_R(IDS_SL_SDRAG), Enable)==Fail)
01297 ReturnValue=FALSE;
01298
01299
01300 pCCStatusBar->UpdatePaneBitmap(_R(IDS_SL_SDRAG),0, TRUE);
01301
01302 }
01303 if (!bSolid && DragState!=Disable)
01304 {
01305 if (pCCStatusBar->PaneState(_R(IDS_SL_SDRAG), Disable)==Fail)
01306 ReturnValue=FALSE;
01307
01308
01309 pCCStatusBar->UpdatePaneBitmap(_R(IDS_SL_SDRAG),0, TRUE);
01310 }
01311 #endif
01312
01313 return ReturnValue;
01314 }
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335 BOOL StatusLine::SetRenderIndicator(RenderState Action)
01336 {
01337 INT32 RenderAnimationStates=sizeof(RenderAnimation)/sizeof(UINT32);
01338 UINT32 BitmapID=0;
01339 switch (Action)
01340 {
01341 case NotRendering:
01342 BitmapID=_R(IDB_SL_RENDN);
01343 RenderAnimationState=0;
01344 break;
01345 case Paused:
01346 BitmapID=_R(IDB_SL_RENDP);
01347 break;
01348 case Rendering:
01349 BitmapID=_R(IDB_SL_RENDR);
01350 RenderAnimationState=0;
01351 break;
01352 case Animate:
01353 if (RenderTimer.Elapsed(RenderDelay))
01354 {
01355 if (RenderAnimationState<0 || RenderAnimationState>=RenderAnimationStates)
01356 RenderAnimationState=0;
01357 BitmapID=RenderAnimation[RenderAnimationState++];
01358 }
01359 break;
01360 default: ERROR2(FALSE,"StatusLine::SetRenderIndicator() - Action invalid");
01361 }
01362
01363 if (!BitmapID)
01364 return TRUE;
01365
01366 RenderTimer.Sample();
01367
01368 if (BitmapID == GetGadgetBitmap(_R(IDB_SL_RENDN)))
01369 return TRUE;
01370 SetGadgetBitmap(_R(IDB_SL_RENDN), BitmapID);
01371
01372
01373 return TRUE;
01374 }
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393 BOOL StatusLine::ShowProgress (BOOL Show, StringBase *JobDescrip)
01394 {
01395 BOOL ShowChanged=(Show != ProgressShown);
01396
01397 String_8 EmptyString(_T(""));
01398
01399
01400 if (!JobDescrip)
01401 JobDescrip=&EmptyString;
01402
01403 BOOL StringChanged=!JobDescription || (*JobDescription!=*JobDescrip);
01404
01405
01406 if (!ShowChanged && !StringChanged)
01407 return TRUE;
01408
01409 if (ShowChanged)
01410 {
01411 HideGadget(_R(IDC_SL_PROGRESSGAUGE), !Show);
01412 HideGadget(_R(IDC_SL_PROGRESSPERCENT), !Show);
01413 Layout();
01414 ProgressShown=Show;
01415
01416 CurrentPercent=-1;
01417 SetPercent(0, TRUE, JobDescrip);
01418
01419 return TRUE;
01420 }
01421
01422 return SetPercent(CurrentPercent, StringChanged, StringChanged?JobDescrip:NULL);
01423 }
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451 BOOL StatusLine::SetPercent(INT32 NewPercent, BOOL ClearBackground ,
01452 StringBase *JobDescrip )
01453
01454
01455
01456 {
01457 if (NewPercent < 0) NewPercent = 0;
01458 if (NewPercent > 99) NewPercent = 99;
01459
01460
01461 if (JobDescrip == NULL && NewPercent == CurrentPercent)
01462 return(TRUE);
01463
01464 CurrentPercent = NewPercent;
01465
01466 String_64 PercentString;
01467 PercentString.MakePercent(CurrentPercent);
01468 SetStringGadgetValue(_R(IDC_SL_PROGRESSPERCENT), PercentString);
01469 SetLongGadgetValue(_R(IDC_SL_PROGRESSGAUGE), CurrentPercent);
01470
01471
01472 if (JobDescrip != NULL)
01473 {
01474 delete JobDescription;
01475 JobDescription = new String_256(*JobDescrip);
01476
01477 if (JobDescription)
01478 {
01479 SetStringGadgetValue(_R(IDC_SL_STATUSTEXT), ProgressShown?*JobDescription:StatusText);
01480 }
01481 else
01482 {
01483 SetStringGadgetValue(_R(IDC_SL_STATUSTEXT), ProgressShown?String_256(_T("")):StatusText);
01484 }
01485
01486 InvalidateGadget(0, TRUE);
01487 PaintGadgetNow(0);
01488 }
01489 else
01490 {
01491
01492 InvalidateGadget(_R(IDC_SL_PROGRESSGAUGE), ClearBackground);
01493 InvalidateGadget(_R(IDC_SL_PROGRESSPERCENT), ClearBackground);
01494 PaintGadgetNow(_R(IDC_SL_PROGRESSGAUGE));
01495 PaintGadgetNow(_R(IDC_SL_PROGRESSPERCENT));
01496 }
01497
01498 return(TRUE);
01499 }
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516 BOOL StatusLine::SetStatusText(const String_256 &text)
01517 {
01518 SetNeedsUpdate();
01519
01520 if (StatusText == text)
01521 return TRUE;
01522
01523 StatusText = text;
01524 if (!ProgressShown)
01525 {
01526 TRACEUSER("amb", _T("updating status text"));
01527 BOOL ok=SetStringGadgetValue(_R(IDC_SL_STATUSTEXT), text);
01528
01529 return ok;
01530 }
01531 return TRUE;
01532 }