statline.cpp

Go to the documentation of this file.
00001 // $Id: statline.cpp 1404 2006-07-04 19:57:01Z gerry $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // status line 
00099 
00100 /*
00101 */
00102 
00103 #include "camtypes.h" 
00104 //#include "resource.h" // for _R(IDC_SNAPPED) - 'snappped' mouse pointer
00105 #include "csrstack.h"
00106 #include "camelot.h"
00107 #include "statline.h"
00108 //#include "ctrlhelp.h"
00109 #include "optsmsgs.h"
00110 //#include "scrvw.h"
00111 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "cstatbar.h"
00116 #include "ccolbar.h"
00117 //#include "document.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00118 #include "basebar.h"
00119 #include "colpick.h"
00120 #include "rulers.h"
00121 //#include "spread.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 
00123 //#include "bars.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00124 //#include "sgallery.h"
00125 
00126 //#include "prevwdlg.h"
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 // constants ...
00141 const String_8 SelDescSuffix(_T(":: "));
00142 const String_8 TruncChar(_T(";"));
00143 const INT32      TextDelay  =1000;          // milisecond
00144 const INT32      RenderDelay=200;           // milisecond
00145 
00146 //void FixFPControlRegister();
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 // render pane animation (could be in statline.cpp but kept here next to pane defn)
00154 static UINT32 RenderAnimation[] = { _R(IDB_SL_REND1), _R(IDB_SL_REND2), _R(IDB_SL_REND3) };
00155 
00156 /*
00157 
00158 Timer mechanism and the status line
00159 ===================================
00160 
00161 Working out the status line text is actually reasonably expensive, especially
00162 given some of the arcane lengths we go to to get it. Painting it is
00163 even more expensive. And doing an Update() on it to ensure it paints
00164 immediately yet more so. The thing this interferes with the most is
00165 typing in the text tool.
00166 
00167 So we use the following algortithm:
00168 
00169 We set a timer to go off every 250ms. This is the idle timer. A little
00170 confusingly it is a one-shot timer, but bear with me.
00171 
00172 If something happens that requires a status line update (or is likely
00173 to) it calls StatusLine::NeedsUpdate(). By default what this does is
00174 reset the timer (so it won't go off for another 250ms). However
00175 it is possible to force an 'immediate' update (actually on the
00176 next idle event) by calling NeedsUpdate(TRUE) which simulates
00177 an immediate timer expiry.
00178 
00179 When the timer expires (whether or not NeedsUpdate() has been called),
00180 it signals to the idle event handler for the DialogOp at the lowest
00181 possible priority. This ensures all rendering etc. will have finished.
00182 
00183 When the idle event is received, it checks to see if NeedsUpdate()
00184 has been called in the interim (i.e. if the timer is running). If
00185 the timer is running, the idle event handler returns saying it wants
00186 no more idles. If not, it attempts to process the status line text.
00187 
00188 If the status line text has changed, it sets the new text (immediately)
00189 but only invalidates it (i.e. does not do an update).
00190 
00191 Whether or not the text changed, it then sets the timer off again
00192 by calling NeedsUpdate().
00193 
00194 
00195 */
00196 
00197 
00198 
00199 
00200 /*****************************************************************************
00201 >   StatusLine::StatusLine()
00202 
00203     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00204     Created:    15/11/94
00205     Purpose:    Constructor for StatusLine
00206 *****************************************************************************/
00207 
00208 StatusLine::StatusLine() : m_Timer(this)
00209 {
00210     // ensure initial updates
00211     OldMemory=0;
00212     MousePosDP=2;
00213     TextTimer.Sample();
00214     RenderTimer.Sample();
00215     RenderAnimationState=0;
00216     MousePosNeedsUpdatingFlag=TRUE;
00217     MousePosPaneNeedsResizing=TRUE;
00218 //  TransparencyNeedsUpdating=TRUE; 
00219 
00220     // create a 'snapped' mouse pointer
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 >   StatusLine::~StatusLine()
00234 
00235     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00236     Created:    24/10/95
00237     Purpose:    destructor for StatusLine
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         // Only zap it out if there is a live status line. Status line objects
00257         // are temporarily created when invoking bar closure
00258         s_pStatusLine = NULL;
00259     }
00260 
00261     GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_LOW, this);
00262 }
00263 
00264 
00265 /*****************************************************************************
00266 >   BOOL StatusLine::OnIdleEvent()
00267 
00268     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00269     Created:    15/11/94
00270     Purpose:    Idle event handler for status line
00271                 Updates the text on the status bar if 'TextDelay' 
00272                 has elapsed since it was last changed.
00273                 Also updates the mouse position pane
00274     Returns:    FALSE (to indicate we want no more idle events)
00275                 The wakeup from the timer will create one for us
00276     Errors:     -
00277 
00278 
00279 *****************************************************************************/
00280 
00281 BOOL StatusLine::OnIdleEvent()
00282 {
00283     if (PrintMonitor::IsPrintingNow())
00284         return FALSE;
00285 
00286     // Don't do any status line updates if the timer is running
00287     if (!m_Timer.IsRunning())
00288     {
00289 
00290         // If the current doc doesn't have a doc view (e.g. it's a clipboard doc), then there's no point
00291         // carrying on, because it's not a proper document, hence doen't require up-to-date status bar info.
00292         if (DocView::GetSelected() == NULL)
00293             return FALSE;
00294     
00295     
00296 #ifndef STANDALONE
00297         // if mouse position pane needs resizing, do it (ensuring it's enabled)
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         // establish if amount of memory changed BODGE
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             // If this ever appears in retail builds it will have to be rewritten properly (it
00328             // isn't internationally portable at the moment).       
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         // The timer had expired, so we need to indicate we need another update
00342         SetNeedsUpdate();
00343     }
00344 
00345     // Always say we don't need more idle events
00346     return FALSE;
00347 }
00348 
00349 /*****************************************************************************
00350 >   void StatusLine::SetNeedsUpdate(BOOL Immediate = FALSE);
00351 
00352     Author:     Alex Bligh <alex@alex.org.uk>
00353     Created:    16/5/2005
00354     Purpose:    Indicate the status line needs an update
00355     Returns:    -
00356     Errors:     -
00357 
00358 *****************************************************************************/
00359 
00360 void StatusLine::SetNeedsUpdate(BOOL Immediate /*=FALSE*/)
00361 {
00362     if (Immediate)
00363     {
00364         // Simulate a timer event
00365         m_Timer.Stop();
00366         OnTimer();
00367         return;
00368     }
00369 
00370     m_Timer.Start(1000, TRUE);
00371 }
00372 
00373 /*****************************************************************************
00374 >   BOOL StatusLine::RefreshHelpText()
00375 
00376     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00377     Created:    3/1/95
00378     Purpose:    refresh the help text pane of the status line
00379     Returns:    FALSE if anything fails (see Errors)
00380     Errors:     CCamApp::GetMousePosAndWindowID() fails,
00381                 pCCStatusBar->UpdatePaneText() fails,
00382                 UpdateText() fails
00383 *****************************************************************************/
00384 
00385 BOOL StatusLine::RefreshHelpText()
00386 {   
00387     // if drag op in progress, don't slow it down, just exit
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     // for new custom colour picker tool ....
00397     // (do NOT update status text if this tool is active!)
00398 
00399     if (IsRestrictedAccessToColourPicker () == TRUE)
00400     {
00401         return (TRUE);
00402     }
00403 
00404     if (!TextValid)
00405     {
00406         TextValid=BaseBar::GetStatusLineText(&text);        // try bar drag
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     // if no valid text so far (and valid current doc else something deep down goes BANG)
00418     // get mouse pos (in DocCoords), handle of window it is over, DocView ptr, spread ptr
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     // if no text so far, try drag ops
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             // drag op in progress so we must have valid text (stops tool being interogated)
00442             if (!TextValid)
00443             {
00444                 text=_T("");    
00445                 TextValid=TRUE;
00446             }
00447         }
00448     }
00449 
00450     // if no text so far, try other bits!
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));                      // over unselected doc
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);                // try buttons/bars
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);                     // try ColourBar
00501             if (TextValid)
00502                 PrefixSelDesc=STATUSLINE_SELDESC_COLBAR;
00503         }
00504 
00505         if (!TextValid)
00506         {
00507             TextValid=ColourPicker::GetStatusLineText(&text);                   // try Colour Editor
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);                  // try Preview Dialog
00519             if (TextValid)
00520                 PrefixSelDesc=STATUSLINE_SELDESC_PREVIEWDLG;
00521         }
00522 #endif
00523 
00524 // WEBSTER - markn 15/1/97
00525 // No rulers in webster
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);  // try Rulers
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             // Lets try the Galleries ....
00549             // ** This uses Naughty Oily stuff. (Bodge for the Viewer).
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                     // Get the screen DPI
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         // blank mouse pos if not over selected doc
00584         if (!OverSelectedDoc)
00585             if (UpdateMousePosAndSnap(NULL,NULL,pDocView,FALSE)==FALSE)
00586                 ReturnValue=FALSE;
00587 #endif
00588     }
00589 
00590     // actually update the text
00591     if (!TextValid)
00592         text=_T("");
00593     if (!UpdateText(&text,PrefixSelDesc))
00594         ReturnValue=FALSE;
00595 
00596     return ReturnValue;
00597 }
00598 
00599 
00600 
00601 /********************************************************************************************
00602 >   static void StatusLine::SetPrefix(const StringBase& str)
00603 
00604     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00605     Created:    1/10/96
00606     Inputs:     str     ---     the string to display as the prefix on the status line
00607     Purpose:    Overrides the default behaviour of showing the selection state as
00608                 the prefix on the status line.  SetDefaultPrefix restores the default
00609                 behaviour of (usually) showing the selection state as the prefix.
00610     SeeAlso:    StatusLine::UpdateText; StatusLine::SetDefaultPrefix;
00611                 StatusLine::GetPrefixWidth
00612 ********************************************************************************************/
00613 
00614 void StatusLine::SetPrefix(const StringBase& str)
00615 {
00616     m_strPrefix = str;
00617 }
00618 
00619 
00620 /********************************************************************************************
00621 >   static void StatusLine::SetDefaultPrefix()
00622 
00623     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00624     Created:    1/10/96
00625     Purpose:    Undoes a call to SetPrefix, restoring the default behaviour of showing the
00626                 selection state as a prefix on the status line.
00627     SeeAlso:    StatusLine::SetPrefix
00628 ********************************************************************************************/
00629 
00630 void StatusLine::SetDefaultPrefix()
00631 {
00632     m_strPrefix.Empty();
00633 }
00634 
00635 
00636 /********************************************************************************************
00637 >   static INT32 StatusLine::GetPrefixWidth()
00638 
00639     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00640     Created:    1/10/96
00641     Returns:    The size of non-default prefix, in pixels.  If using the normal selection state
00642                 prefix then always returns 0.
00643     SeeAlso:    StatusLine::SetPrefix
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 >   BOOL StatusLine::RestrictStatusLineFunctionsToColourPicker (CWindowID colourPicker)
00659 
00660     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00661     Created:    22/10/99
00662     Inputs:     colourPicker - The HWND of the claimed colour picker control
00663     Returns:    TRUE - if successful
00664                 FALSE - otherwise
00665     Purpose:    When the user is dragging a colour picker control, we need to restrict
00666                 access to status line functionality to only the colour picker
00667     SeeAlso:    RestoreStatusLineFunctions
00668 ********************************************************************************************/
00669 
00670 BOOL StatusLine::RestrictStatusLineFunctionsToColourPicker (CWindowID colourPicker)
00671 {
00672     // firstly, lets check for obvious insanity
00673 
00674 PORTNOTE("StatusLine", "Removed use of ColourPicker")
00675 #ifndef EXCLUDE_FROM_XARALX
00676     String_256 ClassNameStr;  // The control type
00677 
00678     // Find out the class type of the gadget
00679     GetClassName (colourPicker, (TCHAR*) ClassNameStr, 255);
00680     
00681     if (ClassNameStr == String_8(TEXT("cc_colPicker")))
00682     {
00683         //if (restrictStatusLineFunctionsToColourPicker == FALSE)
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 >   BOOL StatusLine::RestrictStatusLineFunctionsToColourPicker (CWindowID colourPicker)
00699 
00700     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00701     Created:    22/10/99
00702     Inputs:     colourPicker - The HWND of the claimed colour picker control
00703     Returns:    TRUE - if successful
00704                 FALSE - otherwise
00705     SeeAlso:    RestoreStatusLineFunctions
00706 ********************************************************************************************/
00707 
00708 BOOL StatusLine::RestoreStatusLineFunctions (CWindowID colourPicker)
00709 {
00710     // firstly, lets check for obvious insanity
00711 
00712 PORTNOTE("StatusLine", "Removed use of ColourPicker")
00713 #ifndef EXCLUDE_FROM_XARALX
00714     String_256 ClassNameStr;  // The control type
00715 
00716     // Find out the class type of the gadget
00717     GetClassName (colourPicker, (TCHAR*) ClassNameStr, 255);
00718     
00719     if (ClassNameStr == String_8(TEXT("cc_colPicker")))
00720     {
00721         //if (restrictStatusLineFunctionsToColourPicker == TRUE)
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 >   BOOL StatusLine::UpdateText(String_256* pText, BOOL PrefixSelDesc=TRUE)
00736 
00737     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00738     Created:    15/11/94
00739     Purpose:    update the status line with the given text,
00740                 prefixed with the selection description (if valid to do so)
00741     Inputs:     pText         - pointer to text for status line
00742                 PrefixSelDesc - prefix text with selection description if possible (if TRUE)
00743                                 (this parameter is ignored if the default prefix
00744                                 has been overridden by StatusLine::SetPrefix
00745     Returns:    FALSE if fails (see Erros)
00746     Errors:     pCCStatusBar==NULL
00747                 pCCStatusBar->UpdatePaneText() fails,
00748                 pCCStatusBar->GetPaneRect() fails,
00749                 pCCStatusBar->GetTextWidth() fails,
00750                 TruncateTextToWidth() fails
00751 *********************************************************************************/
00752 
00753 extern BOOL SafeAppendString(StringBase*, const StringBase&, BOOL = TRUE);
00754 
00755 BOOL StatusLine::UpdateText(String_256* pText, BOOL PrefixSelDesc)
00756 {
00757 //  FixFPControlRegister();
00758 
00759 #ifdef STANDALONE
00760     PrefixSelDesc = FALSE;  // Never show Selection Description in Viewer
00761 #endif
00762 
00763     // create a string by concatenating sel desc and help text (as required)
00764     String_256 text("");
00765     SelRange* pSelection = 0;
00766 
00767     if (m_strPrefix.IsEmpty())
00768     {
00769         if (PrefixSelDesc)
00770         {
00771             // Show the selection state.
00772 
00773             // DMc 19/5/99
00774             // Alter the range control before we do the describe
00775             pSelection = GetApplication()->FindSelection();
00776             
00777             if (pSelection) text = pSelection->Describe(STATUS_BAR);
00778         }
00779     }
00780     else
00781     {
00782         // Show the caller-defined prefix.
00783         text = m_strPrefix;
00784     }
00785 
00786     if (text.Length()>0) SafeAppendString(&text, SelDescSuffix, FALSE);
00787     if (pText) SafeAppendString(&text, *pText, FALSE);
00788 
00789     // re-sample time and update status line
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 //  FixFPControlRegister();
00807 
00808 #ifdef STANDALONE
00809     PrefixSelDesc = FALSE;  // Never show Selection Description in Viewer
00810 #endif
00811 
00812     ERROR2IF(restrictStatusLineFunctionsToColourPicker==FALSE,FALSE,"StatusLine::UpdateColourPickerText() - require TRUE to use this function!");
00813 
00814     // create a string by concatenating sel desc and help text (as required)
00815     String_256 text("");
00816     SelRange* pSelection = 0;
00817 
00818     RangeControl rg;
00819 
00820     if (m_strPrefix.IsEmpty())
00821     {
00822         if (PrefixSelDesc)
00823         {
00824             // Show the selection state.
00825 
00826             // DMc 19/5/99
00827             // Alter the range control before we do the describe
00828             pSelection = GetApplication()->FindSelection();
00829             
00830             if (pSelection) text = pSelection->Describe(STATUS_BAR);
00831         }
00832     }
00833     else
00834     {
00835         // Show the caller-defined prefix.
00836         text = m_strPrefix;
00837     }
00838 
00839     if (text.Length()>0) SafeAppendString(&text, SelDescSuffix, FALSE);
00840     if (pText) SafeAppendString(&text, *pText, FALSE);
00841 
00842     // re-sample time and update status line
00843     TextTimer.Sample();
00844     
00845     return SetStatusText(text);
00846 }
00847 
00848 
00849 /*****************************************************************************
00850 >   BOOL StatusLine::TruncateTextToWidth(String_256* pText, INT32 width)
00851 
00852     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00853     Created:    5/1/95
00854     Purpose:    if too long for the given width,
00855                 truncate the given text at one of the specified delimiters
00856     Inputs:     pText - pointer to original text
00857                 width - width to truncate text to
00858     Outputs:    pText - pointer to the (truncated) text
00859     Returns:    FALSE if anything fails (see Errors)
00860     Errors:     pCCStatusBar==NULL,
00861                 pText==NULL,
00862                 pCCStatusBar->GetTextWidth() fails,
00863 *****************************************************************************/
00864 
00865 BOOL StatusLine::TruncateTextToWidth(String_256* pText, INT32 width)
00866 {
00867     ERROR2IF(       pText==NULL,FALSE,"StatusLine::TruncateTextToPane() - pText==NULL");
00868 
00869     // try truncating text at each successive point until it no longer fits the pane then
00870     // use the last one that fitted (if text null or no truncation points use whole text)
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 >   BOOL StatusLine::GetMousePosText(String_256 pText, DocCoord MousePos, Spread* pSpread, INT32 dp = -1)
00905 
00906     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00907     Created:    14/12/94
00908     Purpose:    get mouse position as a string
00909     Inputs:     MousePos - position of mouse in DocCoords
00910                 pSpread  - pointer to spread mouse is over
00911     Outputs:    pText    - mouse position as text
00912     Returns:    FALSE if fails (see Errors)
00913     Errors:     pCCStatusBar==NULL
00914                 pSpread==NULL
00915                 Spread::SpreadCoordToText() fails
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 >   BOOL StatusLine::SetMousePosPaneWidth(Spread* pSpread)
00938 
00939     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00940     Created:    22/12/94
00941     Purpose:    Set the mouse position pane width to be large enough to
00942                 hold any coord in the spread in the current preference units
00943                 Also gets, and caches, the number of decimal places required to resolve 1 pixel
00944     Inputs:     pSpread  - pointer to spread mouse is over
00945     Returns:    FALSE if fails (see Errors)
00946     Errors:     pCCStatusBar==NULL
00947                 pSpread==NULL
00948                 Spread::GetDecimalPlacesForPixelResolution() fails
00949                 GetMousePosText() fails
00950                 pCCStatusBar->GetTextWidth() fails
00951                 pCCStatusBar->SetPaneWidth() fails
00952 *****************************************************************************/
00953 
00954 BOOL StatusLine::SetMousePosPaneWidth(Spread* pSpread)
00955 {   
00956     ERROR2IF(     pSpread==NULL,FALSE,"StatusLine::SetMousePosPaneWidth() - pSpread==NULL");
00957 
00958     // find/cache number of decimal places required to resolve a pixel with current units & scale
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     // get dimensions of spread PasteRect converted (in DocCoords)
00967     DocRect  PasteRect=pSpread->GetPasteboardRect();
00968     DocCoord PasteSize(PasteRect.Width(),PasteRect.Height());
00969 
00970     // get min coord as text, then find it's width
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     // get max coord as text, then find it's width
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 // set pane width
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 >   MsgResult StatusLine::Message(Msg* pMsg)
01036 
01037     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
01038     Created:    31/12/94
01039     Purpose:    handle system messages
01040     Inputs:     pMsg - pointer to message
01041     Returns:    OK, EAT_MSG, FAIL (see Errors)
01042 *****************************************************************************/
01043 
01044 MsgResult StatusLine::Message(Msg* pMsg)
01045 {
01046 //  FixFPControlRegister();
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)); // turn snap off by default
01064                 nobreak; // FALL THROUGH!
01065             }
01066             case DIM_DLG_RESIZED:
01067             {
01068                 if (!ProgressShown)
01069                 {
01070                     // For some reason we need to do a relayout with the gadgets shown
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         // Else fall through
01084     }
01085 
01086 
01087 
01088     // if pref units changed, or zoom changed flag mouse pos pane needs resizing
01089     if (MESSAGE_IS_A(pMsg,OptionsChangingMsg) /* && ((OptionsChangingMsg*)pMsg)->State==OptionsChangingMsg::NEWUNITS */
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     // if doc changing flag transparency needs updating & mouse pos pane needs resizing
01095     if (MESSAGE_IS_A(pMsg,DocChangingMsg) && ((DocChangingMsg*)pMsg)->State==DocChangingMsg::SELCHANGED)
01096     {
01097         //TransparencyNeedsUpdating=TRUE; 
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 >   BOOL StatusLine::UpdateMousePosAndSnap(DocCoord* pDocCoord, Spread* pSpread,
01171                                            DocView* pDocView,   BOOL Snapped)
01172 
01173     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
01174     Created:    2/1/95
01175     Inputs:     pDocoord - 
01176                 pSpread  - 
01177                 pDocView - 
01178                 Snapped  - 
01179     Returns:    FALSE if anything fails (see Errors)
01180     Purpose:    Update mouse position pane, and snapped indicator
01181                 If pDocCoord==NULL && pSpread==NULL && Snapped==FALSE, the mouse pos will be blanked
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     // update mouse position pane if over selected doc, else blank it
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         //  PaintGadgetNow(_R(IDC_SL_MOUSEPOS)); - is there any need to paint this now? Flushes gtk buffer etc. Not a great idea.
01211     }
01212 
01213 // WEBSTER - markn 15/1/97
01214 // No rulers in Webster
01215 #ifndef WEBSTER
01216     // and update ruler mouse followers
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 //  WEBSTER-ranbirr-13/11/96
01227 #ifndef WEBSTER
01228     // if snap indicator not reflecting the desired state, update it.
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     // if snap pointer not reflecting the desired state, update it.
01242     // (The snap pointer is only shown when snapped and during a 'SnappingDrag' drag)
01243     Operation* pDragOp = Operation::GetCurrentDragOp();
01244     if (Snapped && pDragOp!=NULL && pDragOp->SnappingDrag())
01245     {
01246         // Snapped and dragging so show pointer shape if not already shown
01247         if (SnappedCursorID==0)
01248         {
01249             SnappedCursorID = CursorStack::GPush(pSnappedCursor);
01250         }
01251     }
01252     else
01253     {
01254         // Not snapped or dragging so hide pointer shape if it was shown
01255         if (SnappedCursorID!=0)
01256         {
01257             CursorStack::GPop(SnappedCursorID);
01258             SnappedCursorID = 0;    // flag cursor no longer on stack
01259         }
01260     }
01261 
01262     // and mouse position no longer needs updating
01263     MousePosNeedsUpdatingFlag=FALSE;
01264     return ReturnValue;
01265 
01266 #else
01267     return TRUE;
01268 #endif
01269 }
01270 
01271 
01272 
01273 /*******************************************************************************************************
01274 >   BOOL StatusLine::UpdateSolidDragIndicator(BOOL bSolidAllowed, BOOL bSolid)
01275 
01276     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
01277     Created:    23/12/2003
01278     Inputs:     bSolid  - Is Solid mode turned on?
01279     Returns:    FALSE if anything fails (see Errors)
01280     Purpose:    Update mouse position pane, and snapped indicator
01281                 If pDocCoord==NULL && pSpread==NULL && Snapped==FALSE, the mouse pos will be blanked
01282 ********************************************************************************************************/
01283 BOOL StatusLine::UpdateSolidDragIndicator(BOOL bSolidAllowed, BOOL bSolid)
01284 {
01285 //  if (MousePosPaneNeedsResizing)
01286 //      return TRUE;
01287 
01288     BOOL ReturnValue=TRUE;
01289 
01290     // if drag indicator not reflecting the desired state, update it.
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         // force a redraw of the drag pane
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         // force a redraw of the snap pane
01309         pCCStatusBar->UpdatePaneBitmap(_R(IDS_SL_SDRAG),0, TRUE);
01310     }
01311 #endif
01312     
01313     return ReturnValue;
01314 }
01315 
01316 
01317 /*****************************************************************************
01318 >   BOOL StatusLine::SetRenderIndicator(RenderState Action)
01319 
01320     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
01321     Created:    27/1/95
01322     Purpose:    Change state of the render indicator
01323     Inputs:     Action - Rendering    display 'Rendering'    indicator  
01324                          Paused       display 'Paused'       indicator  
01325                          NotRendering display 'NotRendering' indicator (reset animation)
01326                          Animate      display char in animation 
01327                                       (if sufficient time elapsed, advance animation)
01328     Returns:    FALSE if anything fails (see Errors)
01329     Errors:     pCCStatusBar==NULL,
01330                 Action invalid,
01331                 CStatusBar::UpdatePaneText() fails,
01332                 StringBase::Load() fails
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     //PaintGadgetNow(_R(IDB_SL_RENDN));
01372 
01373     return TRUE;
01374 }
01375 
01376 /********************************************************************************************
01377 >   BOOL StatusLine::ShowProgress (BOOL Show=TRUE, StringBase *JobDescrip = NULL)
01378 
01379     Author:     Alex Bligh
01380     Created:    09/05/2006
01381     Inputs:     BOOL Show : TRUE to show, else false
01382                 JobDescription - A BRIEF string describing the job currently being undertaken.
01383                         This will be displayed on the progress bar if possible
01384     Outputs:    -
01385     Returns:    TRUE if the initialisation of the progress bar was successful.
01386     Purpose:    Creates a window and associates it with this CProgressBar object. The window
01387                 appears immediately over the status bar.
01388     Notes:      This currently assumes that it'll only ever be opened at the bottom of the
01389                 Main Frame window.
01390     SeeAlso:    StatusLine::SetPercent; StatusLine::GetPercent
01391 ********************************************************************************************/
01392 
01393 BOOL StatusLine::ShowProgress (BOOL Show, StringBase *JobDescrip)
01394 {
01395     BOOL ShowChanged=(Show != ProgressShown);
01396 
01397     String_8 EmptyString(_T(""));
01398 
01399     // Make "NULL" mean "empty string"
01400     if (!JobDescrip)
01401         JobDescrip=&EmptyString;
01402 
01403     BOOL StringChanged=!JobDescription || (*JobDescription!=*JobDescrip);
01404 
01405     // Return if nothing changed
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;      // Force a redraw
01417         SetPercent(0, TRUE, JobDescrip);    // Force redraw of window _including background_; always refresh string
01418 
01419         return TRUE;
01420     }
01421 
01422     return SetPercent(CurrentPercent, StringChanged, StringChanged?JobDescrip:NULL);
01423 }
01424 
01425 
01426 /********************************************************************************************
01427 >   BOOL StatusLine::SetPercent(INT32 NewPercent,
01428                                     BOOL ClearBackground = FALSE, StringBase *JobDescrip = NULL)
01429 
01430     Author:     Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
01431     Created:    15/02/94
01432     Inputs:     NewPercent - the new percentage value to be displayed by the progress bar
01433 
01434                 ClearBackground - Clears the entire bar background and redraws everything, rather
01435                 than doing a (far more efficient) update of the bar/percentage alone. Use the default
01436                 of FALSE unless absolutely necessary!
01437 
01438                 JobDescrip - NULL, or a pointer to a new job description - pass NULL if this hasn't
01439                 changed, as it makes a copy of the new string every time it is changed. If this is
01440                 non-NULL, then the ClearBackground flag will be forced to TRUE to draw the new text.
01441 
01442     Outputs:    -
01443     Returns:    TRUE if it successfully makes the change.
01444     Purpose:    Sets the currently displayed percentage of the progress bar. The bar
01445                 will be immediately redrawn to reflect the new value. Values outside the
01446                 range 0..99 (inclusive) are clipped to 0 or 99. No redraw will be done if
01447                 NewPercent equals the currently displayed value.
01448     SeeAlso:    CProgressBar::GetPercent; CProgressBar::Create
01449 ********************************************************************************************/
01450 
01451 BOOL StatusLine::SetPercent(INT32 NewPercent, BOOL ClearBackground /* =FALSE */,
01452                                 StringBase *JobDescrip /* =NULL */)
01453 // The extra argument ClearBackground is not mentioned in the help, because it
01454 // is used internally - When the window is first created, the background must be cleared,
01455 // but on normal updates this causes horrible flicker, so is to be avoided.
01456 {
01457     if (NewPercent < 0) NewPercent = 0;
01458     if (NewPercent > 99) NewPercent = 99;
01459 
01460     // If there's no change, don't bother updating
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     // If there is a new Job Description, change to use it
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); // Repaint the whole bar
01487         PaintGadgetNow(0);
01488     }
01489     else
01490     {
01491         // Just repaint the gauge
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 >   BOOL StatusLine::SetStatusText(const String_256 &text)
01503 
01504     Author:     Alex Bligh <alex@alex.org.uk>
01505     Created:    09/05/2006
01506     Inputs:     text - the text to set it to
01507 
01508     Outputs:    -
01509     Returns:    TRUE if it successfully makes the change.
01510     Purpose:    Sets the status line text. Records it. Puts it in the gadget and invalidates
01511                 it if the gadget is shown
01512     SeeAlso:    CProgressBar::GetPercent; CProgressBar::Create
01513 
01514 ********************************************************************************************/
01515 
01516 BOOL StatusLine::SetStatusText(const String_256 &text)
01517 {
01518     SetNeedsUpdate(); // Don't allow another update on idles for 250ms
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 //      PaintGadgetNow(_R(IDC_SL_STATUSTEXT));
01529         return ok;
01530     }
01531     return TRUE;
01532 }

Generated on Sat Nov 10 03:47:04 2007 for Camelot by  doxygen 1.4.4