ExtSkinPaintManager.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:231k
源码类别:
界面编程
开发平台:
Visual C++
- // This is part of the Professional User Interface Suite library.
- // Copyright (C) 2001-2009 FOSS Software, Inc.
- // All rights reserved.
- //
- // http://www.prof-uis.com
- // mailto:support@prof-uis.com
- //
- // This source code can be used, modified and redistributed
- // under the terms of the license agreement that is included
- // in the Professional User Interface Suite package.
- //
- // Warranties and Disclaimers:
- // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
- // INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- // IN NO EVENT WILL FOSS SOFTWARE INC. BE LIABLE FOR ANY DIRECT,
- // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES,
- // INCLUDING DAMAGES FOR LOSS OF PROFITS, LOSS OR INACCURACY OF DATA,
- // INCURRED BY ANY PERSON FROM SUCH PERSON'S USAGE OF THIS SOFTWARE
- // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- #include "StdAfx.h"
- #if (!defined __PROF_SKIN_PAINT_MANAGER_H)
- #include <../ProfSkin/ExtSkinPaintManager.h>
- #endif
- #if (! defined __EXTMINIDOCKFRAMEWND_H)
- #include <../Src/ExtMiniDockFrameWnd.h>
- #endif
- #if (!defined __EXTDOCKBAR_H)
- #include <../Src/ExtDockBar.h>
- #endif
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #if (!defined __EXT_CONTROLBAR_TABBED_FEATURES_H)
- #include <../Src/ExtControlBarTabbedFeatures.h>
- #endif // __EXT_CONTROLBAR_TABBED_FEATURES_H
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #if (! defined __VSSYM32_H__)
- #include <vssym32/vssym32.h>
- #endif // (! defined __VSSYM32_H__)
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- IMPLEMENT_SERIAL( CExtPaintManagerSkin, CExtPaintManager, VERSIONABLE_SCHEMA|1 );
- CExtPaintManagerSkin::CExtPaintManagerSkin(void)
- {
- m_bUseTahomaFont = false;
- #if (!defined __EXT_MFC_NO_PAGECONTAINER_CTRL)
- m_bPageContainerUseButtonStyle = true;
- m_bPageContainerUseGroupBoxStyle = true;
- m_bPageContainerNoEmbossDisabledText = true;
- #endif // (!defined __EXT_MFC_NO_PAGECONTAINER_CTRL)
- #if (!defined __EXT_MFC_NO_SHORTCUTLIST_CTRL)
- m_bShortcutListUseButtonStyleInScrollButtons = true;
- m_bShortcutListUseDockerBkgnd = true;
- m_bShortcutListItemUseButtonStyle = true;
- #endif // (!defined __EXT_MFC_NO_SHORTCUTLIST_CTRL)
- }
- CExtPaintManagerSkin::~CExtPaintManagerSkin(void)
- {
- }
- void CExtPaintManagerSkin::SerializeSynchronizationData( CArchive & ar )
- {
- ASSERT_VALID( this );
- m_Skin.Serialize( ar );
- }
- bool CExtPaintManagerSkin::OnStateSerialize(
- CArchive & ar,
- bool bEnableThrowExceptions // = false
- )
- {
- try
- {
- m_Skin.SerializeCompressedBlock( ar, bEnableThrowExceptions );
- return true;
- }
- catch( CException * pXept )
- {
- if( bEnableThrowExceptions )
- throw;
- pXept->Delete();
- }
- catch( ... )
- {
- if( bEnableThrowExceptions )
- throw;
- }
- return false;
- }
- bool CExtPaintManagerSkin::NcFrame_IsSupported(
- const CWnd * pWnd,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- lParam;
- if( pWnd == NULL )
- return false;
- //ASSERT_VALID( pWnd );
- if( pWnd->GetSafeHwnd() == NULL )
- return false;
- //DWORD dwStyle = pWnd->GetStyle();
- // if( (dwStyle&WS_CHILD) != 0 )
- // return false;
- return true;
- }
- HRGN CExtPaintManagerSkin::NcFrame_GenerateSkinFrameRGN(
- const RECT & rcWnd,
- const CWnd * pWnd,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pWnd );
- rcWnd;
- lParam;
- const CExtSkinGlyph & glyphFrame = m_Skin[_T("NcFrame")][_T("NcArea")].Glyph(_T("Inactive"));
- //CRect rcNcBorders = glyphFrame.GetContentPadding();
- CRect rcThemePadding = glyphFrame.GetPadding();
- bool bRTL = ( (pWnd->GetExStyle()&WS_EX_LAYOUTRTL) != 0 ) ? true : false;
- HRGN hRgn =
- glyphFrame.GetBitmap().GenerateSkinFrameAlphaRGN(
- bRTL,
- rcWnd,
- rcThemePadding
- );
- return hRgn;
- }
- INT CExtPaintManagerSkin::NcFrame_GetCaptionHeight(
- bool bActive,
- const CWnd * pWnd,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- bActive;
- pWnd;
- lParam;
- CRect rcCaption =
- NcFrame_GetHtRect(
- HTCAPTION,
- false,
- true,
- true,
- NULL,
- pWnd,
- NULL
- );
- return rcCaption.Height();
- }
- void CExtPaintManagerSkin::NcFrame_GetMetrics(
- RECT & rcNcBorders,
- RECT & rcThemePadding,
- const CWnd * pWnd,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( NcFrame_IsSupported( pWnd ) );
- rcNcBorders;
- rcThemePadding;
- pWnd;
- lParam;
- const CExtSkinGlyph & glyphFrame = m_Skin[_T("NcFrame")][_T("NcArea")].Glyph(_T("Inactive"));
- rcNcBorders = glyphFrame.GetContentPadding();
- rcThemePadding = glyphFrame.GetPadding();
- }
- CRect CExtPaintManagerSkin::NcFrame_GetHtRect(
- UINT nHT,
- bool bScreenMapping,
- bool bLayoutBordersH,
- bool bLayoutBordersV,
- const CExtCmdIcon * pIcon,
- const CWnd * pWnd,
- LPMINMAXINFO pMinMaxInfo, // = NULL
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( NcFrame_IsSupported( pWnd ) );
- CRect rcNcBorders, rcThemePadding;
- NcFrame_GetMetrics(
- rcNcBorders,
- rcThemePadding,
- pWnd,
- lParam
- );
- CRect rcWnd;
- pWnd->GetWindowRect( &rcWnd );
- if( ! bScreenMapping )
- rcWnd.OffsetRect( -rcWnd.TopLeft() );
- bool bZoomed = pWnd->IsZoomed()? true : false;
- bool bSupportsResizingH = bLayoutBordersH;
- bool bSupportsResizingV = bLayoutBordersV;
- DWORD dwWndStyle = pWnd->GetStyle();
- if( (dwWndStyle&WS_THICKFRAME) != 0
- && ( (! bSupportsResizingH )
- || (! bSupportsResizingV )
- )
- )
- {
- bool bHaveMinMaxInfo = false;
- MINMAXINFO _mmi;
- if( pMinMaxInfo != NULL )
- {
- bHaveMinMaxInfo = true;
- __EXT_MFC_MEMCPY(
- &_mmi,
- sizeof(MINMAXINFO),
- pMinMaxInfo,
- sizeof(MINMAXINFO)
- );
- } // if( pMinMaxInfo != NULL )
- else
- {
- ::memset( &_mmi, 0, sizeof(MINMAXINFO) );
- monitor_parms_t _mp;
- stat_GetMonitorParms( _mp, (CWnd*)pWnd );
- _mmi.ptMaxPosition.x = _mp.m_rcWorkArea.left;
- _mmi.ptMaxPosition.y = _mp.m_rcWorkArea.top;
- _mmi.ptMaxTrackSize.x = _mp.m_rcWorkArea.Width(); // ::GetSystemMetrics( SM_CXMAXTRACK );
- _mmi.ptMaxTrackSize.y = _mp.m_rcWorkArea.Height(); // ::GetSystemMetrics( SM_CYMAXTRACK );
- _mmi.ptMinTrackSize.x = ::GetSystemMetrics( SM_CXMINTRACK );
- _mmi.ptMinTrackSize.y = ::GetSystemMetrics( SM_CYMINTRACK );
- _mmi.ptMaxSize.x = _mmi.ptMaxTrackSize.x;
- _mmi.ptMaxSize.y = _mmi.ptMaxTrackSize.y;
- if( ((CWnd*)pWnd)->SendMessage( WM_GETMINMAXINFO, 0, LPARAM(&_mmi) ) == 0 )
- bHaveMinMaxInfo = true;
- } // else from if( pMinMaxInfo != NULL )
- if( bHaveMinMaxInfo )
- {
- if( _mmi.ptMinTrackSize.x < _mmi.ptMaxTrackSize.x )
- bSupportsResizingH = true;
- if( _mmi.ptMinTrackSize.y < _mmi.ptMaxTrackSize.y )
- bSupportsResizingV = true;
- } // if( bHaveMinMaxInfo )
- } // if( (dwWndStyle&WS_THICKFRAME) != 0 ...
- switch( nHT )
- {
- case HTSYSMENU:
- {
- if( (dwWndStyle&WS_SYSMENU) == 0 )
- break;
- int nIconAreaWidth = 0;
- if( pIcon != NULL && (! pIcon->IsEmpty() ) )
- nIconAreaWidth = pIcon->GetSize().cx + 2;
- return
- CRect(
- rcWnd.left + ( bSupportsResizingH ? rcNcBorders.left : 0 ),
- rcWnd.top + ( bSupportsResizingV ? rcNcBorders.top : 0 ),
- rcWnd.left + ( bSupportsResizingH ? rcNcBorders.left : 0 )
- + nIconAreaWidth,
- rcWnd.top + rcThemePadding.top
- );
- }
- case HTCAPTION:
- // if( (dwWndStyle&WS_CAPTION) == 0 )
- // break;
- return
- CRect(
- rcWnd.left + (bZoomed ? 0 : ( bSupportsResizingH ? rcNcBorders.left : 0 ) ),
- rcWnd.top + (bZoomed ? 0 : ( bSupportsResizingV ? rcNcBorders.top : 0 ) ),
- rcWnd.right - (bZoomed ? 0 : ( bSupportsResizingH ? rcNcBorders.right : 0 ) ),
- rcWnd.top + rcThemePadding.top
- );
- case HTTOP:
- if( bZoomed || (! bSupportsResizingV ) )
- break;
- return
- CRect(
- rcWnd.left + ( bSupportsResizingH ? rcNcBorders.left : 0 ),
- rcWnd.top,
- rcWnd.right - ( bSupportsResizingH ? rcNcBorders.right : 0 ),
- rcWnd.top + rcNcBorders.top
- );
- case HTBOTTOM:
- if( bZoomed || (! bSupportsResizingV ) )
- break;
- return
- CRect(
- rcWnd.left + ( bSupportsResizingH ? rcNcBorders.left : 0 ),
- rcWnd.bottom - rcNcBorders.bottom,
- rcWnd.right - ( bSupportsResizingH ? rcNcBorders.right : 0 ),
- rcWnd.bottom
- );
- case HTLEFT:
- if( bZoomed || (! bSupportsResizingH ) )
- break;
- return
- CRect(
- rcWnd.left,
- rcWnd.top + ( bSupportsResizingV ? rcNcBorders.top : 0 ),
- rcWnd.left + rcNcBorders.left,
- rcWnd.bottom - ( bSupportsResizingV ? rcNcBorders.bottom : 0 )
- );
- case HTRIGHT:
- if( bZoomed || (! bSupportsResizingH ) )
- break;
- return
- CRect(
- rcWnd.right - rcNcBorders.right,
- rcWnd.top + ( bSupportsResizingV ? rcNcBorders.top : 0 ),
- rcWnd.right,
- rcWnd.bottom - ( bSupportsResizingV ? rcNcBorders.bottom : 0 )
- );
- case HTTOPLEFT:
- if( bZoomed || (! bSupportsResizingH ) || (! bSupportsResizingV ) )
- break;
- return
- CRect(
- rcWnd.left,
- rcWnd.top,
- rcWnd.left + rcNcBorders.left,
- rcWnd.top + rcNcBorders.top
- );
- case HTTOPRIGHT:
- if( bZoomed || (! bSupportsResizingH ) || (! bSupportsResizingV ) )
- break;
- return
- CRect(
- rcWnd.right - rcNcBorders.right,
- rcWnd.top,
- rcWnd.right,
- rcWnd.top + rcNcBorders.top
- );
- case HTBOTTOMLEFT:
- if( bZoomed || (! bSupportsResizingH ) || (! bSupportsResizingV ) )
- break;
- return
- CRect(
- rcWnd.left,
- rcWnd.bottom - rcNcBorders.bottom,
- rcWnd.left + rcNcBorders.left,
- rcWnd.bottom
- );
- case HTBOTTOMRIGHT:
- if( bZoomed || (! bSupportsResizingH ) || (! bSupportsResizingV ) )
- break;
- return
- CRect(
- rcWnd.right - rcNcBorders.right,
- rcWnd.bottom - rcNcBorders.bottom,
- rcWnd.right,
- rcWnd.bottom
- );
- } // switch( nHT )
- return CRect( 0, 0, 0, 0 );
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPaintManagerSkin::stat_NcFrameButton_NameFromState(
- CExtPaintManager::e_nc_button_state_t eState
- )
- {
- if( eState == __ENCBS_DISABLED )
- return _T("Disabled");
- if( eState == __ENCBS_HOVER )
- return _T("Hover");
- if( eState == __ENCBS_PRESSED )
- return _T("Pressed");
- ASSERT( eState == __ENCBS_NORMAL );
- return _T("Normal");
- }
- void CExtPaintManagerSkin::NcFrame_Paint(
- CDC & dc,
- const CExtCmdIcon * pIcon,
- __EXT_MFC_SAFE_LPCTSTR strCaption,
- UINT nDrawTextAlignFlags,
- const RECT & rcFrame,
- const RECT & rcClient,
- const RECT & rcIcon,
- const RECT & rcText,
- const RECT & rcHelp,
- const RECT & rcMinimize,
- const RECT & rcMaximizeRestore,
- const RECT & rcClose,
- bool bFrameActive,
- bool bFrameEnabled,
- bool bFrameMaximized,
- CExtPaintManager::e_nc_button_state_t eStateButtonHelp,
- CExtPaintManager::e_nc_button_state_t eStateButtonMinimize,
- CExtPaintManager::e_nc_button_state_t eStateButtonMaximizeRestore,
- CExtPaintManager::e_nc_button_state_t eStateButtonClose,
- const CWnd * pWnd,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- // pIcon;
- // strCaption;
- // nDrawTextAlignFlags;
- // rcFrame;
- rcClient;
- // rcIcon;
- // rcText;
- // rcHelp;
- // rcMinimize;
- // rcMaximizeRestore;
- // rcClose;
- // bFrameActive;
- bFrameEnabled;
- // bFrameMaximized;
- // eStateButtonHelp;
- // eStateButtonMinimize;
- // eStateButtonMaximizeRestore;
- // eStateButtonClose;
- pWnd;
- lParam;
- LPCTSTR strFrameActive =
- bFrameActive ? _T("Active") : _T("Inactive");
- const CExtSkinGlyph & glyphFrame =
- m_Skin[_T("NcFrame")][_T("NcArea")].Glyph(strFrameActive);
- const CExtSkinColor & colorFrameText =
- m_Skin[_T("NcFrame")][_T("NcArea")].Color(strFrameActive);
- glyphFrame.Draw( dc.m_hDC, rcFrame, true );
- if( pIcon != NULL
- && (! pIcon->IsEmpty() )
- && ( ! ::IsRectEmpty( &rcIcon ) )
- && dc.RectVisible( &rcIcon )
- )
- pIcon->Paint(
- const_cast < CExtPaintManagerSkin * > ( this ),
- dc.m_hDC,
- rcIcon.left,
- rcIcon.top,
- -1,
- -1
- );
- if( ! colorFrameText.IsHollow() )
- {
- int nLenCaption =
- int( ( strCaption == NULL ) ? 0 : _tcslen( strCaption ) );
- if( nLenCaption > 0
- && ( ! ::IsRectEmpty( &rcText ) )
- && dc.RectVisible( &rcText )
- )
- {
- const CExtSkinFont & fontFrameText =
- m_Skin[_T("NcFrame")][_T("NcArea")].Font(strFrameActive);
- CFont _font;
- if( fontFrameText.CreateFont( _font ) )
- {
- COLORREF clrText =
- //RGB( 255, 255, 255 );
- COLORREF( colorFrameText );
- CFont * pOldFont = dc.SelectObject(
- //(CFont*)&m_FontBold
- &_font
- );
- COLORREF clrOldText = dc.SetTextColor( clrText );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- dc.DrawText(
- strCaption,
- nLenCaption,
- (LPRECT)&rcText,
- nDrawTextAlignFlags|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- dc.SelectObject( pOldFont );
- } // if( fontFrameText.CreateFont( _font ) )
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- } // else from if( fontFrameText.CreateFont( _font ) )
- #endif // _DEBUG
- }
- } // if( ! colorFrameText.IsHollow() )
- if( ( ! ::IsRectEmpty( &rcHelp ) )
- && dc.RectVisible( &rcHelp )
- )
- {
- LPCTSTR strGlyph = stat_NcFrameButton_NameFromState( eStateButtonHelp );
- const CExtSkinGlyph & glyph = m_Skin[_T("Button")][_T("FrameNcButton")][_T("Help")][strFrameActive].Glyph(strGlyph);
- glyph.Draw( dc.m_hDC, rcHelp );
- }
- if( ( ! ::IsRectEmpty( &rcMinimize ) )
- && dc.RectVisible( &rcMinimize )
- )
- {
- LPCTSTR strGlyph = stat_NcFrameButton_NameFromState( eStateButtonMinimize );
- const CExtSkinGlyph & glyph = m_Skin[_T("Button")][_T("FrameNcButton")]
- [
- ( pWnd != NULL && pWnd->IsIconic() )
- ? _T("Restore")
- : _T("Minimize")
- ]
- [strFrameActive].Glyph(strGlyph);
- glyph.Draw( dc.m_hDC, rcMinimize );
- }
- if( ( ! ::IsRectEmpty( &rcMaximizeRestore ) )
- && dc.RectVisible( &rcMaximizeRestore )
- )
- {
- LPCTSTR strGlyph = stat_NcFrameButton_NameFromState( eStateButtonMaximizeRestore );
- const CExtSkinGlyph & glyph = m_Skin[_T("Button")][_T("FrameNcButton")][ bFrameMaximized ? _T("Restore") : _T("Maximize") ][strFrameActive].Glyph(strGlyph);
- glyph.Draw( dc.m_hDC, rcMaximizeRestore );
- }
- if( ( ! ::IsRectEmpty( &rcClose ) )
- && dc.RectVisible( &rcClose )
- )
- {
- LPCTSTR strGlyph = stat_NcFrameButton_NameFromState( eStateButtonClose );
- const CExtSkinGlyph & glyph = m_Skin[_T("Button")][_T("FrameNcButton")][_T("Close")][strFrameActive].Glyph(strGlyph);
- glyph.Draw( dc.m_hDC, rcClose );
- }
- }
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- void CExtPaintManagerSkin::Ribbon_EmbeddedCaptionPaintText(
- CDC & dc,
- __EXT_MFC_SAFE_LPCTSTR strCaption,
- CRect rcDrawText,
- __EXT_MFC_SAFE_LPCTSTR strCaptionDelimiter,
- const CExtRibbonBar * pRibbonBar,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pRibbonBar );
- if( strCaption == NULL
- || (! dc.RectVisible(&rcDrawText) )
- )
- return;
- if( IsHighContrast() )
- {
- CExtPaintManager::Ribbon_EmbeddedCaptionPaintText(
- dc,
- strCaption,
- rcDrawText,
- strCaptionDelimiter,
- pRibbonBar,
- lParam
- );
- return;
- }
- INT nLenCaption = INT( _tcslen( strCaption ) );
- if( nLenCaption == 0 )
- return;
- bool bFrameActive = true;
- if( pRibbonBar->m_pExtNcFrameImpl != NULL )
- bFrameActive = pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_IsActive();
- LPCTSTR strFrameActive =
- bFrameActive ? _T("Active") : _T("Inactive");
- const CExtSkinColor & colorFrameText =
- m_Skin[_T("NcFrame")][_T("NcArea")].Color(strFrameActive);
- if( colorFrameText.IsHollow() )
- return;
- bool bRTL = ( (pRibbonBar->GetExStyle()&WS_EX_LAYOUTRTL) != 0 ) ? true : false;;
- UINT nBaseDT = Ribbon_EmbeddedCaptionGetTextAlignmentFlags( pRibbonBar );
- //UINT nAlignDT = nBaseDT & (DT_LEFT|DT_CENTER|DT_RIGHT);
- UINT nDT = nBaseDT & (~(DT_CALCRECT));
- if( bRTL )
- {
- if( (nDT&3) == DT_RIGHT )
- {
- nDT &= ~3;
- nDT |= DT_LEFT;
- }
- else if( (nDT&3) == DT_LEFT )
- {
- nDT &= ~3;
- nDT |= DT_RIGHT;
- }
- } // if( bRTL )
- CExtSafeString strLeft = strCaption, strMiddle, strRight;
- INT nLenDelimiter = 0;
- if( strCaptionDelimiter != NULL )
- {
- nLenDelimiter = INT( _tcslen( strCaptionDelimiter ) );
- if( nLenDelimiter > 0 )
- {
- INT nPos = strLeft.Find( strCaptionDelimiter );
- if( nPos >= 0 )
- {
- strRight = strLeft.Right( nLenCaption - nPos - nLenDelimiter );
- strLeft = strLeft.Left( nPos );
- if( ! strRight.IsEmpty() )
- strMiddle = strCaptionDelimiter;
- } // if( nPos >= 0 )
- } // if( nLenDelimiter > 0 )
- } // if( strCaptionDelimiter != NULL )
- CFont * pOldFont = dc.SelectObject( &m_FontCaption );
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldText = dc.GetTextColor();
- nDT &= ~(DT_END_ELLIPSIS);
- INT nWidthLeft = stat_CalcTextDimension( dc, m_FontCaption, strLeft, DT_SINGLELINE|DT_LEFT|DT_TOP|DT_CALCRECT ).Width();
- INT nWidthMiddle = 0, nWidthRight = 0, nWidthAvailable = rcDrawText.Width();
- if( ! strRight.IsEmpty() )
- {
- nWidthMiddle = stat_CalcTextDimension( dc, m_FontCaption, strMiddle, DT_SINGLELINE|DT_LEFT|DT_TOP|DT_CALCRECT ).Width();
- nWidthRight = stat_CalcTextDimension( dc, m_FontCaption, strRight, DT_SINGLELINE|DT_LEFT|DT_TOP|DT_CALCRECT ).Width();
- }
- COLORREF clrRibbon_EmbeddedCaptionTextLeft = colorFrameText;
- double lfHue = 0.0, lfSat = 0.0, lfLum = 0.0, lfAdjustmedLum = 0.25;
- stat_RGBtoHSL( clrRibbon_EmbeddedCaptionTextLeft, &lfHue, &lfSat, &lfLum );
- if( lfLum > 0.50 )
- {
- lfAdjustmedLum = -lfAdjustmedLum;
- if( lfLum > 0.75 )
- lfAdjustmedLum *= 0.25;
- }
- else
- {
- if( lfLum < 0.25 )
- lfAdjustmedLum *= 0.25;
- }
- COLORREF clrRibbon_EmbeddedCaptionTextRight = stat_HLS_Adjust( clrRibbon_EmbeddedCaptionTextLeft, 0.0, lfAdjustmedLum, 0.0 );
- dc.SetTextColor( clrRibbon_EmbeddedCaptionTextLeft );
- if( nWidthAvailable > ( nWidthLeft + nWidthMiddle + nWidthRight ) && (! strRight.IsEmpty() ) )
- {
- if( (nDT&DT_RIGHT) != 0 )
- rcDrawText.left = rcDrawText.right - ( nWidthLeft + nWidthMiddle + nWidthRight );
- else if( (nDT&DT_CENTER) != 0 )
- rcDrawText.left += ( rcDrawText.Width() - ( nWidthLeft + nWidthMiddle + nWidthRight ) ) / 2;
- nDT &= ~(DT_RIGHT|DT_CENTER);
- nDT |= DT_LEFT;
- dc.DrawText( strLeft, strLeft.GetLength(), rcDrawText, nDT );
- rcDrawText.left += nWidthLeft;
- dc.DrawText( strMiddle, strMiddle.GetLength(), rcDrawText, nDT );
- dc.SetTextColor( clrRibbon_EmbeddedCaptionTextRight );
- rcDrawText.left += nWidthMiddle;
- nDT |= DT_END_ELLIPSIS;
- dc.DrawText( strRight, strRight.GetLength(), rcDrawText, nDT );
- } // if( nWidthAvailable > ( nWidthLeft + nWidthMiddle ) && (! strRight.IsEmpty() ) )
- else
- {
- nDT &= ~(DT_LEFT|DT_CENTER|DT_RIGHT);
- nDT |= DT_LEFT; // nDT |= nAlignDT;
- nDT |= DT_END_ELLIPSIS;
- if( bRTL )
- nDT |= DT_RTLREADING;
- dc.DrawText( strLeft, strLeft.GetLength(), rcDrawText, nDT );
- if(! strRight.IsEmpty() )
- {
- rcDrawText.left += nWidthLeft;
- if( ( rcDrawText.Width() + nWidthMiddle ) > 0 )
- {
- dc.DrawText( strMiddle, strMiddle.GetLength(), rcDrawText, nDT );
- dc.SetTextColor( clrRibbon_EmbeddedCaptionTextRight );
- rcDrawText.left += nWidthMiddle;
- dc.DrawText( strRight, strRight.GetLength(), rcDrawText, nDT );
- }
- }
- } // else from if( nWidthAvailable > ( nWidthLeft + nWidthMiddle ) && (! strRight.IsEmpty() ) )
- dc.SetTextColor( clrOldText );
- dc.SetBkMode( nOldBkMode );
- dc.SelectObject( &pOldFont );
- }
- UINT CExtPaintManagerSkin::Ribbon_EmbeddedCaptionGetTextAlignmentFlags(
- const CExtRibbonBar * pRibbonBar,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pRibbonBar );
- if( IsHighContrast() )
- return
- CExtPaintManager::Ribbon_EmbeddedCaptionGetTextAlignmentFlags(
- pRibbonBar,
- lParam
- );
- return DT_SINGLELINE|DT_CENTER|DT_VCENTER;
- }
- void CExtPaintManagerSkin::Ribbon_EmbeddedCaptionAdjustTextRect(
- CRect & rcAdjust,
- const CExtRibbonBar * pRibbonBar,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pRibbonBar );
- if( IsHighContrast() )
- {
- CExtPaintManager::Ribbon_EmbeddedCaptionAdjustTextRect(
- rcAdjust,
- pRibbonBar,
- lParam
- );
- return;
- }
- bool bDwmMode = false;
- if( pRibbonBar->m_pExtNcFrameImpl != NULL
- && pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_IsDwmCaptionReplacement()
- )
- bDwmMode = true;
- if( ( ! bDwmMode )
- && pRibbonBar->GetParent()->IsZoomed()
- )
- {
- rcAdjust.OffsetRect( 0, 3 );
- }
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- #define __EXT_MFC_SKINNED_CAPTION_TEXT_GAP 4
- void CExtPaintManagerSkin::NcFrame_GetRects(
- CExtCmdIcon * pIcon,
- __EXT_MFC_SAFE_LPCTSTR strCaption,
- UINT nDrawTextAlignFlags,
- RECT & rcIcon,
- RECT & rcText,
- RECT & rcHelp,
- RECT & rcMinimize,
- RECT & rcMaximizeRestore,
- RECT & rcClose,
- const CWnd * pWnd,
- LPMINMAXINFO pMinMaxInfo, // = NULL
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- strCaption;
- nDrawTextAlignFlags;
- ::SetRectEmpty( &rcIcon );
- ::SetRectEmpty( &rcText );
- ::SetRectEmpty( &rcHelp );
- ::SetRectEmpty( &rcMinimize );
- ::SetRectEmpty( &rcMaximizeRestore );
- ::SetRectEmpty( &rcClose );
- ASSERT( NcFrame_IsSupported( pWnd ) );
- DWORD dwWndStyle = pWnd->GetStyle();
- // if( (dwWndStyle&WS_CAPTION) == 0 )
- // return;
- DWORD dwWndStyleEx = pWnd->GetExStyle();
- CRect rcNcBorders, rcThemePadding;
- NcFrame_GetMetrics(
- rcNcBorders,
- rcThemePadding,
- pWnd,
- lParam
- );
- CRect rcCaption =
- NcFrame_GetHtRect(
- HTCAPTION,
- false,
- true,
- true,
- pIcon,
- pWnd,
- pMinMaxInfo
- );
- CRect rc = rcCaption;
- ::CopyRect( &rcText, &rcCaption );
- bool bZoomed = pWnd->IsZoomed()? true : false;
- if( (dwWndStyle&WS_SYSMENU) != 0 )
- {
- LPCTSTR strFrameActive = _T("Active");
- const CExtSkinGlyph & glyphClose = m_Skin[_T("Button")][_T("FrameNcButton")][_T("Close")][strFrameActive].Glyph(_T("Normal"));
- CSize _sizeScClose = glyphClose.GetSize();
- CRect _rcOffsetScClose = glyphClose.GetOffset();
- rc.right -= bZoomed ? rcThemePadding.right : 1;
- rc.right -= _rcOffsetScClose.right;
- rc.left = rc.right - _sizeScClose.cx;
- rc.top = rcCaption.top + _rcOffsetScClose.top + ( bZoomed ? _rcOffsetScClose.bottom : 0 );
- rc.bottom = rc.top + _sizeScClose.cy;
- ::CopyRect( &rcClose, &rc );
- rc.OffsetRect( -_sizeScClose.cx, 0 );
- rcText.right = rcCaption.right - __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- if( (dwWndStyle&WS_MAXIMIZEBOX) != 0 )
- {
- const CExtSkinGlyph & glyphMaximize = m_Skin[_T("Button")][_T("FrameNcButton")][_T("Maximize")][strFrameActive].Glyph(_T("Normal"));
- CSize _sizeScMaximize = glyphMaximize.GetSize();
- CRect _rcOffsetScMaximize = glyphMaximize.GetOffset();
- rc.right -= _rcOffsetScMaximize.right;
- rc.top = rcCaption.top + _rcOffsetScMaximize.top + ( bZoomed ? _rcOffsetScMaximize.bottom : 0 );
- rc.left = rc.right - _sizeScMaximize.cx;
- rc.bottom = rc.top + _sizeScMaximize.cy;
- ::CopyRect( &rcMaximizeRestore, &rc );
- rc.OffsetRect( -_sizeScMaximize.cx, 0 );
- rcText.right = rcMaximizeRestore.left - __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- } // if( (dwWndStyle&WS_MAXIMIZEBOX) != 0 )
- if( (dwWndStyle&WS_MINIMIZEBOX) != 0 )
- {
- const CExtSkinGlyph & glyphMinimize = m_Skin[_T("Button")][_T("FrameNcButton")][_T("Minimize")][strFrameActive].Glyph(_T("Normal"));
- CSize _sizeScMinimize = glyphMinimize.GetSize();
- CRect _rcOffsetScMinimize = glyphMinimize.GetOffset();
- rc.right -= _rcOffsetScMinimize.right;
- rc.top = rcCaption.top + _rcOffsetScMinimize.top + ( bZoomed ? _rcOffsetScMinimize.bottom : 0 );
- rc.left = rc.right - _sizeScMinimize.cx;
- rc.bottom = rc.top + _sizeScMinimize.cy;
- ::CopyRect( &rcMinimize, &rc );
- rc.OffsetRect( -_sizeScMinimize.cx, 0 );
- rcText.right = rcMinimize.left - __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- } // if( (dwWndStyle&WS_MINIMIZEBOX) != 0 )
- if( (dwWndStyleEx&WS_EX_CONTEXTHELP) != 0 )
- {
- const CExtSkinGlyph & glyphHelp = m_Skin[_T("Button")][_T("FrameNcButton")][_T("Help")][strFrameActive].Glyph(_T("Normal"));
- CSize _sizeScHelp = glyphHelp.GetSize();
- CRect _rcOffsetScHelp = glyphHelp.GetOffset();
- rc.right -= _rcOffsetScHelp.right;
- rc.top = rcCaption.top + _rcOffsetScHelp.top + ( bZoomed ? _rcOffsetScHelp.bottom : 0 );
- rc.left = rc.right - _sizeScHelp.cx;
- rc.bottom = rc.top + _sizeScHelp.cy;
- ::CopyRect( &rcHelp, &rc );
- rcText.right = rcHelp.left - __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- } // if( (dwWndStyleEx&WS_EX_CONTEXTHELP) != 0 )
- if( pIcon != NULL
- && (! pIcon->IsEmpty() )
- )
- {
- CSize _sizeIcon = pIcon->GetSize();
- if( _sizeIcon.cx > 0 && _sizeIcon.cy > 0 )
- {
- int x = rcCaption.left + (bZoomed ? rcNcBorders.left : 0 );
- int y = rcCaption.top + ( rcCaption.Height() - _sizeIcon.cy ) / 2;
- ::SetRect(
- &rcIcon,
- x,
- y,
- x + _sizeIcon.cx,
- y + _sizeIcon.cy
- );
- rcText.left = rcIcon.right + __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- } // if( _sizeIcon.cx > 0 && _sizeIcon.cy > 0 )
- else
- rcText.left += __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- } // if( pIcon != NULL ...
- else
- rcText.left += __EXT_MFC_SKINNED_CAPTION_TEXT_GAP + (bZoomed ? rcNcBorders.left : 0 );
- } // if( (dwWndStyle&WS_SYSMENU) != 0 )
- else
- {
- rcText.left += __EXT_MFC_SKINNED_CAPTION_TEXT_GAP + (bZoomed ? rcNcBorders.left : 0 );
- rcText.right -= __EXT_MFC_SKINNED_CAPTION_TEXT_GAP;
- }
- }
- bool CExtPaintManagerSkin::Bar_MiniDockFrameGetNcMetrics(
- INT & nResizingFrameDX,
- INT & nResizingFrameDY,
- INT & nCaptionDY,
- CExtMiniDockFrameWnd * pMiniFrameWnd,
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pMiniFrameWnd );
- pMiniFrameWnd;
- lParam;
- LPCTSTR strBarType = _T("ResizableBar");
- CExtToolControlBar * pToolCB = DYNAMIC_DOWNCAST( CExtToolControlBar, pBar );
- if( pToolCB )
- {
- strBarType = _T("ToolBar");
- if( pToolCB->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- strBarType = _T("MenuBar");
- }
- const CExtSkinItem & Frame =
- m_Skin[_T("Frame")][_T("MiniFrame")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinItem & Caption =
- m_Skin[_T("Caption")][_T("Frame")][_T("MiniFrame")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinGlyph & FrameGlyph = Frame.Glyph( _T("Frame") );
- const CExtSkinGlyph & CaptionGlyph = Caption.Glyph( _T("Caption") );
- CRect rcFramePadding = FrameGlyph.GetPadding();
- CSize szCaption = CaptionGlyph.GetSize();
- nResizingFrameDX = rcFramePadding.left;
- nResizingFrameDY = rcFramePadding.top;
- nCaptionDY = szCaption.cy;
- return true;
- }
- bool CExtPaintManagerSkin::Bar_MiniDockFrameNcCalcSize(
- RECT & rcAdjust,
- CExtMiniDockFrameWnd * pMiniFrameWnd,
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pMiniFrameWnd );
- rcAdjust;
- pMiniFrameWnd;
- pBar;
- lParam;
- LPCTSTR strBarType = _T("ResizableBar");
- CExtToolControlBar * pToolCB = DYNAMIC_DOWNCAST( CExtToolControlBar, pBar );
- if( pToolCB )
- {
- strBarType = _T("ToolBar");
- if( pToolCB->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- strBarType = _T("MenuBar");
- }
- const CExtSkinItem & Frame =
- m_Skin[_T("Frame")][_T("MiniFrame")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinItem & Caption =
- m_Skin[_T("Caption")][_T("Frame")][_T("MiniFrame")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinGlyph & FrameGlyph = Frame.Glyph( _T("Frame") );
- const CExtSkinGlyph & CaptionGlyph = Caption.Glyph( _T("Caption") );
- CRect rcFramePadding = FrameGlyph.GetPadding();
- CSize szCaption = CaptionGlyph.GetSize();
- rcAdjust.left += rcFramePadding.left;
- rcAdjust.top += rcFramePadding.top + szCaption.cy;
- rcAdjust.right -= rcFramePadding.right;
- rcAdjust.bottom -= rcFramePadding.bottom;
- return true;
- }
- bool CExtPaintManagerSkin::Bar_MiniDockFrameCaptionCalcRect(
- RECT & rcCaption,
- CExtMiniDockFrameWnd * pMiniFrameWnd,
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pMiniFrameWnd );
- pMiniFrameWnd;
- pBar;
- lParam;
- if( pMiniFrameWnd == NULL )
- return false;
- LPCTSTR strBarType = _T("ResizableBar");
- CExtToolControlBar * pToolCB = DYNAMIC_DOWNCAST( CExtToolControlBar, pBar );
- if( pToolCB )
- {
- strBarType = _T("ToolBar");
- if( pToolCB->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- strBarType = _T("MenuBar");
- }
- const CExtSkinItem & Frame =
- m_Skin[_T("Frame")][_T("MiniFrame")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinItem & Caption =
- m_Skin[_T("Caption")][_T("Frame")][_T("MiniFrame")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinGlyph & FrameGlyph = Frame.Glyph( _T("Frame") );
- const CExtSkinGlyph & CaptionGlyph = Caption.Glyph( _T("Caption") );
- CRect rcFramePadding = FrameGlyph.GetPadding();
- CSize szCaption = CaptionGlyph.GetSize();
- CRect rcFrameCaption;
- ::GetWindowRect( pMiniFrameWnd->GetSafeHwnd(), &rcFrameCaption );
- rcFrameCaption -= rcFrameCaption.TopLeft();
- rcFrameCaption.left += rcFramePadding.left;
- rcFrameCaption.top += rcFramePadding.top;
- rcFrameCaption.right -= rcFramePadding.right;
- rcFrameCaption.bottom = rcFrameCaption.top + szCaption.cy;
- ::CopyRect( &rcCaption, &rcFrameCaption );
- return true;
- }
- void CExtPaintManagerSkin::PaintResizableBarSeparator(
- CDC & dc,
- const RECT & rc,
- bool bHorz,
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- ASSERT( dc.GetSafeHdc() != NULL );
- dc;
- rc;
- bHorz;
- pBar;
- lParam;
- LPCTSTR strSeparatorType = _T("SeparatorV");
- if( bHorz )
- strSeparatorType = _T("SeparatorH");
- CExtSkinGlyph & SeparatorGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("ResizableBar")].Glyph( strSeparatorType );
- SeparatorGlyph.Draw( dc.m_hDC, rc );
- }
- bool CExtPaintManagerSkin::Bar_LayoutNcAreaButton(
- RECT & rcButton,
- const RECT & rcCaption,
- CExtBarNcAreaButton * pLayoutBtn,
- CExtBarNcAreaButton * pPrevBtn,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pLayoutBtn );
- pHelperSrc;
- lParam;
- LPCTSTR strButtonType = _T("");
- if( pLayoutBtn->IsKindOf( RUNTIME_CLASS( CExtBarNcAreaButtonClose ) ) )
- strButtonType = _T("Close");
- else
- if( pLayoutBtn->IsKindOf( RUNTIME_CLASS( CExtBarNcAreaButtonExpand ) )
- || pLayoutBtn->IsKindOf( RUNTIME_CLASS( CExtBarNcAreaButtonMenu ) )
- )
- strButtonType = _T("Options");
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- else
- if( pLayoutBtn->IsKindOf( RUNTIME_CLASS( CExtBarNcAreaButtonAutoHide ) ) )
- strButtonType = _T("PinOff");
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- else
- return false;
- LPCTSTR strBarActiveState =
- pLayoutBtn->IsBarWndActive() ? _T("Active") : _T("Inactive");
- const CExtSkinGlyph & ButtonFrameGlyph =
- m_Skin[_T("Caption")][_T("CaptionButton")][_T("Normal")]
- [strButtonType][strBarActiveState].Glyph( _T("Frame") );
- if( ButtonFrameGlyph.IsEmpty() )
- return false;
- CSize _size = ButtonFrameGlyph.GetSize();
- INT x = rcCaption.right - _size.cx - ButtonFrameGlyph.GetPadding().right;
- INT y = rcCaption.top;
- CRect rc( x, y, x + _size.cx, y + _size.cy );
- if( pPrevBtn != NULL )
- {
- const CRect & rcPrev = *pPrevBtn;
- rc.OffsetRect(
- rcPrev.left - rc.right,
- 0
- );
- }
- rc.OffsetRect(
- -ButtonFrameGlyph.GetOffset().right,
- ButtonFrameGlyph.GetOffset().top
- );
- rcButton = rc;
- return true;
- }
- CRect CExtPaintManagerSkin::Bar_GetCaptionBordersForText(
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- pBar;
- lParam;
- // EG - TO DO - RETURN RESIZABLE BAR CAPTION PADDING
- return CRect( 2, 1, 2, 1 );
- }
- INT CExtPaintManagerSkin::Bar_SeparatorWidthGet(
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- pBar;
- lParam;
- const CExtSkinGlyph & SeparatorGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("ResizableBar")].Glyph( _T("SeparatorV") );
- return SeparatorGlyph.GetSize().cx;
- }
- INT CExtPaintManagerSkin::Bar_SeparatorHeightGet(
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- pBar;
- lParam;
- const CExtSkinGlyph & SeparatorGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("ResizableBar")].Glyph( _T("SeparatorH") );
- return SeparatorGlyph.GetSize().cy;
- }
- INT CExtPaintManagerSkin::Bar_GripperWidthAtLeftGet(
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- pBar;
- lParam;
- return 0;
- }
- INT CExtPaintManagerSkin::Bar_GripperHeightAtTopGet(
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- lParam;
- bool bFloating = true;
- LPCTSTR strBarType = _T("ResizableBar");
- if( pBar )
- {
- if( pBar->IsKindOf( RUNTIME_CLASS( CExtToolControlBar ) ) )
- {
- if( pBar->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- strBarType = _T("MenuBar");
- else
- strBarType = _T("ToolBar");
- }
- bFloating = pBar->IsFloating();
- }
- const CExtSkinItem & Caption = bFloating
- ? m_Skin[_T("Caption")][_T("ControlBar")][strBarType][_T("Floating")][_T("Active")]
- : m_Skin[_T("Caption")][_T("ControlBar")][strBarType][_T("Active")];
- const CExtSkinGlyph & CaptionGlyph = Caption.Glyph( _T("Caption") );
- return CaptionGlyph.GetSize().cy;
- }
- HFONT CExtPaintManagerSkin::Bar_GetCaptionFont(
- bool bHorz,
- CExtToolControlBar * pBar,
- LPARAM lParam // = 0
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- bHorz;
- pBar;
- lParam;
- return NULL;
- }
- HFONT CExtPaintManagerSkin::CreateDefaultFont()
- {
- const CExtSkinFont & skinFont = m_Skin[_T("Button")].Font(_T("Measure"));
- CFont _font;
- if( ! skinFont.CreateFont( _font ) )
- return CExtPaintManager::CreateDefaultFont();
- return (HFONT)_font.Detach();
- }
- CSize CExtPaintManagerSkin::Toolbar_GetMinButtonSize(
- CObject * pHelperSrc,
- LPARAM lParam // = 0
- )
- {
- ASSERT_VALID( this );
- if( pHelperSrc != NULL )
- {
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtPopupMenuWnd ) )
- || ( pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtBarButton ) )
- && ( (!( ((CExtBarButton*)pHelperSrc)->GetBar() ) -> IsDockedVertically() )
- || ( ((CExtBarButton*)pHelperSrc)->GetNoRotateVerticalLayout() )
- )
- )
- )
- {
- CExtSkinGlyph & g =
- m_Skin[_T("Button")][_T("Simple")]
- [_T("PushButton")][_T("ControlBar")][_T("Horizontal")]
- [_T("ToolBar")][_T("Normal")].Glyph( _T("PushButton") )
- ;
- CRect rcPaddingImage = g.GetPadding();
- CRect rcPaddingContent = g.GetContentPadding();
- CSize _size(
- rcPaddingContent.left + rcPaddingContent.right,
- rcPaddingImage.top + rcPaddingImage.bottom
- );
- return _size;
- }
- else if(
- pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtBarButton ) )
- )
- {
- CExtSkinGlyph & g =
- m_Skin[_T("Button")][_T("Simple")]
- [_T("PushButton")][_T("ControlBar")][_T("Vertical")]
- [_T("ToolBar")][_T("Normal")].Glyph( _T("PushButton") )
- ;
- CRect rcPaddingImage = g.GetContentPadding();
- CRect rcPaddingContent = g.GetPadding();
- CSize _size(
- rcPaddingImage.left + rcPaddingImage.right,
- rcPaddingContent.top + rcPaddingContent.bottom
- );
- }
- } // if( pHelperSrc != NULL )
- return
- CExtPaintManager::Toolbar_GetMinButtonSize(
- pHelperSrc,
- lParam
- );
- }
- void CExtPaintManagerSkin::Toolbar_AdjustButtonSize(
- CExtBarButton * pTBB,
- CSize & sizePreCalc
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf( RUNTIME_CLASS( CExtBarContentExpandButton ) ) )
- return;
- CExtToolControlBar * pBar = pTBB->GetBar();
- if( pBar == NULL )
- {
- CExtPaintManager::Toolbar_AdjustButtonSize(
- pTBB,
- sizePreCalc
- );
- return;
- }
- bool bHorizontal = ( (! pTBB->GetNoRotateVerticalLayout() ) && pBar->IsDockedVertically() ) ? false : true;
- LPCTSTR strDockingType = bHorizontal ? _T("Horizontal") : _T("Vertical");
- bool bDockSiteCustomizeMode =
- pBar->_IsDockSiteCustomizeMode();
- bool bPushed =
- ( pTBB->IsPressed() && (!bDockSiteCustomizeMode) )
- ? true : false;
- bool bEnabled =
- ( pTBB->IsDisabled() && (!bDockSiteCustomizeMode) )
- ? false : true;
- bool bHover =
- ( pTBB->IsHover() && (!bDockSiteCustomizeMode) )
- ? true : false;
- if( ! bDockSiteCustomizeMode )
- {
- if( CExtToolControlBar::g_bMenuTracking
- || CExtPopupMenuWnd::IsMenuTracking()
- )
- bHover = false;
- else if( !bHover )
- bHover = pTBB->IsPressedTracking();
- //if( bPushed && bHover && IsPressedTracking() )
- //bHover = false;
- } // if( ! bDockSiteCustomizeMode )
- CExtSkinItem * pButton = NULL;
- if( pTBB->GetSeparatedDropDown() )
- pButton = (&(m_Skin[_T("Button")][_T("SeparatedDropDown")]));
- else if( pTBB->IsAbleToTrackMenu() )
- pButton = (&(m_Skin[_T("Button")][_T("DropDown")]));
- else
- pButton = (&(m_Skin[_T("Button")][_T("Simple")]));
- LPCTSTR strState = _T("Normal");
- if( ! bEnabled )
- strState = _T("Disabled");
- else if( bPushed )
- strState = _T("Pressed");
- else if( bHover /*|| _ppbd.m_bDrawFocusRect*/ )
- strState = _T("Hover");
- // else if( _ppbd.m_bDefaultPushButton )
- // strState = _T("Default");
- pButton =
- (&((*pButton)
- [_T("PushButton")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][strState]
- ));
- CExtSkinGlyph & PushButtonGlyph =
- pButton->Glyph( _T("PushButton") );
- CSize sizeSkin = PushButtonGlyph.GetSize();
- if( sizePreCalc.cx < sizeSkin.cx )
- sizePreCalc.cx = sizeSkin.cx;
- if( sizePreCalc.cy < sizeSkin.cy )
- sizePreCalc.cy = sizeSkin.cy;
- }
- HFONT CExtPaintManagerSkin::Toolbar_GetFont(
- bool bHorz,
- CExtControlBar * pBar,
- LPARAM lParam // = 0
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- pBar;
- lParam;
- if( bHorz )
- return ( (HFONT) m_FontNormal.GetSafeHandle() );
- else
- return ( (HFONT) m_FontNormalVert.GetSafeHandle() );
- }
- bool CExtPaintManagerSkin::Toolbar_GetBGInfo(
- RECT & rcBorders,
- INT & nGripWidthAtLeft,
- INT & nGripHeightAtTop,
- CExtToolControlBar * pBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pBar );
- lParam;
- DWORD dwBarStyle = pBar->GetBarStyle();
- nGripWidthAtLeft = 0;
- nGripHeightAtTop = 0;
- if( (dwBarStyle&CBRS_FLOATING) != 0
- || pBar->IsFloating()
- )
- {
- rcBorders.left = 0;
- rcBorders.top = 0;
- rcBorders.right = 0;
- rcBorders.bottom = 0;
- return true;
- }
- const CExtSkinGlyph * pGripperGlyph = NULL;
- const CExtSkinGlyph & BkGlyph = _GetDockedToolBarGlyph( pBar, &pGripperGlyph );
- ASSERT( pGripperGlyph != NULL );
- rcBorders = BkGlyph.GetPadding();
- if( (dwBarStyle&CBRS_ORIENT_HORZ) != 0 )
- {
- if( (dwBarStyle&CBRS_GRIPPER) != 0 )
- nGripWidthAtLeft = pGripperGlyph->GetSize().cx;
- rcBorders.top = 0;
- rcBorders.bottom = 0;
- } // if( (dwBarStyle&CBRS_ORIENT_HORZ) != 0 )
- else
- {
- if( (dwBarStyle&CBRS_GRIPPER) != 0 )
- nGripHeightAtTop = pGripperGlyph->GetSize().cy;
- rcBorders.left = 0;
- rcBorders.right = 0;
- } // else from if( (dwBarStyle&CBRS_ORIENT_HORZ) != 0 )
- return true;
- }
- const CExtSkinGlyph & CExtPaintManagerSkin::_GetDockedToolBarGlyph(
- CExtToolControlBar * pBar,
- const CExtSkinGlyph ** ppGlyphGripper // = NULL
- ) const
- {
- return
- (
- ( const_cast < CExtPaintManagerSkin * > ( this ) ) ->
- _GetDockedToolBarGlyph(
- pBar,
- const_cast < CExtSkinGlyph ** > ( ppGlyphGripper )
- )
- );
- }
- CExtSkinGlyph & CExtPaintManagerSkin::_GetDockedToolBarGlyph(
- CExtToolControlBar * pBar,
- CExtSkinGlyph ** ppGlyphGripper // = NULL
- )
- {
- ASSERT_VALID( pBar );
- ASSERT( ! pBar->IsFloating() );
- LPCTSTR strBarType = _T("ToolBar");
- if( pBar->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- strBarType = _T("MenuBar");
- LPCTSTR strDockingType = _T("Horizontal");
- if( pBar->IsDockedVertically() )
- strDockingType = _T("Vertical");
- LPCTSTR strDockingAbility = _T("Dockable");
- if( pBar->m_pDockSite == NULL )
- strDockingAbility = _T("Static");
- CExtSkinGlyph & ToolBarBk =
- m_Skin[_T("Background")][_T("ControlBar")][strBarType][strDockingType][strDockingAbility]
- .Glyph( _T("Background") );
- if( ppGlyphGripper != NULL )
- {
- LPCTSTR strGlyphType = _T("GripperV");
- if( pBar->IsDockedVertically() )
- strGlyphType = _T("GripperH");
- CExtSkinGlyph & GripperGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][strBarType][strDockingType]
- .Glyph( strGlyphType );
- (*ppGlyphGripper) = &GripperGlyph;
- }
- return ToolBarBk;
- }
- bool CExtPaintManagerSkin::Toolbar_GetSizeOfCEB(
- SIZE & sizeReal,
- const SIZE & sizePreCalc,
- CDC & dc,
- BOOL bHorz,
- CExtBarContentExpandButton * pTBB,
- LPARAM lParam // = 0
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- sizeReal;
- sizePreCalc;
- dc;
- bHorz;
- pTBB;
- lParam;
- LPCTSTR strToolBarType = bHorz ? _T("Horizontal") : _T("Vertical");
- LPCTSTR strDockingAbility = _T("Dockable");
- CExtToolControlBar * pToolBar = pTBB->GetBar();
- if( pToolBar && pToolBar->m_pDockSite == NULL )
- strDockingAbility = _T("Static");
- CExtSkinGlyph & ChevronGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("ToolBar")][strToolBarType][strDockingAbility]
- .Glyph( _T("ChevronPartial") );
- if( bHorz )
- {
- sizeReal.cx = ChevronGlyph.GetSize().cx;
- sizeReal.cy = sizePreCalc.cy;
- } // if( bHorz )
- else
- {
- sizeReal.cx = sizePreCalc.cx;
- sizeReal.cy = ChevronGlyph.GetSize().cy;
- } // else from if( bHorz )
- return true;
- }
- void CExtPaintManagerSkin::PaintToolbarExpandButton(
- CDC & dc,
- const RECT & rcButtonArea,
- bool bHorz, // if false - down
- bool bBarIsCompletelyVisible,
- bool bEnabled,
- bool bPushed,
- bool bHover,
- CObject * pHelperSrc,
- LPARAM lParam, // = 0L
- bool bTransparentBackground // = false
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- dc;
- rcButtonArea;
- bHorz;
- bBarIsCompletelyVisible;
- bEnabled;
- bPushed;
- bHover;
- pHelperSrc;
- lParam;
- bTransparentBackground;
- CRect rect(rcButtonArea);
- rect.NormalizeRect();
- if( !dc.RectVisible( &rect ) )
- return;
- CRect rectButton( rect );
- PAINTPUSHBUTTONDATA _ppbd(
- pHelperSrc, bHorz, rectButton, NULL,
- NULL, false, bHover, bPushed, false,
- bEnabled, false, false, false, 0
- );
- PaintPushButton( dc, _ppbd );
- LPCTSTR strToolBarType = bHorz ? _T("Horizontal") : _T("Vertical");
- LPCTSTR strChevronType = bBarIsCompletelyVisible ? _T("ChevronAll") : _T("ChevronPartial");
- LPCTSTR strDockingAbility = _T("Dockable");
- CExtToolControlBar * pToolBar = DYNAMIC_DOWNCAST( CExtToolControlBar, pHelperSrc );
- if( pToolBar && pToolBar->m_pDockSite == NULL )
- strDockingAbility = _T("Static");
- CExtSkinGlyph & ChevronGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("ToolBar")][strToolBarType][strDockingAbility]
- .Glyph( strChevronType );
- ChevronGlyph.Draw( dc.m_hDC, rcButtonArea );
- }
- void CExtPaintManagerSkin::PaintToolbarTextField(
- CDC & dc,
- PAINTTOOLBARTEXTFIELDDATA & _ptbtfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CRect rcTextField( _ptbtfd.m_rcButton );
- if( ! _ptbtfd.m_bEnabled )
- rcTextField.DeflateRect( 1, 2 );
- if( _ptbtfd.m_bComboField )
- {
- PAINTCOMBOFRAMEDATA _pcfd(
- _ptbtfd.m_pHelperSrc,
- rcTextField,
- _ptbtfd.m_bHover,
- _ptbtfd.m_bPushed,
- _ptbtfd.m_bEnabled
- );
- _pcfd.m_bNoTopOuterBorder = true;
- PaintComboFrame( dc, _pcfd );
- dc.SelectClipRgn( NULL );
- } // if( _ptbtfd.m_bComboField )
- else
- {
- } // else from if( _ptbtfd.m_bComboField )
- CRect rcBk( _ptbtfd.m_rcTextField );
- if( ! _ptbtfd.m_bEnabled )
- rcBk.DeflateRect( 0, 1 );
- // dc.FillSolidRect(
- // &rcBk,
- // GetColor( _ptbtfd.m_bEnabled ? COLOR_WINDOW : COLOR_3DFACE, _ptbtfd.m_pHelperSrc, _ptbtfd.m_lParam )
- // );
- if( ! _ptbtfd.m_sText.IsEmpty() )
- {
- COLORREF clrTextOld =
- dc.SetTextColor(
- ::GetSysColor( _ptbtfd.m_bEnabled ? COLOR_WINDOWTEXT : COLOR_GRAYTEXT )
- );
- CFont * pFontOld =
- dc.SelectObject( &m_FontNormal );
- int nBkModeOld = dc.SetBkMode( TRANSPARENT );
- CRect rcText( _ptbtfd.m_rcTextField );
- rcText.left += 5;
- rcText.top += 2;
- bool bRTL = ( (g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0 ) ? true : false;
- DWORD dwDtAlignFlags = bRTL ? (DT_RTLREADING|DT_RIGHT) : 0;
- dc.DrawText(
- _ptbtfd.m_sText,
- _ptbtfd.m_sText.GetLength(),
- &rcText,
- _ptbtfd.m_nDrawTextFlags|dwDtAlignFlags
- );
- dc.SetBkMode( nBkModeOld );
- dc.SelectObject( pFontOld );
- dc.SetTextColor( clrTextOld );
- } // if( !_ptbtfd.m_sText.IsEmpty() )
- }
- void CExtPaintManagerSkin::PaintComboFrame(
- CDC & dc,
- CExtPaintManager::PAINTCOMBOFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- INT nDD = GetSystemMetrics(SM_CXHTHUMB);
- CRect rectClient( _pcfd.m_rcClient );
- if( _pcfd.m_pHelperSrc != NULL
- && _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS(CComboBox) )
- )
- {
- CRect rcExclude( rectClient );
- rcExclude.DeflateRect( 2, 2 );
- if( _pcfd.m_bRightText )
- rcExclude.left += nDD;
- else
- rcExclude.right -= nDD;
- dc.ExcludeClipRect( &rcExclude );
- PaintDockerBkgnd(
- true,
- dc,
- (CWnd*)_pcfd.m_pHelperSrc,
- _pcfd.m_lParam
- );
- }
- LPCTSTR strGlyphName = _T("Disabled");
- if( _pcfd.m_bEnabled )
- {
- if( _pcfd.m_bPushed )
- strGlyphName = _T("Pressed");
- else if( _pcfd.m_bHover )
- strGlyphName = _T("Hover");
- else
- strGlyphName = _T("Normal");
- } // if( _pcfd.m_bEnabled )
- CRect rectFrame = rectClient;
- CRect rcDDButton( rectClient );
- rcDDButton.left = rcDDButton.right - nDD;
- rectFrame.right = rcDDButton.left;
- CExtSkinGlyph & glyphFrame =
- m_Skin[_T("ComboBox")][_T("ComboBoxFrame")].Glyph( strGlyphName );
- CExtSkinGlyph & glyphDropDownButton =
- m_Skin[_T("ComboBox")][_T("ComboBoxDropDownButton")].Glyph( strGlyphName );
- CExtSkinGlyph & glyphDropDownArrow =
- m_Skin[_T("ComboBox")][_T("ComboBoxDropDownArrow")].Glyph( strGlyphName );
- if( _pcfd.m_bRightText )
- {
- CDC dcX;
- VERIFY( dcX.CreateCompatibleDC( NULL ) );
- CExtBitmap _bmpBk;
- VERIFY( _bmpBk.FromSurface( dc.m_hDC, rectClient ) );
- COLORREF * pClrSurface = NULL;
- HBITMAP hBitmap = _bmpBk.CreateBitmap( &pClrSurface );
- ASSERT( hBitmap != NULL && pClrSurface != NULL );
- CBitmap _bmp;
- _bmp.Attach( hBitmap );
- CBitmap * pOldBmp = dcX.SelectObject( CBitmap::FromHandle( hBitmap ) );
- glyphFrame.Draw( dcX.GetSafeHdc(), rectFrame );
- glyphDropDownButton.Draw( dcX.GetSafeHdc(), rcDDButton );
- glyphDropDownArrow.Draw( dcX.GetSafeHdc(), rcDDButton );
- dcX.SelectObject( pOldBmp );
- CExtBitmap _bmpData;
- VERIFY( _bmpData.FromBitmap( hBitmap ) );
- _bmpData.FlipHorizontal();
- _bmpData.Draw( dc.m_hDC, rectClient );
- }
- else
- {
- glyphFrame.Draw( dc.m_hDC, rectFrame );
- glyphDropDownButton.Draw( dc.m_hDC, rcDDButton );
- glyphDropDownArrow.Draw( dc.m_hDC, rcDDButton );
- }
- }
- void CExtPaintManagerSkin::PaintPushButton(
- CDC & dc,
- CExtPaintManager::PAINTPUSHBUTTONDATA & _ppbd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _ppbd.m_rcClient.IsRectEmpty() )
- return;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( _ppbd.m_pHelperSrc != NULL )
- {
- CExtBarButton * pTBB = DYNAMIC_DOWNCAST( CExtBarButton, _ppbd.m_pHelperSrc );
- if( pTBB != NULL )
- {
- if( pTBB->IsRibbonPaintingMode()
- || pTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonDialogLauncher ) )
- )
- {
- Ribbon_PaintPushButton( dc, _ppbd );
- return;
- }
- CExtToolControlBar * pBar = pTBB->GetBar();
- if( pBar != NULL
- && pBar->IsKindOf( RUNTIME_CLASS( CExtRibbonPage ) )
- && (! pTBB->IsNoRibbonLayout() )
- && (! pTBB->IsKindOf( RUNTIME_CLASS( CExtBarMdiRightButton ) ) )
- )
- {
- Ribbon_PaintPushButton( dc, _ppbd );
- return;
- }
- } // if( pTBB != NULL )
- } // if( _ppbd.m_pHelperSrc != NULL )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( _ppbd.m_pHelperSrc != NULL
- && ( ( _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtPopupColorMenuWnd) )
- && _ppbd.m_bHelperColorCellButton
- )
- #if (!defined __EXT_MFC_NO_DATE_PICKER)
- || _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtDatePickerWnd) )
- #endif
- )
- )
- {
- CExtPaintManager::PaintPushButton( dc, _ppbd );
- return;
- }
- enum ButtonDrawingMode
- {
- eModeControl,
- eModeToolBar,
- eModeMenuBar,
- eModePopupMenu,
- };
- bool bHorizontal = true;
- ButtonDrawingMode aDrawingMode = eModeControl;
- if( _ppbd.m_pHelperSrc != NULL )
- {
- if( _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtBarButton ) ) )
- {
- CExtBarButton * pBarButton = (CExtBarButton*)_ppbd.m_pHelperSrc;
- CExtToolControlBar * pToolBar = DYNAMIC_DOWNCAST( CExtToolControlBar, pBarButton->GetBar() );
- ASSERT( pToolBar != NULL );
- if( pToolBar->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) )
- aDrawingMode = eModeMenuBar;
- else
- aDrawingMode = eModeToolBar;
- if( ! pBarButton->GetNoRotateVerticalLayout() )
- {
- if( pToolBar->IsDockedVertically() )
- bHorizontal = false;
- }
- }
- else if( _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtPopupMenuWnd ) ) )
- {
- aDrawingMode = eModePopupMenu;
- }
- else if( _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CWnd ) ) )
- {
- PaintDockerBkgnd( true, dc, (CWnd*)_ppbd.m_pHelperSrc );
- }
- }
- CExtSkinItem
- * pButton = NULL,
- * pPushButton = NULL,
- * pDropDownButton = NULL,
- * pDropDownArrow = NULL;
- if( _ppbd.m_bSeparatedDropDown )
- pButton = (&(m_Skin[_T("Button")][_T("SeparatedDropDown")]));
- else if( _ppbd.m_bDropDown )
- pButton = (&(m_Skin[_T("Button")][_T("DropDown")]));
- else
- pButton = (&(m_Skin[_T("Button")][_T("Simple")]));
- LPCTSTR strDockingType = bHorizontal ? _T("Horizontal") : _T("Vertical");
- if( ! _ppbd.m_bEnabled )
- {
- _ppbd.m_bHover = false;
- _ppbd.m_bDrawFocusRect = false;
- _ppbd.m_bIndeterminate = false;
- }
- if( _ppbd.m_bSeparatedDropDown && (_ppbd.m_bPushed || _ppbd.m_bPushedDropDown) )
- _ppbd.m_bHover = false;
- LPCTSTR strState = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState = _T("Disabled");
- // else if( _ppbd.m_bPushed )
- else if( _ppbd.m_bPushed || _ppbd.m_bIndeterminate )
- strState = _T("Pressed");
- else if( _ppbd.m_bHover || _ppbd.m_bDrawFocusRect )
- strState = _T("Hover");
- // else if( _ppbd.m_bIndeterminate )
- // strState = _T("Indeterminate");
- else if( _ppbd.m_bDefaultPushButton )
- strState = _T("Default");
- switch( aDrawingMode )
- {
- case eModeControl:
- {
- pPushButton = &(*pButton)[_T("PushButton")][_T("Control")][strState];
- if( _ppbd.m_bDropDown )
- {
- pDropDownButton = &(*pButton)[_T("DropDownButton")][_T("Control")][strState];
- pDropDownArrow = &(*pButton)[_T("DropDownArrow")][_T("Control")][strState];
- }
- break;
- }
- case eModePopupMenu:
- case eModeToolBar:
- {
- pPushButton =
- (&((*pButton)
- [_T("PushButton")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][strState]
- ));
- if( aDrawingMode == eModePopupMenu )
- pPushButton =
- (&((*pPushButton)[_T("PaletteMenu")]));
- if( _ppbd.m_bDropDown )
- {
- pDropDownButton =
- (&((*pButton)
- [_T("DropDownButton")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][strState]
- ));
- pDropDownArrow =
- (&((*pButton)
- [_T("DropDownArrow")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][strState]
- ));
- if( aDrawingMode == eModePopupMenu )
- {
- pDropDownButton =
- (&((*pDropDownButton)[_T("PaletteMenu")]));
- pDropDownArrow =
- (&((*pDropDownArrow)[_T("PaletteMenu")]));
- }
- } // if( _ppbd.m_bDropDown )
- else
- {
- if( _ppbd.m_pHelperSrc != NULL
- && _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtBarContentExpandButton ) )
- )
- pPushButton =
- (&((*pPushButton)[_T("Chevron")]));
- } // else from if( _ppbd.m_bDropDown )
- break;
- }
- case eModeMenuBar:
- {
- pPushButton =
- (&((*pButton)
- [_T("PushButton")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][_T("MenuBar")][strState]
- ));
- if( _ppbd.m_bDropDown )
- {
- pDropDownButton =
- (&((*pButton)
- [_T("DropDownButton")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][_T("MenuBar")][strState]
- ));
- pDropDownArrow =
- (&((*pButton)
- [_T("DropDownArrow")][_T("ControlBar")][strDockingType]
- [_T("ToolBar")][_T("MenuBar")][strState]
- ));
- }
- break;
- }
- }
- ASSERT( pPushButton != NULL );
- ASSERT( _ppbd.m_bDropDown ? ( pDropDownButton != NULL ) : true );
- ASSERT( _ppbd.m_bDropDown ? ( pDropDownArrow != NULL ) : true );
- if( (! _ppbd.m_bPushed )
- && pDropDownButton
- && _ppbd.m_bPushedDropDown
- )
- pDropDownButton =
- (&( pDropDownButton->GetParent()->Nested( _T("Pressed") ) ));
- BYTE nScaPushButton = BYTE(0x0FF), nScaDropDownButton = BYTE(0x0FF), nScaDropDownArrow = BYTE(0x0FF);
- if( _ppbd.m_bIndeterminate )
- {
- if( pPushButton != NULL )
- {
- CExtSkinItem * pIndeterminate = pPushButton->NestedGet( _T("Indeterminate") );
- if( pIndeterminate != NULL )
- pPushButton = pIndeterminate;
- else
- nScaPushButton = BYTE(0x080);
- }
- if( pDropDownButton != NULL )
- {
- CExtSkinItem * pIndeterminate = pDropDownButton->NestedGet( _T("Indeterminate") );
- if( pIndeterminate != NULL )
- pDropDownButton = pIndeterminate;
- else
- nScaDropDownButton = BYTE(0x080);
- }
- if( pDropDownArrow != NULL )
- {
- CExtSkinItem * pIndeterminate = pDropDownArrow->NestedGet( _T("Indeterminate") );
- if( pIndeterminate != NULL )
- pDropDownArrow = pIndeterminate;
- else
- nScaDropDownArrow = BYTE(0x080);
- }
- }
- bool bRTL = _ppbd.IsRTL();
- CRect rectClient( _ppbd.m_rcClient );
- // rectClient.DeflateRect( _ppbd.m_rcBorderSizes );
- CRect rectCaption( &rectClient );
- if( _ppbd.m_bDropDown )
- {
- CRect rectDeflateSimpleDropDown( 0, 0, 0, 0 );
- if( ! _ppbd.m_bSeparatedDropDown )
- {
- CExtSkinGlyph & PushButtonGlyph =
- pPushButton->Glyph( _T("PushButton") );
- PushButtonGlyph.Draw( dc.m_hDC, rectClient );
- rectDeflateSimpleDropDown =
- PushButtonGlyph.GetContentPadding();
- rectClient.DeflateRect( &rectDeflateSimpleDropDown );
- } // if( ! _ppbd.m_bSeparatedDropDown )
- CRect rectDropDown( rectClient );
- if( _ppbd.m_bHorz )
- {
- if( bRTL )
- {
- rectCaption.left +=
- __DROPDOWN_ARROW_GAP*2
- + g_glyph_btn_expand_bottom.Size().cx
- ;
- rectDropDown.right = rectCaption.left;
- } // if( bRTL )
- else
- {
- rectCaption.right -=
- __DROPDOWN_ARROW_GAP*2
- + g_glyph_btn_expand_bottom.Size().cx
- ;
- rectDropDown.left = rectCaption.right;
- } // else from if( bRTL )
- } // if( _ppbd.m_bHorz )
- else
- {
- rectCaption.bottom -=
- __DROPDOWN_ARROW_GAP*2
- + g_glyph_btn_expand_right.Size().cy
- ;
- rectDropDown.top = rectCaption.bottom;
- } // if( _ppbd.m_bHorz )
- rectClient = rectCaption;
- if( _ppbd.m_bSeparatedDropDown )
- {
- CExtSkinGlyph & PushButtonGlyph =
- pPushButton->Glyph( _T("PushButton") );
- PushButtonGlyph.Draw( dc.m_hDC, rectClient, false, nScaPushButton );
- rectClient.DeflateRect(
- &PushButtonGlyph.GetContentPadding()
- );
- CExtSkinGlyph & DropDownButtonGlyph =
- pDropDownButton->Glyph( _T("DropDownButton") );
- DropDownButtonGlyph.Draw( dc.m_hDC, rectDropDown, false, nScaDropDownButton );
- CRect rectDropDownArrow( rectDropDown );
- rectDropDownArrow.DeflateRect(
- DropDownButtonGlyph.GetContentPadding()
- );
- CExtSkinGlyph & DropDownArrowGlyph =
- pDropDownArrow->Glyph( _T("DropDownArrow") );
- if( ! _ppbd.m_bNoDropDownArrow )
- DropDownArrowGlyph.Draw( dc.m_hDC, rectDropDownArrow, false, nScaDropDownArrow );
- }
- else
- {
- CExtSkinGlyph & DropDownArrowGlyph =
- pDropDownArrow->Glyph( _T("DropDownArrow") );
- if( ! _ppbd.m_bNoDropDownArrow )
- DropDownArrowGlyph.Draw( dc.m_hDC, rectDropDown, false, nScaDropDownArrow );
- rectClient.DeflateRect( &rectDeflateSimpleDropDown );
- rectCaption = rectClient;
- }
- } // if( _ppbd.m_bDropDown )
- else
- {
- CExtSkinGlyph & PushButtonGlyph =
- pPushButton->Glyph( _T("PushButton") );
- PushButtonGlyph.Draw( dc.m_hDC, rectClient, false, nScaPushButton );
- rectClient.DeflateRect(
- &PushButtonGlyph.GetContentPadding()
- );
- rectCaption = rectClient;
- } // else from if( _ppbd.m_bDropDown )
- CRect rcFocus( rectCaption );
- CExtSafeString sTitle = _T("");
- if( _ppbd.m_sText != NULL )
- sTitle = _ppbd.m_sText;
- COLORREF clrOldText = dc.GetTextColor();
- COLORREF clrOldBk = dc.GetBkColor();
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF bgColor = 0;
- if( _ppbd.m_clrForceBk != ((COLORREF)-1L) )
- bgColor = _ppbd.m_clrForceBk;
- else if( _ppbd.m_bHover || _ppbd.m_bPushed )
- bgColor = GetColor( CLR_3DFACE_IN, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- else
- bgColor = GetColor( CLR_3DFACE_OUT, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- // Draw the icon
- if( rectClient.bottom > rectClient.top
- && rectClient.right > rectClient.left
- )
- {
- if( _ppbd.m_pIcon != NULL && (! _ppbd.m_pIcon->IsEmpty()) )
- {
- PaintIcon(
- dc,
- _ppbd.m_bHorz,
- _ppbd.m_pIcon,
- rectClient,
- _ppbd.m_bPushed,
- _ppbd.m_bEnabled,
- _ppbd.m_bHover,
- _ppbd.m_nIconAlignment,
- _ppbd.m_bForceRtlLayout && _ppbd.m_bHorz,
- NULL,
- &rectCaption,
- &_ppbd.m_rcIconMargins,
- _ppbd.m_clrCustomAccentEffectForIcon
- );
- if( _ppbd.m_nFocusMode == __EBFM_CAPTION_AREA )
- rcFocus = rectCaption;
- if( _ppbd.m_bHorz
- && _ppbd.m_pHelperSrc != NULL
- && _ppbd.m_pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtPopupMenuWnd))
- )
- {
- // if painting tool button with icon in popup menu
- if( bRTL )
- rectCaption.right -= 3;
- else
- rectCaption.left += 3;
- }
- if( ! rectCaption.IsRectEmpty() )
- {
- if( _ppbd.m_bHorz )
- {
- rectCaption.DeflateRect(
- _ppbd.m_rcTextMargins.left,
- _ppbd.m_rcTextMargins.top,
- _ppbd.m_rcTextMargins.right,
- _ppbd.m_rcTextMargins.bottom
- );
- }
- else
- {
- rectCaption.DeflateRect(
- _ppbd.m_rcTextMargins.top,
- _ppbd.m_rcTextMargins.right,
- _ppbd.m_rcTextMargins.bottom,
- _ppbd.m_rcTextMargins.left
- );
- }
- }
- } // if( _ppbd.m_pIcon != NULL && (! _ppbd.m_pIcon->IsEmpty()) )
- else
- {
- // -2.62
- // if( _ppbd.m_bHorz )
- // rectCaption.DeflateRect( 2, 0 );
- // else
- // rectCaption.DeflateRect( 0, 2 );
- PaintSysCmdGlyph(
- dc,
- _ppbd.m_nHelperSysCmdID,
- rectClient,
- false,
- _ppbd.m_bPushed,
- _ppbd.m_bEnabled
- );
- } // else from if( _ppbd.m_pIcon != NULL && (! _ppbd.m_pIcon->IsEmpty()) )
- }
- if( rectCaption.bottom > rectCaption.top
- && rectCaption.right > rectCaption.left
- )
- { // if we have valid area for text
- if( ! sTitle.IsEmpty() )
- {
- if( _ppbd.m_bPushed )
- {
- CSize sizePushedOffset = GetPushedOffset();
- rectCaption.OffsetRect(sizePushedOffset);
- }
- dc.SetBkColor( bgColor );
- COLORREF clrText = COLORREF(-1L);
- if( _ppbd.m_bEnabled )
- {
- if( _ppbd.m_bPushed )
- {
- if( _ppbd.m_clrForceTextPressed == COLORREF(-1L) )
- {
- const CExtSkinColor & skinColor =
- pPushButton->Color( _T("Pressed") );
- if( ! skinColor.IsHollow() )
- clrText = COLORREF( skinColor );
- }
- else
- clrText = _ppbd.m_clrForceTextPressed;
- }
- else if( _ppbd.m_bHover )
- {
- if( _ppbd.m_clrForceTextHover == COLORREF(-1L) )
- {
- const CExtSkinColor & skinColor =
- pPushButton->Color( _T("Hover") );
- if( ! skinColor.IsHollow() )
- clrText = COLORREF( skinColor );
- }
- else
- clrText = _ppbd.m_clrForceTextHover;
- }
- else
- {
- if( _ppbd.m_clrForceTextNormal == COLORREF(-1L) )
- {
- const CExtSkinColor & skinColor =
- pPushButton->Color( _T("Normal") );
- if( ! skinColor.IsHollow() )
- clrText = COLORREF( skinColor );
- }
- else
- clrText = _ppbd.m_clrForceTextNormal;
- }
- } // if( _ppbd.m_bEnabled )
- else
- {
- if( _ppbd.m_clrForceTextDisabled == COLORREF(-1L) )
- {
- const CExtSkinColor & skinColor =
- pPushButton->Color( _T("Disabled") );
- if( ! skinColor.IsHollow() )
- clrText = COLORREF( skinColor );
- }
- else
- clrText = _ppbd.m_clrForceTextDisabled;
- } // else from if( _ppbd.m_bEnabled )
- if( clrText != COLORREF(-1L) )
- { // if skinned color is not hollow
- dc.SetTextColor( clrText );
- CFont _font, * pCurrFont = NULL;
- if( _ppbd.m_hFont != NULL )
- {
- if( _ppbd.m_bHorz )
- pCurrFont = CFont::FromHandle(_ppbd.m_hFont);
- else
- {
- LOGFONT lf;
- ::memset(&lf,0,sizeof(LOGFONT));
- ::GetObject(_ppbd.m_hFont, sizeof(LOGFONT), &lf);
- if( lf.lfEscapement == 0 )
- {
- lf.lfEscapement = __EXT_VERT_FONT_ESCAPEMENT__;
- VERIFY( _font.CreateFontIndirect(&lf) );
- pCurrFont = &_font;
- }
- else
- {
- // suppose font already prepared
- pCurrFont = CFont::FromHandle( _ppbd.m_hFont );
- }
- }
- } // if( _ppbd.m_hFont != NULL )
- else
- {
- if( _ppbd.m_bEnabled )
- {
- if( _ppbd.m_bPushed )
- {
- const CExtSkinFont & skinFont =
- pPushButton->Font(
- _ppbd.m_bDefaultPushButton
- ? _T("PressedDefault")
- : _T("Pressed")
- );
- if( skinFont.CreateFont(
- _font,
- _ppbd.m_bHorz
- ? 0
- : __EXT_VERT_FONT_ESCAPEMENT__
- )
- )
- pCurrFont = &_font;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- }
- else if( _ppbd.m_bHover )
- {
- const CExtSkinFont & skinFont =
- pPushButton->Font(
- _ppbd.m_bDefaultPushButton
- ? _T("HoverDefault")
- : _T("Hover")
- );
- if( skinFont.CreateFont(
- _font,
- _ppbd.m_bHorz
- ? 0
- : __EXT_VERT_FONT_ESCAPEMENT__
- )
- )
- pCurrFont = &_font;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- }
- else
- {
- const CExtSkinFont & skinFont =
- pPushButton->Font(
- _ppbd.m_bDefaultPushButton
- ? _T("NormalDefault")
- : _T("Normal")
- );
- if( skinFont.CreateFont(
- _font,
- _ppbd.m_bHorz
- ? 0
- : __EXT_VERT_FONT_ESCAPEMENT__
- )
- )
- pCurrFont = &_font;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- }
- } // if( _ppbd.m_bEnabled )
- else
- {
- const CExtSkinFont & skinFont =
- pPushButton->Font(
- _ppbd.m_bDefaultPushButton
- ? _T("DisabledDefault")
- : _T("Disabled")
- );
- if( skinFont.CreateFont(
- _font,
- _ppbd.m_bHorz
- ? 0
- : __EXT_VERT_FONT_ESCAPEMENT__
- )
- )
- pCurrFont = &_font;
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- }
- #endif // _DEBUG
- } // else from if( _ppbd.m_bEnabled )
- } // else from if( _ppbd.m_hFont != NULL )
- if( pCurrFont->GetSafeHandle() != NULL )
- {
- CFont * pOldFont = dc.SelectObject( pCurrFont );
- CExtSafeString sBtn( sTitle );
- if( _ppbd.m_bHorz )
- {
- CRect rcTextLocation( 0, 0, 0, 0);
- UINT nDtMeasureFlags =
- DT_LEFT | DT_TOP | DT_CALCRECT | ((bRTL || _ppbd.m_bForceRtlText) ? DT_RTLREADING : 0);
- if( _ppbd.m_bWordBreak )
- {
- rcTextLocation = rectCaption;
- rcTextLocation.OffsetRect( -rcTextLocation.TopLeft() );
- rcTextLocation.bottom = rcTextLocation.top;
- nDtMeasureFlags |= DT_WORDBREAK;
- }
- else
- nDtMeasureFlags |= DT_SINGLELINE;
- dc.DrawText(
- sBtn,
- -1,
- rcTextLocation,
- nDtMeasureFlags
- );
- rcTextLocation.OffsetRect(
- rectCaption.TopLeft() - rcTextLocation.TopLeft()
- );
- UINT nDtDrawFlags = 0;
- if( (_ppbd.m_nTextAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_RIGHT )
- {
- nDtDrawFlags |= DT_RIGHT;
- rcTextLocation.OffsetRect(
- rectCaption.Width() - rcTextLocation.Width(),
- 0
- );
- }
- else if( (_ppbd.m_nTextAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- {
- nDtDrawFlags |= DT_CENTER;
- rcTextLocation.OffsetRect(
- ( rectCaption.Width() - rcTextLocation.Width() ) / 2,
- 0
- );
- }
- else
- nDtDrawFlags |= DT_LEFT;
- if( (_ppbd.m_nTextAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_BOTTOM )
- {
- nDtDrawFlags |= DT_BOTTOM;
- rcTextLocation.OffsetRect(
- 0,
- rectCaption.Height() - rcTextLocation.Height()
- );
- }
- else if( (_ppbd.m_nTextAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_TOP )
- {
- nDtDrawFlags |= DT_TOP;
- }
- else
- {
- nDtDrawFlags |= DT_VCENTER;
- rcTextLocation.OffsetRect(
- 0,
- ( rectCaption.Height() - rcTextLocation.Height() ) / 2
- );
- }
- if( _ppbd.m_bWordBreak )
- nDtDrawFlags |= DT_WORDBREAK;
- else
- nDtDrawFlags |= DT_SINGLELINE;
- if( _ppbd.m_bPushed )
- {
- CSize szPushedOffset = GetPushedOffset();
- rcTextLocation.OffsetRect( szPushedOffset );
- }
- if( _ppbd.m_bForceUseDrawTextApiH )
- {
- dc.DrawText(
- sTitle,
- -1,
- &rcTextLocation,
- nDtDrawFlags
- );
- } // if( _ppbd.m_bForceUseDrawTextApiH )
- else
- {
- if( _ppbd.m_bEnabled
- || _ppbd.m_clrForceTextDisabled != ((COLORREF)-1L)
- )
- {
- dc.DrawText(
- LPCTSTR(sTitle),
- sTitle.GetLength(),
- &rcTextLocation,
- nDtDrawFlags
- );
- }
- else
- {
- CRect rcDrawTextOffs = rcTextLocation;
- rcDrawTextOffs.OffsetRect( 1, 1 );
- COLORREF clrTextRestore =
- dc.SetTextColor(
- GetColor(
- COLOR_3DHILIGHT,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- )
- );
- dc.DrawText(
- LPCTSTR(sTitle),
- sTitle.GetLength(),
- &rcDrawTextOffs,
- nDtDrawFlags
- );
- dc.SetTextColor(
- GetColor(
- COLOR_3DSHADOW,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- )
- );
- dc.DrawText(
- LPCTSTR(sTitle),
- sTitle.GetLength(),
- rcTextLocation,
- nDtDrawFlags
- );
- dc.SetTextColor( clrTextRestore );
- } // else from if( _ppbd.m_bEnabled )
- } // else from if( _ppbd.m_bForceUseDrawTextApiH )
- } // if( _ppbd.m_bHorz )
- else
- {
- INT nTextLength = sTitle.GetLength();
- INT nAmpIndex = sTitle.Find( _T('&') );
- if( nAmpIndex >= 0 )
- sBtn =
- sTitle.Left( nAmpIndex )
- + sTitle.Right( nTextLength - ( nAmpIndex + 1 ) );
- static TCHAR stat_strDummyAmpSeq[] = _T("