ExtSkinPaintManager.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:231k
源码类别:
界面编程
开发平台:
Visual C++
- sCaption
- );
- if( nAvailableWidth >= nWidth
- || sCaption.IsEmpty()
- )
- break;
- sCaption.Delete( sCaption.GetLength() - 1 );
- }
- if( sCaption.GetLength() > 0 )
- dc.DrawText(
- sCaption,
- sCaption.GetLength(),
- (LPRECT)&_pgd.m_rcText,
- nDtAlign|DT_SINGLELINE|DT_VCENTER|DT_NOCLIP
- );
- } // if( bFloatingFixedBar )
- else
- {
- dc.DrawText(
- _pgd.m_sCaption,
- nTextLen,
- (LPRECT)&_pgd.m_rcText,
- nDtAlign|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS
- );
- } // else if( bFloatingFixedBar )
- } // if text is horizontal
- else
- { // if text is vertical
- LOGFONT lf;
- ::memset(&lf,0,sizeof(LOGFONT));
- pCurrFont->GetLogFont(&lf);
- int _cyHorzFont = abs(lf.lfHeight);
- int _cyTextMargin =
- (_pgd.m_rcText.Width() - _cyHorzFont) / 2
- ;
- CRect rcString =
- CRect(
- CPoint(
- _pgd.m_rcText.left + _cyTextMargin - -1,//__ExtMfc_CXTEXTMARGIN,
- _pgd.m_rcText.bottom - 0//__ExtMfc_CYTEXTMARGIN
- ),
- _pgd.m_rcText.Size() //m_sizeHorz
- );
- rcString.DeflateRect(2,2);
- CRect rcExclude;
- rcExclude.SetRect(
- _pgd.m_rcGripper.left,
- _pgd.m_rcGripper.top,
- _pgd.m_rcGripper.right,
- _pgd.m_rcText.top
- );
- dc.ExcludeClipRect( &rcExclude );
- rcString.OffsetRect( -2, -3 );
- dc.DrawText(
- _pgd.m_sCaption,
- nTextLen,
- rcString,
- DT_SINGLELINE //|DT_CENTER|DT_VCENTER
- |DT_NOCLIP |DT_NOPREFIX
- ); // don't forget DT_NOCLIP
- //dc.IntersectClipRect( &rectGripper );
- dc.SelectClipRgn(NULL);
- } // if text is vertical
- dc.SelectObject( pOldFont );
- dc.SetBkMode(nOldBkMode);
- dc.SetTextColor(clrOldText);
- } // if( ! CaptionTextColor.IsHollow() )
- }
- } // if( _pgd.m_bSideBar || _pgd.m_bFloating )
- else
- {
- CExtSkinGlyph * pGripperGlyph = NULL;
- _GetDockedToolBarGlyph(
- STATIC_DOWNCAST( CExtToolControlBar, _pgd.m_pHelperSrc ),
- &pGripperGlyph
- );
- ASSERT( pGripperGlyph != NULL );
- pGripperGlyph->Draw( dc.m_hDC, rectGripper2 );
- } // else from if( _pgd.m_bSideBar || _pgd.m_bFloating )
- }
- void CExtPaintManagerSkin::PaintDockingCaptionButton(
- CDC & dc,
- CExtPaintManager::PAINTDOCKINGCAPTIONBUTTONDATA & _pdcbd
- )
- {
- LPCTSTR strButtonType = _T("");
- switch( _pdcbd.m_eType )
- {
- case CExtPaintManager::__DCBT_CLOSE:
- strButtonType = _T("Close");
- break;
- case CExtPaintManager::__DCBT_ARROW_DOWN:
- strButtonType = _T("Options");
- break;
- case CExtPaintManager::__DCBT_WND_KEEP:
- strButtonType = _T("PinOn");
- break;
- case CExtPaintManager::__DCBT_WND_UNKEEP:
- strButtonType = _T("PinOff");
- break;
- default:
- CExtPaintManager::PaintDockingCaptionButton( dc, _pdcbd );
- return;
- }
- LPCTSTR strButtonState = _T("");
- if( !_pdcbd.m_bEnabled )
- strButtonState = _T("Disabled");
- else if( _pdcbd.m_bPushed )
- strButtonState = _T("Pressed");
- else if( _pdcbd.m_bHover )
- strButtonState = _T("Hover");
- else
- strButtonState = _T("Normal");
- LPCTSTR strBarActiveState =
- _pdcbd.m_bBarWndActive ? _T("Active") : _T("Inactive");
- CExtSkinGlyph & ButtonFrameGlyph =
- m_Skin[_T("Caption")][_T("CaptionButton")]
- [strButtonState][strButtonType][strBarActiveState].Glyph( _T("Frame") );
- ButtonFrameGlyph.Draw( dc.m_hDC, _pdcbd.m_rcClient );
- CExtSkinGlyph & ButtonGlyph =
- m_Skin[_T("Caption")][_T("CaptionButton")]
- [strButtonState][strButtonType][strBarActiveState].Glyph( strButtonType );
- ButtonGlyph.Draw( dc.m_hDC, _pdcbd.m_rcClient );
- }
- INT CExtPaintManagerSkin::GetSeparatorHeight()
- {
- ASSERT_VALID( this );
- CExtSkinGlyph & SeparatorGlyph = m_Skin[_T("MenuItem")][_T("Separator")].Glyph( _T("Separator") );
- return SeparatorGlyph.GetSize().cy;
- }
- CSize CExtPaintManagerSkin::GetResizingGriperSize(
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- pHelperSrc;
- lParam;
- return CSize( 18, 18 );
- }
- void CExtPaintManagerSkin::PaintResizingGripper(
- CDC & dc,
- const RECT & rcGrip,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( rcGrip.left > rcGrip.right
- || rcGrip.top > rcGrip.bottom
- || ( ! dc.RectVisible(&rcGrip) )
- )
- return;
- lParam;
- //COLORREF clrLineShadow = GetColor( COLOR_WINDOW, pHelperSrc, lParam );
- //COLORREF clrLineFace = GetColor( COLOR_3DSHADOW, pHelperSrc, lParam );
- //CPen penLineShadow(PS_SOLID, 1, clrLineShadow);
- //CPen penLineFace(PS_SOLID, 1, clrLineFace);
- //CPen * pOldPen = NULL;
- //
- //CPoint ptTop = CPoint( rcGrip.right, rcGrip.bottom - 3 );
- //CPoint ptBottom = CPoint( rcGrip.right - 2, rcGrip.bottom - 1 );
- //
- // for( int nLine = 0; nLine < 3; nLine++ )
- // {
- // pOldPen = dc.SelectObject( &penLineFace );
- // dc.MoveTo( ptBottom );
- // dc.LineTo( ptTop );
- // ptBottom.Offset( -1, 0 );
- // ptTop.Offset( 0, -1 );
- // dc.MoveTo( ptBottom );
- // dc.LineTo( ptTop );
- // dc.SelectObject( pOldPen );
- //
- // pOldPen = dc.SelectObject( &penLineShadow );
- // ptBottom.Offset( -1, 0 );
- // ptTop.Offset( 0, -1 );
- // dc.MoveTo( ptBottom );
- // dc.LineTo( ptTop );
- // dc.SelectObject( pOldPen );
- //
- // ptBottom.Offset( -2, 0 );
- // ptTop.Offset( 0, -2 );
- // }
- LPCTSTR strWindowType = _T("Generic");
- if( pHelperSrc != NULL )
- {
- ASSERT_VALID( pHelperSrc );
- #ifndef __EXT_MFC_NO_STATUSBAR
- if( pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtStatusControlBar)) )
- strWindowType = _T("StatusBar");
- else
- #endif // ifndef __EXT_MFC_NO_STATUSBAR
- if( pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtResizableDialog)) )
- strWindowType = _T("Dialog");
- } // if( pHelperSrc != NULL )
- CExtSkinGlyph & ResizingGripperGlyph =
- m_Skin[_T("ResizingGripper")][strWindowType]
- .Glyph( _T("ResizingGripper") );
- ResizingGripperGlyph.Draw( dc.m_hDC, rcGrip );
- }
- #ifndef __EXT_MFC_NO_STATUSBAR
- bool CExtPaintManagerSkin::StatusBar_QuerySkinSupport(
- const CExtStatusControlBar * pStatusBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pStatusBar );
- pStatusBar;
- lParam;
- return true;
- }
- bool CExtPaintManagerSkin::StatusBar_ErasePaneBackground(
- CDC & dc,
- int nPaneIdx,
- const RECT & rcPane,
- const CExtStatusControlBar * pStatusBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pStatusBar );
- dc;
- nPaneIdx;
- rcPane;
- pStatusBar;
- lParam;
- int iWidth = 0;
- UINT nIndex = 0, nPaneStyle = 0;
- pStatusBar->GetPaneInfo( nPaneIdx, nIndex, nPaneStyle, iWidth );
- bool bDisabled = ( ( nPaneStyle & SBPS_DISABLED ) != 0 ) ? true : false;
- LPCTSTR strPaneState = bDisabled ? _T("Disabled") : _T("Enabled");
- const CExtSkinGlyph & PaneGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("StatusBar")][strPaneState].Glyph( _T("Pane") );
- CExtSkinGlyph * pPaneGlyph = const_cast<CExtSkinGlyph*>( &PaneGlyph );
- pPaneGlyph->Draw( dc.m_hDC, rcPane );
- return false;
- }
- bool CExtPaintManagerSkin::StatusBar_PaintPane(
- CDC & dc,
- int nPaneIdx,
- const RECT & rcPane,
- DWORD dwPaneStyle,
- HICON hIcon,
- __EXT_MFC_SAFE_LPCTSTR sPaneText,
- UINT nDrawTextFlags,
- COLORREF clrText,
- const CExtStatusControlBar * pStatusBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pStatusBar );
- nPaneIdx;
- clrText;
- pStatusBar;
- lParam;
- bool bDisabled = ( ( dwPaneStyle & SBPS_DISABLED ) != 0 ) ? true : false;
- LPCTSTR strPaneState = bDisabled ? _T("Disabled") : _T("Enabled");
- const CExtSkinGlyph & PaneGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("StatusBar")][strPaneState].Glyph( _T("Pane") );
- CRect rectPane( rcPane );
- rectPane.DeflateRect(
- &PaneGlyph.GetContentPadding()
- );
- CRect rcText( rectPane );
- if( hIcon != NULL )
- {
- CExtCmdIcon _icon;
- _icon.AssignFromHICON( hIcon, true );
- CSize sizeIcon = _icon.GetSize();
- ASSERT( sizeIcon.cx > 0 && sizeIcon.cy > 0 );
- rcText.left += sizeIcon.cx + PaneGlyph.GetIconIndent();
- _icon.Paint(
- const_cast < CExtPaintManagerSkin * > ( this ),
- dc,
- rectPane.left,
- rectPane.top + ( rectPane.Height() - sizeIcon.cy ) / 2,
- -1,
- -1
- );
- } // if( hIcon != NULL )
- int nPaneTextLen =
- (sPaneText == NULL)
- ? int(0)
- : int(_tcslen(sPaneText))
- ;
- if( ( !bDisabled )
- || ( bDisabled && ( !pStatusBar->m_bHideTextOnDisabledPanes ) )
- && nPaneTextLen > 0
- )
- { // if text painting is allowed
- if( rcText.right > rcText.left )
- {
- const CExtSkinColor & PaneTextColor =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("StatusBar")][strPaneState].Color( _T("Text") );
- if( ! PaneTextColor.IsHollow() )
- {
- COLORREF clrTextCustom = // RGB( 212, 220, 220 );
- PaneTextColor;
- COLORREF clrTextRestore = dc.SetTextColor( clrTextCustom );
- dc.DrawText(
- LPCTSTR(sPaneText),
- nPaneTextLen,
- &rcText,
- nDrawTextFlags
- );
- if( clrTextRestore != COLORREF(-1L) )
- dc.SetTextColor( clrTextRestore );
- } // if( ! PaneTextColor.IsHollow() )
- } // if( rcText.right > rcText.left )
- } // if text painting is allowed
- return true;
- }
- bool CExtPaintManagerSkin::StatusBar_PaintSeparator(
- CDC & dc,
- int nPaneIdxAfterSep,
- const RECT & rcPaneBefore,
- const RECT & rcPaneAfter,
- const CExtStatusControlBar * pStatusBar,
- LPARAM lParam // = 0
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pStatusBar );
- nPaneIdxAfterSep;
- rcPaneBefore;
- rcPaneAfter;
- pStatusBar;
- lParam;
- int iWidth = 0;
- UINT nIndex = 0, nPaneStyle = 0;
- pStatusBar->GetPaneInfo( nPaneIdxAfterSep, nIndex, nPaneStyle, iWidth );
- bool bDisabled = ( ( nPaneStyle & SBPS_DISABLED ) != 0 ) ? true : false;
- LPCTSTR strPaneState = bDisabled ? _T("Disabled") : _T("Enabled");
- CRect rcSeparator(
- rcPaneBefore.right,
- rcPaneAfter.top,
- rcPaneAfter.left,
- rcPaneAfter.bottom
- );
- const CExtSkinGlyph & SeparatorGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][_T("StatusBar")][strPaneState].Glyph( _T("Separator") );
- CExtSkinGlyph * pGlyph = const_cast<CExtSkinGlyph*>( &SeparatorGlyph );
- CSize _sizeGlyph = pGlyph->GetSize();
- int nWidth = rcSeparator.Width();
- if( nWidth != _sizeGlyph.cx )
- {
- rcSeparator.left += ( nWidth - _sizeGlyph.cx ) / 2;
- rcSeparator.right = rcSeparator.left + _sizeGlyph.cx;
- }
- pGlyph->Draw( dc.m_hDC, rcSeparator );
- return true;
- }
- #endif // ifndef __EXT_MFC_NO_STATUSBAR
- void CExtPaintManagerSkin::PaintIcon(
- CDC & dc,
- bool bHorz,
- CExtCmdIcon * pIcon,
- const CRect & rcClient,
- bool bPushed,
- bool bEnabled,
- bool bHover, // = false
- INT nIconAlignment, // = 0
- bool bRTL, // = false
- CRect * prcIcon, // = NULL
- CRect * prcText, // = NULL
- CRect * prcIconMargins, // = NULL
- COLORREF clrCustomAccentEffectForIcon // = COLORREF(-1L)
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- bHorz;
- bHover;
- bRTL;
- if( pIcon == NULL || pIcon->IsEmpty() )
- {
- if( prcIcon != NULL )
- *prcIcon = CRect( 0, 0, 0, 0 );
- if( prcText != NULL )
- *prcText = rcClient;
- return;
- }
- CSize _sizeIcon = pIcon->GetSize();
- ASSERT( _sizeIcon.cx > 0 && _sizeIcon.cy > 0 );
- CRect rcIconMargins( 0, 0, 0, 0 );
- if( prcIconMargins != NULL )
- rcIconMargins = *prcIconMargins;
- CRect rcTextLocation( rcClient );
- CRect rcIconLocation( 0, 0, _sizeIcon.cx, _sizeIcon.cy );
- if( bHorz )
- {
- rcIconLocation.OffsetRect(
- rcClient.left,
- rcClient.top
- );
- if( ( _sizeIcon.cx + rcIconMargins.left + rcIconMargins.right ) > rcClient.Width() )
- {
- nIconAlignment &= ~__ALIGN_HORIZ_MASK;
- nIconAlignment |= __ALIGN_HORIZ_CENTER;
- }
- if( ( _sizeIcon.cy + rcIconMargins.top + rcIconMargins.bottom ) > rcClient.Height() )
- {
- nIconAlignment &= ~__ALIGN_VERT_MASK;
- nIconAlignment |= __ALIGN_VERT_CENTER;
- }
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_RIGHT )
- {
- rcIconLocation.OffsetRect( rcClient.right - rcIconLocation.right - rcIconMargins.right, 0 );
- rcTextLocation.right = rcIconLocation.left - rcIconMargins.left;
- }
- else if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- {
- rcIconLocation.OffsetRect( ( rcClient.right - rcIconLocation.right ) / 2 + rcIconMargins.left - rcIconMargins.right, 0 );
- }
- else if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_LEFT )
- {
- rcIconLocation.OffsetRect( rcIconMargins.left, 0 );
- rcTextLocation.left = rcIconLocation.right + rcIconMargins.right;
- }
- if( (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_TOP )
- {
- rcIconLocation.OffsetRect( 0, rcIconMargins.top );
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- rcTextLocation.top = rcIconLocation.bottom + rcIconMargins.bottom;
- }
- else if( (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_CENTER )
- {
- rcIconLocation.OffsetRect( 0, ( rcClient.bottom - rcIconLocation.bottom ) / 2 + rcIconMargins.top - rcIconMargins.bottom );
- }
- else if( (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_BOTTOM )
- {
- rcIconLocation.OffsetRect( 0, rcClient.bottom - rcIconLocation.bottom - rcIconMargins.bottom );
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- rcTextLocation.bottom = rcIconLocation.top - rcIconMargins.top;
- }
- }
- else
- {
- rcIconLocation.OffsetRect(
- rcClient.right - rcIconLocation.Width(),
- rcClient.top
- );
- if( ( _sizeIcon.cy + rcIconMargins.top + rcIconMargins.bottom ) > rcClient.Height() )
- {
- nIconAlignment &= ~__ALIGN_HORIZ_MASK;
- nIconAlignment |= __ALIGN_HORIZ_CENTER;
- }
- if( ( _sizeIcon.cx + rcIconMargins.left + rcIconMargins.right ) > rcClient.Width() )
- {
- nIconAlignment &= ~__ALIGN_VERT_MASK;
- nIconAlignment |= __ALIGN_VERT_CENTER;
- }
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_RIGHT )
- {
- rcIconLocation.OffsetRect( 0, rcClient.bottom - rcIconLocation.bottom - rcIconMargins.bottom );
- rcTextLocation.bottom = rcIconLocation.top - rcIconMargins.top;
- }
- else if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- {
- rcIconLocation.OffsetRect( 0, ( rcClient.bottom - rcIconLocation.bottom ) / 2 + rcIconMargins.top - rcIconMargins.bottom );
- }
- else if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_LEFT )
- {
- rcIconLocation.OffsetRect( 0, rcIconMargins.top );
- rcTextLocation.top = rcIconLocation.bottom;
- }
- if( (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_TOP )
- {
- rcIconLocation.OffsetRect( rcIconMargins.right, 0 );
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- rcTextLocation.right = rcIconLocation.left;
- }
- else if( (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_CENTER )
- {
- rcIconLocation.OffsetRect( ( rcClient.left - rcIconLocation.left ) / 2 + rcIconMargins.right - rcIconMargins.left, 0 );
- }
- else if( (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_BOTTOM )
- {
- rcIconLocation.OffsetRect( rcClient.left - rcIconLocation.left - rcIconMargins.left, 0 );
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- rcTextLocation.left = rcIconLocation.right;
- }
- }
- if( (nIconAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER
- && (nIconAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_CENTER
- )
- rcTextLocation.SetRectEmpty();
- if( rcTextLocation.top >= rcTextLocation.bottom
- || rcTextLocation.left >= rcTextLocation.right
- )
- rcTextLocation.SetRectEmpty();
- // if button is pressed then press the icon also
- if( bPushed )
- {
- CSize sizePushedOffset = GetPushedOffset();
- rcIconLocation.OffsetRect( sizePushedOffset.cx, sizePushedOffset.cy );
- }
- if( ( ! bEnabled )
- && clrCustomAccentEffectForIcon != COLORREF(-1L)
- )
- {
- pIcon->PaintAccentColorized(
- this,
- dc.GetSafeHdc(),
- clrCustomAccentEffectForIcon,
- rcIconLocation.left,
- rcIconLocation.top
- );
- }
- else
- {
- pIcon->Paint(
- this,
- dc.GetSafeHdc(),
- rcIconLocation.left,
- rcIconLocation.top,
- -1,
- -1,
- (! bEnabled )
- ? CExtCmdIcon::__PAINT_DISABLED
- : bPushed
- ? CExtCmdIcon::__PAINT_PRESSED
- : bHover
- ? CExtCmdIcon::__PAINT_HOVER
- : CExtCmdIcon::__PAINT_NORMAL
- );
- }
- if( prcIcon != NULL )
- *prcIcon = rcIconLocation;
- if( prcText != NULL )
- *prcText = rcTextLocation;
- }
- #if (!defined __EXT_MFC_NO_TAB_CTRL)
- bool CExtPaintManagerSkin::QueryTabWndHoverChangingRedraw(
- const CExtTabWnd * pWndTab,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pWndTab );
- pWndTab;
- lParam;
- return true;
- }
- void CExtPaintManagerSkin::PaintTabbedTabClientArea(
- CDC & dc,
- CRect & rcClient,
- CRect & rcTabItemsArea,
- CRect & rcTabNearBorderArea,
- DWORD dwOrientation,
- bool bGroupedMode,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this);
- ASSERT( dc.GetSafeHdc() != NULL );
- if( pHelperSrc == NULL
- || (! pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtTabWnd ) ) )
- )
- CExtPaintManager::PaintTabbedTabClientArea(
- dc,
- rcClient,
- rcTabItemsArea,
- rcTabNearBorderArea,
- dwOrientation,
- bGroupedMode,
- pHelperSrc,
- lParam
- );
- PaintTabClientArea(
- dc,
- rcClient,
- rcTabItemsArea,
- rcTabNearBorderArea,
- dwOrientation,
- bGroupedMode,
- pHelperSrc,
- lParam
- );
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPaintManagerSkin::GetSkinnedTabControlType(
- const CExtTabWnd * pWndTab
- )
- {
- ASSERT_VALID( this );
- if( pWndTab == NULL )
- return _T("Control");
- ASSERT_VALID( pWndTab );
- if( pWndTab->IsKindOf( RUNTIME_CLASS( CExtDynAutoHideArea ) ) )
- return _T("AutoHideArea");
- if( pWndTab->IsKindOf( RUNTIME_CLASS( CExtDynTabWnd ) ) )
- return _T("ResizableBarGroup");
- if( pWndTab->_IsMdiTabCtrl() )
- return _T("MDI");
- if( pWndTab->GetSafeHwnd() == NULL )
- return _T("Control");
- CWnd * pWndParent = pWndTab->GetParent();
- if( pWndParent != NULL
- && pWndParent->IsKindOf( RUNTIME_CLASS( CExtTabPageContainerWnd ) )
- )
- return _T("PageContainer");
- return _T("Control");
- }
- __EXT_MFC_SAFE_LPCTSTR CExtPaintManagerSkin::GetSkinnedTabControlOrientation(
- const CExtTabWnd * pWndTab
- )
- {
- ASSERT_VALID( this );
- if( pWndTab == NULL )
- return _T("Top");
- ASSERT_VALID( pWndTab );
- DWORD dwOrientation = pWndTab->OrientationGet();
- if( dwOrientation == __ETWS_ORIENT_BOTTOM )
- return _T("Bottom");
- if( dwOrientation == __ETWS_ORIENT_LEFT )
- return _T("Left");
- if( dwOrientation == __ETWS_ORIENT_RIGHT )
- return _T("Right");
- return _T("Top");
- }
- void CExtPaintManagerSkin::PaintTabClientArea(
- CDC & dc,
- CRect & rcClient,
- CRect & rcTabItemsArea,
- CRect & rcTabNearBorderArea,
- DWORD dwOrientation,
- bool bGroupedMode,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this);
- ASSERT( dc.GetSafeHdc() != NULL );
- if( pHelperSrc == NULL
- || (! pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtTabWnd ) ) )
- || (! PaintDockerBkgnd( true, dc, (CExtTabWnd*)pHelperSrc, lParam ) )
- )
- {
- CExtPaintManager::PaintTabClientArea(
- dc,
- rcClient,
- rcTabItemsArea,
- rcTabNearBorderArea,
- dwOrientation,
- bGroupedMode,
- pHelperSrc,
- lParam
- );
- return;
- }
- CWnd * pGen = STATIC_DOWNCAST( CWnd, pHelperSrc );
- CExtTabWnd * pExtTabWnd = DYNAMIC_DOWNCAST( CExtTabWnd, pGen );
- LPCTSTR strSkinnedTabControlType = GetSkinnedTabControlType( pExtTabWnd );
- LPCTSTR strSkinnedTabControlOrientation = GetSkinnedTabControlOrientation( pExtTabWnd );
- CExtSkinGlyph & tabAreaEntire =
- m_Skin[_T("Background")][_T("Tab")][_T("EntireArea")]
- [strSkinnedTabControlOrientation][strSkinnedTabControlType]
- .Glyph( _T("Area") );
- tabAreaEntire.Draw( dc.m_hDC, rcClient );
- CExtSkinGlyph & tabAreaItems =
- m_Skin[_T("Background")][_T("Tab")][_T("ItemsArea")]
- [strSkinnedTabControlOrientation][strSkinnedTabControlType]
- .Glyph( _T("Area") );
- tabAreaItems.Draw( dc.m_hDC, rcTabItemsArea );
- CExtSkinGlyph & tabAreaNearBorder =
- m_Skin[_T("Background")][_T("Tab")][_T("NearBorder")]
- [strSkinnedTabControlOrientation][strSkinnedTabControlType]
- .Glyph( _T("Area") );
- CRect rcTabNearBorderArea2 = rcTabNearBorderArea;
- CRect rcOffset = tabAreaNearBorder.GetOffset();
- rcTabNearBorderArea2.OffsetRect( rcOffset.left, rcOffset.top );
- tabAreaNearBorder.Draw( dc.m_hDC, rcTabNearBorderArea2 );
- }
- void CExtPaintManagerSkin::PaintTabItem(
- CDC & dc,
- CRect & rcTabItemsArea,
- bool bTopLeft,
- bool bHorz,
- bool bSelected,
- bool bCenteredText,
- bool bGroupedMode,
- bool bInGroupActive,
- bool bInvertedVerticalMode,
- const CRect & rcEntireItem,
- CSize sizeTextMeasured,
- CFont * pFont,
- __EXT_MFC_SAFE_LPCTSTR sText,
- CExtCmdIcon * pIcon,
- CObject * pHelperSrc,
- LPARAM lParam, // = 0L
- COLORREF clrForceText, // = COLORREF(-1L)
- COLORREF clrForceTabBk, // = COLORREF(-1L)
- COLORREF clrForceTabBorderLT, // = COLORREF(-1L)
- COLORREF clrForceTabBorderRB, // = COLORREF(-1L)
- COLORREF clrForceTabSeparator, // = COLORREF(-1L)
- bool bDwmMode // = false
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- bDwmMode;
- if( pHelperSrc == NULL
- // || ( (! pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtTabWnd ) ) )
- // && (! pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtBarButton ) ) )
- // )
- || IsHighContrast()
- )
- {
- CExtPaintManager::PaintTabItem(
- dc,
- rcTabItemsArea,
- bTopLeft,
- bHorz,
- bSelected,
- bCenteredText,
- bGroupedMode,
- bInGroupActive,
- bInvertedVerticalMode,
- rcEntireItem,
- sizeTextMeasured,
- pFont,
- sText,
- pIcon,
- pHelperSrc,
- lParam, // = 0L
- clrForceText, // = COLORREF(-1L)
- clrForceTabBk, // = COLORREF(-1L)
- clrForceTabBorderLT, // = COLORREF(-1L)
- clrForceTabBorderRB, // = COLORREF(-1L)
- clrForceTabSeparator // = COLORREF(-1L)
- );
- return;
- }
- LPCTSTR _sText = LPCTSTR(sText);
- CExtTabWnd * pWndTab = DYNAMIC_DOWNCAST( CExtTabWnd, pHelperSrc );
- CExtBarButton * pTBB = DYNAMIC_DOWNCAST( CExtBarButton, pHelperSrc );
- bool bDrawIcon =
- ( pWndTab != NULL
- && pIcon != NULL
- && (! pIcon->IsEmpty() )
- && (pWndTab->GetTabWndStyle()&__ETWS_HIDE_ICONS) == 0
- )
- ? true : false;
- LPCTSTR strGroupped = _T("Simple"); // bGroupedMode ? _T("Groupped") : _T("Simple");
- if( bGroupedMode )
- bSelected = false;
- LPCTSTR strItemType = _T("Disabled");
- bool bHover = false, bEnabled = false;
- CExtTabWnd::TAB_ITEM_INFO * pTII = NULL;
- bool bNoPrefix = false;
- if( pWndTab != NULL )
- {
- ASSERT_VALID( pWndTab );
- pTII = pWndTab->ItemGet( LONG( lParam ) );
- ASSERT( pTII != NULL );
- ASSERT_VALID( pTII );
- if( pTII->EnabledGet() )
- {
- bEnabled = true;
- strItemType = bSelected ? _T("Selected") : _T("Default");
- bHover = ( pWndTab->GetHoverTrackingItem() == lParam ) ? true : false;
- }
- bNoPrefix = ( ( pWndTab->GetTabWndStyleEx() & __ETWS_EX_NO_PREFIX ) != 0 ) ? true : false;
- }
- else if( pTBB != NULL )
- {
- if( pTBB->IsEnabled() )
- {
- bEnabled = true;
- strItemType = bSelected ? _T("Selected") : _T("Default");
- bHover = pTBB->IsHover();
- }
- }
- LPCTSTR strHover = bHover ? _T("Hover") : _T("Normal");
- LPCTSTR strSkinnedTabControlType = GetSkinnedTabControlType( pWndTab );
- LPCTSTR strSkinnedTabControlOrientation = GetSkinnedTabControlOrientation( pWndTab );
- CExtSkinGlyph & tabItem =
- m_Skin[_T("TabItem")][strGroupped][strItemType][strHover]
- [strSkinnedTabControlOrientation][strSkinnedTabControlType]
- .Glyph( _T("Area") );
- CExtSkinColor & tabText =
- m_Skin[_T("TabItem")][strGroupped][strItemType][strHover]
- [strSkinnedTabControlOrientation][strSkinnedTabControlType]
- .Color( _T("Text") );
- COLORREF clrText = RGB(0,0,0);
- if( tabText.IsHollow() )
- _sText = _T("");
- else
- clrText = tabText;
- CRect rcEntireItemA = rcEntireItem;
- rcEntireItemA.top += tabItem.GetOffset().top;
- rcEntireItemA.bottom += tabItem.GetOffset().bottom;
- rcEntireItemA.left += tabItem.GetOffset().left;
- rcEntireItemA.right += tabItem.GetOffset().right;
- #if (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool bDetectedDynTPC = false;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pTII != NULL )
- {
- CObject * pObject = pTII->EventProviderGet();
- if( pObject != NULL )
- {
- CExtDynamicControlBar * pBar = DYNAMIC_DOWNCAST( CExtDynamicControlBar, pObject );
- if( pBar != NULL )
- {
- bool bFlashCaptionHighlightedState = false;
- if( pBar->FlashCaptionIsInProgress( &bFlashCaptionHighlightedState ) )
- {
- if( bFlashCaptionHighlightedState )
- {
- clrForceText = pBar->m_clrFlashCaptionText;
- clrForceTabBk = pBar->m_clrFlashCaptionBackground;
- bSelected = true;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bDetectedDynTPC = true;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- }
- }
- }
- }
- }
- #endif// (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
- COLORREF clrColorizeTabShape = COLORREF(-1L);
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pHelperSrc != NULL
- && clrForceTabBk != COLORREF(-1L)
- && ( bDetectedDynTPC
- || pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtDynTabWnd ) )
- || pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtDynAutoHideArea ) )
- )
- )
- {
- if( clrForceText != COLORREF(-1L) )
- clrText = clrForceText;
- clrColorizeTabShape = clrForceTabBk;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- if( pHelperSrc != NULL
- && clrForceTabBk != COLORREF(-1L)
- && pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtTabWnd ) )
- && ((CExtTabWnd*)pHelperSrc)->_IsMdiTabCtrl()
- )
- {
- if( clrForceText != COLORREF(-1L) )
- clrText = clrForceText;
- clrColorizeTabShape = clrForceTabBk;
- }
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- tabItem.Draw( dc.m_hDC, rcEntireItemA, false, BYTE(0xFF), clrColorizeTabShape );
- CRect rcEntireItemB = rcEntireItem;
- CRect rcDeflate = tabItem.GetContentPadding();
- if( bHorz )
- rcEntireItemB.OffsetRect( rcDeflate.left, 0 );
- else
- rcEntireItemB.OffsetRect( 0, rcDeflate.top );
- CExtCmdIcon * pIconTabItemCloseButton = NULL;
- CExtTabWnd * pTabWnd = DYNAMIC_DOWNCAST( CExtTabWnd, pHelperSrc );
- CRect rcTabItemCloseButton( 0, 0, 0, 0 );
- CExtCmdIcon::e_paint_type_t ePaintStateITICB = CExtCmdIcon::__PAINT_NORMAL;
- if( pTabWnd != NULL && ::IsWindow(pTabWnd->m_hWnd) )
- {
- ASSERT_VALID( pTabWnd );
- CExtTabWnd::TAB_ITEM_INFO * pTii = pTabWnd->ItemGet( LONG( lParam ) );
- ASSERT( pTii != NULL );
- ASSERT_VALID( pTii );
- pIconTabItemCloseButton =
- pTabWnd->OnTabWndQueryItemCloseButtonShape( pTii );
- ePaintStateITICB =
- (CExtCmdIcon::e_paint_type_t)
- pTabWnd->OnTabWndQueryItemCloseButtonPaintState( pTii );
- if( pIconTabItemCloseButton != NULL )
- rcTabItemCloseButton = pTii->CloseButtonRectGet();
- }
- CExtPaintManager::stat_PaintTabItemImpl(
- dc,
- rcTabItemsArea,
- bTopLeft,
- bHorz,
- bSelected,
- bEnabled,
- bCenteredText,
- bGroupedMode,
- bInGroupActive,
- bInvertedVerticalMode,
- bDrawIcon,
- rcEntireItemB, //rcEntireItem,
- sizeTextMeasured,
- pFont,
- _sText,
- bNoPrefix,
- pIcon,
- pIconTabItemCloseButton,
- INT(ePaintStateITICB),
- rcTabItemCloseButton,
- clrText,
- COLORREF(-1L), // clrTabBk,
- COLORREF(-1L), // clrTabBorderLT,
- COLORREF(-1L), // clrTabBorderRB,
- COLORREF(-1L), // clrTabSeparator
- true,
- pHelperSrc
- );
- }
- void CExtPaintManagerSkin::PaintTabButton(
- CDC & dc,
- CRect & rcButton,
- LONG nHitTest,
- bool bTopLeft,
- bool bHorz,
- bool bEnabled,
- bool bHover,
- bool bPushed,
- bool bGroupedMode,
- CObject * pHelperSrc,
- LPARAM lParam, // = 0L
- bool bFlat // = false
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- bTopLeft;
- bHorz;
- lParam;
- if( pHelperSrc == NULL
- || (! pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtTabWnd ) ) )
- )
- {
- CExtPaintManager::PaintTabButton(
- dc,
- rcButton,
- nHitTest,
- bTopLeft,
- bHorz,
- bEnabled,
- bHover,
- bPushed,
- bGroupedMode,
- pHelperSrc,
- lParam,
- bFlat
- );
- return;
- }
- LPCTSTR strButtonType = _T("Close");
- switch( nHitTest )
- {
- case __ETWH_BUTTON_LEFTUP:
- strButtonType = _T("Up");
- break;
- case __ETWH_BUTTON_RIGHTDOWN:
- strButtonType = _T("Down");
- break;
- case __ETWH_BUTTON_HELP:
- strButtonType = _T("Help");
- break;
- case __ETWH_BUTTON_CLOSE:
- strButtonType = _T("Close");
- break;
- case __ETWH_BUTTON_TAB_LIST:
- strButtonType = _T("TabList");
- break;
- case __ETWH_BUTTON_SCROLL_HOME:
- strButtonType = _T("Home");
- break;
- case __ETWH_BUTTON_SCROLL_END:
- strButtonType = _T("End");
- break;
- default:
- CExtPaintManager::PaintTabButton(
- dc,
- rcButton,
- nHitTest,
- bTopLeft,
- bHorz,
- bEnabled,
- bHover,
- bPushed,
- bGroupedMode,
- pHelperSrc,
- lParam,
- bFlat
- );
- return;
- } // switch( nHitTest )
- CExtTabWnd * pWndTab = STATIC_DOWNCAST( CExtTabWnd, pHelperSrc );
- LPCTSTR strGroupped = _T("Simple"); // bGroupedMode ? _T("Groupped") : _T("Simple");
- LPCTSTR strState =
- bEnabled
- ? ( bPushed
- ? _T("Pressed")
- : bHover ? _T("Hover") : _T("Normal")
- )
- : _T("Disabled")
- ;
- //LPCTSTR strSkinnedTabControlType = GetSkinnedTabControlType( pWndTab );
- LPCTSTR strSkinnedTabControlOrientation = GetSkinnedTabControlOrientation( pWndTab );
- CExtSkinGlyph & tabItem =
- m_Skin[_T("TabButton")][strGroupped][strButtonType][strState]
- [strSkinnedTabControlOrientation] //[strSkinnedTabControlType]
- .Glyph( _T("Area") );
- tabItem.Draw( dc.m_hDC, rcButton );
- }
- void CExtPaintManagerSkin::PaintTabNcAreaRect(
- CDC & dc,
- const RECT & rc,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( pHelperSrc == NULL
- || (! pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtTabWnd ) ) )
- )
- {
- CExtPaintManager::PaintTabNcAreaRect(
- dc,
- rc,
- pHelperSrc,
- lParam
- );
- return;
- }
- PaintDockerBkgnd( false, dc, (CWnd*)pHelperSrc, lParam );
- }
- void CExtPaintManagerSkin::TabWnd_MeasureItemAreaMargins(
- CExtTabWnd * pTabWnd,
- LONG & nSpaceBefore,
- LONG & nSpaceAfter,
- LONG & nSpaceOver
- )
- {
- ASSERT_VALID( this );
- ASSERT( pTabWnd != NULL && ::IsWindow(pTabWnd->m_hWnd) );
- ASSERT_VALID( pTabWnd );
- CExtPaintManager::TabWnd_MeasureItemAreaMargins(
- pTabWnd,
- nSpaceBefore,
- nSpaceAfter,
- nSpaceOver
- );
- }
- void CExtPaintManagerSkin::TabWnd_UpdateItemMeasure(
- CExtTabWnd * pTabWnd,
- CExtTabWnd::TAB_ITEM_INFO * pTii,
- CDC & dcMeasure,
- CSize & sizePreCalc
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTii );
- ASSERT( dcMeasure.GetSafeHdc() != NULL );
- ASSERT( pTii->GetTabWnd() == pTabWnd );
- CExtPaintManager::TabWnd_UpdateItemMeasure(
- pTabWnd,
- pTii,
- dcMeasure,
- sizePreCalc
- );
- }
- void CExtPaintManagerSkin::GetThemeAccentTabColors(
- COLORREF * pClrSetectedTabItemText,
- COLORREF * pClrSetectedTabItemFace, // = NULL
- COLORREF * pClrSetectedTabItemBorderLight, // = NULL
- COLORREF * pClrSetectedTabItemBorderDark, // = NULL
- CObject * pHelperSrc, // = NULL
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- CExtPaintManager::GetThemeAccentTabColors(
- pClrSetectedTabItemText,
- pClrSetectedTabItemFace,
- pClrSetectedTabItemBorderLight,
- pClrSetectedTabItemBorderDark,
- pHelperSrc,
- lParam
- );
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CTRL)
- void CExtPaintManagerSkin::PaintSeparator(
- CDC & dc,
- const RECT & rectItem,
- bool bHorz,
- bool bTransparentBk,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtToolControlBar * pToolBar = DYNAMIC_DOWNCAST( CExtToolControlBar, pHelperSrc );
- if( pToolBar == NULL )
- {
- CExtPaintManager::PaintSeparator(
- dc,
- rectItem,
- bHorz,
- bTransparentBk,
- pHelperSrc,
- lParam
- );
- return;
- }
- LPCTSTR strBarType = _T("ToolBar");
- if( pToolBar->IsKindOf( RUNTIME_CLASS( CExtMenuControlBar ) ) )
- strBarType = _T("MenuBar");
- LPCTSTR strSeparatorType = bHorz ? _T("SeparatorV") : _T("SeparatorH");
- CExtSkinGlyph & SeparatorGlyph =
- m_Skin[_T("ImageCollection")][_T("ControlBar")][strBarType].Glyph( strSeparatorType );
- CSize _size = SeparatorGlyph.GetSize();
- if( _size.cx == 0 || _size.cy == 0 )
- return;
- CRect rectItemA = rectItem;
- if( bHorz )
- {
- rectItemA.left += ( rectItemA.Width() - _size.cx ) / 2;
- rectItemA.right = rectItemA.left + _size.cx;
- }
- else
- {
- rectItemA.top += ( rectItemA.Height() - _size.cy ) / 2;
- rectItemA.bottom = rectItemA.top + _size.cy;
- }
- SeparatorGlyph.Draw( dc.m_hDC, rectItemA );
- }
- COLORREF CExtPaintManagerSkin::GetIconAlphaColor() const
- {
- ASSERT_VALID( this );
- COLORREF clrIconAlpha = m_Skin[ _T("General") ].Color( _T("IconAlphaColor") );
- return clrIconAlpha;
- }
- double CExtPaintManagerSkin::GetIconAlphaAdjustPercent() const
- {
- ASSERT_VALID( this );
- // return 0.70; // 70% enlighten
- return -0.50;
- }
- bool CExtPaintManagerSkin::AdjustIcon(
- CExtCmdIcon * pIcon
- )
- {
- ASSERT_VALID( this );
- if( pIcon == NULL )
- return false;
- if( (pIcon->m_dwFlags&__EXT_ICON_PERSISTENT_BITMAP_DISABLED) == 0 )
- {
- pIcon->m_bmpDisabled.Empty();
- pIcon->m_bmpDisabled = pIcon->m_bmpNormal;
- pIcon->m_bmpDisabled.Make32();
- COLORREF clrAlpha = GetIconAlphaColor();
- if( clrAlpha == COLORREF(-1L) )
- {
- pIcon->m_bmpDisabled.MakeMono( GetColor( COLOR_3DFACE ) );
- pIcon->m_bmpDisabled.AdjustAlpha( -0.70 ); // -0.50
- }
- else
- {
- double H = 0.0, S = 0.0, L = 0.0;
- CExtBitmap::stat_RGBtoHSL( clrAlpha, &H, &S, &L );
- S = 0.3;
- clrAlpha = CExtBitmap::stat_HLStoRGB( H, L, S );
- pIcon->m_bmpDisabled.MakeMono( clrAlpha );
- double lfAlphaAdjustPercent = GetIconAlphaAdjustPercent();
- pIcon->m_bmpDisabled.AdjustAlpha( lfAlphaAdjustPercent );
- }
- return true;
- }
- return false;
- }
- CSize CExtPaintManagerSkin::GetCheckButtonBoxSize(
- CDC & dc,
- CExtPaintManager::PAINTCHECKRADIOBUTTONDATA & _pcbd
- ) const
- {
- ASSERT_VALID( this );
- dc;
- _pcbd;
- const CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][_T("Unchecked")].Glyph(_T("Normal"));
- CSize _size = _glyph.GetSize();
- return _size;
- }
- CSize CExtPaintManagerSkin::GetRadioButtonBoxSize(
- CDC & dc,
- CExtPaintManager::PAINTCHECKRADIOBUTTONDATA & _pcbd
- ) const
- {
- ASSERT_VALID( this );
- dc;
- _pcbd;
- const CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][_T("Unchecked")].Glyph(_T("Normal"));
- CSize _size = _glyph.GetSize();
- return _size;
- }
- COLORREF CExtPaintManagerSkin::QueryObjectTextColor(
- CDC & dc,
- bool bEnabled,
- bool bFocused,
- bool bHovered,
- bool bPressed,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( pHelperSrc == NULL )
- return
- CExtPaintManager::QueryObjectTextColor(
- dc,
- bEnabled,
- bFocused,
- bHovered,
- bPressed,
- pHelperSrc,
- lParam
- );
- ASSERT_VALID( pHelperSrc );
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtHyperLinkButton) ) )
- { // hyper-link
- if( ! bEnabled )
- return COLORREF(m_Skin[_T("Button")][_T("HyperLink")].Color(_T("Disabled")));
- if( bPressed )
- return COLORREF(m_Skin[_T("Button")][_T("HyperLink")].Color(_T("Pressed")));
- if( bHovered )
- return COLORREF(m_Skin[_T("Button")][_T("HyperLink")].Color(_T("Hover")));
- if( bFocused )
- return COLORREF(m_Skin[_T("Button")][_T("HyperLink")].Color(_T("Focused")));
- return COLORREF(m_Skin[_T("Button")][_T("HyperLink")].Color(_T("Normal")));
- } // hyper-link
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtCheckBox) ) )
- { // check box button
- if( ! bEnabled )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][_T("Unchecked")].Color(_T("Disabled")));
- if( bPressed )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][_T("Unchecked")].Color(_T("Pressed")));
- if( bHovered )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][_T("Unchecked")].Color(_T("Hover")));
- if( bFocused )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][_T("Unchecked")].Color(_T("Focused")));
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][_T("Unchecked")].Color(_T("Normal")));
- } // check box button
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtRadioButton) ) )
- { // check box button
- if( ! bEnabled )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][_T("Unchecked")].Color(_T("Disabled")));
- if( bPressed )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][_T("Unchecked")].Color(_T("Pressed")));
- if( bHovered )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][_T("Unchecked")].Color(_T("Hover")));
- if( bFocused )
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][_T("Unchecked")].Color(_T("Focused")));
- return COLORREF(m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][_T("Unchecked")].Color(_T("Normal")));
- } // check box button
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtLabel) ) )
- { // static
- if( ! bEnabled )
- return COLORREF(m_Skin[_T("Label")].Color(_T("Disabled")));
- return COLORREF(m_Skin[_T("Label")].Color(_T("Normal")));
- } // static
- return
- CExtPaintManager::QueryObjectTextColor(
- dc,
- bEnabled,
- bFocused,
- bHovered,
- bPressed,
- pHelperSrc,
- lParam
- );
- }
- void CExtPaintManagerSkin::PaintCheckButtonBox(
- CDC & dc,
- CExtPaintManager::PAINTCHECKRADIOBUTTONDATA & _pcbd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- LPCTSTR strState = _T("Normal");
- if( ! _pcbd.m_bEnabled )
- strState = _T("Disabled");
- else if( _pcbd.m_bPushed )
- strState = _T("Pressed");
- else if( _pcbd.m_bHover )
- strState = _T("Hover");
- // else if( _pcbd.m_bFocus )
- // strState = _T("Focused");
- LPCTSTR strChecked = _T("Unchecked");
- switch( _pcbd.m_eState )
- {
- case CExtPaintManager::BOX_UNCHECKED:
- case CExtPaintManager::BOX_LDOWN_UNCHECKED:
- case CExtPaintManager::BOX_DISABLED_UNCHECKED:
- case CExtPaintManager::BOX_MOUSE_HOVER_UNCHECKED:
- break;
- case CExtPaintManager::BOX_CHECKED:
- case CExtPaintManager::BOX_LDOWN_CHECKED:
- case CExtPaintManager::BOX_MOUSE_HOVER_CHECKED:
- case CExtPaintManager::BOX_DISABLED_CHECKED:
- strChecked = _T("Checked");
- break;
- case CExtPaintManager::BOX_INDETERMINATE:
- case CExtPaintManager::BOX_LDOWN_INDETERMINATE:
- case CExtPaintManager::BOX_MOUSE_HOVER_INDETERMINATE:
- case CExtPaintManager::BOX_DISABLED_INDETERMINATE:
- strChecked = _T("Indeterminate");
- break;
- } // switch( _pcrbd.m_eState )
- const CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Check")][strChecked].Glyph(strState);
- _glyph.Draw( dc.m_hDC, _pcbd.m_rcBox );
- }
- void CExtPaintManagerSkin::PaintRadioButtonBox(
- CDC & dc,
- CExtPaintManager::PAINTCHECKRADIOBUTTONDATA & _pcbd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- LPCTSTR strState = _T("Normal");
- if( ! _pcbd.m_bEnabled )
- strState = _T("Disabled");
- else if( _pcbd.m_bPushed )
- strState = _T("Pressed");
- else if( _pcbd.m_bHover )
- strState = _T("Hover");
- // else if( _pcbd.m_bFocus )
- // strState = _T("Focused");
- LPCTSTR strChecked = _T("Unchecked");
- switch( _pcbd.m_eState )
- {
- case CExtPaintManager::BOX_UNCHECKED:
- case CExtPaintManager::BOX_LDOWN_UNCHECKED:
- case CExtPaintManager::BOX_DISABLED_UNCHECKED:
- case CExtPaintManager::BOX_MOUSE_HOVER_UNCHECKED:
- break;
- case CExtPaintManager::BOX_CHECKED:
- case CExtPaintManager::BOX_LDOWN_CHECKED:
- case CExtPaintManager::BOX_MOUSE_HOVER_CHECKED:
- case CExtPaintManager::BOX_DISABLED_CHECKED:
- strChecked = _T("Checked");
- break;
- case CExtPaintManager::BOX_INDETERMINATE:
- case CExtPaintManager::BOX_LDOWN_INDETERMINATE:
- case CExtPaintManager::BOX_MOUSE_HOVER_INDETERMINATE:
- case CExtPaintManager::BOX_DISABLED_INDETERMINATE:
- strChecked = _T("Checked");
- break;
- } // switch( _pcrbd.m_eState )
- const CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("CheckAndRadio")][_T("Radio")][strChecked].Glyph(strState);
- _glyph.Draw( dc.m_hDC, _pcbd.m_rcBox );
- }
- bool CExtPaintManagerSkin::PaintGroupBoxFrame(
- CDC & dc,
- const RECT & rcBorder,
- COLORREF clrFrame, // = COLORREF(-1L)
- CObject * pHelperSrc, // = NULL
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- clrFrame;
- pHelperSrc;
- lParam;
- if( rcBorder.left >= rcBorder.right
- || rcBorder.top >= rcBorder.bottom
- || (! dc.RectVisible( &rcBorder ) )
- )
- return true;
- const CExtSkinGlyph & _glyph = m_Skin[_T("GroupBox")].Glyph(_T("Border"));
- _glyph.Draw( dc.m_hDC, rcBorder );
- return true;
- }
- bool CExtPaintManagerSkin::PaintGroupBoxLabel(
- CDC & dc,
- __EXT_MFC_SAFE_LPCTSTR strText,
- COLORREF clrText,
- HFONT hFont,
- DWORD dwDrawTextFlags,
- bool bEnabled,
- const RECT & rcText,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- pHelperSrc;
- lParam;
- int nLenText = int( ( strText != NULL ) ? _tcslen(strText) : 0 );
- if( nLenText == 0
- || rcText.left >= rcText.right
- || rcText.top >= rcText.bottom
- || (! dc.RectVisible( &rcText ) )
- )
- return true;
- if( clrText == COLORREF(-1L) )
- {
- clrText =
- QueryObjectTextColor(
- dc,
- bEnabled,
- false,
- false,
- false,
- pHelperSrc
- );
- if( clrText == COLORREF(-1L) )
- clrText =
- GetColor(
- bEnabled
- ? COLOR_BTNTEXT
- : CExtPaintManager::CLR_TEXT_DISABLED,
- pHelperSrc
- );
- }
- // if( clrText == COLORREF(-1L) )
- // {
- CExtSkinColor & skinColor =
- m_Skin[_T("GroupBox")].Color(
- bEnabled ? _T("Enabled") : _T("Disabled") );
- if( skinColor.IsHollow() )
- return true;
- clrText = COLORREF( skinColor );
- // } // if( clrText == COLORREF(-1L) )
- HFONT hDrawFont = ( hFont != NULL ) ? hFont : ( (HFONT) m_FontNormal.GetSafeHandle() );
- HGDIOBJ hOldFont = dc.SelectObject( hDrawFont );
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldText = dc.SetTextColor( clrText );
- CRect rc( rcText );
- dc.DrawText(
- LPCTSTR(strText),
- int(_tcslen(strText)),
- rc,
- dwDrawTextFlags
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- dc.SelectObject( hOldFont );
- return true;
- }
- #if( !defined __EXT_MFC_NO_SPIN || !defined __EXT_MFC_NO_DURATIONWND )
- void CExtPaintManagerSkin::PaintSpinButtonArrow(
- CDC & dc,
- const CRect & rcButton,
- bool bUp,
- bool bHorz,
- bool bEnabled,
- bool bPushed,
- bool bHover,
- bool bHotTrack,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- bHotTrack;
- pHelperSrc;
- lParam;
- LPCTSTR strState = _T("Disabled");
- if( bEnabled )
- {
- if( bPushed )
- strState = _T("Pressed");
- else if( bHover )
- strState = _T("Hover");
- else
- strState = _T("Normal");
- } // if( bEnabled )
- LPCTSTR strHorzVert = NULL, strUpDown = NULL;
- if( bHorz )
- {
- strHorzVert = _T("Horizontal");
- strUpDown = bUp ? _T("Left") : _T("Right");
- } // if( bHorz )
- else
- {
- strHorzVert = _T("Vertical");
- strUpDown = bUp ? _T("Up") : _T("Down");
- } // else from if( bHorz )
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Button")][_T("Spin")][strHorzVert][strUpDown][_T("Arrow")]
- .Glyph(strState);
- _glyph.Draw( dc.m_hDC, rcButton );
- }
- void CExtPaintManagerSkin::PaintSpinButton(
- CDC & dc,
- const CRect & rcButton,
- bool bUp,
- bool bHorz,
- bool bEnabled,
- bool bFlat,
- bool bDrawBorder,
- bool bPushed,
- bool bHover,
- bool bHotTrack,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- bFlat;
- bDrawBorder;
- LPCTSTR strState = _T("Disabled");
- if( bEnabled )
- {
- if( bPushed )
- strState = _T("Pressed");
- else if( bHover )
- strState = _T("Hover");
- else
- strState = _T("Normal");
- } // if( bEnabled )
- LPCTSTR strHorzVert = NULL, strUpDown = NULL;
- if( bHorz )
- {
- strHorzVert = _T("Horizontal");
- strUpDown = bUp ? _T("Left") : _T("Right");
- } // if( bHorz )
- else
- {
- strHorzVert = _T("Vertical");
- strUpDown = bUp ? _T("Up") : _T("Down");
- } // else from if( bHorz )
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Button")][_T("Spin")][strHorzVert][strUpDown][_T("Button")]
- .Glyph(strState);
- _glyph.Draw( dc.m_hDC, rcButton );
- CRect rcContentPadding = _glyph.GetContentPadding();
- CRect rcArrow = rcButton;
- rcArrow.DeflateRect(
- rcContentPadding.left,
- rcContentPadding.top,
- rcContentPadding.right,
- rcContentPadding.bottom
- );
- PaintSpinButtonArrow(
- dc,
- rcArrow, // rcButton,
- bUp,
- bHorz,
- bEnabled,
- bPushed,
- bHover,
- bHotTrack,
- pHelperSrc,
- lParam
- );
- }
- #endif // #if( !defined __EXT_MFC_NO_SPIN || !defined __EXT_MFC_NO_DURATIONWND )
- void CExtPaintManagerSkin::PaintControlFrame(
- CDC & dc,
- CExtPaintManager::PAINTCONTROLFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CRect rcItem( _pcfd.m_rcClient );
- LPCTSTR strControlType = _T("Generic");
- if( _pcfd.m_pHelperSrc != NULL )
- {
- if( _pcfd.m_pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtEdit)) )
- strControlType = _T("Edit");
- }
- LPCTSTR strState = _T("Disabled");
- LPCTSTR strActive = _T("Inactive");
- LPCTSTR strHover = _T("Normal");
- if( _pcfd.m_bEnabled )
- {
- strState = _T("Normal");
- if( _pcfd.m_bFocus )
- strActive = _T("Active");
- if( _pcfd.m_bHover )
- strHover = _T("Hover");
- }
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("ControlFrame")][strActive][strControlType].Glyph(strState);
- _glyph.Draw( dc.m_hDC, rcItem );
- COLORREF clrInner =
- GetColor(
- ( ! _pcfd.m_bEnabled )
- ? COLOR_3DFACE
- : COLOR_WINDOW,
- _pcfd.m_pHelperSrc,
- _pcfd.m_lParam
- );
- rcItem.DeflateRect(2,2);
- dc.Draw3dRect( rcItem, clrInner, clrInner );
- }
- bool CExtPaintManagerSkin::AdjustControlFont(
- HFONT & hFont,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( hFont != NULL );
- hFont;
- pHelperSrc;
- lParam;
- //LOGFONT _lf;
- // ::memset( &_lf, 0, sizeof(LOGFONT) );
- // ::GetObject( (HGDIOBJ)hFont, sizeof(LOGFONT), (LPVOID) &_lf );
- // hFont = ::CreateFontIndirect( &_lf );
- // ASSERT( hFont != NULL );
- // return true;
- return false;
- }
- DLGTEMPLATE * CExtPaintManagerSkin::AdjustDialogTemplate(
- const DLGTEMPLATE * lpDialogTemplate,
- CObject * pHelperSrc,
- bool bWizard, // = false
- LPARAM lParam // = 0L
- )
- {
- ASSERT( lpDialogTemplate != NULL );
- bWizard;
- lParam;
- LPCTSTR strSkinnedFontType = NULL;
- if( pHelperSrc != NULL )
- {
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtResDlg) ) )
- {
- strSkinnedFontType =
- ((CExtResDlg *)pHelperSrc) ->
- OnQuerySkinnedFontParmName();
- }
- else if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtResPP) ) )
- {
- strSkinnedFontType =
- ((CExtResPP *)pHelperSrc) ->
- OnQuerySkinnedFontParmName();
- }
- else if( pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtResPS) ) )
- {
- strSkinnedFontType =
- ((CExtResPS *)pHelperSrc) ->
- OnQuerySkinnedFontParmName();
- }
- } // if( pHelperSrc != NULL )
- if( strSkinnedFontType == NULL )
- return NULL;
- ASSERT( _tcslen(strSkinnedFontType) > 0 );
- CExtSkinFont & skinFont =
- m_Skin[_T("DialogTemplate")].Font(strSkinnedFontType);
- const LOGFONT & lf = skinFont.LogFontGet();
- if( _tcslen(lf.lfFaceName) == 0 )
- return NULL;
- if( lf.lfHeight == 0 )
- return NULL;
- CDialogTemplate dlgTemplate( lpDialogTemplate );
- dlgTemplate.SetFont(
- lf.lfFaceName,
- WORD( abs( lf.lfHeight ) )
- );
- return (DLGTEMPLATE*)dlgTemplate.Detach();
- }
- #if (!defined __EXT_MFC_NO_DATE_PICKER)
- void CExtPaintManagerSkin::PaintDatePickerPushButton(
- CDC & dc,
- const CRect & rcButton,
- LONG nButtonType, // __EDPWH_BTN_NONE or __EDPWH_BTN_TODAY
- __EXT_MFC_SAFE_LPCTSTR strCaption,
- bool bFlat,
- bool bDrawBorder,
- bool bPushed,
- bool bHover,
- HFONT hFont,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtMemoryDC dcMem( &dc, &rcButton );
- CExtPaintManager::PaintDatePickerPushButton(
- dcMem,
- rcButton,
- nButtonType,
- strCaption,
- bFlat,
- bDrawBorder,
- bPushed,
- bHover,
- hFont,
- pHelperSrc,
- lParam
- );
- }
- void CExtPaintManagerSkin::PaintDatePickerClientArea(
- CDC & dc,
- const RECT & rcTotalClient,
- const RECT & rcUsedClient,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( ! dc.RectVisible(&rcTotalClient) )
- return;
- dc.FillSolidRect(
- &rcTotalClient,
- GetColor( CExtPaintManager::CLR_3DFACE_OUT, pHelperSrc, lParam )
- );
- dc.FillSolidRect(
- &rcUsedClient,
- GetColor( COLOR_WINDOW, pHelperSrc, lParam )
- );
- }
- #endif // (!defined __EXT_MFC_NO_DATE_PICKER)
- #if (!defined __EXT_MFC_NO_SHORTCUTLIST_CTRL)
- void CExtPaintManagerSkin::PaintShortcutListItem(
- CDC & dc,
- CExtPaintManager::PAINTSHORTCUTLISTITEMSDATA & _pslid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtSkinItem * pButton = (&(m_Skin[_T("Button")][_T("Simple")]));
- CExtSkinItem * pSkinItem =
- (&((*pButton)
- [_T("PushButton")][_T("ControlBar")][_T("Horizontal")]
- [_T("ToolBar")][_T("MenuBar")][_T("Normal")]
- ));
- const CExtSkinColor & skinColor =
- pSkinItem->Color( _T("Normal") );
- if( skinColor.IsHollow() )
- m_clrShortcutListItemAlternativeText = COLORREF( -1L );
- else
- m_clrShortcutListItemAlternativeText = COLORREF( skinColor );
- CExtPaintManager::PaintShortcutListItem( dc, _pslid );
- }
- #endif // (!defined __EXT_MFC_NO_SHORTCUTLIST_CTRL)
- CExtPaintManager::SCROLLBARSKINDATA * CExtPaintManagerSkin::ScrollBar_GetSkinData(
- bool bHorzBar,
- CObject * pHelperSrc,
- LPARAM lParam, // = 0L
- bool bLightAccent // = true
- )
- {
- ASSERT_VALID( this );
- bLightAccent;
- if( IsHighContrast() )
- return
- CExtPaintManager::ScrollBar_GetSkinData(
- bHorzBar,
- pHelperSrc,
- lParam,
- bLightAccent
- );
- if( pHelperSrc != NULL )
- {
- ASSERT_VALID( pHelperSrc );
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtZoomScrollBar ) ) )
- {
- switch( ((CExtZoomScrollBar*)pHelperSrc)->m_eSO )
- {
- case CExtScrollBar::__ESO_TOP:
- case CExtScrollBar::__ESO_BOTTOM:
- return (&m_Skin.m_SBSD_ZoomH);
- case CExtScrollBar::__ESO_LEFT:
- case CExtScrollBar::__ESO_RIGHT:
- return (&m_Skin.m_SBSD_ZoomV);
- default:
- return bHorzBar ? (&m_Skin.m_SBSD_ZoomH) : (&m_Skin.m_SBSD_ZoomV);
- } // switch( ((CExtZoomScrollBar*)pHelperSrc)->m_eSO )
- } // if( pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtZoomScrollBar ) ) )
- } // if( pHelperSrc != NULL )
- return bHorzBar ? (&m_Skin.m_SBSD_ClassicH) : (&m_Skin.m_SBSD_ClassicV);
- }
- bool CExtPaintManagerSkin::ScrollBar_GetMetrics(
- INT * p_nHorzBarHeight, // = NULL
- INT * p_nVertBarWidth, // = NULL
- INT * p_nHorzButtonWidth, // = NULL
- INT * p_nVertButtonHeight, // = NULL
- INT * p_nHorzThumbMinWidth, // = NULL
- INT * p_nVertThumbMinHeight, // = NULL
- CObject * pHelperSrc, // = NULL
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- bool bDefaultMetricsRetrived =
- CExtPaintManager::ScrollBar_GetMetrics(
- p_nHorzBarHeight,
- p_nVertBarWidth,
- p_nHorzButtonWidth,
- p_nVertButtonHeight,
- p_nHorzThumbMinWidth,
- p_nVertThumbMinHeight,
- pHelperSrc,
- lParam
- );
- if( IsHighContrast() )
- return bDefaultMetricsRetrived;
- if( ! bDefaultMetricsRetrived )
- {
- if( p_nHorzBarHeight != NULL )
- (*p_nHorzBarHeight) = ::GetSystemMetrics( SM_CYHSCROLL );
- if( p_nVertBarWidth != NULL )
- (*p_nVertBarWidth) = ::GetSystemMetrics( SM_CXVSCROLL );
- if( p_nHorzButtonWidth != NULL )
- (*p_nHorzButtonWidth) = ::GetSystemMetrics( SM_CXHSCROLL );
- if( p_nVertButtonHeight != NULL )
- (*p_nVertButtonHeight) = ::GetSystemMetrics( SM_CYVSCROLL );
- } // if( ! bDefaultMetricsRetrived )
- if( p_nHorzThumbMinWidth != NULL )
- {
- CExtPaintManager::SCROLLBARSKINDATA * pSBSD =
- ( const_cast < CExtPaintManagerSkin * > ( this ) ) ->
- ScrollBar_GetSkinData( true, pHelperSrc, lParam, true );
- if( pSBSD != NULL )
- {
- CRect rcPaddingOfThumbButton =
- pSBSD->m_arrPartPadding[INT(__ESBSPT_COLD)][INT(__ESBMHT_THUMB)];
- INT nMinExtent = rcPaddingOfThumbButton.left + rcPaddingOfThumbButton.right;
- if( (*p_nHorzThumbMinWidth) < nMinExtent )
- (*p_nHorzThumbMinWidth) = nMinExtent;
- } // if( pSBSD != NULL )
- } // if( p_nHorzThumbMinWidth != NULL )
- if( p_nVertThumbMinHeight != NULL )
- {
- CExtPaintManager::SCROLLBARSKINDATA * pSBSD =
- ( const_cast < CExtPaintManagerSkin * > ( this ) ) ->
- ScrollBar_GetSkinData( false, pHelperSrc, lParam, true );
- if( pSBSD != NULL )
- {
- CRect rcPaddingOfThumbButton =
- pSBSD->m_arrPartPadding[INT(__ESBSPT_COLD)][INT(__ESBMHT_THUMB)];
- INT nMinExtent = rcPaddingOfThumbButton.top + rcPaddingOfThumbButton.bottom;
- if( (*p_nVertThumbMinHeight) < nMinExtent )
- (*p_nVertThumbMinHeight) = nMinExtent;
- } // if( pSBSD != NULL )
- } // if( p_nVertThumbMinHeight != NULL )
- return true;
- }
- bool CExtPaintManagerSkin::PaintDocumentClientAreaBkgnd(
- CDC & dc,
- CWnd * pWnd,
- LPARAM lParam // = NULL
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( pWnd->GetSafeHwnd() != NULL && ::IsWindow(pWnd->GetSafeHwnd()) );
- return PaintDockerBkgnd( true, dc, pWnd, lParam );
- }
- #ifndef __EXT_MFC_NO_GRIDWND
- bool CExtPaintManagerSkin::Grid_PaintButton(
- CDC & dc,
- const RECT & rcButton,
- INT nButtonType,
- bool bPressed,
- bool bHovered,
- bool bFocused,
- bool bEnabled,
- COLORREF clrFace,
- COLORREF clrLight,
- COLORREF clrShadow,
- COLORREF clrWindow,
- COLORREF clrText,
- DWORD dwHelperPaintFlags,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( pHelperSrc == NULL )
- return false;
- ASSERT_VALID( pHelperSrc );
- if( IsHighContrast() )
- return
- CExtPaintManager::Grid_PaintButton(
- dc,
- rcButton,
- nButtonType,
- bPressed,
- bHovered,
- bFocused,
- bEnabled,
- clrFace,
- clrLight,
- clrShadow,
- clrWindow,
- clrText,
- dwHelperPaintFlags,
- pHelperSrc,
- lParam
- );
- CRect rc( rcButton );
- // dc.FillSolidRect( &rc, clrWindow );
- LPCTSTR strState = _T("Disabled");
- if( bEnabled )
- {
- if( bPressed )
- strState = _T("Pressed");
- else if( bHovered )
- strState = _T("Hover");
- else
- strState = _T("Normal");
- } // if( bEnabled )
- CExtSafeString strGlyphBackground = strState;
- strGlyphBackground += _T("-Background");
- CExtSafeString strGlyphArrow = strState;
- strGlyphArrow += _T("-Arrow");
- LPCTSTR strButtonType = NULL, strArrow = NULL;
- CExtBitmap * pBitmap = NULL;
- switch( nButtonType )
- {
- case INT(CExtGridCell::__EBTT_DROPDOWN):
- strButtonType = _T("DropDown");
- if( (dwHelperPaintFlags&__EGCPF_NO_BUTTON_DROPDOWN_ARROW) == 0 )
- strArrow = LPCTSTR(strGlyphArrow);
- break;
- case INT(CExtGridCell::__EBTT_ELLIPSIS):
- strButtonType = _T("Ellipsis");
- if( (dwHelperPaintFlags&__EGCPF_NO_BUTTON_ELLIPSIS_DOTS) == 0 )
- strArrow = LPCTSTR(strGlyphArrow);
- break;
- case INT(CExtGridCell::__EBTT_UPDOWN_UP):
- strButtonType = _T("Up");
- strArrow = LPCTSTR(strGlyphArrow);
- break;
- case INT(CExtGridCell::__EBTT_UPDOWN_DOWN):
- strButtonType = _T("Down");
- strArrow = LPCTSTR(strGlyphArrow);
- break;
- case INT(CExtGridCell::__EBTT_FILTER_APPLIED):
- //strButtonType = _T("DropDown");
- pBitmap = &m_bmpFilterApplied;
- break;
- case INT(CExtGridCell::__EBTT_FILTER_UNAPPLIED):
- //strButtonType = _T("DropDown");
- pBitmap = &m_bmpFilterUnApplied;
- break;
- } // switch( nButtonType )
- if( strButtonType != NULL )
- {
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Button")][_T("Grid")][strButtonType]
- .Glyph( LPCTSTR(strGlyphBackground) );
- _glyph.Draw( dc.m_hDC, rcButton );
- } // if( strButtonType != NULL )
- if( strArrow != NULL )
- {
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Button")][_T("Grid")][strButtonType]
- .Glyph( LPCTSTR(strArrow) );
- _glyph.Draw( dc.m_hDC, rcButton );
- } // if( strArrow != NULL )
- if( pBitmap != NULL
- && (! pBitmap->IsEmpty() )
- )
- {
- CRect rcDst( rc.TopLeft(), pBitmap->GetSize() );
- rcDst.OffsetRect(
- ( rc.Width() - rcDst.Width() ) / 2,
- ( rc.Height() - rcDst.Height() ) / 2
- );
- pBitmap->AlphaBlend( dc.m_hDC, rcDst );
- } // if( pBitmap != NULL ...
- return true;
- }
- bool CExtPaintManagerSkin::Grid_PaintHeaderSortArrow(
- CDC & dc,
- const RECT & rcSortArrow,
- bool bHorz,
- bool bAscending,
- COLORREF * pColorValues,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- return
- CExtPaintManager::Grid_PaintHeaderSortArrow(
- dc,
- rcSortArrow,
- bHorz,
- bAscending,
- pColorValues,
- pHelperSrc,
- lParam
- );
- if( pColorValues == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("SortArrow")]
- .Glyph(
- bHorz
- ? ( bAscending ? _T("AscendingLeftRight") : _T("DescendingLeftRight") )
- : ( bAscending ? _T("AscendingTopBottom") : _T("DescendingTopBottom") )
- );
- _glyph.Draw( dc.m_hDC, rcSortArrow );
- return true;
- }
- bool CExtPaintManagerSkin::Grid_PaintHeaderBackground(
- CDC & dc,
- const RECT & rcArea,
- LONG nColNo,
- LONG nRowNo,
- INT nColType,
- INT nRowType,
- DWORD dwAreaFlags,
- DWORD dwHelperPaintFlags,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- return
- CExtPaintManager::Grid_PaintHeaderBackground(
- dc,
- rcArea,
- nColNo,
- nRowNo,
- nColType,
- nRowType,
- dwAreaFlags,
- dwHelperPaintFlags,
- pHelperSrc,
- lParam
- );
- CExtGridWnd * pGridWnd = ( pHelperSrc != NULL ) ? ( DYNAMIC_DOWNCAST( CExtGridWnd, pHelperSrc ) ) : NULL;
- if( pGridWnd == NULL )
- return false;
- bool bHoverByColumn = ( (dwHelperPaintFlags&__EGCPF_HOVER_BY_COLUMN) != 0 ) ? true : false;
- bool bHoverByRow = ( (dwHelperPaintFlags&__EGCPF_HOVER_BY_ROW) != 0 ) ? true : false;
- bool bHighlightedBySelectedColumn = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_SELECTED_COLUMN) != 0 ) ? true : false;
- bool bHighlightedBySelectedRow = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_SELECTED_ROW) != 0 ) ? true : false;
- bool bHighlightedByFocusedColumn = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN) != 0 ) ? true : false;
- bool bHighlightedByFocusedRow = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW) != 0 ) ? true : false;
- // bool bFocusedControl = ( (dwHelperPaintFlags&__EGCPF_FOCUSED_CONTROL) != 0 ) ? true : false;
- bool bHighlightPressing = ( (dwHelperPaintFlags&(__EGCPF_HIGHLIGHTED_BY_PRESSED_COLUMN|__EGCPF_HIGHLIGHTED_BY_PRESSED_ROW)) != 0 ) ? true : false;
- LPCTSTR strOuterAreaLocation = NULL;
- if( nColType == 0 && nRowType == 0 )
- {
- if( nColNo >= 0 && nRowNo >= 0 )
- return false;
- strOuterAreaLocation = _T("GeneralOuterBackground");
- }
- else if( nColType == 0 && nRowType == -1 )
- strOuterAreaLocation = _T("Top");
- else if( nColType == 0 && nRowType == 1 )
- strOuterAreaLocation = _T("Bottom");
- else if( nColType == -1 && nRowType == 0 )
- strOuterAreaLocation = _T("Left");
- else if( nColType == 1 && nRowType == 0 )
- strOuterAreaLocation = _T("Right");
- else if( nColType == -1 && nRowType == -1 )
- strOuterAreaLocation = _T("TopLeft");
- else if( nColType == 1 && nRowType == -1 )
- strOuterAreaLocation = _T("TopRight");
- else if( nColType == -1 && nRowType == 1 )
- strOuterAreaLocation = _T("BottomLeft");
- else if( nColType == 1 && nRowType == 1 )
- strOuterAreaLocation = _T("BottomRight");
- if( strOuterAreaLocation == NULL )
- return false;
- if( nColNo >= 0L && nRowNo >= 0L )
- {
- LPCTSTR strHeaderCellState = _T("Normal");
- if( bHighlightPressing )
- strHeaderCellState = _T("Pressed");
- else if( bHoverByColumn && bHoverByRow )
- strHeaderCellState = _T("Hover");
- else if( bHighlightedByFocusedColumn || bHighlightedByFocusedRow )
- strHeaderCellState = _T("HighlightedByFocus");
- else if( bHighlightedBySelectedColumn || bHighlightedBySelectedRow )
- strHeaderCellState = _T("HighlightedBySelection");
- else if( bHoverByColumn || bHoverByRow )
- {
- if( nColType == 0 || nRowType == 0 )
- strHeaderCellState = _T("HighlightedByHover");
- }
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("HeaderCell")][strOuterAreaLocation]
- .Glyph( strHeaderCellState );
- _glyph.Draw( dc.m_hDC, rcArea );
- } // if( nColNo >= 0L && nRowNo >= 0L )
- else
- {
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("OuterBackground")][strOuterAreaLocation]
- .Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, rcArea );
- } // else from if( nColNo >= 0L && nRowNo >= 0L )
- return true;
- }
- COLORREF CExtPaintManagerSkin::Grid_OnQueryTextColor(
- const CExtGridCell & _cell,
- CDC & dc,
- LONG nVisibleColNo,
- LONG nVisibleRowNo,
- LONG nColNo,
- LONG nRowNo,
- INT nColType,
- INT nRowType,
- DWORD dwAreaFlags,
- DWORD dwHelperPaintFlags
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( (&_cell) );
- if( (dwHelperPaintFlags&__EGCPF_PRINTING_TARGET_MASK) != 0 )
- return COLORREF(-1L);
- if( IsHighContrast() )
- return
- CExtPaintManager::Grid_OnQueryTextColor(
- _cell,
- dc,
- nVisibleColNo,
- nVisibleRowNo,
- nColNo,
- nRowNo,
- nColType,
- nRowType,
- dwAreaFlags,
- dwHelperPaintFlags
- );
- LPCTSTR strOuterAreaLocation = NULL;
- if( nColType == 0 && nRowType == 0 )
- return COLORREF(-1L);
- else if( nColType == 0 && nRowType == -1 )
- strOuterAreaLocation = _T("Top");
- else if( nColType == 0 && nRowType == 1 )
- strOuterAreaLocation = _T("Bottom");
- else if( nColType == -1 && nRowType == 0 )
- strOuterAreaLocation = _T("Left");
- else if( nColType == 1 && nRowType == 0 )
- strOuterAreaLocation = _T("Right");
- else if( nColType == -1 && nRowType == -1 )
- strOuterAreaLocation = _T("TopLeft");
- else if( nColType == 1 && nRowType == -1 )
- strOuterAreaLocation = _T("TopRight");
- else if( nColType == -1 && nRowType == 1 )
- strOuterAreaLocation = _T("BottomLeft");
- else if( nColType == 1 && nRowType == 1 )
- strOuterAreaLocation = _T("BottomRight");
- if( strOuterAreaLocation == NULL )
- return COLORREF(-1L);
- bool bHoverByColumn = ( (dwHelperPaintFlags&__EGCPF_HOVER_BY_COLUMN) != 0 ) ? true : false;
- bool bHoverByRow = ( (dwHelperPaintFlags&__EGCPF_HOVER_BY_ROW) != 0 ) ? true : false;
- bool bHighlightedBySelectedColumn = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_SELECTED_COLUMN) != 0 ) ? true : false;
- bool bHighlightedBySelectedRow = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_SELECTED_ROW) != 0 ) ? true : false;
- bool bHighlightedByFocusedColumn = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN) != 0 ) ? true : false;
- bool bHighlightedByFocusedRow = ( (dwHelperPaintFlags&__EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW) != 0 ) ? true : false;
- // bool bFocusedControl = ( (dwHelperPaintFlags&__EGCPF_FOCUSED_CONTROL) != 0 ) ? true : false;
- bool bHighlightPressing = ( (dwHelperPaintFlags&(__EGCPF_HIGHLIGHTED_BY_PRESSED_COLUMN|__EGCPF_HIGHLIGHTED_BY_PRESSED_ROW)) != 0 ) ? true : false;
- LPCTSTR strHeaderCellState = _T("Normal");
- if( bHighlightPressing )
- strHeaderCellState = _T("Pressed");
- else if( bHoverByColumn && bHoverByRow )
- strHeaderCellState = _T("Hover");
- else if( bHighlightedByFocusedColumn || bHighlightedByFocusedRow )
- strHeaderCellState = _T("HighlightedByFocus");
- else if( bHighlightedBySelectedColumn || bHighlightedBySelectedRow )
- strHeaderCellState = _T("HighlightedBySelection");
- else if( bHoverByColumn || bHoverByRow )
- strHeaderCellState = _T("HighlightedByHover");
- const CExtSkinColor & colorText =
- m_Skin[_T("Grid")][_T("HeaderCell")][strOuterAreaLocation]
- .Color( strHeaderCellState );
- if( colorText.IsHollow() )
- return COLORREF(-1L);
- COLORREF clr = COLORREF( colorText );
- return clr;
- }
- #endif // #ifndef __EXT_MFC_NO_GRIDWND
- #if (!defined __EXT_MFC_NO_REPORTGRIDWND)
- bool CExtPaintManagerSkin::ReportGrid_PaintHeaderRowBackground(
- CDC & dc,
- const RECT & rcArea,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- // dc;
- // rcArea;
- // pHelperSrc;
- // lParam;
- // return false;
- return
- CExtPaintManagerSkin::Grid_PaintHeaderBackground(
- dc,
- rcArea,
- -1L,
- -1L,
- 0,
- 0,
- 0,
- 0,
- pHelperSrc,
- lParam
- );
- }
- bool CExtPaintManagerSkin::ReportGrid_PaintHeaderSortArrow(
- CDC & dc,
- const RECT & rcSortArrow,
- bool bAscending,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- return
- CExtPaintManager::ReportGrid_PaintHeaderSortArrow(
- dc,
- rcSortArrow,
- bAscending,
- pHelperSrc,
- lParam
- );
- static COLORREF ColorValues[4] =
- {
- RGB(0,0,0),
- RGB(0,0,0),
- RGB(0,0,0),
- RGB(0,0,0),
- };
- return Grid_PaintHeaderSortArrow( dc, rcSortArrow, false, bAscending, ColorValues, pHelperSrc, lParam );
- }
- bool CExtPaintManagerSkin::ReportGrid_PaintGroupAreaBackground(
- CDC & dc,
- const RECT & rcArea,
- __EXT_MFC_SAFE_LPCTSTR strEmptyAreaCaption, // not NULL if area is empty
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- return
- CExtPaintManager::ReportGrid_PaintGroupAreaBackground(
- dc,
- rcArea,
- strEmptyAreaCaption,
- pHelperSrc,
- lParam
- );
- bool bSomeThemedBackground = false;
- CExtSkinGlyph & glyphBack = m_Skin[_T("Background")][_T("ReportGroupArea")].Glyph( _T("Background") );
- if( glyphBack.IsEmpty() )
- {
- CWnd * pWnd = DYNAMIC_DOWNCAST( CWnd, pHelperSrc );
- if( pWnd != NULL
- && PaintDockerBkgnd( true, dc, pWnd, lParam )
- )
- bSomeThemedBackground = true;
- }
- else
- {
- glyphBack.Draw( dc.m_hDC, rcArea );
- bSomeThemedBackground = true;
- }
- if( bSomeThemedBackground )
- {
- CExtSkinColor & skinColor = m_Skin[_T("Grid")].Color( _T("ReportEmptyMessageColor") );
- if( ! skinColor.IsHollow() )
- {
- INT nTextLen = 0;
- if( strEmptyAreaCaption != NULL
- && ( nTextLen = INT( _tcslen( strEmptyAreaCaption ) ) ) > 0
- )
- {
- COLORREF clrEmptyMessageText = COLORREF( skinColor );
- CRect rcCaption = rcArea;
- rcCaption.DeflateRect( 5, 5, 0, 5 );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldTextColor = dc.SetTextColor( clrEmptyMessageText );
- dc.DrawText(
- LPCTSTR(strEmptyAreaCaption),
- nTextLen,
- rcCaption,
- DT_SINGLELINE|DT_NOCLIP
- );
- dc.SetTextColor( clrOldTextColor );
- dc.SetBkMode( nOldBkMode );
- }
- }
- return true;
- }
- return false;
- }
- COLORREF CExtPaintManagerSkin::ReportGrid_GetHeaderTextColor(
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- pHelperSrc;
- lParam;
- return COLORREF(-1L);
- }
- COLORREF CExtPaintManagerSkin::ReportGrid_GetGroupConnectorColor(
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- pHelperSrc;
- lParam;
- CExtSkinColor & skinColor = m_Skin[_T("Grid")].Color( _T("ReportGroupConnector") );
- if( ! skinColor.IsHollow() )
- {
- COLORREF clr = COLORREF( skinColor );
- return clr;
- }
- return COLORREF(-1L);
- }
- bool CExtPaintManagerSkin::ReportGrid_PaintGroupAreaItemBackground(
- CDC & dc,
- const RECT & rcItem,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- pHelperSrc;
- lParam;
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("OuterBackground")][_T("ReportGroupAreaItem")]
- .Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, rcItem );
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_REPORTGRIDWND)
- CFont * CExtPaintManagerSkin::MenuCaptionGetFont(
- CExtPopupMenuWnd * pPopup,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pPopup );
- if( IsHighContrast() )
- return CExtPaintManager::MenuCaptionGetFont( pPopup, lParam );
- return (CFont *)(&m_FontBold);
- }
- CSize CExtPaintManagerSkin::MenuCaption_Measure(
- CDC & dc,
- __EXT_MFC_SAFE_LPCTSTR sMenuCaptionText,
- CExtPopupMenuWnd * pPopup,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pPopup );
- if( sMenuCaptionText == NULL )
- return CSize( 0, 0 );
- CExtSafeString _sText = sMenuCaptionText;
- if( _sText.GetLength() == 0 )
- return CSize( 0, 0 );
- if( IsHighContrast() )
- return
- CExtPaintManager::MenuCaption_Measure(
- dc,
- sMenuCaptionText,
- pPopup,
- lParam
- );
- CFont * pFont = MenuCaptionGetFont( pPopup, lParam );
- ASSERT( pFont->GetSafeHandle() != NULL );
- CSize _size =
- stat_CalcTextDimension(
- dc,
- *pFont,
- _sText,
- DT_SINGLELINE|DT_TOP|DT_LEFT
- ).Size();
- const CExtSkinGlyph & _glyph = m_Skin[_T("MenuCaption")].Glyph( _T("Background") );
- const CRect & rcContentPadding = _glyph.GetContentPadding();
- _size.cx += rcContentPadding.left + rcContentPadding.right;
- _size.cy += rcContentPadding.top + rcContentPadding.bottom;
- return _size;
- }
- void CExtPaintManagerSkin::MenuCaption_Paint(
- CDC & dc,
- const RECT & rcMenuCaption,
- __EXT_MFC_SAFE_LPCTSTR sMenuCaptionText,
- CExtPopupMenuWnd * pPopup,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- // ASSERT_VALID( pPopup );
- if( ( ! dc.RectVisible( &rcMenuCaption ) )
- //|| sMenuCaptionText == NULL
- )
- return;
- if( IsHighContrast() )
- {
- CExtPaintManager::MenuCaption_Paint(
- dc,
- rcMenuCaption,
- sMenuCaptionText,
- pPopup,
- lParam
- );
- return;
- }
- INT nTextLen = ( sMenuCaptionText != NULL ) ? INT( _tcslen( sMenuCaptionText ) ) : 0;
- // if( nTextLen == 0 )
- // return;
- CRect _rcMenuCaption = rcMenuCaption;
- if( _rcMenuCaption.IsRectEmpty()
- || ( ! dc.RectVisible( &_rcMenuCaption ) )
- )
- return;
- CRect _rcMenuCaptionBk = _rcMenuCaption;
- //_rcMenuCaptionBk.InflateRect( 2, 2, 2, 0 );
- const CExtSkinGlyph & _glyph = m_Skin[_T("MenuCaption")].Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, _rcMenuCaptionBk );
- const CExtSkinColor & _color = m_Skin[_T("MenuCaption")].Color( _T("TextColor") );
- if( ! _color.IsHollow() )
- {
- COLORREF clrMenuCaptionText = _color;
- const CRect & rcContentPadding = _glyph.GetContentPadding();
- _rcMenuCaption.DeflateRect( &rcContentPadding );
- if( nTextLen != 0 )
- {
- bool bRTL = ( pPopup != NULL ) ? pPopup->OnQueryLayoutRTL() : false;
- UINT nDT = DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS|DT_NOCLIP
- | ( bRTL ? DT_RIGHT : DT_LEFT );
- CFont * pFont = MenuCaptionGetFont( pPopup, lParam );
- ASSERT( pFont->GetSafeHandle() != NULL );
- CFont * pOldFont = dc.SelectObject( pFont );
- COLORREF clrOldText = dc.SetTextColor( clrMenuCaptionText );
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- dc.DrawText(
- LPCTSTR( sMenuCaptionText ),
- nTextLen,
- &_rcMenuCaption,
- nDT
- );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- dc.SelectObject( pOldFont );
- } // if( nTextLen != 0 )
- } // if( ! _color.IsHollow() )
- }
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- bool CExtPaintManagerSkin::Ribbon_OptionsPageBackgroundIsDefault() const
- {
- ASSERT_VALID( this );
- return true;
- }
- CFont * CExtPaintManagerSkin::RibbonGallery_GetItemFont(
- CExtRibbonGalleryWnd * pGalleryWnd,
- LPVOID pGalleryItemData,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pGalleryWnd );
- if( IsHighContrast() )
- return
- CExtPaintManager::RibbonGallery_GetItemFont(
- pGalleryWnd,
- pGalleryItemData,
- lParam
- );
- CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI =
- (CExtToolBoxWnd::TOOLBOX_ITEM_DATA *)pGalleryItemData;
- if( pTBCI->ItemGetNext( __TBCGN_PARENT ) == pGalleryWnd->ItemGetRoot() )
- return (&m_FontBold);
- else
- return (&m_FontNormal);
- }
- CSize CExtPaintManagerSkin::RibbonGallery_MeasureItem(
- CDC & dc,
- CExtRibbonGalleryWnd * pGalleryWnd,
- LPVOID pGalleryItemData,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pGalleryWnd );
- return
- CExtPaintManager::RibbonGallery_MeasureItem(
- dc,
- pGalleryWnd,
- pGalleryItemData,
- lParam
- );
- }
- bool CExtPaintManagerSkin::RibbonGallery_DrawItem(
- CDC & dc,
- CExtRibbonGalleryWnd * pGalleryWnd,
- const RECT & rcItem,
- LPVOID pGalleryItemData,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pGalleryWnd );
- if( IsHighContrast() )
- return
- CExtPaintManager::RibbonGallery_DrawItem(
- dc,
- pGalleryWnd,
- rcItem,
- pGalleryItemData,
- lParam
- );
- CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI =
- (CExtToolBoxWnd::TOOLBOX_ITEM_DATA *)pGalleryItemData;
- DWORD dwItemStyle = pTBCI->GetItemStyle();
- CRect _rcItem = rcItem;
- CSize sizeItem = _rcItem.Size();
- if( (dwItemStyle & __TBWI_VISIBLE) == 0
- || _rcItem.IsRectEmpty()
- || (! dc.RectVisible( &_rcItem ) )
- )
- return true;
- __EXT_MFC_SAFE_LPCTSTR sText = pTBCI->TextGet();
- DWORD dwToolBoxWndStyles = pGalleryWnd->GetToolBoxWndStyle();
- bool bTreeBoxes = ( (dwToolBoxWndStyles&__TBWS_TREE_BOXES) != 0 ) ? true : false;
- bool bListViewMode = false;
- CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_Parent = pTBCI->ItemGetNext( __TBCGN_PARENT );
- CExtToolBoxWnd::TOOLBOX_ITEM_DATA * pTBCI_Root = pGalleryWnd->ItemGetRoot();
- ASSERT( pTBCI_Parent != NULL );
- if( pTBCI_Parent != pTBCI_Root )
- {
- bTreeBoxes = false;
- ASSERT( pTBCI_Parent->ItemGetNext( __TBCGN_PARENT ) == pTBCI_Root );
- if( pTBCI_Parent->GetItemStyle() & __TBWI_LISTBOX_VIEW )
- bListViewMode = true;
- LPCTSTR strItemState = _T("Disabled");
- if( (dwItemStyle & __TBWI_ENABLED) != 0 )
- {
- strItemState = _T("Normal");
- if( (dwItemStyle & (__TBWI_PRESSED|__TBWI_SELECTED) ) != 0 )
- {
- if( (dwItemStyle & __TBWI_HOVER) != 0 )
- strItemState = _T("Hover");
- else
- strItemState = _T("Pressed");;
- }
- else if( (dwItemStyle & __TBWI_HOVER) != 0 )
- strItemState = _T("Hover");
- } // else if( _ppbd.m_bEnabled )
- CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("RibbonGallery")][strItemState].Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, rcItem );
- } // if( pTBCI_Parent != pTBCI_Root )
- else
- {
- bListViewMode = true;
- MenuCaption_Paint(
- dc,
- rcItem,
- sText,
- ( pGalleryWnd->GetSafeHwnd() != NULL )
- ? ( DYNAMIC_DOWNCAST( CExtPopupMenuWnd, pGalleryWnd->GetParent() ) )
- : NULL
- );
- return true;
- } // else from if( pTBCI_Parent != pTBCI_Root )
- bool bMultipleExp = ( (dwToolBoxWndStyles&__TBWS_MULTIPLE_EXPANDED_GROUPS) != 0 ) ? true : false;
- bool bAllowSelectionDrawing = true;
- if( bMultipleExp
- && pTBCI->ItemGetNext( __TBCGN_PARENT ) != pGalleryWnd->ItemGetActive()
- )
- bAllowSelectionDrawing = false;
- bool bEnabled = (dwItemStyle & __TBWI_ENABLED) ? true : false;
- CSize sizeIcon( 0, 0 );
- CExtCmdIcon & _icon = pTBCI->IconGet();
- sizeIcon = _icon.GetSize();
- sizeIcon.cx = UiScalingDo( sizeIcon.cx, __EUIST_X );
- sizeIcon.cy = UiScalingDo( sizeIcon.cy, __EUIST_Y );
- if( bListViewMode )
- {
- if( (dwToolBoxWndStyles&(__TBWS_FLAT_GROUPS_2005|__TBWS_PM_BUTTONS)) != 0 )
- _rcItem.DeflateRect( __EXT_TOOLBOXWND_2005_MARGIN_DX, 0 );
- if( bTreeBoxes )
- {
- int nTreeBoxAreaDX = max( sizeItem.cy, __EXT_TOOLBOXWND_TREE_BOX_AREA_DY );
- CRect rcTreeBox = _rcItem;
- rcTreeBox.right = rcTreeBox.left + nTreeBoxAreaDX;
- bool bPlus = true;
- if( bMultipleExp )
- {
- if( (dwItemStyle&__TBWI_EXPANDED) != 0 )
- bPlus = false;
- } // if( bMultipleExp )
- else
- {
- if( (dwItemStyle&__TBWI_ACTIVE) != 0 )
- bPlus = false;
- } // else from if( bMultipleExp )
- pGalleryWnd->OnToolBoxWndDrawTreeBox(
- pTBCI,
- _rcItem,
- rcTreeBox,
- (! bPlus ),
- dc
- );
- _rcItem.left += nTreeBoxAreaDX;
- } // if( bTreeBoxes )
- CRect rcText = _rcItem;
- rcText.DeflateRect(
- __EXT_TOOLBOXWND_ITEM_MARGIN_DX,
- __EXT_TOOLBOXWND_ITEM_MARGIN_DY
- );
- if( ( ! _icon.IsEmpty() ) && sizeIcon.cx > 0 && sizeIcon.cy > 0 )
- {
- CRect rcIcon = rcText;
- rcIcon.right = rcIcon.left + sizeIcon.cx;
- rcText.left += sizeIcon.cx + __EXT_TOOLBOXWND_ICON2TEXT_DX;
- rcIcon.top += (rcIcon.Height() - sizeIcon.cy) / 2;
- _icon.Paint(
- this,
- dc.GetSafeHdc(),
- rcIcon,
- bEnabled
- ? CExtCmdIcon::__PAINT_NORMAL
- : CExtCmdIcon::__PAINT_DISABLED
- );
- }
- if( (rcText.right - rcText.left > 6)
- && (rcText.bottom - rcText.top > 6)
- )
- {
- INT nTextLen = 0;
- if( sText != NULL
- && ( nTextLen = INT(_tcslen(sText)) ) > 0
- )
- {
- CFont * pOldFont = dc.SelectObject( pTBCI->ItemGetFont() );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- CExtSkinItem & _item = m_Skin[_T("MenuItem")][_T("MenuItem")][_T("Normal")];
- COLORREF clrText = COLORREF( _item.Color( _T("TextColor") ) );
- COLORREF clrTextOld = dc.SetTextColor( clrText );
- CRect _rcText = rcText;
- _rcText.OffsetRect( 0, -1 );
- dc.DrawText(
- sText,
- nTextLen,
- _rcText,
- DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS
- );
- dc.SetTextColor( clrTextOld );
- dc.SetBkMode( nOldBkMode );
- dc.SelectObject( pOldFont );
- }
- }
- } // if( bListViewMode )
- else
- {
- if( ( ! _icon.IsEmpty() ) && sizeIcon.cx > 0 && sizeIcon.cy > 0 )
- {
- CRect rcIcon = _rcItem;
- rcIcon.DeflateRect(
- (rcIcon.Width() - sizeIcon.cx) / 2,
- (rcIcon.Height() - sizeIcon.cy) / 2
- );
- rcIcon.right = rcIcon.left + sizeIcon.cx;
- rcIcon.bottom = rcIcon.top + sizeIcon.cy;
- _icon.Paint(
- this,
- dc.GetSafeHdc(),
- rcIcon,
- bEnabled
- ? CExtCmdIcon::__PAINT_NORMAL
- : CExtCmdIcon::__PAINT_DISABLED
- );
- }
- } // else from if( bListViewMode )
- CWnd * pWnd = pGalleryWnd->GetParent();
- if( pWnd != NULL
- && pWnd->IsKindOf( RUNTIME_CLASS( CExtRibbonGalleryPopupMenuWnd ) )
- && (((CExtRibbonGalleryPopupMenuWnd*)pWnd)->TrackFlagsGet()&TPMX_RIBBON_FILE_MENU)
- )
- {
- CRect rcClient;
- pGalleryWnd->GetClientRect( &rcClient );
- dc.FillSolidRect( rcClient.left, rcClient.top, 1, rcClient.Height(), RGB(197,197,197) );
- dc.FillSolidRect( rcClient.left+1, rcClient.top, 1, rcClient.Height(), RGB(245,245,245) );
- }
- return true;
- }
- bool CExtPaintManagerSkin::RibbonGallery_EraseEntireBk(
- CDC & dc,
- const CRect & rcClient,
- const CRect & rcActiveChildArea,
- CRgn & rgnActiveChildArea,
- const CRect & rcActiveChildArea2,
- CRgn & rgnActiveChildArea2,
- CExtRibbonGalleryWnd * pGalleryWnd,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pGalleryWnd );
- return
- CExtPaintManager::RibbonGallery_EraseEntireBk(
- dc,
- rcClient,
- rcActiveChildArea,
- rgnActiveChildArea,
- rcActiveChildArea2,
- rgnActiveChildArea2,
- pGalleryWnd,
- lParam
- );
- }
- void CExtPaintManagerSkin::RibbonGallery_PaintScrollArea(
- CDC & dc,
- CExtRibbonGalleryInplaceScrollBar * pSB,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pSB );
- ASSERT( pSB->GetSafeHwnd() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManager::RibbonGallery_PaintScrollArea(
- dc,
- pSB,
- lParam
- );
- return;
- }
- PaintDockerBkgnd( true, dc, pSB, lParam );
- CRect rcClient;
- pSB->GetClientRect( &rcClient );
- bool bKeyFocusMode = false;
- CExtRibbonGalleryWnd * pRibbonGalleryWnd =
- STATIC_DOWNCAST( CExtRibbonGalleryWnd, pSB->GetParent() );
- if( pRibbonGalleryWnd->m_bInPlaceGallery
- && pRibbonGalleryWnd->_IsKeyFocusGallery()
- )
- bKeyFocusMode = true;
- INT nIndex, nCount = sizeof(pSB->m_arrButtons) / sizeof(pSB->m_arrButtons[0]);
- INT nNextTop = 0;
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- bool bForceHover = false;
- CRect rc = pSB->RgBtnGetRect( (CExtRibbonGalleryInplaceScrollBar::e_ButtonType_t)nIndex );
- INT nBtnHeightSrc = -1;
- INT nBtnHeightDst = -1; // UiScalingDo( nBtnHeightSrc, __EUIST_X );
- LPCTSTR strSubPath = NULL;
- switch( nIndex )
- {
- case INT(CExtRibbonGalleryInplaceScrollBar::__BTT_UP):
- strSubPath = _T("ButtonUp");
- if( nBtnHeightSrc < 0 )
- {
- nBtnHeightSrc = 21;
- nBtnHeightDst = UiScalingDo( nBtnHeightSrc, __EUIST_X );
- }
- break;
- case INT(CExtRibbonGalleryInplaceScrollBar::__BTT_DOWN):
- strSubPath = _T("ButtonDown");
- if( nBtnHeightSrc < 0 )
- {
- nBtnHeightSrc = 19;
- nBtnHeightDst = UiScalingDo( nBtnHeightSrc, __EUIST_X );
- }
- break;
- case INT(CExtRibbonGalleryInplaceScrollBar::__BTT_MENU):
- strSubPath = _T("ButtonMenu");
- if( nBtnHeightSrc < 0 )
- {
- nBtnHeightSrc = 20;
- nBtnHeightDst = UiScalingDo( nBtnHeightSrc, __EUIST_X );
- }
- if( bKeyFocusMode )
- bForceHover = true;
- break;
- } // switch( nIndex )
- if( strSubPath == NULL )
- continue;
- ASSERT( nBtnHeightSrc > 0 );
- ASSERT( nBtnHeightDst > 0 );
- LPCTSTR strState = _T("Normal");
- rc.top = nNextTop;
- rc.bottom = rc.top + nBtnHeightDst;
- CExtRibbonGalleryInplaceScrollBar::e_ButtonState_t eBST = pSB->m_arrButtons[ nIndex ];
- if( bForceHover )
- eBST = CExtRibbonGalleryInplaceScrollBar::__BST_HOVER;
- switch( eBST )
- {
- case CExtRibbonGalleryInplaceScrollBar::__BST_DISABLED:
- strState = _T("Disabled");
- break;
- case CExtRibbonGalleryInplaceScrollBar::__BST_NORMAL:
- break;
- case CExtRibbonGalleryInplaceScrollBar::__BST_HOVER:
- strState = _T("Hover");
- break;
- case CExtRibbonGalleryInplaceScrollBar::__BST_PRESSED:
- strState = _T("Pressed");
- break;
- } // switch( eBST )
- CExtSkinGlyph & _glyphButtonBackground = m_Skin[_T("RibbonScrollBar")][strSubPath][strState].Glyph(_T("Background"));
- CExtSkinGlyph & _glyphButtonArrow = m_Skin[_T("RibbonScrollBar")][strSubPath][strState].Glyph(_T("Arrow"));
- if( rc.bottom > rcClient.bottom )
- rc.bottom = rcClient.bottom;
- _glyphButtonBackground.Draw( dc.m_hDC, rc );
- _glyphButtonArrow.Draw( dc.m_hDC, rc );
- nNextTop = rc.bottom;
- }
- }
- bool CExtPaintManagerSkin::Ribbon_GroupCaptionIsAtTop(
- const CExtRibbonButtonGroup * pGroupTBB,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- pGroupTBB;
- lParam;
- return false;
- }
- void CExtPaintManagerSkin::Ribbon_PaintGroupBk(
- CDC & dc,
- const RECT & rcGroupBk,
- const CExtRibbonButtonGroup * pGroupTBB,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- if( IsHighContrast() )
- {
- CExtPaintManager::Ribbon_PaintGroupBk( dc, rcGroupBk, pGroupTBB, lParam );
- return;
- }
- // if( pGroupTBB->ParentButtonGet() != NULL )
- // return;
- // if( pGroupTBB->GetBar()->GetParent()->IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
- // return;
- // CExtSkinGlyph & _glyph = m_Skin[_T("Ribbon")][_T("Group")].Glyph(_T("Background"));
- // _glyph.Draw( dc.m_hDC, rcGroupBk );
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pGroupTBB );
- if( pGroupTBB->ParentButtonGet() != NULL )
- return;
- if( ::IsRectEmpty( &rcGroupBk ) )
- return;
- if( ! dc.RectVisible( &rcGroupBk ) )
- return;
- CRect _rcGroupBk = rcGroupBk;
- _rcGroupBk.InflateRect( 0, 0, 1, 1 );
- CExtSafeString strCaptionText = pGroupTBB->GetText();
- INT nCaptionTextLength = strCaptionText.GetLength();
- bool bEnabled = pGroupTBB->IsEnabled();
- bool bHover = ( bEnabled && pGroupTBB->IsHover() ) ? true : false;
- if( bHover && pGroupTBB->GetBar()->GetMenuTrackingButton() >= 0 )
- bHover = false;
- bool bCollapsed = pGroupTBB->TopCollapsedStateGet();
- if( bCollapsed )
- {
- bool bPressed = false;
- if( bEnabled )
- bPressed = pGroupTBB->IsPressed();
- PAINTPUSHBUTTONDATA _ppbd;
- _ppbd.m_rcClient = _rcGroupBk;
- _ppbd.m_bFlat = false;
- _ppbd.m_bEnabled = bEnabled;
- _ppbd.m_bHover = bHover;
- _ppbd.m_bPushed = bPressed;
- _ppbd.m_bHorz = true;
- PaintPushButton( dc, _ppbd );
- CExtCmdIcon * pCmdIcon = Ribbon_GetGroupCollapsedIcon( pGroupTBB, lParam );
- //CExtCmdIcon * pCmdIcon = ((CExtBarButton*)pGroupTBB)->GetIconPtr();
- CRect rcIconArea = _rcGroupBk, rcTextArea = _rcGroupBk;
- if( pCmdIcon != NULL && (! pCmdIcon->IsEmpty() ) )
- {
- CSize _sizeIcon = pCmdIcon->GetSize();
- rcIconArea.left += ( rcIconArea.Width() - _sizeIcon.cx ) / 2;
- rcIconArea.top += ( rcIconArea.Height() - _sizeIcon.cy ) / 2 - 6;
- rcIconArea.right = rcIconArea.left + _sizeIcon.cx;
- rcIconArea.bottom = rcIconArea.top + _sizeIcon.cy;
- rcTextArea.top = rcIconArea.bottom + 7;
- } // if( pCmdIcon != NULL && (! pCmdIcon->IsEmpty() ) )
- else
- rcTextArea.top += 16;
- rcIconArea.OffsetRect( 0, -10 );
- if( pCmdIcon != NULL && (! pCmdIcon->IsEmpty() ) )
- {
- pCmdIcon->Paint(
- this,
- dc,
- rcIconArea.left,
- rcIconArea.top,
- -1,
- -1
- );
- } // if( pCmdIcon != NULL && (! pCmdIcon->IsEmpty() ) )
- if( nCaptionTextLength > 0 )
- {
- LPCTSTR strState = _T("Normal");
- if( bPressed )
- strState = _T("Pressed");
- else if( bHover )
- strState = _T("Hover");
- const CExtSkinColor & skinTextColor = m_Skin[_T("Ribbon")][_T("Group")][_T("Collapsed")][strState].Color( _T("RibbonGroupCaptionTextColor") );
- if( ! skinTextColor.IsHollow() )
- {
- CExtRibbonPage * pRibbonPage = const_cast < CExtRibbonPage * > ( pGroupTBB->GetRibbonPage() );
- ASSERT_VALID( pRibbonPage );
- ASSERT( pRibbonPage->GetSafeHwnd() != NULL );
- CFont * pFont = pRibbonPage->OnGetToolbarFont( false, false );
- ASSERT( pFont->GetSafeHandle() != NULL );
- //CFont * pOldFont = dc.SelectObject( pFont );
- CFont * pOldFont = dc.SelectObject( &m_FontRibbonGroupCaption );
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldTextColor = dc.SetTextColor( COLORREF(skinTextColor) );
- CRect rcCaption = rcTextArea;
- rcCaption.OffsetRect( 0, -5 );
- // dc.DrawText(
- // LPCTSTR( strCaptionText ),
- // nCaptionTextLength,
- // &rcCaption,
- // DT_CENTER|DT_TOP //m_nRibbonGroupCaptionTextDF
- // );
- Ribbon_PaintText(
- dc,
- LPCTSTR( strCaptionText ),
- rcCaption,
- DT_CENTER|DT_TOP,
- true,
- NULL,
- (CObject*)pGroupTBB,
- lParam
- );
- dc.SetTextColor( clrOldTextColor );
- dc.SetBkMode( nOldBkMode );
- dc.SelectObject( pOldFont );
- } // if( ! skinTextColor.IsHollow() )
- } // if( nCaptionTextLength > 0 )
- } // if( bCollapsed )
- else
- {
- const CExtRibbonPage * pRibbonPage = pGroupTBB->GetRibbonPage();
- ASSERT_VALID( pRibbonPage );
- CWnd * pWndParent = pRibbonPage->GetParent();
- bool bDrawCaption = true, bPopupMode =
- ( pWndParent != NULL
- && pWndParent->IsKindOf( RUNTIME_CLASS( CExtRibbonPopupMenuWnd ) )
- && (! ((CExtRibbonPopupMenuWnd*)pWndParent)->m_wndRibbonPage.m_bHelperAutoHideMode )
- ) ? true : false;
- INT nCaptionHeight = 0;
- if( bPopupMode && (! Ribbon_IsPopupGroupWithCaption( (CObject*) pRibbonPage ) ) )
- {
- bDrawCaption = false;
- strCaptionText.Empty();
- nCaptionTextLength = 0;
- }
- else
- {
- strCaptionText.Replace( _T("r"), _T(" ") );
- strCaptionText.Replace( _T("n"), _T(" ") );
- strCaptionText.Replace( _T("t"), _T(" ") );
- strCaptionText.Replace( _T(" "), _T(" ") );
- strCaptionText.TrimLeft( _T(" ") );
- strCaptionText.TrimRight( _T(" ") );
- nCaptionHeight = Ribbon_GroupCaptionGetHeight( pGroupTBB, lParam );
- ASSERT( nCaptionHeight >= 0 );
- }
- // COLORREF clrBorder = RGB(0,0,0);
- // if( bEnabled )
- // {
- // if( bHover )
- // {
- // clrBorder = GetColor( COLOR_3DDKSHADOW );
- // dc.FillRect( &_rcGroupBk, &m_brushLighterDefault );
- // } // if( bHover )
- // else
- // clrBorder = GetColor( COLOR_3DSHADOW );
- // } // if( bEnabled )
- // else
- // clrBorder = GetColor( COLOR_3DSHADOW );
- if( nCaptionHeight > 0 && nCaptionTextLength > 0 )
- {
- CRect rcCaption = _rcGroupBk;
- bool bTopCaption = Ribbon_GroupCaptionIsAtTop( pGroupTBB );
- if( bTopCaption )
- rcCaption.bottom = rcCaption.top + nCaptionHeight;
- else
- rcCaption.top = rcCaption.bottom - nCaptionHeight;
- // dc.FillSolidRect( &rcCaption, GetColor( COLOR_3DSHADOW ) );
- // dc.Draw3dRect( &rcCaption, clrBorder, clrBorder );
- if( pGroupTBB->ParentButtonGet() != NULL )
- return;
- if( pGroupTBB->GetBar()->GetParent()->IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
- return;
- CExtSkinGlyph & _glyph = m_Skin[_T("Ribbon")][_T("Group")].Glyph(_T("Background"));
- _glyph.Draw( dc.m_hDC, rcGroupBk );
- CExtRibbonPage * pRibbonPage = const_cast < CExtRibbonPage * > ( pGroupTBB->GetRibbonPage() );
- ASSERT_VALID( pRibbonPage );
- ASSERT( pRibbonPage->GetSafeHwnd() != NULL );
- CFont * pFont = pRibbonPage->OnGetToolbarFont( false, false );
- ASSERT( pFont->GetSafeHandle() != NULL );
- CRect rcCaptionTextAlignmentDLB =
- pGroupTBB->GetCaptionTextAlignmentRect();
- if( ! rcCaptionTextAlignmentDLB.IsRectEmpty() )
- {
- rcCaption.left =
- max(
- rcCaption.left,
- rcCaptionTextAlignmentDLB.left
- );
- rcCaption.right =
- min(
- rcCaption.right,
- rcCaptionTextAlignmentDLB.right
- );
- } // if( ! rcCaptionTextAlignmentDLB.IsRectEmpty() )
- /// CExtSkinColor & skinTextColor = m_Skin[_T("Button")][_T("Simple")][_T("Control")].Color( _T("Normal") );
- LPCTSTR strState = _T("Normal");
- if( bHover )
- strState = _T("Hover");
- const CExtSkinColor & skinTextColor = m_Skin[_T("Ribbon")][_T("Group")][_T("Expanded")][strState].Color( _T("RibbonGroupCaptionTextColor") );
- if( ! skinTextColor.IsHollow() )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontRibbonGroupCaption );
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldTextColor = dc.SetTextColor( COLORREF(skinTextColor) );
- UINT nRibbonGroupCaptionTextShadowDF = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_END_ELLIPSIS;
- dc.DrawText(
- LPCTSTR( strCaptionText ),
- nCaptionTextLength,
- &rcCaption,
- nRibbonGroupCaptionTextShadowDF
- );
- dc.SetTextColor( clrOldTextColor );
- dc.SetBkMode( nOldBkMode );
- dc.SelectObject( pOldFont );
- }
- } // if( nCaptionHeight > 0 && nCaptionTextLength > 0 )
- } // else from if( bCollapsed )
- }
- void CExtPaintManagerSkin::Ribbon_PaintPageBk(
- CDC & dc,
- const RECT & rcPageBk,
- const CExtRibbonPage * pRibbonPage,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- if( IsHighContrast() )
- {
- CExtPaintManager::Ribbon_PaintPageBk( dc, rcPageBk, pRibbonPage, lParam );
- return;
- }
- if( pRibbonPage->GetParent()->IsKindOf( RUNTIME_CLASS(CExtPopupMenuWnd) ) )
- return;
- CExtSkinGlyph & _glyph = m_Skin[_T("Ribbon")][_T("Page")].Glyph(_T("Background"));
- _glyph.Draw( dc.m_hDC, rcPageBk );
- }
- void CExtPaintManagerSkin::Ribbon_PaintPushButton(
- CDC & dc,
- CExtPaintManager::PAINTPUSHBUTTONDATA & _ppbd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _ppbd.m_rcClient.IsRectEmpty() )
- return;
- if( ! dc.RectVisible( &_ppbd.m_rcClient ) )
- return;
- if( IsHighContrast() )
- {
- CExtPaintManager::Ribbon_PaintPushButton( dc, _ppbd );
- return;
- }
- ASSERT_VALID( _ppbd.m_pHelperSrc );
- CExtBarButton * pTBB = DYNAMIC_DOWNCAST( CExtBarButton, _ppbd.m_pHelperSrc );
- ASSERT( pTBB != NULL );
- CExtBarButton * pParentTBB = pTBB->ParentButtonGet();
- CExtRibbonButton * pRibbonTBB = DYNAMIC_DOWNCAST( CExtRibbonButton, _ppbd.m_pHelperSrc );
- CExtSafeString strText = pTBB->GetText();
- INT nTextLength = strText.GetLength();
- bool bDLB = false;
- if( nTextLength == 0
- && _ppbd.m_pHelperSrc != NULL
- && _ppbd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonDialogLauncher ) )
- )
- {
- bDLB = true;
- strText = _T("...");
- nTextLength = strText.GetLength();
- }
- enum e_layout_case_t
- {
- __ELC_TOOL,
- __ELC_SMALL,
- __ELC_LARGE,
- };
- e_layout_case_t eLC = __ELC_TOOL;
- if( bDLB )
- eLC = __ELC_SMALL;
- else if( pRibbonTBB != NULL )
- {
- if( pParentTBB == NULL
- || pParentTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonToolGroup ) )
- )
- {
- if( pParentTBB == NULL )
- {
- const CExtRibbonNode * pRibbonNode = pTBB->Ribbon_GetNode();
- if( pRibbonNode != NULL )
- {
- const CExtCustomizeCmdTreeNode * pParentNode = pRibbonNode->GetParentNode();
- if( pParentNode != NULL
- && ( pParentNode->IsKindOf( RUNTIME_CLASS( CExtRibbonNodeRightButtonsCollection ) )
- || pParentNode->IsKindOf( RUNTIME_CLASS( CExtRibbonNodeQuickAccessButtonsCollection ) )
- )
- )
- eLC = __ELC_SMALL;
- } // if( pRibbonNode != NULL )
- } // if( pParentTBB == NULL )
- }
- else
- {
- if( pRibbonTBB->RibbonILV_Get() == __EXT_RIBBON_ILV_SIMPLE_LARGE )
- eLC = __ELC_LARGE;
- else
- eLC = __ELC_SMALL;
- }
- } // else if( pRibbonTBB != NULL )
- else
- {
- if( pParentTBB == NULL
- || ( ! pParentTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonToolGroup ) ) )
- )
- eLC = __ELC_SMALL;
- } // if( pRibbonTBB != NULL )
- //_ppbd.m_bDropDown = true;
- //_ppbd.m_bSeparatedDropDown = true;
- //_ppbd.m_bPushedDropDown = true;
- INT nILV = pTBB->RibbonILV_Get();
- CRect rcCP = pTBB->OnRibbonGetContentPadding();
- CRect rcIcon = _ppbd.m_rcClient;
- rcIcon.DeflateRect(
- rcCP.left,
- rcCP.top,
- rcCP.right,
- rcCP.bottom
- );
- INT nTextToIconDistance = 0;
- CRect rcText = rcIcon;
- CSize _sizeIcon( 0, 0 );
- CExtCmdIcon * pCmdIcon = pTBB->GetIconPtr();
- if( pCmdIcon != NULL && (! pCmdIcon->IsEmpty() ) )
- {
- _sizeIcon = Ribbon_GetIconSize( pTBB, nILV, _ppbd.m_lParam );
- if( nTextLength >= 0 )
- nTextToIconDistance = Ribbon_GetTextToIconDistance( dc, nILV, pTBB, _ppbd.m_lParam );
- if( eLC == __ELC_LARGE )
- {
- rcIcon.bottom = rcIcon.top + _sizeIcon.cy;
- rcIcon.OffsetRect( ( rcIcon.Width() - _sizeIcon.cx ) / 2, 4 );
- if( nTextLength > 0 )
- {
- rcText.top = rcIcon.bottom;
- rcText.top += nTextToIconDistance;
- };
- } // if( eLC == __ELC_LARGE )
- else
- {
- if( nTextLength > 0 )
- {
- rcIcon.right = rcText.left = rcIcon.left + _sizeIcon.cx;
- rcText.left += nTextToIconDistance;
- }
- else
- {
- rcIcon = _ppbd.m_rcClient;
- if( pTBB->IsAbleToTrackMenu()
- //&& _ppbd.m_bSeparatedDropDown
- && (! pTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButtonGroup ) ) )
- )
- rcIcon.right -= GetDropDownButtonWidth( _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- rcIcon.OffsetRect( ( rcIcon.Width() - _sizeIcon.cx ) / 2 + 1, 0 );
- }
- rcIcon.OffsetRect( 0, ( rcIcon.Height() - _sizeIcon.cy ) / 2 );
- } // else from if( eLC == __ELC_LARGE )
- } // if( pCmdIcon != NULL && (! pCmdIcon->IsEmpty() ) )
- else
- pCmdIcon = NULL;
- const CExtSkinColor * pSkinTextColor = NULL;
- bool bDrawDropDownWithText = _ppbd.m_bDropDown;
- switch( eLC )
- {
- case __ELC_LARGE:
- ASSERT_VALID( pTBB );
- rcText = Ribbon_CalcLargeDropDownRect( pTBB );
- if( ! pTBB->IsKindOf( RUNTIME_CLASS( CExtRibbonButton ) ) )
- bDrawDropDownWithText = false;
- if( _ppbd.m_bSeparatedDropDown )
- {
- LPCTSTR strState1 = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState1 = _T("Disabled");
- else if( ( _ppbd.m_bPushed && (!_ppbd.m_bPushedDropDown) ) || _ppbd.m_bIndeterminate )
- strState1 = _T("Pressed");
- else if( _ppbd.m_bPushed && _ppbd.m_bPushedDropDown )
- strState1 = _T("Hover");
- else if( _ppbd.m_bHover && (!_ppbd.m_bHoverDropDown) )
- strState1 = _T("Hover");
- else if( _ppbd.m_bHover && _ppbd.m_bHoverDropDown )
- strState1 = _T("HoverNP");
- LPCTSTR strState2 = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState2 = _T("Disabled");
- else if( _ppbd.m_bPushed || _ppbd.m_bIndeterminate )
- strState2 = _T("Pressed");
- else if( _ppbd.m_bHover && _ppbd.m_bHoverDropDown )
- strState2 = _T("Hover");
- else if( _ppbd.m_bHover && (!_ppbd.m_bHoverDropDown) )
- strState2 = _T("HoverNP");
- CRect rcB = _ppbd.m_rcClient;
- CRect rcD = _ppbd.m_rcClient;
- rcB.bottom = rcD.top = rcText.top;
- const CExtSkinGlyph & _glyphB = m_Skin[_T("Button")][_T("RibbonButton")][_T("Large")][_T("SplitButton")][_T("PushButton")][strState1].Glyph( _T("Background") );
- _glyphB.Draw( dc.m_hDC, rcB );
- const CExtSkinGlyph & _glyphD = m_Skin[_T("Button")][_T("RibbonButton")][_T("Large")][_T("SplitButton")][_T("DropDownButton")][strState2].Glyph( _T("Background") );
- _glyphD.Draw( dc.m_hDC, rcD );
- const CExtSkinColor & skinTextColor = m_Skin[_T("Button")][_T("RibbonButton")][_T("Large")][_T("SplitButton")][_T("DropDownButton")][strState2].Color( _T("RibbonButtonTextColor") );
- pSkinTextColor = &skinTextColor;
- }
- else
- {
- LPCTSTR strState = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState = _T("Disabled");
- else if( _ppbd.m_bPushed || _ppbd.m_bIndeterminate )
- strState = _T("Pressed");
- else if( _ppbd.m_bHover )
- strState = _T("Hover");
- const CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("RibbonButton")][_T("Large")][ _ppbd.m_bDropDown ? _T("DropDownButton") : _T("PushButton") ][strState].Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, _ppbd.m_rcClient );
- const CExtSkinColor & skinTextColor = m_Skin[_T("Button")][_T("RibbonButton")][_T("Large")][ _ppbd.m_bDropDown ? _T("DropDownButton") : _T("PushButton") ][strState].Color( _T("RibbonButtonTextColor") );
- pSkinTextColor = &skinTextColor;
- }
- break; // case __ELC_LARGE
- case __ELC_TOOL:
- case __ELC_SMALL:
- {
- LPCTSTR strBT = ( eLC == __ELC_TOOL ) ? _T("Tool") : _T("Small");
- if( _ppbd.m_bSeparatedDropDown )
- {
- LPCTSTR strState1 = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState1 = _T("Disabled");
- else if( ( _ppbd.m_bPushed && (!_ppbd.m_bPushedDropDown) ) || _ppbd.m_bIndeterminate )
- strState1 = _T("Pressed");
- else if( _ppbd.m_bPushed && _ppbd.m_bPushedDropDown )
- strState1 = _T("Hover");
- else if( _ppbd.m_bHover && (!_ppbd.m_bHoverDropDown) )
- strState1 = _T("Hover");
- else if( _ppbd.m_bHover && _ppbd.m_bHoverDropDown )
- strState1 = _T("HoverNP");
- LPCTSTR strState2 = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState2 = _T("Disabled");
- else if( _ppbd.m_bPushed || _ppbd.m_bIndeterminate )
- strState2 = _T("Pressed");
- else if( _ppbd.m_bHover && _ppbd.m_bHoverDropDown )
- strState2 = _T("Hover");
- else if( _ppbd.m_bHover && (!_ppbd.m_bHoverDropDown) )
- strState2 = _T("HoverNP");
- INT nDropDownButtonWidth = GetDropDownButtonWidth( _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- CRect rcB = _ppbd.m_rcClient;
- CRect rcD = _ppbd.m_rcClient;
- rcB.right -= nDropDownButtonWidth;
- rcD.left = rcB.right;
- const CExtSkinGlyph & _glyphB = m_Skin[_T("Button")][_T("RibbonButton")][strBT][_T("SplitButton")][_T("PushButton")][strState1].Glyph( _T("Background") );
- _glyphB.Draw( dc.m_hDC, rcB );
- const CExtSkinGlyph & _glyphD = m_Skin[_T("Button")][_T("RibbonButton")][strBT][_T("SplitButton")][_T("DropDownButton")][strState2].Glyph( _T("Background") );
- _glyphD.Draw( dc.m_hDC, rcD );
- const CExtSkinColor & skinTextColor = m_Skin[_T("Button")][_T("RibbonButton")][strBT][_T("SplitButton")][_T("PushButton")][strState1].Color( _T("RibbonButtonTextColor") );
- pSkinTextColor = &skinTextColor;
- }
- else
- {
- LPCTSTR strState = _T("Normal");
- if( ! _ppbd.m_bEnabled )
- strState = _T("Disabled");
- else if( _ppbd.m_bPushed || _ppbd.m_bIndeterminate )
- strState = _T("Pressed");
- else if( _ppbd.m_bHover )
- strState = _T("Hover");
- const CExtSkinGlyph & _glyph = m_Skin[_T("Button")][_T("RibbonButton")][strBT][ _ppbd.m_bDropDown ? _T("DropDownButton") : _T("PushButton") ][strState].Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, _ppbd.m_rcClient );
- const CExtSkinColor & skinTextColor = m_Skin[_T("Button")][_T("RibbonButton")][strBT][ _ppbd.m_bDropDown ? _T("DropDownButton") : _T("PushButton") ][strState].Color( _T("RibbonButtonTextColor") );
- pSkinTextColor = &skinTextColor;
- }
- }
- break; // cases __ELC_TOOL and __ELC_SMALL
- } // switch( eLC )
- if( pCmdIcon != NULL )
- {
- ASSERT( ! pCmdIcon->IsEmpty() );
- CSize _sizeRealIcon = pCmdIcon->GetSize();
- if( _sizeRealIcon != _sizeIcon )
- rcIcon.OffsetRect(
- ( _sizeIcon.cx - _sizeRealIcon.cx ) / 2,
- ( _sizeIcon.cy - _sizeRealIcon.cy) / 2
- );
- rcIcon.right = rcIcon.left + _sizeRealIcon.cx;
- rcIcon.bottom = rcIcon.top + _sizeRealIcon.cy;
- bool bCenterBigIconVerticallyMode = ( eLC == __ELC_LARGE && nTextLength == 0 && ( ! _ppbd.m_bDropDown ) ) ? true : false;
- if( bCenterBigIconVerticallyMode)
- rcIcon.OffsetRect(
- 0,
- _ppbd.m_rcClient.top - rcIcon.top + ( _ppbd.m_rcClient.Height() - rcIcon.Height() ) / 2
- );
- CExtCmdIcon::e_paint_type_t ePT = CExtCmdIcon::__PAINT_DISABLED;
- if( _ppbd.m_bEnabled )
- {
- if( _ppbd.m_bPushed )
- ePT = CExtCmdIcon::__PAINT_PRESSED;
- else if( _ppbd.m_bHover )
- ePT = CExtCmdIcon::__PAINT_HOVER;
- else
- ePT = CExtCmdIcon::__PAINT_NORMAL;
- } // if( _ppbd.m_bEnabled )
- pCmdIcon->Paint(
- this,
- dc.m_hDC,
- rcIcon,
- ePT
- );
- } // if( pCmdIcon != NULL )
- if( nTextLength > 0 || _ppbd.m_bDropDown )
- {
- UINT nDT = 0;
- if( eLC != __ELC_LARGE )
- {
- strText.Replace( _T("r"), _T(" ") );
- strText.Replace( _T("n"), _T(" ") );
- strText.Replace( _T("t"), _T(" ") );
- strText.Replace( _T(" "), _T(" ") );
- strText.TrimLeft( _T(" ") );
- strText.TrimRight( _T(" ") );
- nTextLength = INT( strText.GetLength() );
- nDT = DT_CENTER|DT_VCENTER|DT_SINGLELINE;
- } // if( eLC != __ELC_LARGE )
- else
- nDT = DT_CENTER|DT_TOP;
- if( nTextLength > 0 || _ppbd.m_bDropDown )
- {
- CFont * pFont = pTBB->GetBar()->OnGetToolbarFont( false, false );
- ASSERT( pFont->GetSafeHandle() != NULL );
- CFont * pOldFont = dc.SelectObject( pFont );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrText =
- ( pSkinTextColor != NULL && (! pSkinTextColor->IsHollow() ) )
- ? COLORREF( (*pSkinTextColor) )
- : GetColor( _ppbd.m_bEnabled ? COLOR_BTNTEXT : CLR_TEXT_DISABLED )
- ;
- COLORREF clrOldText = dc.SetTextColor( clrText );
- // if( eLC == __ELC_LARGE )
- Ribbon_PaintText(
- dc,
- ( nTextLength > 0 ) ? LPCTSTR(strText) : _T(""),
- rcText,
- nDT,
- bDrawDropDownWithText,
- NULL,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- );
- // else
- // dc.DrawText(
- // LPCTSTR(strText),
- // nTextLength,
- // rcText,
- // nDT
- // );
- dc.SetTextColor( clrOldText );
- dc.SetBkMode( nOldBkMode );
- dc.SelectObject( pOldFont );
- } // if( nTextLength > 0 || _ppbd.m_bDropDown )
- } // if( nTextLength > 0 || _ppbd.m_bDropDown )
- }
- INT CExtPaintManagerSkin::Ribbon_GetTabIntersectionHeight(
- const CExtRibbonPage * pRibbonPage,
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- if( IsHighContrast() )
- return CExtPaintManager::Ribbon_GetTabIntersectionHeight( pRibbonPage, lParam );
- return 0;
- }
- void CExtPaintManagerSkin::Ribbon_PaintTabItem(
- CDC & dc,
- CRect & rcTabItemsArea,
- bool bSelected,
- const CRect & rcEntireItem,
- CFont * pFont,
- __EXT_MFC_SAFE_LPCTSTR sText,
- CExtCmdIcon * pIcon,
- CObject * pHelperSrc,
- LPARAM lParam, // = 0L
- COLORREF clrForceText, // = COLORREF(-1L)
- COLORREF clrForceTabBk, // = COLORREF(-1L)
- COLORREF clrForceTabBorderLT, // = COLORREF(-1L)
- COLORREF clrForceTabBorderRB, // = COLORREF(-1L)
- COLORREF clrForceTabSeparator // = COLORREF(-1L)
- )
- {
- ASSERT_VALID( this );
- CRect _rcEntireItem = rcEntireItem;
- if( ! IsHighContrast() )
- {
- if( bSelected )
- _rcEntireItem.bottom += 1;
- else
- _rcEntireItem.bottom += 3;
- }
- CExtPaintManager::Ribbon_PaintTabItem(
- dc,
- rcTabItemsArea,
- bSelected,
- _rcEntireItem,
- pFont,
- sText,
- pIcon,
- pHelperSrc,
- lParam,
- clrForceText,
- clrForceTabBk,
- clrForceTabBorderLT,
- clrForceTabBorderRB,
- clrForceTabSeparator
- );
- }
- void CExtPaintManagerSkin::Ribbon_PaintText(
- CDC & dc,
- __EXT_MFC_SAFE_LPCTSTR strText,
- const RECT & rcText,
- UINT nDrawTextFlags,
- bool bDrawDropDownArrow,
- CExtBitmap * pBmpAlternativeDropDownArrow,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- CExtPaintManager::Ribbon_PaintText(
- dc,
- strText,
- rcText,
- nDrawTextFlags,
- bDrawDropDownArrow,
- pBmpAlternativeDropDownArrow,
- pHelperSrc,
- lParam
- );
- }
- bool CExtPaintManagerSkin::Ribbon_FileButtonIsItegrationSupported() const
- {
- ASSERT_VALID( this );
- if( IsHighContrast() )
- return CExtPaintManager::Ribbon_FileButtonIsItegrationSupported();
- return false;
- }
- void CExtPaintManagerSkin::Ribbon_NcOverPaint(
- CDC & dc,
- bool bFrameActive,
- INT nWidthFromLeft,
- bool bDwmMode,
- LPCRECT pRectDwmText,
- __EXT_MFC_SAFE_LPCTSTR strDwmCaptionTitle,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManager::Ribbon_NcOverPaint(
- dc,
- bFrameActive,
- nWidthFromLeft,
- bDwmMode,
- pRectDwmText,
- strDwmCaptionTitle,
- pHelperSrc,
- lParam
- );
- return;
- }
- bool bZoomedMode = false;
- if( pHelperSrc != NULL )
- {
- CExtRibbonBar * pRibbonBar = DYNAMIC_DOWNCAST( CExtRibbonBar, pHelperSrc );
- if( pRibbonBar != NULL )
- {
- if( pRibbonBar->GetParent()->IsZoomed() )
- bZoomedMode = true;
- } // if( pRibbonBar != NULL )
- } // if( pHelperSrc != NULL )
- nWidthFromLeft += 15;
- INT nTextLen = 0;
- if( pHelperSrc != NULL
- && pHelperSrc->IsKindOf( RUNTIME_CLASS(CExtRibbonBar) )
- )
- {
- CExtRibbonBar * pRibbonBar = STATIC_DOWNCAST( CExtRibbonBar, pHelperSrc );
- CRect rcIcon( 0, 0, 0, 0 );
- if( bDwmMode
- && pRectDwmText != NULL
- && LPCTSTR(strDwmCaptionTitle) != NULL
- && ( nTextLen = INT(_tcslen(LPCTSTR(strDwmCaptionTitle))) ) > 0
- // && pRectDwmText->left < pRectDwmText->right
- // && pRectDwmText->top < pRectDwmText->bottom
- // && dc.RectVisible( pRectDwmText )
- )
- {
- CWnd * pWnd = (CWnd*)pHelperSrc;
- bool bRTL = ( (pWnd->GetExStyle()&WS_EX_LAYOUTRTL) != 0 ) ? true : false;
- for( ; (pWnd->GetStyle()&WS_CHILD) != 0; pWnd = pWnd->GetParent() );
- if( pWnd != NULL )
- {
- CRect rcText = *pRectDwmText;
- if( pRibbonBar->m_pExtNcFrameImpl != NULL )
- {
- CRect rcIcon( 0, 0, 0, 0 );
- CExtCmdIcon _icon;
- pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_GetIcon( _icon );
- if( ! _icon.IsEmpty() )
- {
- CSize _sizeIcon = _icon.GetSize();
- ASSERT( _sizeIcon.cx > 0 && _sizeIcon.cy > 0 );
- INT nIconTop = rcText.top + ( rcText.Height() - _sizeIcon.cy ) / 2;
- rcIcon.SetRect(
- rcText.left,
- nIconTop,
- rcText.left + _sizeIcon.cx,
- nIconTop + _sizeIcon.cy
- );
- INT nV = ::GetSystemMetrics( SM_CXFRAME );
- rcIcon.OffsetRect( nV, 0 );
- rcText.left = rcIcon.right + nV;
- if( dc.RectVisible( &rcIcon ) )
- {
- DWORD dwOldRTF = 0;
- CExtCmdIcon::e_paint_type_t ePT = CExtCmdIcon::__PAINT_NORMAL;
- CWnd * pFrameWnd = pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_GetFrameWindow();
- if( pFrameWnd != NULL
- && (! pFrameWnd->IsWindowEnabled() )
- )
- ePT = CExtCmdIcon::__PAINT_DISABLED;
- CExtBitmap & _bmp = _icon.GetBitmap( ePT, this );
- if( bDwmMode && bRTL )
- {
- dwOldRTF = _bmp.RunTimeFlagsGet();
- _bmp.RunTimeFlagsSet( dwOldRTF | __EXT_BMP_FLAG_NO_RTL_DETECTION );
- }
- if( bRTL )
- {
- CExtBitmap _bmp2 = _bmp;
- _bmp2.FlipHorizontal();
- if( ! _bmp2.IsEmpty() )
- {
- CSize _size = _bmp2.GetSize();
- _bmp2.AlphaBlend(
- dc.m_hDC,
- rcIcon.left,
- rcIcon.top,
- rcIcon.Width(),
- rcIcon.Height(),
- 0,
- 0,
- rcIcon.Width(),
- rcIcon.Height()
- );
- }
- }
- else
- {
- _icon.Paint(
- this,
- dc,
- rcIcon,
- pWnd->IsWindowEnabled()
- ? CExtCmdIcon::__PAINT_NORMAL
- : CExtCmdIcon::__PAINT_DISABLED
- );
- }
- if( bDwmMode && bRTL )
- {
- _bmp.RunTimeFlagsSet( dwOldRTF );
- }
- }
- } // if( ! _icon.IsEmpty() )
- }
- if( pRectDwmText->left < pRectDwmText->right
- && pRectDwmText->top < pRectDwmText->bottom
- && dc.RectVisible( pRectDwmText )
- )
- {
- HWND hWndOpenThemeData = pWnd->m_hWnd;
- if( g_PaintManager.m_UxTheme.OpenThemeDataEx(
- hWndOpenThemeData,
- VSCLASS_WINDOW,
- __EXT_UX_OTD_NONCLIENT
- ) != NULL
- )
- { // if extended theme data was open successfully
- static const int g_nDwmGlowSize2007 = 10;
- CExtSafeString strWindowText = LPCTSTR(strDwmCaptionTitle);
- CFont * pOldFont = dc.SelectObject( &m_FontCaption );
- INT nTextWidthRequredPX = rcText.Width() - g_nDwmGlowSize2007 * 2;
- CExtUxTheme::__EXT_UX_DTTOPTS dtoMeasure = { sizeof(CExtUxTheme::__EXT_UX_DTTOPTS) };
- dtoMeasure.dwFlags = __EXT_UX_DTT_COMPOSITED | __EXT_UX_DTT_GLOWSIZE;
- dtoMeasure.iGlowSize = g_nDwmGlowSize2007;
- CRect rcTextMeasure;
- rcTextMeasure.SetRect( 0, 0, 0, 0 );
- g_PaintManager.m_UxTheme.GetThemeTextExtent(
- dc.m_hDC,
- 0,
- 0,
- strWindowText,
- -1,
- DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_CALCRECT,
- NULL,
- &rcTextMeasure
- );
- INT nTextWidthCurrentPX = rcTextMeasure.Width();
- bool bDrawText = true;
- if( nTextWidthCurrentPX > nTextWidthRequredPX )
- {
- bDrawText = false;
- INT nLenCalc = strWindowText.GetLength() - 1;
- for( ; nLenCalc > 0; nLenCalc -- )
- {
- CExtSafeString strCalc = strWindowText.Left( nLenCalc );
- // if( bRTL )
- // {
- // CString strTmp = strCalc;
- // strCalc = _T("...");
- // strCalc += strTmp;
- // } // if( bRTL )
- // else
- strCalc += _T("...");
- rcTextMeasure.SetRect( 0, 0, 0, 0 );
- g_PaintManager.m_UxTheme.GetThemeTextExtent(
- dc.m_hDC,
- 0,
- 0,
- strCalc,
- -1,
- DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_CALCRECT,
- NULL,
- &rcTextMeasure
- );
- INT nTextWidthCurrentPX = rcTextMeasure.Width();
- if( nTextWidthCurrentPX <= nTextWidthRequredPX )
- {
- strWindowText = strCalc;
- bDrawText = true;
- break;
- } // if( nTextWidthCurrentPX <= nTextWidthRequredPX )
- } // for( ; nLenCalc > 0; nLenCalc -- )
- } // if( nTextWidthCurrentPX > nTextWidthRequredPX )
- dc.SelectObject( &pOldFont );
- if( bDrawText )
- {
- DWORD dwOldLayout1 = LAYOUT_LTR, dwOldLayout2 = LAYOUT_LTR;
- if( bRTL )
- dwOldLayout1 = dc.SetLayout( LAYOUT_RTL );
- CExtMemoryDC dc32(
- &dc,
- &rcText,
- CExtMemoryDC::MDCOPT_TO_MEMORY
- | CExtMemoryDC::MDCOPT_FORCE_DIB
- | CExtMemoryDC::MDCOPT_FILL_BITS
- | CExtMemoryDC::MDCOPT_DIB_NEGATIVE_HEIGHT
- );
- ASSERT( dc32.GetSafeHdc() != NULL );
- dc.FillSolidRect( &rcText, RGB(0,0,0) );
- if( bRTL )
- dwOldLayout2 = dc32.SetLayout( LAYOUT_RTL );
- pOldFont = dc32.SelectObject( &m_FontCaption );
- CExtUxTheme::__EXT_UX_DTTOPTS dto = { sizeof(CExtUxTheme::__EXT_UX_DTTOPTS) };
- dto.dwFlags = __EXT_UX_DTT_TEXTCOLOR;
- dto.iGlowSize = g_nDwmGlowSize2007;
- if( ( ! g_PaintManager.m_bIsWin7OrLater ) && pWnd->IsZoomed() )
- dto.crText = RGB(0x0FF,0x0FF,0x0FF);
- else
- {
- dto.dwFlags |= __EXT_UX_DTT_COMPOSITED | __EXT_UX_DTT_GLOWSIZE;
- dto.crText = bFrameActive ? RGB(0,0,0) : RGB(0x060,0x060,0x060);
- }
- g_PaintManager.m_UxTheme.DrawThemeTextEx(
- dc32.m_hDC,
- 0,
- 0,
- strWindowText,
- -1,
- DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX,
- rcText,
- &dto
- );
- dc32.SelectObject( pOldFont );
- if( bRTL )
- {
- dc.SetLayout( dwOldLayout1 );
- dc32.SetLayout( dwOldLayout2 );
- } // if( bRTL )
- } // if( bDrawText )
- g_PaintManager.m_UxTheme.CloseThemeData();
- } // if extended theme data was open successfully
- }
- } // if( pWnd != NULL )
- } // if( bDwmMode ...
- // if( pRibbonBar->m_pExtNcFrameImpl != NULL
- // && pRibbonBar->RibbonLayout_IsFrameIntegrationEnabled()
- // && pRibbonBar->RibbonQuickAccessBar_AboveTheRibbonGet()
- // && Ribbon_IsSystemMenuIconPresent()
- // )
- // {
- // CWnd * pWndFrameImpl = pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_GetFrameWindow();
- // if( pWndFrameImpl->GetSafeHwnd() != NULL )
- // {
- // CRect rcSeparator( 0, 0, 0, 0 );
- // if( bDwmMode )
- // rcSeparator.SetRect( rcIcon.right, rcIcon.top, rcIcon.right + 2, rcIcon.bottom );
- // else
- // {
- // CRect rcWnd;
- // pWndFrameImpl->GetWindowRect( &rcWnd );
- // rcIcon = pRibbonBar->m_pExtNcFrameImpl->NcFrameImpl_GetNcHtRect(HTSYSMENU,false,false,false,NULL,&rcWnd);
- // rcSeparator.SetRect( rcIcon.right + 0, rcIcon.top, rcIcon.right + 2, rcIcon.bottom - 3 );
- // if( pWndFrameImpl->IsZoomed() )
- // rcSeparator.OffsetRect( m_rcNcFrameBordersActive.left, m_rcNcFrameBordersActive.top );
- // }
- // Ribbon_PaintSeparator( dc, rcSeparator, NULL );
- // //rcSeparator.InflateRect( 2, 2 ); dc.FillSolidRect( rcSeparator, 255 );
- // }
- //
- // }
- }
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- bool CExtPaintManagerSkin::_PaintHeaderPartImpl(
- CDC & dc,
- CRect rc,
- CObject * pHelperSrc,
- LPARAM lParam,
- bool bDrawItemLikeBackground, // = false
- bool bHover, // = false
- bool bPressed // = false
- )
- {
- ASSERT( dc.GetSafeHdc() != NULL );
- pHelperSrc;
- lParam;
- LPCTSTR strOuterAreaLocation = bDrawItemLikeBackground ? _T("Top") : _T("GeneralOuterBackground");
- if( bDrawItemLikeBackground )
- {
- LPCTSTR strHeaderCellState = _T("Normal");
- if( bPressed )
- strHeaderCellState = _T("Pressed");
- else if( bHover )
- strHeaderCellState = _T("Hover");
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("HeaderCell")][strOuterAreaLocation]
- .Glyph( strHeaderCellState );
- _glyph.Draw( dc.m_hDC, rc );
- } // if( bDrawItemLikeBackground )
- else
- {
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("OuterBackground")][strOuterAreaLocation]
- .Glyph( _T("Background") );
- _glyph.Draw( dc.m_hDC, rc );
- } // else from if( bDrawItemLikeBackground )
- return true;
- }
- INT CExtPaintManagerSkin::GetDropDownButtonWidth(
- CObject * pHelperSrc, // = NULL
- LPARAM lParam // = 0L
- ) const
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pHelperSrc != NULL )
- {
- ASSERT_VALID( pHelperSrc );
- }
- #endif // _DEBUG
- if( IsHighContrast() )
- return CExtPaintManager::GetDropDownButtonWidth( pHelperSrc, lParam );
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- bool bRibbonMode = false;
- if( pHelperSrc != NULL )
- {
- if( pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtRibbonButton ) ) )
- bRibbonMode = true;
- else if( pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtBarButton ) ) )
- {
- CExtToolControlBar * pToolBar = ((CExtBarButton*)pHelperSrc)->GetSafeBar();
- if( pToolBar != NULL
- && pToolBar->IsKindOf( RUNTIME_CLASS( CExtRibbonPage ) )
- )
- bRibbonMode = true;
- }
- }
- if( bRibbonMode )
- {
- INT nDD = 9;
- nDD = UiScalingDo( nDD, __EUIST_X );
- return nDD;
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- return CExtPaintManager::GetDropDownButtonWidth( pHelperSrc, lParam );
- }
- void CExtPaintManagerSkin::Header_PaintBackground(
- CDC & dc,
- CRect rc,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManager::Header_PaintBackground( dc, rc, pHelperSrc, lParam );
- return;
- }
- if( ! _PaintHeaderPartImpl( dc, rc, pHelperSrc, lParam ) )
- CExtPaintManager::Header_PaintBackground( dc, rc, pHelperSrc, lParam );
- }
- void CExtPaintManagerSkin::Header_PaintItem(
- CDC & dc,
- CRect rcItemEntire,
- CRect rcItemData,
- CRect rcIcon,
- CRect rcText,
- CRect rcSortArrow,
- CRect rcButton,
- CRect rcButtonIcon,
- bool bSorted,
- bool bSortedAscending,
- INT nColNo,
- INT nColCount,
- const CExtCmdIcon & iconItem,
- const CExtCmdIcon & iconButton,
- bool bHover,
- bool bPressed,
- bool bButtonEvent,
- __EXT_MFC_SAFE_LPCTSTR strItemText,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManager::Header_PaintItem(
- dc, rcItemEntire, rcItemData, rcIcon, rcText, rcSortArrow, rcButton, rcButtonIcon,
- bSorted, bSortedAscending, nColNo, nColCount, iconItem, iconButton, bHover, bPressed, bButtonEvent,
- strItemText, pHelperSrc, lParam
- );
- return;
- }
- COLORREF clrLT1 = GetColor( COLOR_3DHIGHLIGHT, pHelperSrc, lParam );
- COLORREF clrRB1 = GetColor( COLOR_3DSHADOW, pHelperSrc, lParam );
- CRect rcDraw = rcItemEntire;
- if( ! rcButton.IsRectEmpty() )
- rcDraw.right = rcButton.left;
- if( ! _PaintHeaderPartImpl(
- dc, rcDraw, pHelperSrc, lParam, true,
- bHover && (!bButtonEvent),
- bPressed && (!bButtonEvent) )
- )
- {
- bool bDrawBorder = true;
- if( (!bButtonEvent) && ( bHover || bPressed ) )
- {
- bDrawBorder = !bPressed;
- if( bPressed && bHover )
- dc.FillRect( &rcDraw, &m_brushDarkerDefault );
- else if( bPressed )
- dc.FillRect( &rcDraw, &m_brushDarkDefault );
- else if( bHover )
- dc.FillRect( &rcDraw, &m_brushLighterDefault );
- }
- if( bDrawBorder )
- dc.Draw3dRect( &rcDraw, clrLT1, clrRB1 );
- }
- if( (! rcButton.IsRectEmpty() )
- && dc.RectVisible( &rcButton )
- )
- {
- rcDraw = rcButton;
- if( ! _PaintHeaderPartImpl(
- dc, rcDraw, pHelperSrc, lParam, true,
- bHover && bButtonEvent,
- bPressed && bButtonEvent
- )
- )
- {
- bool bDrawBorder = true;
- if( bButtonEvent && ( bHover || bPressed ) )
- {
- bDrawBorder = !bPressed;
- if( bPressed && bHover )
- dc.FillRect( &rcDraw, &m_brushDarkerDefault );
- else if( bPressed )
- dc.FillRect( &rcDraw, &m_brushDarkDefault );
- else if( bHover )
- dc.FillRect( &rcDraw, &m_brushLighterDefault );
- }
- if( bDrawBorder )
- dc.Draw3dRect( &rcDraw, clrLT1, clrRB1 );
- }
- if( (! iconButton.IsEmpty() )
- && (! rcButtonIcon.IsRectEmpty() )
- && dc.RectVisible( &rcButtonIcon )
- )
- iconButton.Paint( this, dc, rcButtonIcon );
- }
- if( (! iconItem.IsEmpty() )
- && (! rcIcon.IsRectEmpty() )
- && dc.RectVisible( &rcIcon )
- )
- iconItem.Paint( this, dc, rcIcon );
- if( bSorted
- && (! rcSortArrow.IsRectEmpty() )
- && dc.RectVisible( &rcSortArrow )
- )
- {
- const CExtSkinGlyph & _glyph =
- m_Skin[_T("Grid")][_T("SortArrow")]
- .Glyph( bSortedAscending ? _T("AscendingTopBottom") : _T("DescendingTopBottom") );
- _glyph.Draw( dc.m_hDC, rcSortArrow );
- }
- INT nTextLen = ( LPCTSTR(strItemText) != NULL ) ? INT( _tcslen(LPCTSTR(strItemText)) ) : 0;
- if( nTextLen > 0
- && (! rcText.IsRectEmpty() )
- && dc.RectVisible( &rcText )
- )
- {
- LPCTSTR strOuterAreaLocation = _T("Top");
- LPCTSTR strHeaderCellState = _T("Normal");
- if( ! bButtonEvent )
- {
- if( bPressed )
- strHeaderCellState = _T("Pressed");
- else if( bHover )
- strHeaderCellState = _T("Hover");
- }
- const CExtSkinColor & colorText =
- m_Skin[_T("Grid")][_T("HeaderCell")][strOuterAreaLocation]
- .Color( strHeaderCellState );
- if( ! colorText.IsHollow() )
- {
- COLORREF clrTextColor = COLORREF( colorText );
- CFont * pItemFont = & m_FontNormal;
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- COLORREF clrOldText = dc.SetTextColor( clrTextColor );
- CFont * pOldFont = dc.SelectObject( pItemFont );
- dc.DrawText( LPCTSTR(strItemText), nTextLen, (LPRECT)&rcText, DT_LEFT|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS );
- dc.SelectObject( pOldFont );
- dc.SetTextColor( clrOldText );
- dc.SetBkMode( nOldBkMode );
- }
- }
- }