ExtPaintManager.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:1653k
- dc.SetTextColor(clrOldText);
- }
- }
- }
- CSize CExtPaintManager::GetPushedOffset()
- {
- ASSERT_VALID( this );
- return CSize( 1, 1 );
- }
- CSize CExtPaintManagerXP::GetPushedOffset()
- {
- ASSERT_VALID( this );
- return CSize( 0, 0 );
- }
- CSize CExtPaintManagerNativeXP::GetPushedOffset()
- {
- ASSERT_VALID( this );
- if( g_PaintManager.m_UxTheme.IsControlsThemed() )
- return CSize( 0, 0 );
- return CExtPaintManager::GetPushedOffset();
- }
- #define __XP_DSS_MONO DSS_MONO
- void CExtPaintManagerXP::InitTranslatedColors()
- {
- ASSERT_VALID( this );
- m_DSS_DISABLED_style = __XP_DSS_MONO;
- CExtPaintManager::InitTranslatedColors();
- if( ! IsHighContrast() )
- {
- int nBitsPerPixel = stat_GetBPP();
-
- COLORREF clrSysWindow = ::GetSysColor(COLOR_WINDOW);
- COLORREF clrSys3dFace = ::GetSysColor(COLOR_3DFACE);
- COLORREF clrSys3dHilight = ::GetSysColor(COLOR_3DHILIGHT);
- COLORREF clrSys3dShadow = ::GetSysColor(COLOR_3DSHADOW);
- COLORREF clrSys3dDkShadow = ::GetSysColor(COLOR_3DDKSHADOW);
- COLORREF clrSysBtnText = ::GetSysColor(COLOR_BTNTEXT);
-
- COLORREF xpclr_MenuLight = clrSysWindow;
- COLORREF xpclr_ControlBarBk = clrSys3dFace;
- COLORREF xpclr_Highlight = clrSys3dFace;
- COLORREF xpclr_Separator = clrSys3dShadow;
- COLORREF xpclr_Gripper = clrSys3dShadow;
- COLORREF xpclr_PanelBorder = clrSys3dShadow;
- COLORREF xpclr_RarelyUsedMenuLeft = clrSys3dShadow;
- COLORREF xpclr_HighlightDarked = clrSys3dShadow;
- COLORREF xpclr_HighlightBorder = clrSysBtnText;
-
- if( nBitsPerPixel > 8 )
- {
- // xp - menu face
- xpclr_MenuLight =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_3DFACE ),
- ::GetSysColor( COLOR_WINDOW ),
- 143
- );
-
- // xp - rarely used item left side
- xpclr_RarelyUsedMenuLeft =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_3DFACE ),
- ::GetSysColor( COLOR_3DSHADOW ),
- 90
- );
-
- // xp - control bar background
- xpclr_ControlBarBk =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_WINDOW ),
- ::GetSysColor( COLOR_3DFACE ),
- 165
- );
-
- // xp - blue like light ver
- xpclr_Highlight =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_HIGHLIGHT ),
- ::GetSysColor( COLOR_WINDOW ),
- 30
- );
-
- // xp - blue like dark ver
- xpclr_HighlightDarked =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_HIGHLIGHT ),
- ::GetSysColor( COLOR_WINDOW ),
- 50
- );
-
- // xp - blue dark selected border
- xpclr_HighlightBorder =
- ::GetSysColor( COLOR_HIGHLIGHT );
-
- // xp - dark gray separator
- xpclr_Separator =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_3DSHADOW ),
- ::GetSysColor( COLOR_WINDOW ),
- 70
- );
- // xp - dark gray gripper
- xpclr_Gripper =
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_3DSHADOW ),
- ::GetSysColor( COLOR_WINDOW ),
- 50
- );
-
- // xp - dark panel border (for floating control bars)
- xpclr_PanelBorder =
- RGB(
- ( 750L*long(GetRValue(clrSys3dShadow)) + 250L*long(GetRValue(clrSys3dDkShadow)) ) / 1000L,
- ( 750L*long(GetGValue(clrSys3dShadow)) + 250L*long(GetGValue(clrSys3dDkShadow)) ) / 1000L,
- ( 750L*long(GetBValue(clrSys3dShadow)) + 250L*long(GetBValue(clrSys3dDkShadow)) ) / 1000L
- );
- } // if( nBitsPerPixel > 8 )
-
- m_mapColorTranslate[CLR_3DFACE_OUT] = InstallColor( xpclr_ControlBarBk );
- m_mapColorTranslate[CLR_3DFACE_IN] = InstallColor( xpclr_Highlight );
- m_mapColorTranslate[CLR_3DFACE_DISABLED] = COLOR_3DFACE;
-
- int idxClrDark = InstallColor( xpclr_PanelBorder );
-
- m_mapColorTranslate[CLR_3DLIGHT_OUT] = idxClrDark;
- m_mapColorTranslate[CLR_3DLIGHT_IN] = idxClrDark;
- m_mapColorTranslate[CLR_3DLIGHT_DISABLED] = idxClrDark;
-
- m_mapColorTranslate[CLR_3DHILIGHT_OUT] = idxClrDark;
- m_mapColorTranslate[CLR_3DHILIGHT_IN] = idxClrDark;
- m_mapColorTranslate[CLR_3DHILIGHT_DISABLED] = idxClrDark;
-
- m_mapColorTranslate[CLR_3DSHADOW_OUT] = idxClrDark;
- m_mapColorTranslate[CLR_3DSHADOW_IN] = idxClrDark;
- m_mapColorTranslate[CLR_3DSHADOW_DISABLED] = idxClrDark;
-
- m_mapColorTranslate[CLR_3DDKSHADOW_OUT] = idxClrDark;
- m_mapColorTranslate[CLR_3DDKSHADOW_IN] = idxClrDark;
- m_mapColorTranslate[CLR_3DDKSHADOW_DISABLED] = idxClrDark;
-
- m_mapColorTranslate[CLR_TEXT_OUT] = COLOR_WINDOWTEXT;
- m_mapColorTranslate[CLR_TEXT_IN] =
- InstallColor(
- (nBitsPerPixel > 8)
- ? RGB(0,0,0)
- : clrSys3dHilight
- );
-
- m_mapColorTranslate[XPCLR_TEXT_FIELD_BORDER_NORMAL] = COLOR_3DFACE;
- m_mapColorTranslate[XPCLR_TEXT_FIELD_BORDER_DISABLED] = InstallColor( xpclr_Separator );
-
- m_mapColorTranslate[XPCLR_PUSHEDHOVERTEXT] = COLOR_HIGHLIGHTTEXT;
-
- m_mapColorTranslate[XPCLR_3DFACE_DARK] = InstallColor( xpclr_ControlBarBk );
- m_mapColorTranslate[XPCLR_3DFACE_NORMAL] = InstallColor( xpclr_MenuLight );
- m_mapColorTranslate[XPCLR_SEPARATOR] = InstallColor( xpclr_Separator );
-
- m_mapColorTranslate[XPCLR_RARELY_BORDER] = InstallColor( xpclr_RarelyUsedMenuLeft );
-
- m_mapColorTranslate[CLR_TEXT_DISABLED] = COLOR_GRAYTEXT;
- // Menu text colors
- m_mapColorTranslate[CLR_MENUTEXT_OUT] = COLOR_WINDOWTEXT;
- m_mapColorTranslate[CLR_MENUTEXT_IN] = m_mapColorTranslate[CLR_TEXT_IN];
- m_mapColorTranslate[CLR_MENUTEXT_DISABLED] = COLOR_GRAYTEXT;
- m_mapColorTranslate[XPCLR_HILIGHT] = InstallColor( xpclr_HighlightDarked );
- m_mapColorTranslate[XPCLR_HILIGHT_BORDER] = InstallColor( xpclr_HighlightBorder );
- m_mapColorTranslate[XPCLR_HILIGHT_BORDER_SELECTED] = InstallColor( xpclr_HighlightBorder );
-
- m_mapColorTranslate[XPCLR_MENU_BORDER] =
- InstallColor(
- CExtBitmap::stat_RGB_Enlight(
- ::GetSysColor( COLOR_BTNTEXT ),
- ::GetSysColor( COLOR_BTNSHADOW ),
- 20
- )
- );
-
- m_mapColorTranslate[XPCLR_3DFACE_FLOAT_R] = InstallColor( xpclr_MenuLight );
- m_mapColorTranslate[XPCLR_3DFACE_FLOAT_F] = InstallColor( GetColor( CLR_3DFACE_OUT, this ) );
- m_mapColorTranslate[XPCLR_GRIPPER] = InstallColor( xpclr_Gripper );
-
- // Task Pane Colors
- m_mapColorTranslate[CLR_TASK_PANE_BK_TOP] = InstallColor( xpclr_MenuLight );
- m_mapColorTranslate[CLR_TASK_PANE_BK_BOTTOM] = InstallColor( xpclr_MenuLight );
-
- m_mapColorTranslate[CLR_TASK_PANE_GROUP_CAPTION_TEXT_NORMAL] =
- COLOR_WINDOWTEXT;
- m_mapColorTranslate[CLR_TASK_PANE_GROUP_CAPTION_TEXT_NORMAL_HOVERED] =
- COLOR_WINDOWTEXT;
- m_mapColorTranslate[CLR_TASK_PANE_GROUP_CAPTION_TEXT_HIGHLIGHTED] =
- COLOR_WINDOWTEXT;
- m_mapColorTranslate[CLR_TASK_PANE_GROUP_CAPTION_TEXT_HIGHLIGHTED_HOVERED] =
- COLOR_WINDOWTEXT;
- }
- else
- {
- m_mapColorTranslate[CLR_3DFACE_IN] = COLOR_HIGHLIGHT;
- m_mapColorTranslate[XPCLR_TEXT_FIELD_BORDER_NORMAL] = COLOR_3DFACE;
- m_mapColorTranslate[XPCLR_TEXT_FIELD_BORDER_DISABLED] = COLOR_3DSHADOW;
-
- m_mapColorTranslate[XPCLR_PUSHEDHOVERTEXT] = COLOR_HIGHLIGHTTEXT;
-
- m_mapColorTranslate[XPCLR_3DFACE_DARK] = COLOR_3DFACE;
- m_mapColorTranslate[XPCLR_3DFACE_NORMAL] = COLOR_3DFACE;
- m_mapColorTranslate[XPCLR_SEPARATOR] = COLOR_3DSHADOW;
-
- m_mapColorTranslate[XPCLR_RARELY_BORDER] = COLOR_3DFACE;
- m_mapColorTranslate[XPCLR_HILIGHT] = COLOR_HIGHLIGHT;
- m_mapColorTranslate[XPCLR_HILIGHT_BORDER] = InstallColor( RGB(255,255,255) );
- m_mapColorTranslate[XPCLR_HILIGHT_BORDER_SELECTED] = InstallColor( RGB(0,0,0) );
-
- m_mapColorTranslate[XPCLR_MENU_BORDER] = InstallColor( RGB(255,255,255) );
- m_mapColorTranslate[XPCLR_3DFACE_FLOAT_R] = COLOR_3DFACE;
- m_mapColorTranslate[XPCLR_3DFACE_FLOAT_F] = COLOR_3DFACE;
-
- m_mapColorTranslate[XPCLR_GRIPPER] = COLOR_3DSHADOW;
- }
- }
- void CExtPaintManagerXP::PaintPushButton(
- CDC & dc,
- CExtPaintManager::PAINTPUSHBUTTONDATA & _ppbd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _ppbd.m_rcClient.IsRectEmpty() )
- return;
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( _ppbd.m_pHelperSrc != NULL )
- {
- CExtBarButton * pTBB = DYNAMIC_DOWNCAST( CExtBarButton, _ppbd.m_pHelperSrc );
- if( pTBB != NULL )
- {
- if( pTBB->IsRibbonPaintingMode() )
- {
- Ribbon_PaintPushButton( dc, _ppbd );
- return;
- }
- CExtToolControlBar * pBar = pTBB->GetBar();
- if( pBar != NULL
- && pBar->IsKindOf( RUNTIME_CLASS( CExtRibbonPage ) )
- && (! pTBB->IsNoRibbonLayout() )
- && (! pTBB->IsKindOf( RUNTIME_CLASS( CExtBarMdiRightButton ) ) )
- )
- {
- Ribbon_PaintPushButton( dc, _ppbd );
- return;
- }
- } // if( pTBB != NULL )
- } // if( _ppbd.m_pHelperSrc != NULL )
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- bool bRTL = _ppbd.IsRTL();
- if( !_ppbd.m_bEnabled )
- {
- _ppbd.m_bHover = false;
- _ppbd.m_bDrawFocusRect = false;
- _ppbd.m_bIndeterminate = false;
- } // if( ! _ppbd.m_bEnabled )
- COLORREF clrOldText = dc.GetTextColor();
- COLORREF clrOldBk = dc.GetBkColor();
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- int nIdxMainGradientLeft = -1;
- int nIdxMainGradientRight = -1;
- COLORREF bgColor, bgColorDD;
- if( _ppbd.m_clrForceBk != ((COLORREF)-1L) )
- bgColor = bgColorDD = _ppbd.m_clrForceBk;
- else if(_ppbd.m_bHover
- || _ppbd.m_bPushed
- || _ppbd.m_bIndeterminate
- || _ppbd.m_bPushedDropDown
- || _ppbd.m_bDefaultPushButton
- )
- {
- bgColor = bgColorDD = GetColor( CLR_3DFACE_IN, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- if( _ppbd.m_bPushed || _ppbd.m_bPushedDropDown || _ppbd.m_bDefaultPushButton )
- {
- if( _ppbd.m_bDefaultPushButton )
- bgColorDD = bgColor = dc.GetNearestColor( stat_HLS_Adjust( GetColor( XPCLR_HILIGHT ), 0.0, 0.2, 0.0 ) );
- if( _ppbd.m_bPushed || _ppbd.m_bPushedDropDown )
- (( _ppbd.m_bPushedDropDown ) ? bgColorDD : bgColor ) =
- GetColor( _ppbd.m_bHover ? XPCLR_HILIGHT : CLR_3DFACE_IN, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- }
- if( (!_ppbd.m_bHover)
- && _ppbd.m_bPushed
- && (!_ppbd.m_bPushedDropDown)
- && _ppbd.m_bSeparatedDropDown
- )
- bgColorDD = GetColor( CLR_3DFACE_OUT, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- if( _ppbd.m_bIndeterminate && ( !_ppbd.m_bHover ) && ( !_ppbd.m_bPushed ) )
- bgColor = dc.GetNearestColor( stat_HLS_Adjust( bgColor, 0.0, 0.5, 0.5 ) );
-
- if( _ppbd.m_bHover || ( _ppbd.m_bDefaultPushButton && (! _ppbd.m_bPushed ) ) )
- {
- if( _ppbd.m_bPushed )
- {
- nIdxMainGradientLeft = m_nIdxClrBtnHovPresLeft;
- nIdxMainGradientRight = m_nIdxClrBtnHovPresRight;
- } // if( _ppbd.m_bPushed )
- else
- {
- nIdxMainGradientLeft = m_nIdxClrBtnHoverLeft;
- nIdxMainGradientRight = m_nIdxClrBtnHoverRight;
- } // else from if( _ppbd.m_bPushed )
- } // if( _ppbd.m_bHover )
- else if( _ppbd.m_bPushed )
- {
- nIdxMainGradientLeft = m_nIdxClrBtnPressedLeft;
- nIdxMainGradientRight = m_nIdxClrBtnPressedRight;
- } // else if( _ppbd.m_bPushed )
- } // if( _ppbd.m_bHover || _ppbd.m_bPushed || _ppbd.m_bIndeterminate || _ppbd.m_bPushedDropDown )
- else
- {
- bgColor = bgColorDD =
- GetColor(
- _ppbd.m_bFlat ? CLR_3DFACE_OUT : COLOR_3DFACE,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- );
- }
- COLORREF clrDkBorder =
- GetColor(
- (_ppbd.m_bHover || _ppbd.m_bPushed || _ppbd.m_bPushedDropDown )
- ? XPCLR_HILIGHT_BORDER
- : ( _ppbd.m_bFlat ? XPCLR_HILIGHT_BORDER : COLOR_3DSHADOW )
- ,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- );
- bool bPushedDropDown = false;
- if( (_ppbd.m_bPushed && !_ppbd.m_bSeparatedDropDown)
- || _ppbd.m_bPushedDropDown
- )
- bPushedDropDown = true;
- CRect rectClient( _ppbd.m_rcClient );
- CRect rectCaption( _ppbd.m_rcClient );
- CRect rectDropDown( 0, 0, 0, 0 );
- if( _ppbd.m_bDropDown )
- {
- rectDropDown = rectClient;
- if( _ppbd.m_bHorz )
- {
- if( bRTL )
- {
- rectCaption.left +=
- __DROPDOWN_ARROW_GAP*2
- + g_glyph_btn_expand_bottom.Size().cx
- ;
- rectDropDown.right = rectCaption.left + 1;
- } // if( bRTL )
- else
- {
- rectCaption.right -=
- __DROPDOWN_ARROW_GAP*2
- + g_glyph_btn_expand_bottom.Size().cx
- ;
- rectDropDown.left = rectCaption.right - 1;
- } // else from if( bRTL )
- } // if( _ppbd.m_bHorz )
- else
- {
- rectCaption.bottom -=
- __DROPDOWN_ARROW_GAP*2
- + g_glyph_btn_expand_right.Size().cy
- ;
- rectDropDown.top = rectCaption.bottom - 1;
- } // if( _ppbd.m_bHorz )
- if( (! _ppbd.m_bTransparentBackground )
- && ( _ppbd.m_bHover || _ppbd.m_bPushedDropDown )
- || _ppbd.m_clrForceBk != ((COLORREF)-1L)
- )
- dc.FillSolidRect( &rectDropDown, bgColorDD );
- if( _ppbd.m_bSeparatedDropDown )
- {
- rectClient = rectCaption;
- if( bPushedDropDown )
- {
- if( (!_ppbd.m_bFlat) || _ppbd.m_bDrawBorder )
- dc.Draw3dRect( rectDropDown, clrDkBorder, clrDkBorder );
- } // if( bPushedDropDown )
- else
- {
- if( (!_ppbd.m_bFlat) || (_ppbd.m_bHover && _ppbd.m_bDrawBorder) )
- dc.Draw3dRect( rectDropDown, clrDkBorder, clrDkBorder );
- } // else from if( bPushedDropDown )
- } // if( _ppbd.m_bSeparatedDropDown )
- } // if( _ppbd.m_bDropDown )
- if( ( ! _ppbd.m_bTransparentBackground )
- || _ppbd.m_bIndeterminate
- || _ppbd.m_clrForceBk != ((COLORREF)-1L)
- )
- {
- if( nIdxMainGradientLeft >= 0 && nIdxMainGradientRight >= 0 )
- {
- COLORREF clrLeft = GetColor( _ppbd.m_bHorz ? nIdxMainGradientRight : nIdxMainGradientLeft, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- COLORREF clrRight = GetColor( _ppbd.m_bHorz ? nIdxMainGradientLeft : nIdxMainGradientRight, _ppbd.m_pHelperSrc, _ppbd.m_lParam );
- if( _ppbd.m_bDefaultPushButton && ( ! ( _ppbd.m_bHover || _ppbd.m_bPushed || _ppbd.m_bPushedDropDown ) ) )
- {
- clrLeft = dc.GetNearestColor( stat_HLS_Adjust( clrLeft, 0.0, 0.2, 0.0 ) );
- clrRight = dc.GetNearestColor( stat_HLS_Adjust( clrRight, 0.0, 0.2, 0.0 ) );
- }
- stat_PaintGradientRect( dc, rectClient, clrLeft, clrRight, _ppbd.m_bHorz );
- } // if( nIdxMainGradientLeft >= 0 && nIdxMainGradientRight >= 0 )
- else
- dc.FillSolidRect( &rectClient, bgColor );
- } // if( ! _ppbd.m_bTransparentBackground . . .
- // Draw pressed button
- if( _ppbd.m_bPushed || _ppbd.m_bIndeterminate || _ppbd.m_bPushedDropDown )
- {
- if( (!_ppbd.m_bFlat) || _ppbd.m_bDrawBorder )
- dc.Draw3dRect( rectClient, clrDkBorder, clrDkBorder );
- } // if( bPushed . . .
- else // ...else draw non pressed button
- {
- if( _ppbd.m_bFlat )
- {
- if( _ppbd.m_bHover && _ppbd.m_bDrawBorder )
- dc.Draw3dRect( rectClient, clrDkBorder, clrDkBorder );
- } // if( _ppbd.m_bFlat )
- else
- {
- dc.Draw3dRect( rectClient, clrDkBorder, clrDkBorder );
- if( _ppbd.m_bHover )
- dc.Draw3dRect( _ppbd.m_rcClient, clrDkBorder, clrDkBorder );
- } // else from if( _ppbd.m_bFlat )
- } // else from if( _ppbd.m_bPushed || _ppbd.m_bPushedDropDown )
- if( _ppbd.m_bDropDown && (! _ppbd.m_bNoDropDownArrow ) )
- {
- CRect rectGlyph( rectDropDown );
- if( bPushedDropDown )
- rectGlyph.OffsetRect( GetPushedOffset() );
- COLORREF ColorValues[2] =
- {
- RGB(0,0,0),
- RGB(0,0,0),
- };
- bool bSetDefaultColorForDD = true;
- if( _ppbd.m_bEnabled )
- {
- if( m_clrCustomDropDownGlyphEnabled != COLORREF(-1L) )
- {
- ColorValues[1] = m_clrCustomDropDownGlyphEnabled;
- bSetDefaultColorForDD = false;
- }
- }
- else
- {
- if( m_clrCustomDropDownGlyphDisabled != COLORREF(-1L) )
- {
- ColorValues[1] = m_clrCustomDropDownGlyphDisabled;
- bSetDefaultColorForDD = false;
- }
- }
- if( bSetDefaultColorForDD )
- ColorValues[1] =
- GetColor(
- _ppbd.m_bEnabled
- ? COLOR_BTNTEXT
- : COLOR_3DSHADOW
- ,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- );
- if( bRTL && (rectGlyph.Width()&1) == 0 )
- rectGlyph.right++;
- PaintGlyphCentered(
- dc,
- rectGlyph,
- _ppbd.m_bHorz ? g_glyph_btn_expand_bottom : g_glyph_btn_expand_right,
- ColorValues
- );
- } // if( _ppbd.m_bDropDown && (! _ppbd.m_bNoDropDownArrow ) )
- dc.SetBkColor( bgColor );
- rectCaption.DeflateRect( _ppbd.m_rcBorderSizes );
- rectClient = rectCaption;
- CRect rcFocus( rectCaption );
- // Draw icon
- if( rectClient.bottom > rectClient.top
- && rectClient.right > rectClient.left
- )
- PaintPushButtonIcon(
- dc,
- rectClient,
- rectCaption,
- rcFocus,
- _ppbd
- );
- CExtSafeString sTitle( _T("") );
- if( _ppbd.m_sText != NULL )
- sTitle = _ppbd.m_sText;
- // Draw text
- if( rectCaption.bottom > rectCaption.top
- && rectCaption.right > rectCaption.left
- && (!sTitle.IsEmpty())
- )
- PaintPushButtonText(
- dc,
- rectCaption,
- _ppbd
- );
- // Draw focus rectangle
- if( _ppbd.m_bDrawFocusRect
- && ( ( !sTitle.IsEmpty() ) || _ppbd.m_nFocusMode == __EBFM_CLIENT_AREA )
- && rcFocus.bottom > rcFocus.top
- && rcFocus.right > rcFocus.left
- )
- {
- rcFocus.DeflateRect( 2, 2 );
- dc.DrawFocusRect( &rcFocus );
- }
- dc.SetBkMode( nOldBkMode );
- dc.SetBkColor( clrOldBk );
- dc.SetTextColor( clrOldText );
- }
- void CExtPaintManagerXP::PaintPushButtonText(
- CDC & dc,
- CRect & rcCaption,
- CExtPaintManager::PAINTPUSHBUTTONDATA & _ppbd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _ppbd.m_rcClient.IsRectEmpty() )
- return;
- CExtSafeString sTitle( _T("") );
- if( _ppbd.m_sText != NULL )
- sTitle = _ppbd.m_sText;
- bool bRTL = _ppbd.IsRTL();
- if( rcCaption.bottom > rcCaption.top
- && rcCaption.right > rcCaption.left
- && (!sTitle.IsEmpty())
- )
- {
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- if( _ppbd.m_bPushed || _ppbd.m_bPushedDropDown )
- {
- CSize sizePushedOffset = GetPushedOffset();
- rcCaption.OffsetRect(sizePushedOffset);
- }
- if( _ppbd.m_bEnabled )
- {
- if( _ppbd.m_bHover || _ppbd.m_bPushed )
- {
- if( _ppbd.m_bPushed
- && _ppbd.m_clrForceTextPressed != ((COLORREF)-1L)
- )
- dc.SetTextColor( _ppbd.m_clrForceTextPressed );
- else if( _ppbd.m_bHover
- && _ppbd.m_clrForceTextHover != ((COLORREF)-1L)
- )
- dc.SetTextColor( _ppbd.m_clrForceTextHover );
- else if( _ppbd.m_clrForceTextNormal != ((COLORREF)-1L) )
- dc.SetTextColor( _ppbd.m_clrForceTextNormal );
- else
- dc.SetTextColor( GetColor( COLOR_BTNTEXT, _ppbd.m_pHelperSrc, _ppbd.m_lParam ) );
- }
- else
- {
- dc.SetTextColor(
- ( _ppbd.m_clrForceTextNormal == ((COLORREF)-1L) )
- ? GetColor(
- ( _ppbd.m_bHover && _ppbd.m_bPushed ) ? XPCLR_PUSHEDHOVERTEXT : COLOR_BTNTEXT,
- _ppbd.m_pHelperSrc,
- _ppbd.m_lParam
- )
- : _ppbd.m_clrForceTextNormal
- );
- }
- }
- else
- {
- dc.SetTextColor(
- ( _ppbd.m_clrForceTextDisabled == ((COLORREF)-1L) )
- ? GetColor( CLR_TEXT_DISABLED, _ppbd.m_pHelperSrc, _ppbd.m_lParam )
- : _ppbd.m_clrForceTextDisabled
- );
- }
- CFont * pOldBtnFont = NULL;
- CFont * pCurrFont = NULL;
- CFont fontDummy;
- if( _ppbd.m_hFont != NULL )
- {
- if( _ppbd.m_bHorz )
- pCurrFont = CFont::FromHandle( _ppbd.m_hFont );
- else
- {
- LOGFONT lf;
- ::memset(&lf,0,sizeof(LOGFONT));
- ::GetObject( _ppbd.m_hFont, sizeof(LOGFONT), &lf );
- if( lf.lfEscapement == 0 )
- {
- lf.lfEscapement = __EXT_VERT_FONT_ESCAPEMENT__;
- VERIFY(
- fontDummy.CreateFontIndirect(&lf)
- );
- pCurrFont = &fontDummy;
- }
- else
- {
- // suppose font already prepared
- pCurrFont = CFont::FromHandle( _ppbd.m_hFont );
- }
- }
- } // if( _ppbd.m_hFont != NULL )
- else
- {
- if( _ppbd.m_bHorz )
- {
- if( _ppbd.m_bDefaultPushButton )
- pCurrFont = &m_FontBold;
- else
- pCurrFont = &m_FontNormal;
- }
- else
- {
- if( _ppbd.m_bDefaultPushButton )
- pCurrFont = &m_FontBoldVert;
- else
- pCurrFont = &m_FontNormalVert;
- }
- } // else from if( _ppbd.m_hFont != NULL )
- ASSERT( pCurrFont != NULL );
- pOldBtnFont = dc.SelectObject( pCurrFont );
- CExtSafeString sBtn( sTitle );
- if( _ppbd.m_bHorz )
- {
- CRect rcTextLocation( 0, 0, 0, 0);
- UINT nDtMeasureFlags =
- DT_LEFT | DT_TOP | DT_CALCRECT | ((bRTL || _ppbd.m_bForceRtlText) ? DT_RTLREADING : 0);
- if( _ppbd.m_bWordBreak )
- {
- rcTextLocation = rcCaption;
- rcTextLocation.OffsetRect( -rcTextLocation.TopLeft() );
- rcTextLocation.bottom = rcTextLocation.top;
- nDtMeasureFlags |= DT_WORDBREAK;
- }
- else
- nDtMeasureFlags |= DT_SINGLELINE;
- dc.DrawText(
- sBtn,
- -1,
- rcTextLocation,
- nDtMeasureFlags
- );
- rcTextLocation.OffsetRect(
- rcCaption.TopLeft() - rcTextLocation.TopLeft()
- );
-
- UINT nDtDrawFlags = 0;
- if( (_ppbd.m_nTextAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_RIGHT )
- {
- nDtDrawFlags |= DT_RIGHT;
- rcTextLocation.OffsetRect(
- rcCaption.Width() - rcTextLocation.Width(),
- 0
- );
- }
- else if( (_ppbd.m_nTextAlignment&__ALIGN_HORIZ_MASK) == __ALIGN_HORIZ_CENTER )
- {
- nDtDrawFlags |= DT_CENTER;
- rcTextLocation.OffsetRect(
- ( rcCaption.Width() - rcTextLocation.Width() ) / 2,
- 0
- );
- }
- else
- nDtDrawFlags |= DT_LEFT;
-
- if( (_ppbd.m_nTextAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_BOTTOM )
- {
- nDtDrawFlags |= DT_BOTTOM;
- rcTextLocation.OffsetRect(
- 0,
- rcCaption.Height() - rcTextLocation.Height()
- );
- }
- else if( (_ppbd.m_nTextAlignment&__ALIGN_VERT_MASK) == __ALIGN_VERT_TOP )
- {
- nDtDrawFlags |= DT_TOP;
- }
- else
- {
- nDtDrawFlags |= DT_VCENTER;
- rcTextLocation.OffsetRect(
- 0,
- ( rcCaption.Height() - rcTextLocation.Height() ) / 2
- );
- }
- if( _ppbd.m_bWordBreak )
- nDtDrawFlags |= DT_WORDBREAK;
- else
- nDtDrawFlags |= DT_SINGLELINE;
- dc.DrawText(
- sTitle,
- -1,
- rcTextLocation,
- nDtDrawFlags
- );
- } // if( _ppbd.m_bHorz )
- else
- {
- INT nTextLength = sTitle.GetLength();
- INT nAmpIndex = sTitle.Find( _T('&') );
- if( nAmpIndex >= 0 )
- sBtn =
- sTitle.Left( nAmpIndex )
- + sTitle.Right( nTextLength - ( nAmpIndex + 1 ) );
- static TCHAR stat_strDummyAmpSeq[] = _T("