cstatbar.cpp

Go to the documentation of this file.
00001 // $Id: cstatbar.cpp 1282 2006-06-09 09:46:49Z alex $
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 // CCStatusBar
00099 
00100 
00101 #include "camtypes.h"
00102 #include <afxpriv.h>
00103 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 #include "fonts.h"
00105 #include "csrstack.h"
00106 #include "cstatbar.h"
00107 #include "ctrlhelp.h"
00108 #include "statline.h"
00109 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include <afxcmn.h>
00111 
00112 #define IS_CHICAGO ((LOBYTE(LOWORD(GetVersion()))) > 3) 
00113 
00114 DECLARE_SOURCE("$Revision: 1282 $");
00115 
00116 IMPLEMENT_DYNAMIC(CCStatusBar, CStatusBar)
00117 
00118 #define new CAM_DEBUG_NEW
00119 
00120 BEGIN_MESSAGE_MAP(CCStatusBar, CStatusBar)
00121     //{{AFX_MSG_MAP(CCStatusBar)
00122     ON_WM_LBUTTONDBLCLK()
00123     ON_WM_MOUSEMOVE()
00124     ON_MESSAGE_VOID(WM_INITIALUPDATE, OnInitialUpdate)
00125     //}}AFX_MSG_MAP
00126 END_MESSAGE_MAP()
00127 
00128 // #define STATUSBAR_POPOUT(X) TRUE
00129 // #define STATUSBAR_POPOUT(X) (X & SBPS_POPOUT)
00130 // SBPS_POPOUT = SBT_POPOUT = 0x0200
00131 
00132 /******************************************************************************
00133 >   CCStatusBar::CCStatusBar()
00134 
00135     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00136     Created:    9/12/94
00137     Purpose:    CCStatusBar constructor
00138 ******************************************************************************/
00139 
00140 CCStatusBar::CCStatusBar() : CStatusBar()
00141 {
00142     ERROR3IF(this == NULL,"CStatusBar::CStatusBar() - this == NULL");
00143 
00144     OldMousePos = CPoint(0,0);
00145     NumPanes = 0;
00146     pPaneData = NULL;
00147     // >>Webster (Adrian 2/2/97)
00148     // We change the status bar font to Arial Narrow 9
00149     // Note that this is a system-wide setting, so we change it "quietly" (i.e. don't broadcast a WM_WININICHANGE)
00150     // so as not to affect other applications already running
00151     //NONCLIENTMETRICS ncMetrics;
00152     //ncMetrics.cbSize = sizeof(NONCLIENTMETRICS);
00153     //::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncMetrics, 0);
00154     //m_OldFont.CreateFontIndirect(&ncMetrics.lfStatusFont);
00155     //CFont newStatusFont;
00156     //newStatusFont.CreatePointFont(90, _T("Arial Narrow")); 
00157     //newStatusFont.GetLogFont(&ncMetrics.lfStatusFont);
00158     //::SystemParametersInfo(SPI_SETNONCLIENTMETRICS, 0, &ncMetrics, 0);
00159     // <<Webster
00160 }
00161 
00162 
00163 /******************************************************************************
00164 >   CCStatusBar::~CCStatusBar()
00165 
00166     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00167     Created:    3/2/95
00168     Purpose:    CCStatusBar destructor
00169     Errors:     this==NULL
00170                 NumPanes==0
00171                 pPaneData==NULL
00172     ******************************************************************************/
00173 CCStatusBar::~CCStatusBar()
00174 {
00175     ERROR3IF(     this==NULL,"CStatusBar::~CStatusBar() - this==NULL");
00176     ERROR3IF( NumPanes==0,   "CStatusBar::~CStatusBar() - NumPanes==0");
00177     ERROR3IF(pPaneData==NULL,"CStatusBar::~CStatusBar() - pPaneData==NULL");
00178 
00179     delete pPaneData;
00180 
00181 }
00182 
00183 
00184 /******************************************************************************
00185 >   BOOL CCStatusBar::Create(CFrameWnd* pParentWnd,
00186                             DWORD dwStyle=WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,
00187                             UINT32 nID=_R(AFX_IDW_STATUS_BAR));
00188 
00189     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00190     Created:    9/12/94
00191     Purpose:    Just a copy of CStatusBar Create() but allow double clicks
00192                 and use our own font
00193     Inputs:     pParentWnd - pointer to parent window
00194                 dwStyle    - stlye flags
00195                 nID        - window ID
00196     Returns:    FALSE if fails (see Errors)
00197     Errors:     this==NULL,
00198                 pParentWnd==NULL,
00199                 CWnd::Create() failed
00200 ******************************************************************************/
00201 /*  UIC Function body changed to below - for win '95 Common Control
00202 
00203 BOOL CCStatusBar::Create(CFrameWnd* pParentWnd, DWORD dwStyle, UINT32 nID)
00204 {
00205     ERROR2IF(      this == NULL,FALSE,"CCStatusBar::Create() - this == NULL");
00206     ERROR2IF(pParentWnd == NULL,FALSE,"CCStatusBar::Create() - pParentWnd == NULL");
00207 
00208     m_dwStyle = (UINT32)dwStyle;    // save the style
00209     CString WndClassName = AfxRegisterWndClass(CS_DBLCLKS,                  // class style bits
00210                                              Cursor::Arrow->Handle(),       // cursor handle
00211                                              (HBRUSH)(COLOR_BTNFACE+1));    // window background
00212     // create the HWND
00213     CRect rect;
00214     rect.SetRectEmpty();
00215     BOOL CreatedOK = CWnd::Create(WndClassName, NULL, dwStyle, rect, pParentWnd, nID);
00216     ERROR2IF(!CreatedOK,FALSE,"CCStatusBar::Create() - CWnd::Create() failed");
00217 
00218     // set initial font and calculate bar height
00219     SendMessage(WM_SETFONT, (WPARAM)FontFactory::GetFont(STOCKFONT_STATUSBAR));
00220     return TRUE;
00221 }
00222 */
00223 BOOL CCStatusBar::Create(CFrameWnd* pParentWnd, DWORD dwStyle, UINT32 nID)
00224 {
00225     BOOL CreatedOK = CStatusBar::Create((CWnd*)pParentWnd,dwStyle,nID);
00226     ERROR2IF(!CreatedOK,FALSE,"CCStatusBar::Create() - CWnd::Create() failed");
00227 
00228     // set initial font and calculate bar height
00229     SendMessage(WM_SETFONT, (WPARAM)FontFactory::GetFont(STOCKFONT_STATUSBAR));
00230 
00231     INT32 Bits = GetClassLong(m_hWnd,GCL_STYLE);
00232     Bits |= CS_DBLCLKS;
00233     SetClassLong(m_hWnd,GCL_STYLE,Bits); 
00234 
00235     // >>Webster (Adrian 2/2/97)
00236     // We change the system -wide status bar font back to what it used to be before starting Webster
00237     //NONCLIENTMETRICS ncMetrics;
00238     //ncMetrics.cbSize = sizeof(NONCLIENTMETRICS);
00239     //::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncMetrics, 0);
00240     //m_OldFont.GetLogFont(&ncMetrics.lfStatusFont);
00241     //::SystemParametersInfo(SPI_SETNONCLIENTMETRICS, 0, &ncMetrics, 0);
00242     // <<Webster
00243 
00244     
00245     return TRUE;
00246 }
00247 /******************************************************************************
00248 >   BOOL CCStatusBar::UpdateStatusLineFont()
00249 
00250     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00251     Created:    9/12/94
00252     Purpose:    
00253     Returns:    FALSE if fails
00254     Errors:     
00255 ******************************************************************************/
00256 // UIC function for Win '95 changes
00257 
00258 BOOL CCStatusBar::UpdateStatusLineFont()
00259 {
00260     SendMessage(WM_SETFONT, (WPARAM)FontFactory::GetFont(STOCKFONT_STATUSBAR));
00261 
00262     return TRUE;
00263 }
00264 
00265 /******************************************************************************
00266 >   BOOL CCStatusBar::SetIndicators(StatusLinePaneData* pSLPD, INT32 Panes)
00267 
00268     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00269     Created:    9/12/94
00270     Purpose:    Interface to CStatusBar::SetIndicators
00271                 ALSO enables/disables panes according to data passed in
00272     Inputs:     pSLPD - pointer to array of StatusLinePaneData
00273                 Panes - number of panes
00274     Returns:    FALSE if fails
00275     Errors:     this==NULL
00276                 PAneState() fails
00277 ******************************************************************************/
00278 BOOL CCStatusBar::SetIndicators(StatusBarPaneData* pSLPD, INT32 Panes)
00279 {
00280     ERROR2IF(this == NULL,FALSE,"CStatusBar::SetIndicators() - this == NULL");
00281     ERROR2IF(NumPanes != 0,   FALSE,"CStatusBar::SetIndicators() - NumPanes != 0");
00282     ERROR2IF(pPaneData != NULL,FALSE,"CStatusBar::SetIndicators() - pPaneData != NULL");
00283 
00284     // copy pane data into class
00285     NumPanes = Panes;
00286     pPaneData = new StatusBarPaneData[NumPanes];    
00287     ERROR2IF(pPaneData==NULL,FALSE,"CCStatusBar::SetIndicators() - pPaneData==NULL");
00288     for (UINT32 i = 0; i < NumPanes; i++)
00289         pPaneData[i] = pSLPD[i];
00290 
00291     // call equivalent routine in base class
00292     UINT32* pPaneIDs = new UINT32[NumPanes];
00293     ERROR2IF(pPaneIDs == NULL,FALSE,"CCStatusBar::SetIndicators() - pPaneIDs == NULL");
00294     for (i = 0; i < NumPanes; i++)
00295         pPaneIDs[i] = pPaneData[i].PaneID;
00296     CStatusBar::SetIndicators(pPaneIDs,NumPanes);
00297     delete pPaneIDs;
00298 
00299     // set initial pane states & bitmap pane widths
00300     BOOL ReturnValue = TRUE;
00301     for (i = 0; i < NumPanes; i++)
00302     {
00303         if (PaneState(pPaneData[i].PaneID, pPaneData[i].InitState) == Fail)
00304             ReturnValue = FALSE;
00305 
00306         if(pPaneData[i].OwnerDrawn)
00307         {
00308             UINT32 PaneStyle = GetPaneStyle(i);
00309             SetPaneStyle(i,PaneStyle|SBPS_OWNERDRAW);
00310         }
00311 
00312         if (pPaneData[i].BitmapID)
00313         {
00314             CBitmap bitmap;
00315             BITMAP  BMObject;
00316             if (bitmap.LoadBitmap(pPaneData[i].BitmapID) == 0)
00317                 ReturnValue = FALSE;
00318 
00319             if (bitmap.GetObject(sizeof(BITMAP), &BMObject) == 0)
00320                 ReturnValue = FALSE;
00321 
00322             // Small bodge here to allow Print Colours pane to contain both bitmap and text
00323             // Don't force pane width if paneID is that of the Print Colours pane
00324             if (pPaneData[i].PaneID!=_R(IDS_SL_PRINTMODE))
00325             {
00326                 if (SetPaneWidth(BMObject.bmWidth-2, pPaneData[i].PaneID) == FALSE) // NB bodge offset '-2' !!!!
00327                     ReturnValue = FALSE;
00328             }
00329         }
00330     }
00331 
00332     return ReturnValue;
00333 }
00334 
00335 
00336 /******************************************************************************
00337 >   BOOL CCStatusBar::UnSetIndicators()
00338 
00339     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00340     Created:    08/01/2004
00341     Purpose:    Interface to CStatusBar::SetIndicators
00342                 ALSO enables/disables panes according to data passed in
00343     Inputs:     pSLPD - pointer to array of StatusLinePaneData
00344                 Panes - number of panes
00345     Returns:    FALSE if fails
00346     Errors:     this==NULL
00347 ******************************************************************************/
00348 BOOL CCStatusBar::UnSetIndicators()
00349 {
00350     ERROR2IF(this == NULL,FALSE,"CStatusBar::SetIndicators() - this == NULL");
00351 //  ERROR2IF(NumPanes != 0,   FALSE,"CStatusBar::SetIndicators() - NumPanes != 0");
00352 //  ERROR2IF(pPaneData != NULL,FALSE,"CStatusBar::SetIndicators() - pPaneData != NULL");
00353 
00354     if (NumPanes!=0 && pPaneData!=NULL)
00355     {
00356         delete[] pPaneData;
00357     }
00358 
00359     NumPanes=0;
00360     pPaneData = NULL;
00361 
00362     return TRUE;
00363 }
00364 
00365 
00366 /******************************************************************************
00367 >   void CCStatusBar::OnLButtonDblClk(UINT32 nFlags, CPoint point)
00368 
00369     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00370     Created:    9/12/94
00371     Inputs:     nFlags - 
00372                 point  - mouse position
00373     Purpose:    Handle mouse left button double clicks over the status bar
00374     Errors:     this==NULL
00375                 GetpStatusLine() fails
00376 ******************************************************************************/
00377 
00378 void CCStatusBar::OnLButtonDblClk(UINT32 nFlags, CPoint point)
00379 {
00380     if (this!=NULL)
00381     {
00382         StatusLine* pStatusLine=GetApplication()->GetpStatusLine();
00383         if (pStatusLine)
00384         {
00385             INT32 PaneIndex=GetPaneIndexFromPoint(point);
00386             INT32 PaneID=GetItemID(PaneIndex);
00387             pStatusLine->PaneDoubleClick(PaneID);
00388         }
00389     }
00390     else
00391         ERROR3("CCStatusBar::OnLButtonDblClk() - this==NULL");
00392 }
00393 
00394 /******************************************************************************
00395 >   BOOL CCStatusBar::UpdateStatusLineFont()PaneText(INT32 PaneID, StringBase* ptext, BOOL ImmediateUpdate=FALSE);
00396 
00397     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00398     Created:    9/12/94
00399     Purpose:    Update specified status bar pane
00400     Inputs:     PaneID - id of pane
00401                 ptext  - text (or NULL)
00402                 ImmediateUpdate - redraw pane now (rather than queuing)
00403     Returns:    FALSE if failed (see Errors)
00404     Errors:     this==NULL,
00405                 PaneID unrecognised
00406 ******************************************************************************/
00407 
00408 BOOL CCStatusBar::UpdatePaneText(INT32 PaneID, StringBase* ptext, BOOL ImmediateUpdate)
00409 {
00410     ERROR2IF(this==NULL,FALSE,"CStatusBar::UpdatePaneText() - this==NULL");
00411     
00412     INT32 PaneIndex=CommandToIndex(PaneID);
00413     ERROR2IF(PaneIndex==-1,FALSE,"CStatusBar::UpdatePaneText() - unknown PaneID");
00414     
00415     SetPaneText(PaneIndex, ptext==NULL ? NULL : (TCHAR*)*ptext);
00416     if (ImmediateUpdate && ptext) UpdateWindow();
00417 
00418     return TRUE;
00419 }
00420 
00421 /******************************************************************************
00422 >   void CCStatusBar::OnInitialUpdate()
00423 
00424     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00425     Created:    15/12/94
00426     Purpose:    Just a copy of CStatusBar version but doesn't disable panes!
00427 ******************************************************************************/
00428 
00429 void CCStatusBar::OnInitialUpdate()
00430 {
00431     OnIdleUpdateCmdUI(FALSE, 0L);
00432 }
00433 
00434 
00435 /******************************************************************************
00436 >   BOOL CCStatusBar::GetPaneRect(CRect* pRect, INT32 PaneID);
00437 
00438     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00439     Created:    21/12/94
00440     Purpose:    get dimensions of status bar pane 
00441     Inputs:     PaneID - id of pane
00442     Outputs:    pRect  - pane rect
00443     Returns:    FALSE if failed (see Errors)
00444     Errors:     this==NULL,
00445                 PaneID unrecognised
00446 ******************************************************************************/
00447 BOOL CCStatusBar::GetPaneRect(CRect* pRect, INT32 PaneID)
00448 {
00449     ERROR2IF(this==NULL,FALSE,"CStatusBar::UpdatePaneText() - this==NULL");
00450 
00451     INT32 PaneIndex=CommandToIndex(PaneID);
00452     ERROR2IF(PaneIndex==-1,FALSE,"CStatusBar::UpdatePaneText() - unknown PaneID");
00453 
00454     GetItemRect(PaneIndex,pRect);
00455     return TRUE;
00456 }
00457 
00458 /******************************************************************************
00459 >   INT32 CCStatusBar::GetTextWidth(StringBase* ptext, BOOL fBold = FALSE);
00460 
00461     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00462     Created:    21/12/94
00463     Purpose:    Get the width of the given text as if it were on the status bar
00464     Inputs:     ptext  - text
00465                 fBold  - if TRUE, assume bold text (by default FALSE)
00466     Returns:    width of text, or -1 if failed (see Errors)
00467     Errors:     this==NULL,
00468 ******************************************************************************/
00469 INT32 CCStatusBar::GetTextWidth(StringBase* ptext, BOOL fBold)
00470 {
00471     ERROR2IF(this==NULL,-1,"CStatusBar::GetTextWidth() - this==NULL");
00472     
00473     StockFont sf = (fBold ? STOCKFONT_STATUSBARBOLD : STOCKFONT_STATUSBAR);
00474 
00475     CClientDC dcScreen(NULL);
00476     HGDIOBJ OldObject = dcScreen.SelectObject(FontFactory::GetFont(sf));
00477     INT32 result = dcScreen.GetTextExtent(*ptext, ptext->Length()).cx;
00478     dcScreen.SelectObject(OldObject);   
00479 
00480     return result;
00481 }
00482 
00483 /******************************************************************************
00484 >   BOOL CCStatusBar::SetPaneWidth(INT32 width, INT32 PaneID);
00485 
00486     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00487     Created:    21/12/94
00488     Purpose:    Set the width of a status bar pane
00489     Inputs:     PaneID - id of pane
00490                 width  - new pane width
00491     Returns:    FALSE if failed (see Errors)
00492     Errors:     this==NULL,
00493                 PaneID unrecognised (or 0 as it is variable width!),
00494                 width<0
00495 ******************************************************************************/
00496 
00497 BOOL CCStatusBar::SetPaneWidth(INT32 width, INT32 PaneID)
00498 {
00499     ERROR2IF(this==NULL,FALSE,"CStatusBar::SetPaneWidth() - this==NULL");
00500     ERROR2IF(width<0 ,FALSE,"CStatusBar::SetPaneWidth() - width<0");
00501 
00502     INT32 PaneIndex=CommandToIndex(PaneID);
00503     ERROR2IF(PaneIndex == -1,FALSE,"CStatusBar::SetPaneWidth() - unknown PaneID");
00504     ERROR2IF(PaneIndex == 0 ,FALSE,"CStatusBar::SetPaneWidth() - Pane with ID==0 is variable width!!!");
00505 
00506     UINT32 nStyle;
00507     UINT32 OldPaneID;
00508     INT32  OldWidth;
00509     GetPaneInfo(PaneIndex, OldPaneID, nStyle, OldWidth);
00510     SetPaneInfo(PaneIndex, OldPaneID, nStyle, width);
00511 
00512     return TRUE;
00513 }
00514 
00515 
00516 /******************************************************************************
00517 >   FlagState CCStatusBar::PaneState(INT32 PaneID, FlagState NewState=NoChange);
00518 
00519     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00520     Created:    21/12/94
00521     Purpose:    Read/write pane state
00522     Inputs:     PaneID - id of pane
00523                 state  - Disable/Enable/Toggle/NoChange
00524     Returns:    previous state Disable/Enable/Fail (see Errors)
00525     Errors:     this==NULL,
00526                 PaneID unrecognised
00527                 NewState invalid
00528 ******************************************************************************/
00529 
00530 FlagState CCStatusBar::PaneState(INT32 PaneID, FlagState NewState)
00531 {
00532     ERROR2IF(this == NULL,Fail,"CStatusBar::PaneState() - this == NULL");
00533 
00534     INT32 PaneIndex = CommandToIndex(PaneID);
00535     ERROR2IF(PaneIndex == -1, Fail, "CStatusBar::PaneState() - unknown PaneID");
00536 
00537     UINT32 OldStyle;
00538     UINT32 NewStyle;
00539     UINT32 OldPaneID;
00540     INT32  width;
00541     GetPaneInfo(PaneIndex, OldPaneID, OldStyle, width);
00542     switch (NewState)
00543     {
00544         case Disable:  NewStyle = OldStyle | SBPS_DISABLED; break;
00545         case Enable:   NewStyle = OldStyle &~ SBPS_DISABLED; break;
00546         case Toggle:   NewStyle = OldStyle ^ SBPS_DISABLED; break;
00547         case NoChange: NewStyle = OldStyle; break;
00548         default: ERROR3("CCStatusBar::PaneState() - passed invalid NewState");
00549     }
00550     if (NewStyle != OldStyle)
00551         SetPaneInfo(PaneIndex, OldPaneID, NewStyle, width);
00552 
00553     return ((OldStyle & SBPS_DISABLED) ? Disable : Enable);
00554 }
00555 
00556 
00557 /******************************************************************************
00558 >   BOOL CCStatusBar::PaneExists(INT32 PaneID);
00559 
00560     Author:     Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
00561     Created:    08/01/2004
00562     Purpose:    Test wheter pane exists without ERRORing
00563     Inputs:     PaneID - id of pane
00564     Returns:    TRUE if specified pane exists
00565     Errors:     this==NULL,
00566 ******************************************************************************/
00567 
00568 BOOL CCStatusBar::PaneExists(INT32 PaneID)
00569 {
00570     ERROR2IF(this == NULL,Fail,"CStatusBar::PaneState() - this == NULL");
00571 
00572     INT32 PaneIndex = CommandToIndex(PaneID);
00573     return (PaneIndex != -1);
00574 }
00575 
00576 
00577 /******************************************************************************
00578 >   void CCStatusBar::OnMouseMove(UINT32 nFlags, CPoint MousePos )
00579 
00580     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00581     Created:    3/1/95
00582     Purpose:    handle mouse moves over the status bar
00583     Inputs:     nFlags   - 
00584                 MousePos -
00585     Errors:     this==NULL,
00586 ******************************************************************************/
00587 
00588 void CCStatusBar::OnMouseMove(UINT32 nFlags, CPoint MousePos)
00589 {
00590     ERROR3IF(this==NULL,"CCStatBar::OnMouseMove() - this==NULL");
00591 
00592     if (MousePos==OldMousePos)
00593         return;
00594 
00595     INT32 PaneIndex=GetPaneIndexFromPoint(MousePos);
00596     if (PaneIndex==-1)
00597         ControlHelper::BubbleHelpDisable();
00598     else
00599         ControlHelper::DoBubbleHelpOn(GetSafeHwnd(),PaneIndex,BubbleHelpCallBack,this);
00600 
00601     StatusLine* pStatusLine=GetApplication()->GetpStatusLine();
00602     if (pStatusLine)
00603     {
00604         String_256 Text("");
00605         GetStatusLineText(&Text,MousePos,GetSafeHwnd());
00606         if (!pStatusLine->UpdateText(&Text,STATUSLINE_SELDESC_STATBAR))
00607             ERROR3("CCStatusBar::OnMouseMove() - pStatusLine->UpdateText() failed");
00608     }
00609 
00610     OldMousePos=MousePos;
00611 }
00612 
00613 
00614 /******************************************************************************
00615 >   BOOL CCStatusBar::GetStatusLineText(String_256* pText, CPoint MousePos, HWND hWnd)
00616 
00617     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00618     Created:    3/1/95
00619     Purpose:    if over StatusLine, gets help for a given point
00620     Inputs:     MousePos - position in window
00621                 hWnd     - handle of window
00622     Outputs:    pText    -
00623     Returns:    TRUE if ptext hold valid text, else FALSE if not over a pane
00624     Errors:     this==NULL,
00625                 StringBase::Load() fails,
00626 ******************************************************************************/
00627 
00628 BOOL CCStatusBar::GetStatusLineText(String_256* pText, CPoint MousePos, HWND hWnd)
00629 {
00630     ERROR2IF(this==NULL,FALSE,"CCStatusBar::GetStatusLineText() - this==NULL");
00631 
00632     if (GetSafeHwnd()!=hWnd)
00633         return FALSE;
00634 
00635     INT32 PaneIndex=GetPaneIndexFromPoint(MousePos);
00636     if (PaneIndex==-1)
00637         return FALSE;
00638 
00639     return (pText->Load(pPaneData[PaneIndex].StatusHelpID)!=0);
00640 }
00641 
00642 
00643 /******************************************************************************
00644 >   INT32 CCStatusBar::GetPaneIndexFromPoint(CPoint point)
00645 
00646     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00647     Created:    3/1/95
00648     Purpose:    find the Index of a status bar pane given a point
00649     Inputs:     point - 
00650     Returns:    Index of pane containing point, or -1 if none
00651     Errors:     this==NULL,
00652 ******************************************************************************/
00653 
00654 INT32 CCStatusBar::GetPaneIndexFromPoint(CPoint point)
00655 {
00656     ERROR2IF(this==NULL,-1,"CCStatBar::GetPaneIndexFromPoint() - this==NULL");
00657 
00658     for (UINT32 i=0; i<NumPanes; i++)
00659     {
00660         RECT PaneRect;
00661         GetItemRect(i,&PaneRect);
00662         if (CRect(PaneRect).PtInRect(point))
00663             return i;
00664     }
00665     return -1;
00666 }
00667 
00668 
00669 /*********************************************************************************************
00670     static TCHAR* CCStatusBar::BubbleHelpCallBack(HWND hWnd, UINT32 PaneIndex, void* UserData)
00671 
00672     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00673     Created:    3/1/95
00674     Purpose:    Bubble help call back handler
00675                 (called some time after call to DoBubbleHelpOn() if mouse ha not moved)
00676     Inputs:     hWnd     - not used
00677                 PaneID   - ID of pane bubble help requesteed for
00678                 UserData - not used
00679     Returns:    pointer to text, or NULL if fails (see Errors)
00680     Errors:     PaneIndex out of range
00681                 StringBase::Load() fails
00682 **********************************************************************************************/
00683 TCHAR* CCStatusBar::BubbleHelpCallBack(HWND, UINT32 PaneIndex, void*)
00684 {
00685     static String_64 BubbleHelpText("");
00686 
00687     CCStatusBar* pCCStatusBar=GetApplication()->GetpCCStatusBar();
00688     ERROR3IF(pCCStatusBar==NULL,"CCStatusBar::BubbleHelpCallBack() - pCCStatusBar==NULL");
00689     if (pCCStatusBar && PaneIndex>=0 && PaneIndex<pCCStatusBar->NumPanes)
00690         BubbleHelpText.Load(pCCStatusBar->pPaneData[PaneIndex].BubbleHelpID);
00691     else
00692         ERROR3("CCStatusBar::BubbleHelpCallBack() - PaneIndex out of range");
00693 
00694     return (TCHAR*)BubbleHelpText;
00695 }
00696 
00697 
00699 // the following are copied from MFC in order to get greater control over StatusBar redraw
00700 /*  UIC Commented-out struct AFX_STATUSPANE
00701 struct AFX_STATUSPANE
00702 {
00703     UINT32    nID;        // IDC of indicator: 0 => normal text area
00704     UINT32    nStyle;     // style flags (SBPS_*)
00705     INT32     cxText;     // width of string area in pixels
00706                         //   on both sides there is a 1 pixel gap and
00707                         //    a one pixel border, making a pane 4 pixels wider
00708     LPCTSTR  lpszText;  // text in the pane
00709 };
00710 */
00711 
00712 struct AUX_DATA
00713 {
00714     // system metrics
00715     INT32 cxVScroll, cyHScroll;
00716     INT32 cxIcon, cyIcon;
00717 
00718     INT32 cxBorder2, cyBorder2;
00719 
00720     // device metrics for screen
00721     INT32 cxPixelsPerInch, cyPixelsPerInch;
00722     INT32 cySysFont;
00723 
00724     // solid brushes with convenient gray colors and system colors
00725     HBRUSH hbrLtGray, hbrDkGray;
00726     HBRUSH hbrBtnHilite, hbrBtnFace, hbrBtnShadow;
00727     HBRUSH hbrWindowFrame;
00728     HPEN hpenBtnHilite, hpenBtnShadow, hpenBtnText;
00729 
00730     // color values of system colors used for CToolBar
00731     COLORREF clrBtnFace, clrBtnShadow, clrBtnHilite;
00732     COLORREF clrBtnText, clrWindowFrame;
00733 
00734     // standard cursors
00735     HCURSOR hcurWait;
00736     HCURSOR hcurArrow;
00737     HCURSOR hcurHelp;       // cursor used in Shift+F1 help
00738 
00739     // special GDI objects allocated on demand
00740     HFONT   hStatusFont;
00741     HFONT   hToolTipsFont;
00742     HBITMAP hbmMenuDot;
00743 
00744     // other system information
00745     UINT32    nWinVer;        // Major.Minor version numbers
00746     BOOL    bWin32s;        // TRUE if Win32s (or Chicago)
00747     BOOL    bWin4;          // TRUE if Windows 4.0
00748     BOOL    bNotWin4;       // TRUE if not Windows 4.0
00749     BOOL    bSmCaption;     // TRUE if WS_EX_SMCAPTION is supported
00750     BOOL    bWin31;         // TRUE if actually Win32s on Windows 3.1
00751 
00752     // special Windows API entry points
00753     INT32 (WINAPI* pfnSetScrollInfo)(HWND, INT32, LPCSCROLLINFO, BOOL);
00754     BOOL (WINAPI* pfnGetScrollInfo)(HWND, INT32, LPSCROLLINFO);
00755 
00756 // Implementation
00757     AUX_DATA();
00758     ~AUX_DATA();
00759     void UpdateSysColors();
00760 };
00761 
00762 extern AFX_DATA AUX_DATA afxData;
00763 
00764 #define CX_BORDER   1
00765 #define CY_BORDER   1
00766 
00767 /******************************************************************************
00768 >   void CCStatusBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
00769 
00770     Author:     Chris_Snook (Xara Group Ltd) <camelotdev@xara.com>
00771     Created:    4/3/96
00772     Purpose:    The status line is incorrectly sized under Windows 95
00773                 
00774 ******************************************************************************/
00775 // UIC 
00776 
00777 CSize CCStatusBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
00778 {
00779     CSize NewSize(0,0);
00780     NewSize = CStatusBar::CalcFixedLayout(0,bHorz);
00781 // Removed, makes the status line too wide.
00782 /*  if(IS_CHICAGO)
00783     {
00784         NewSize.cy +=4;
00785     }
00786 */
00787     return NewSize;
00788  }
00789 
00790 /******************************************************************************
00791 >   void CCStatusBar::DoPaint(CDC* pdc)
00792 
00793     Author:     -
00794     Created:    -
00795     Purpose:    Complete copy of MFC function so that it can call the CCStatusBar
00796                 version of DrawStatusText (which is not virtual in CStatusBar!!!!)
00797 ******************************************************************************/
00798 // UIC Replaced (DoPaint) with DrawItem(LPITEMSTRUCT lpDrawItemStruct) 
00799 
00800 void CCStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
00801 {
00802     INT32 itemID = lpDrawItemStruct->itemID;
00803     CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
00804     
00805     ASSERT_VALID(pDC);
00806     ASSERT_VALID(this);
00807 
00808     CRect rect;
00809     GetClientRect(&rect);
00810     CStatusBarCtrl* pCStatusBarCtrl = &GetStatusBarCtrl();
00811     pCStatusBarCtrl->GetRect(itemID, &rect);
00812     CBrush TheBrush(GetSysColor(COLOR_BTNFACE)) ;
00813     pDC->FillRect(&rect,&TheBrush);
00814 
00815 //  ASSERT_VALID(pDC);
00816 //  ASSERT_VALID(this);
00817 
00818         // slight bodge here
00819         if(itemID==0)
00820         {
00821             CString Text = GetPaneText(itemID);
00822             DrawStatusText(pDC, lpDrawItemStruct->rcItem,(LPCTSTR)Text, GetPaneStyle(itemID));
00823         }
00824         else if ((pPaneData[itemID].PaneID)== _R(IDS_SL_MOUSEPOS))
00825         {
00826             CString Text = GetPaneText(itemID);
00827             DrawStatusText(pDC, lpDrawItemStruct->rcItem, (LPCTSTR)Text, GetPaneStyle(itemID));
00828         }
00829         else if ((pPaneData[itemID].PaneID)== _R(IDS_SL_PRINTMODE))
00830         {
00831             RECT rcPane = lpDrawItemStruct->rcItem;
00832 
00833             if (pPaneData[itemID].BitmapID)
00834             {
00835                 // Paint bitmap to left end of pane
00836                 rcPane.right = rcPane.left + 16;
00837                 PaintBitmap(pDC, rcPane, pPaneData[itemID].BitmapID, GetPaneStyle(itemID));
00838 
00839                 // Reset rectangle so text doesn't overlap bitmap
00840                 rcPane = lpDrawItemStruct->rcItem;
00841                 rcPane.left = rcPane.left + 16;
00842             }
00843             CString Text = GetPaneText(itemID);
00844             DrawStatusText(pDC, rcPane, (LPCTSTR)Text, GetPaneStyle(itemID));
00845         }
00846         else if (pPaneData[itemID].BitmapID)
00847         {
00848             if (GetPaneStyle(itemID) & SBPS_DISABLED)
00849             { 
00850                 PaintBitmap(pDC, lpDrawItemStruct->rcItem, pPaneData[itemID].OffBitmapID, GetPaneStyle(itemID));
00851             }
00852             else
00853             {  
00854                 PaintBitmap(pDC, lpDrawItemStruct->rcItem, pPaneData[itemID].BitmapID, GetPaneStyle(itemID));
00855             }
00856             
00857         }   
00858 }
00859   
00860 /*
00861  void CCStatusBar::DoPaint(CDC* pDC)
00862 {
00863     ASSERT_VALID(this);
00864     ASSERT_VALID(pDC);
00865 
00866     CControlBar::DoPaint(pDC);      // draw border
00867 
00868     CRect rect;
00869     GetClientRect(rect);
00870     CalcInsideRect(rect, TRUE);
00871 
00872     ASSERT(m_hFont != NULL);        // must have a font!
00873     HGDIOBJ hOldFont = pDC->SelectObject(m_hFont);
00874 
00875     // protect space for size box
00876     INT32 cxSizeBox = m_bHideSizeBox ? 0 : m_cxSizeBox;
00877     INT32 xMax = (rect.right -= cxSizeBox);
00878     if (cxSizeBox == 0)
00879         xMax += m_cxRightBorder + 1;
00880 
00881     // walk through to calculate extra space
00882     INT32 cxExtra = rect.Width() + m_cxDefaultGap;
00883     AFX_STATUSPANE* pSBP = (AFX_STATUSPANE*)m_pData;
00884     for (INT32 i = 0; i < m_nCount; i++, pSBP++)
00885         cxExtra -= (pSBP->cxText + CX_BORDER * 4 + m_cxDefaultGap);
00886     // if cxExtra <= 0 then we will not stretch but just clip
00887 
00888     for (i = 0, pSBP = (AFX_STATUSPANE*)m_pData; i < m_nCount; i++, pSBP++)
00889     {
00890         ASSERT(pSBP->cxText >= 0);
00891         INT32 cxText = pSBP->cxText;
00892         if ((pSBP->nStyle & SBPS_STRETCH) && cxExtra > 0)
00893         {
00894             cxText += cxExtra;
00895             cxExtra = 0;
00896         }
00897         rect.right = rect.left + cxText + CX_BORDER * 4;
00898         rect.right = min(rect.right, xMax);
00899 //      if (!afxData.bWin32s || pDC->RectVisible(&rect))
00900         if (pDC->RectVisible(&rect))
00901         {
00902 //NEW CODE
00903             if (pPaneData[i].BitmapID)
00904             {
00905                 if (pSBP->nStyle & SBPS_DISABLED)
00906                     PaintBitmap(pDC, rect, pPaneData[i].OffBitmapID, pSBP->nStyle);
00907                 else
00908                     PaintBitmap(pDC, rect, pPaneData[i].BitmapID, pSBP->nStyle);
00909             }
00910             else
00911 // END OF NEW CODE
00912                 DrawStatusText(pDC, rect, pSBP->lpszText, pSBP->nStyle);
00913         }
00914         rect.left = rect.right + m_cxDefaultGap;
00915         if (rect.left >= xMax)
00916             break;
00917     }
00918     pDC->SelectObject(hOldFont);
00919 
00920     // draw the size box in the bottom right corner
00921     if (cxSizeBox != 0)
00922     {
00923         INT32 cxMax = min(cxSizeBox, rect.Height()+m_cyTopBorder);
00924         rect.left = xMax + (cxSizeBox - cxMax) + CX_BORDER;
00925         rect.bottom -= CX_BORDER;
00926         HPEN hPenOld = (HPEN)pDC->SelectObject(afxData.hpenBtnHilite);
00927         for (INT32 i = 0; i < cxMax; i += 4)
00928         {
00929             pDC->MoveTo(rect.left+i, rect.bottom);
00930             pDC->LineTo(rect.left+cxMax, rect.bottom-cxMax+i);
00931         }
00932         pDC->SelectObject(afxData.hpenBtnShadow);
00933         for (i = 1; i < cxMax; i += 4)
00934         {
00935             pDC->MoveTo(rect.left+i, rect.bottom);
00936             pDC->LineTo(rect.left+cxMax, rect.bottom-cxMax+i);
00937         }
00938         for (i = 2; i < cxMax; i += 4)
00939         {
00940             pDC->MoveTo(rect.left+i, rect.bottom);
00941             pDC->LineTo(rect.left+cxMax, rect.bottom-cxMax+i);
00942         }
00943         pDC->SelectObject(hPenOld);
00944     }
00945 } 
00946 
00947 */
00948 
00949 
00950 /*************************************************************************************************
00951 >   void CCStatusBar::DrawStatusText(CDC* pDC, const CRect& rect, LPCTSTR lpszText, UINT32 nStyle)
00952     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00953     Created:    -
00954     Purpose:    Copy of MFC function to allow everything upto the first ':' to be emboldened
00955 *************************************************************************************************/
00956 
00957 void CCStatusBar::DrawStatusText(CDC* pDC, const CRect& rect, LPCTSTR lpszText, UINT32 nStyle)
00958 {
00959     ASSERT_VALID(pDC);
00960 /*  UIC 
00961     if (!(nStyle & SBPS_NOBORDERS))
00962     {
00963         // Colours are in parameter order:
00964         // clrTopLeft   Specifies the color of the top and left sides of the three-dimensional rectangle.
00965         // clrBottomRight   Specifies the color of the bottom and right sides of the three-dimensional rectangle.
00966         if (nStyle & SBPS_POPOUT)
00967             pDC->Draw3dRect(rect, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); //afxData.clrBtnHilite, afxData.clrBtnShadow);
00968         else
00969             pDC->Draw3dRect(rect, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); //afxData.clrBtnShadow, afxData.clrBtnHilite);
00970     }
00971 */ 
00972     // just support left justified text
00973     if (lpszText != NULL) // && !(nStyle & SBPS_DISABLED))
00974     {
00975         CRect rectText(rect);
00976         if (!(nStyle & SBPS_NOBORDERS)) // only adjust if there are borders
00977             rectText.InflateRect(-2*CX_BORDER, -CY_BORDER);
00978         else
00979             rectText.OffsetRect(0, -CY_BORDER); // baselines line up
00980     /*  UIC
00981         // chicago bodge - shift the text up by one pixel
00982         if(IS_CHICAGO)
00983             rectText.OffsetRect(0, -1); 
00984     */  
00985 
00986         // background is already grey   
00987         INT32 nOldMode = pDC->SetBkMode(TRANSPARENT);  
00988         COLORREF crBkColor = GetSysColor(COLOR_BTNFACE);  
00989         pDC->SetBkColor(crBkColor);  
00990         //COLORREF crBkColor   = pDC->SetBkColor(afxData.clrBtnFace);  
00991         COLORREF crTextColor = GetSysColor(COLOR_BTNTEXT);
00992         pDC->SetTextColor(crTextColor); //afxData.clrBtnText); 
00993 
00994     if (nStyle & SBPS_DISABLED)
00995             pDC->SetTextColor(crTextColor); //afxData.clrBtnShadow);
00996 
00997         // align on bottom (since descent is more important than ascent)
00998         pDC->SetTextAlign(TA_LEFT | TA_BOTTOM);
00999 
01000 // NEW CODE - output all text upto the first colon (if any) in bold
01001         String_256 text(lpszText);
01002         INT32 BoldLen=text.Sub(String_8("::"))+1;   // include one colon
01003         if (BoldLen>0)
01004         {
01005             // split into 2 strings
01006             String_256 BoldText("");
01007             text.Left(&BoldText,BoldLen);
01008             text.Right(&text,text.Length()-BoldLen-1); // strip one colon
01009 
01010             // select bold font and find width of bold text (limited to text rect width)
01011         //  HGDIOBJ hOldFont=pDC->SelectObject(FontFactory::GetFont(STOCKFONT_STATUSBARBOLD));
01012             HGDIOBJ hOldBoldFont=pDC->SelectObject(FontFactory::GetFont(STOCKFONT_STATUSBARBOLD));  //UIC 
01013 
01014             INT32 BoldTextWidth=pDC->GetTextExtent(BoldText,BoldText.Length()).cx;
01015             INT32 TextRectWidth=rectText.Width();
01016             if (BoldTextWidth>TextRectWidth)
01017                 BoldTextWidth=TextRectWidth;
01018 
01019             // output the bold text, modify text rect, restore font
01020             pDC->ExtTextOut(rectText.left, rectText.bottom,
01021                 ETO_CLIPPED, &rectText, (TCHAR*)BoldText, BoldLen, NULL);
01022             rectText.left+=BoldTextWidth;
01023         //  pDC->SelectObject(hOldFont);
01024             pDC->SelectObject(hOldBoldFont); // UIC
01025         }
01026 // END OF NEW CODE
01027         HGDIOBJ hOldFont=pDC->SelectObject(FontFactory::GetFont(STOCKFONT_STATUSBAR)); // UIC   
01028         // output remaining text
01029         pDC->ExtTextOut(rectText.left, rectText.bottom,
01030             ETO_CLIPPED, &rectText, (TCHAR*)text, text.Length(), NULL);
01031         pDC->SelectObject(hOldFont);    // UIC 
01032     }
01033 }
01034 
01036 
01037 
01038 /******************************************************************************
01039 
01040 >   BOOL CCStatusBar::PaintBitmap(CDC* pDC, const CRect& rect, UINT32 BitmapID, UINT32 nStyle)
01041 
01042     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
01043     Created:    3/2/95
01044     Purpose:    Paint a bitmap into a StatusLine pane
01045                 Accounting for Styles: BORDERS/POPOUT/DISABLED
01046     Inputs:     pDC      - 
01047                 rect     - 
01048                 BitmapID - 
01049                 nStyle   -
01050     Returns:    FALSE if failed
01051     Errors:     this == NULL
01052     SeeAlso:    CColourBar::PaintEditOrNewButton;
01053 
01054 ******************************************************************************/
01055 
01056 BOOL CCStatusBar::PaintBitmap(CDC* pDC, const CRect& rect, UINT32 BitmapID, UINT32 nStyle)
01057 {
01058     CRect BMRect(rect);
01059     if (!(nStyle & SBPS_NOBORDERS))
01060         BMRect.SetRect(rect.left+CX_BORDER, rect.top+CY_BORDER, rect.right-CX_BORDER, rect.bottom-CY_BORDER);
01061 
01062     if (BitmapID)
01063     {
01064         CDC srcDC;
01065         srcDC.CreateCompatibleDC(NULL);
01066 
01067         CBitmap bitmap;
01068         bitmap.LoadBitmap(BitmapID);
01069 
01070         CBitmap* pOldBitmap = srcDC.SelectObject(&bitmap);
01071 
01072         pDC->BitBlt(BMRect.left, BMRect.top, BMRect.Width(), BMRect.Height(), &srcDC, 0,0, SRCCOPY);
01073 
01074         // Now plot the glyph bitmap. It is a masked plot - all the light grey pixels
01075         // are plotted using the system COLOR_BTNFACE colour.
01076         CDC MonoDC;
01077         MonoDC.CreateCompatibleDC(NULL);
01078 
01079         // ...Now create a mono bitmap for the mask
01080         CBitmap MonoBitmap;
01081         MonoBitmap.CreateBitmap(BMRect.Width(), BMRect.Height(), 1, 1, NULL);
01082         CBitmap *OldMonoBitmap = MonoDC.SelectObject(&MonoBitmap);
01083 
01084         // Plot all light grey pixels in the glyph as black in our mask, while other pixels are white
01085         // The transparent bits on the bitmap button should be coloured purple to be see through 
01086         MonoDC.PatBlt(0, 0, BMRect.Width(), BMRect.Height(), WHITENESS);
01087         srcDC.SetBkColor(RGB(255,0,255));       // purple masking colour
01088         MonoDC.BitBlt(0, 0, BMRect.Width(), BMRect.Height(), &srcDC, 0, 0, SRCCOPY);
01089 
01090         pDC->SetTextColor(0L);                  // 0's in mono -> 0 (for ROP)
01091         pDC->SetBkColor((COLORREF)0x00FFFFFFL); // 1's in mono -> 1
01092 
01093         // And then blit the mask shape over the top, using the correct button face colour
01094         // (The areas not in the mask will not be plotted, so we are rendering the mask area only)
01095         CBrush HighlightBrush;
01096         HighlightBrush.CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
01097 
01098         CBrush *OldBrush = pDC->SelectObject(&HighlightBrush);
01099         // draw highlight color where we have 0's in the mask, using a special RasterOp code (DSPDxax)
01100         pDC->BitBlt(BMRect.left, BMRect.top, BMRect.Width(), BMRect.Height(), &MonoDC, 0, 0, 0x00E20746L);
01101 
01102         // Put back the old brush
01103         pDC->SelectObject(OldBrush);
01104 
01105         MonoDC.SelectObject(OldMonoBitmap);
01106 
01107         // Put back the old bitmap
01108         srcDC.SelectObject(pOldBitmap);
01109     }
01110 /*  UIC 
01111 
01112     if (!(nStyle & SBPS_NOBORDERS))
01113     {
01114         // Colours are in parameter order:
01115         // clrTopLeft   Specifies the color of the top and left sides of the three-dimensional rectangle.
01116         // clrBottomRight   Specifies the color of the bottom and right sides of the three-dimensional rectangle.
01117 
01118         if (nStyle & SBPS_POPOUT)
01119             pDC->Draw3dRect(rect, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); //afxData.clrBtnHilite, afxData.clrBtnShadow);
01120         else
01121             pDC->Draw3dRect(rect, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); //afxData.clrBtnShadow, afxData.clrBtnHilite);
01122     }
01123 */
01124     return TRUE;
01125 }
01126 
01127 
01128 /***********************************************************************************************
01129 >   BOOL CCStatusBar::UpdatePaneBitmap(INT32 PaneID, UINT32 BitmapID, BOOL ImmediateUpdate=FALSE);
01130 
01131     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
01132     Created:    6/2/95
01133     Purpose:    Update specified status bar pane
01134     Inputs:     PaneID   - id of pane
01135                 BitmapID - text (or NULL)
01136                 ImmediateUpdate - redraw pane now (rather than queuing)
01137     Returns:    FALSE if failed (see Errors)
01138     Errors:     this==NULL,
01139                 PaneID unrecognised
01140 ************************************************************************************************/
01141 
01142 BOOL CCStatusBar::UpdatePaneBitmap(INT32 PaneID, UINT32 BitmapID, BOOL ImmediateUpdate)
01143 {
01144     ERROR2IF(this == NULL,FALSE,"CStatusBar::UpdatePaneBitmap() - this == NULL");
01145 
01146     INT32 PaneIndex = CommandToIndex(PaneID);
01147     ERROR2IF(PaneIndex == -1,FALSE,"CStatusBar::UpdatePaneBitmap() - unknown PaneID");
01148 
01149     /*if (pPaneData[PaneIndex].BitmapID != BitmapID)
01150     {
01151 */
01152         if (BitmapID!=0)
01153             pPaneData[PaneIndex].BitmapID = BitmapID;
01154 
01155         CRect rect;
01156         GetItemRect(PaneIndex,&rect);
01157 
01158         UINT32 nStyle;
01159         INT32  nWidth;
01160         UINT32 nID;
01161         GetPaneInfo(PaneIndex,nID,nStyle,nWidth);
01162         if (!(nStyle & SBPS_NOBORDERS))
01163             rect.SetRect(rect.left+CX_BORDER, rect.top+CY_BORDER, rect.right-CX_BORDER, rect.bottom-CY_BORDER);
01164 
01165         InvalidateRect(rect);
01166         if (ImmediateUpdate)
01167             UpdateWindow();
01168 //  }
01169 
01170     return TRUE;
01171 }
01172 
01173 
01174 

Generated on Sat Nov 10 03:48:18 2007 for Camelot by  doxygen 1.4.4