ExtPaintManager.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:1653k
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- hWnd = pWnd->GetSafeHwnd();
- }
- if( PaintMenuSeparator_UX( hWnd, dc, rectItem, nIconAreaWidth, bRarelyUsed, bIsForceNoLeftGradient, pHelperSrc, lParam ) )
- return;
- CRect rcSeparator( rectItem );
- rcSeparator.top += ( rectItem.bottom - rectItem.top ) / 2;
- rcSeparator.bottom = rcSeparator.top + 1;
- rcSeparator.DeflateRect( 3, 0 );
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- if( pHelperSrc != NULL
- && pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtRibbonGalleryPopupMenuWnd ) )
- && ( ((CExtPopupMenuWnd*)pHelperSrc)->TrackFlagsGet() & TPMX_RIBBON_FILE_MENU ) == 0
- && ((CExtRibbonGalleryPopupMenuWnd*)pHelperSrc)->ItemGetCount() > 0
- )
- {
- CRect rcC;
- ((CExtRibbonGalleryPopupMenuWnd*)pHelperSrc)->_GetClientRect( &rcC );
- rcSeparator.left = rcC.left;
- rcSeparator.right = rcC.right;
- rcSeparator.DeflateRect( 1, 0 );
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- dc.FillSolidRect(
- &rcSeparator,
- ::GetSysColor( COLOR_3DSHADOW )
- );
- }
- void CExtPaintManager::PaintSysCmdGlyph(
- CDC & dc,
- UINT nHelperSysCmdID,
- const RECT & rcItem,
- bool bHover,
- bool bPushed,
- bool bEnabled,
- COLORREF clrForceGlyphColor // = COLORREF(-1L)
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- e_docking_caption_button_t eGlyph = __DCBT_EMPTY;
- switch( nHelperSysCmdID )
- {
- case SC_CLOSE:
- eGlyph = __DCBT_CLOSE;
- break;
- case SC_RESTORE:
- eGlyph = __DCBT_WND_RESTORE;
- break;
- case SC_MINIMIZE:
- eGlyph = __DCBT_WND_MINIMIZE;
- break;
- case SC_MAXIMIZE:
- eGlyph = __DCBT_WND_MAXIMIZE;
- break;
- case SC_CONTEXTHELP:
- eGlyph = __DCBT_WND_CONTEXTHELP;
- break;
- } // switch( nHelperSysCmdID )
- if( eGlyph == __DCBT_EMPTY )
- return;
- COLORREF ColorValues[2] = { RGB(0,0,0), RGB(0,0,0), };
- CRect _rcItem( rcItem );
- if( bPushed )
- _rcItem.OffsetRect( GetPushedOffset() );
- if( clrForceGlyphColor != COLORREF(-1L) )
- ColorValues[1] = clrForceGlyphColor;
- else if( bEnabled )
- ColorValues[1] = GetColor( bHover ? CLR_MENUTEXT_IN : CLR_MENUTEXT_OUT, this );
- else
- {
- ColorValues[1] = GetColor( CLR_3DHILIGHT_OUT, this );
- _rcItem.OffsetRect(1,1);
- PaintGlyphCentered( dc, _rcItem, *g_DockingCaptionGlyphs[eGlyph], ColorValues );
- _rcItem.OffsetRect( -1, -1 );
- ColorValues[1] = GetColor( CLR_3DSHADOW_OUT, this );
- } // if( bEnabled )
- PaintGlyphCentered( dc, _rcItem, *g_DockingCaptionGlyphs[eGlyph], ColorValues );
- }
- void CExtPaintManagerXP::PaintSysCmdGlyph(
- CDC & dc,
- UINT nHelperSysCmdID,
- const RECT & rcItem,
- bool bHover,
- bool bPushed,
- bool bEnabled,
- COLORREF clrForceGlyphColor // = COLORREF(-1L)
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- e_docking_caption_button_t eGlyph = __DCBT_EMPTY;
- switch( nHelperSysCmdID )
- {
- case SC_CLOSE:
- eGlyph = __DCBT_CLOSE;
- break;
- case SC_RESTORE:
- eGlyph = __DCBT_WND_RESTORE;
- break;
- case SC_MINIMIZE:
- eGlyph = __DCBT_WND_MINIMIZE;
- break;
- case SC_MAXIMIZE:
- eGlyph = __DCBT_WND_MAXIMIZE;
- break;
- case SC_CONTEXTHELP:
- eGlyph = __DCBT_WND_CONTEXTHELP;
- break;
- } // switch( nHelperSysCmdID )
- if( eGlyph == __DCBT_EMPTY )
- return;
- COLORREF ColorValues[2] = { RGB(0,0,0), RGB(0,0,0), };
- CRect _rcItem( rcItem );
- if( bPushed )
- _rcItem.OffsetRect( GetPushedOffset() );
- if( clrForceGlyphColor != COLORREF(-1L) )
- ColorValues[1] = clrForceGlyphColor;
- else if( bEnabled )
- {
- if( m_bEnabledHoverIconShadows && bHover && (!bPushed) )
- {
- // COLOR_3DDKSHADOW changed to COLOR_3DSHADOW
- // by the Dmitry Yakovlev's advice
- ColorValues[1] = GetColor( COLOR_3DSHADOW, this );
- PaintGlyphCentered( dc, _rcItem, *g_DockingCaptionGlyphs[eGlyph], ColorValues );
- // corrected by the Dmitry Yakovlev's advice
- _rcItem.OffsetRect( -2, -2 );
- } // if( m_bEnabledHoverIconShadows && bHover && (!bPushed) )
- ColorValues[1] = GetColor( bHover ? CLR_MENUTEXT_IN : CLR_MENUTEXT_OUT, this );
- } // if( bEnabled )
- else
- ColorValues[1] = GetColor( CLR_MENUTEXT_DISABLED, this );
- PaintGlyphCentered( dc, _rcItem, *g_DockingCaptionGlyphs[eGlyph], ColorValues );
- }
- int CExtPaintManager::TearOff_GetCaptionHeight() const
- {
- ASSERT_VALID( this );
- return 8;
- }
- void CExtPaintManager::TearOff_GetCaptionPaint(
- CDC & dc,
- const RECT & rectItem,
- bool bHover,
- bool bPressed,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- dc;
- rectItem;
- bHover;
- bPressed;
- pHelperSrc;
- lParam;
- }
- CExtPaintManager::PAINTMENUITEMDATA::PAINTMENUITEMDATA()
- : m_pHelperSrc( NULL )
- , m_lParam( 0L )
- , m_rcItem( 0, 0, 0, 0 )
- , m_rcItemWithIndents( 0, 0, 0, 0 )
- , m_nIconAreaWidth( 0 )
- , m_sText( _T("") )
- , m_sAccelText( _T("") )
- , m_sExtendedText( _T("") )
- , m_pIcon( NULL )
- , m_bPopup( false )
- , m_bSelected( false )
- , m_bPushedCheck( false )
- , m_bPushedRadio( false )
- , m_bIndeterminate( false )
- , m_bEnabled( false )
- , m_bRarelyUsed( false )
- , m_bRarelyUsedPrev( false )
- , m_bRarelyUsedNext( false )
- , m_nHelperSysCmdID( 0L )
- , m_bForceNoLeftGradient( false )
- , m_bCustomizeListMode( false )
- , m_bSeparatedDropDown( false )
- , m_rcInPlaceWnd( 0, 0, 0, 0 )
- , m_strInPlaceText( _T("") )
- , m_bXtraMark( false )
- , m_bXtraChecked( false )
- , m_bBigAccent( false )
- , m_bHelperPopupDropped( false )
- , m_hCustomFont( NULL )
- , m_clrCustomAccentEffectForIcon( COLORREF(-1L) )
- , m_clrForceMenuText( COLORREF(-1L) )
- {
- }
- CExtPaintManager::PAINTMENUITEMDATA::PAINTMENUITEMDATA(
- CObject * pHelperSrc,
- const RECT & rcItem,
- const RECT & rcItemWithIndents,
- INT nIconAreaWidth,
- __EXT_MFC_SAFE_LPCTSTR sText,
- __EXT_MFC_SAFE_LPCTSTR sAccelText,
- CExtCmdIcon * pIcon,
- bool bPopup,
- bool bSelected,
- bool bPushedCheck,
- bool bPushedRadio,
- bool bIndeterminate,
- bool bEnabled,
- bool bRarelyUsed,
- bool bRarelyUsedPrev,
- bool bRarelyUsedNext,
- UINT nHelperSysCmdID, // for painting system menu glyphs
- HFONT hCustomFont
- )
- : m_pHelperSrc( pHelperSrc )
- , m_lParam( 0L )
- , m_rcItem( rcItem )
- , m_rcItemWithIndents( rcItemWithIndents )
- , m_nIconAreaWidth( nIconAreaWidth )
- , m_sText( (sText == NULL) ? _T("") : sText )
- , m_sAccelText( (sAccelText == NULL) ? _T("") : sAccelText )
- , m_sExtendedText( _T("") )
- , m_pIcon( pIcon )
- , m_bPopup( bPopup )
- , m_bSelected( bSelected )
- , m_bPushedCheck( bPushedCheck )
- , m_bPushedRadio( bPushedRadio )
- , m_bIndeterminate( bIndeterminate )
- , m_bEnabled( bEnabled )
- , m_bRarelyUsed( bRarelyUsed )
- , m_bRarelyUsedPrev( bRarelyUsedPrev )
- , m_bRarelyUsedNext( bRarelyUsedNext )
- , m_nHelperSysCmdID( nHelperSysCmdID )
- , m_bForceNoLeftGradient( false )
- , m_bCustomizeListMode( false )
- , m_bSeparatedDropDown( false )
- , m_rcInPlaceWnd( 0, 0, 0, 0 )
- , m_strInPlaceText( _T("") )
- , m_bXtraMark( false )
- , m_bXtraChecked( false )
- , m_bBigAccent( false )
- , m_bHelperPopupDropped( false )
- , m_hCustomFont( hCustomFont )
- , m_clrCustomAccentEffectForIcon( COLORREF(-1L) )
- , m_clrForceMenuText( COLORREF(-1L) )
- {
- }
- void CExtPaintManager::PaintMenuItem(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty() )
- return;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- } // if( _pmid.m_pHelperSrc != NULL )
- CExtSafeString _sText =
- (_pmid.m_sText==NULL) ? _T("") : _pmid.m_sText;
- CExtSafeString _sAccelText =
- (_pmid.m_sAccelText==NULL) ? _T("") : _pmid.m_sAccelText;
- COLORREF clr3dFace = GetColor( CLR_3DFACE_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- COLORREF clrBk = clr3dFace;
- COLORREF clrText =
- GetColor(
- _pmid.m_bEnabled
- ? CLR_MENUTEXT_OUT
- : CLR_MENUTEXT_DISABLED,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- );
- CRect rcBk( _pmid.m_rcItem );
- CRect rcBkWithIndents( _pmid.m_rcItemWithIndents );
- dc.FillSolidRect( rcBkWithIndents, clrBk );
- if( _pmid.m_bSelected )
- {
- ASSERT( _pmid.m_bEnabled );
- clrBk = GetColor( COLOR_HIGHLIGHT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- clrText = GetColor( CLR_MENUTEXT_IN, _pmid.m_pHelperSrc, _pmid.m_lParam );
- }
- if( _pmid.m_bRarelyUsed )
- {
- dc.FillRect( rcBkWithIndents, &m_brushLightDefault );
- if( ! _pmid.m_bRarelyUsedPrev )
- {
- CPen penShadow(
- PS_SOLID,
- 1,
- GetColor( COLOR_3DSHADOW, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- CPen * pOldPen =
- dc.SelectObject( &penShadow );
- ASSERT( pOldPen != NULL );
- dc.MoveTo( rcBkWithIndents.left, rcBkWithIndents.top );
- dc.LineTo( rcBkWithIndents.right, rcBkWithIndents.top );
- dc.SelectObject( pOldPen );
- }
- if( ! _pmid.m_bRarelyUsedNext )
- {
- CPen penLight(
- PS_SOLID,
- 1,
- GetColor( COLOR_3DHIGHLIGHT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- CPen * pOldPen =
- dc.SelectObject( &penLight );
- ASSERT( pOldPen != NULL );
- dc.MoveTo( rcBkWithIndents.left, rcBkWithIndents.bottom - 1 );
- dc.LineTo( rcBkWithIndents.right, rcBkWithIndents.bottom - 1 );
- dc.SelectObject( pOldPen );
- }
- }
- bool bSmallerSelRect =
- ( (_pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()))
- || _pmid.m_bPushedCheck
- || _pmid.m_bPushedRadio
- ) ? true : false;
- if( bSmallerSelRect )
- {
- if( bRTL )
- rcBk.right -= _pmid.m_nIconAreaWidth;
- else
- rcBk.left += _pmid.m_nIconAreaWidth;
- }
- rcBk.DeflateRect( 1, 0, 0, 0 );
- if( _pmid.m_bSelected || (!_pmid.m_bRarelyUsed) )
- dc.FillSolidRect( rcBk, clrBk );
- if( ! bSmallerSelRect )
- {
- if( bRTL )
- rcBk.right -= _pmid.m_nIconAreaWidth;
- else
- rcBk.left += _pmid.m_nIconAreaWidth;
- }
- rcBk.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
- COLORREF clrOldText = dc.SetTextColor( clrText );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- rcBk.DeflateRect( __EXT_MENU_GAP, 0 );
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- ASSERT( pOldFont != NULL );
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- CRect rcMeasureText( 0, 0, 0, 0 );
- dc.DrawText(
- _sText,
- _sText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- CRect rcDrawText( rcBk ), rcDrawTextExtended( rcBk );
- INT nLenTextExtended = ( _pmid.m_sExtendedText != NULL ) ? INT( _tcslen( _pmid.m_sExtendedText ) ) : 0;
- if( nLenTextExtended > 0 )
- {
- rcDrawText.bottom
- = rcDrawTextExtended.top
- = rcDrawText.top + rcMeasureText.Height();
- }
- else
- {
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- }
- COLORREF clrTextRestore = dc.GetTextColor();
- if( _pmid.m_clrForceMenuText != COLORREF(-1L) )
- dc.SetTextColor( _pmid.m_clrForceMenuText );
-
- if( bRTL )
- {
- rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- if( _pmid.m_bEnabled )
- {
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- dc.DrawText(
- _pmid.m_sExtendedText,
- nLenTextExtended,
- &rcDrawTextExtended,
- dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- }
- }
- else
- {
- CRect rcDrawTextOffs = rcDrawText;
- rcDrawTextOffs.OffsetRect( 1, 1 );
- COLORREF clrTextRestore = COLORREF(-1L);
- if( _pmid.m_clrForceMenuText == COLORREF(-1L) )
- clrTextRestore =
- dc.SetTextColor(
- GetColor(
- COLOR_3DHILIGHT,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawTextOffs,
- DT_SINGLELINE|dwDtAlignFlags
- );
- dc.SetTextColor(
- GetColor(
- CLR_MENUTEXT_DISABLED,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- dc.DrawText(
- _pmid.m_sExtendedText,
- nLenTextExtended,
- &rcDrawTextExtended,
- dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- }
- if( clrTextRestore != COLORREF(-1L) )
- dc.SetTextColor( clrTextRestore );
- }
- }
- else
- {
- if( _pmid.m_clrForceMenuText == COLORREF(-1L) )
- {
- dc.DrawState(
- rcDrawText.TopLeft(),
- rcDrawText.Size(),
- _sText,
- (_pmid.m_bEnabled ? DSS_NORMAL : m_DSS_DISABLED_style),
- TRUE,
- 0,
- (CBrush*)NULL
- );
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- COLORREF clrOldTextColor = COLORREF(-1L);
- if( ! _pmid.m_bEnabled )
- clrOldTextColor = dc.SetTextColor( GetColor(COLOR_3DSHADOW) );
- dc.DrawText(
- _pmid.m_sExtendedText,
- nLenTextExtended,
- &rcDrawTextExtended,
- dwDtAlignFlags
- );
- if( ! _pmid.m_bEnabled )
- dc.SetTextColor( clrOldTextColor );
- dc.SelectObject( pOldFont );
- }
- }
- else
- {
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- dc.DrawText(
- _pmid.m_sExtendedText,
- nLenTextExtended,
- &rcDrawTextExtended,
- dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- }
- }
- }
- if( ! _sAccelText.IsEmpty() )
- {
- rcMeasureText.SetRect( 0, 0, 0, 0 );
- dc.DrawText(
- _sAccelText,
- _sAccelText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- rcDrawText = rcBk;
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- if( bRTL )
- {
- rcDrawText.right =
- rcDrawText.left
- + rcMeasureText.Width()
- + __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.right = rcDrawText.right;
- }
- else
- {
- rcDrawText.left =
- rcDrawText.right
- - rcMeasureText.Width()
- - __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.left = rcDrawText.left;
- }
- if( bRTL )
- {
- rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- if( _pmid.m_bEnabled )
- {
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- }
- else
- {
- CRect rcDrawTextOffs = rcDrawText;
- rcDrawTextOffs.OffsetRect( 1, 1 );
- COLORREF clrTextRestore = COLORREF(-1L);
- if( _pmid.m_clrForceMenuText == COLORREF(-1L) )
- clrTextRestore =
- dc.SetTextColor(
- GetColor(
- COLOR_3DHILIGHT,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawTextOffs,
- DT_SINGLELINE|dwDtAlignFlags
- );
- dc.SetTextColor(
- GetColor(
- CLR_MENUTEXT_DISABLED,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- if( clrTextRestore != COLORREF(-1L) )
- dc.SetTextColor( clrTextRestore );
- } // else from if( _pmid.m_bEnabled )
- } // if( bRTL )
- else
- {
- if( _pmid.m_clrForceMenuText == COLORREF(-1L) )
- dc.DrawState(
- rcDrawText.TopLeft(),
- rcDrawText.Size(),
- _sAccelText,
- (_pmid.m_bEnabled ? DSS_NORMAL : m_DSS_DISABLED_style),
- TRUE,
- 0,
- (CBrush*)NULL
- );
- else
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- }
- } // if( ! _sAccelText.IsEmpty() )
- dc.SetTextColor( clrTextRestore );
- if( _pmid.m_bPopup )
- {
- CRect rcPopupArrow( _pmid.m_rcItem );
- rcPopupArrow.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
- if( bRTL )
- rcPopupArrow.right =
- rcPopupArrow.left + __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcPopupArrow.left =
- rcPopupArrow.right - __EXT_MENU_POPUP_ARROW_AREA_DX;
- if( _pmid.m_bCustomizeListMode )
- {
- COLORREF ColorValues[2] =
- {
- RGB(0,0,0),
- GetColor(
- _pmid.m_bSelected
- ? CLR_MENUTEXT_IN
- : CLR_MENUTEXT_OUT,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- };
- PaintGlyphCentered(
- dc,
- rcPopupArrow,
- _pmid.m_bSeparatedDropDown
- ? g_glyph_customize_dropdown_src
- : g_glyph_customize_popup_src,
- ColorValues
- );
- } // if( _pmid.m_bCustomizeListMode )
- else
- {
- COLORREF clrPopupArrow = clrText;
- if( _pmid.m_bSeparatedDropDown )
- {
- if( _pmid.m_bSelected )
- {
- if( _pmid.m_bHelperPopupDropped )
- clrPopupArrow = GetColor( CLR_3DHILIGHT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- else
- {
- clrPopupArrow = GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- CRect rcButton(
- bRTL ? _pmid.m_rcItem.left : rcPopupArrow.left,
- _pmid.m_rcItem.top,
- bRTL ? rcPopupArrow.right : _pmid.m_rcItem.right,
- _pmid.m_rcItem.bottom
- );
- if( _pmid.m_bRarelyUsed )
- dc.FillRect(
- &rcButton,
- &m_brushLightDefault
- );
- else
- dc.FillSolidRect(
- &rcButton,
- GetColor( CLR_3DFACE_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- }
- } // if( _pmid.m_bSelected )
- else
- {
- CRect rcSeparator(
- bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- rcBk.top,
- bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- rcBk.bottom
- );
- PaintSeparator(
- dc,
- rcSeparator,
- true,
- true,
- NULL
- );
- } // else from if( _pmid.m_bSelected )
- } // if( _pmid.m_bSeparatedDropDown )
- dc.SelectObject( &m_FontMarlett );
- CRect _rcPopupArrow( rcPopupArrow );
- if( bRTL )
- _rcPopupArrow.right -= 2;
- else
- _rcPopupArrow.left += 2;
- dc.SetTextColor( clrPopupArrow );
- dc.DrawText(
- bRTL ? _T("3") : _T("4"),
- _rcPopupArrow,
- DT_CENTER|DT_VCENTER|DT_SINGLELINE
- );
- } // else from if( _pmid.m_bCustomizeListMode )
- } // if( _pmid.m_bPopup )
-
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- // paint icon area
- PaintMenuItemIcon( dc, _pmid );
- // paint inplace control area
- PaintMenuItemInPlaceWnd( dc, _pmid );
- }
- void CExtPaintManager::PaintMenuItemIcon(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty() )
- return;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CSize sizeIcon( __EXT_MENU_ICON_CX, __EXT_MENU_ICON_CY );
- if( _pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()) )
- {
- sizeIcon = _pmid.m_pIcon->GetSize();
- if( sizeIcon.cx <= 18 && sizeIcon.cy < sizeIcon.cx )
- sizeIcon.cy = sizeIcon.cx;
- }
- CRect rcIcon( _pmid.m_rcItem.TopLeft(), sizeIcon );
- if( bRTL )
- rcIcon.OffsetRect( _pmid.m_rcItem.Width() - sizeIcon.cx, 0 );
- if( _pmid.m_bXtraMark )
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth/2 - rcIcon.Width() ) / 2 + _pmid.m_nIconAreaWidth/2 - 2 )
- * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- if( _pmid.m_bXtraChecked )
- {
- CRect rcXtraMark(
- bRTL ? (_pmid.m_rcItem.right - _pmid.m_rcItem.Height() - 1) : (_pmid.m_rcItem.left + 1),
- _pmid.m_rcItem.top + 1,
- bRTL ? (_pmid.m_rcItem.right - 1) : (_pmid.m_rcItem.left + _pmid.m_rcItem.Height() - 1),
- _pmid.m_rcItem.bottom - 1
- );
- dc.FillRect(
- rcXtraMark,
- &m_brushLightDefault
- );
- COLORREF clrCheck = GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- int x = rcXtraMark.left + rcXtraMark.Width() / 2 - 3;
- int y = rcXtraMark.top + rcXtraMark.Height() / 2 - 3;
- ASSERT( !_pmid.m_bPushedRadio );
- stat_PaintCheckMark( dc, x, y, clrCheck );
- dc.Draw3dRect(
- rcXtraMark,
- GetColor( CLR_3DSHADOW_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- GetColor( CLR_3DHILIGHT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- }
- }
- else
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth - rcIcon.Width() ) / 2 ) * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- }
- CRect rcIconFrame(rcIcon);
- rcIconFrame.InflateRect(
- __EXT_MENU_IMG_RECT_OUT_GAP,
- __EXT_MENU_IMG_RECT_OUT_GAP
- );
- if( _pmid.m_bIndeterminate )
- dc.FillRect(
- rcIconFrame,
- &m_brushLightestSystem
- );
- else if( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio )
- dc.FillRect(
- rcIconFrame,
- &m_brushLightDefault
- );
- if( _pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()) )
- {
- _pmid.m_pIcon->Paint(
- this,
- dc,
- rcIcon.left,
- rcIcon.top,
- -1,
- -1,
- _pmid.m_bEnabled
- ? CExtCmdIcon::__PAINT_NORMAL
- : CExtCmdIcon::__PAINT_DISABLED
- );
- if( _pmid.m_bSelected
- && _pmid.m_bEnabled
- && (! ( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio ) )
- )
- dc.Draw3dRect(
- &rcIconFrame,
- GetColor( CLR_3DHILIGHT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- GetColor( CLR_3DSHADOW_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- }
- else
- {
- PaintSysCmdGlyph(
- dc,
- _pmid.m_nHelperSysCmdID,
- rcIcon,
- _pmid.m_bSelected,
- false,
- _pmid.m_bEnabled
- );
- }
-
- if( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio )
- {
- if( _pmid.m_pIcon == NULL || _pmid.m_pIcon->IsEmpty() )
- {
- COLORREF clrCheck = GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- int x = rcIcon.left + rcIcon.Width()/2 - 3;
- int y = rcIcon.top + rcIcon.Height()/2 - 3;
- if( _pmid.m_bPushedCheck )
- {
- ASSERT( !_pmid.m_bPushedRadio );
- if( _pmid.m_bIndeterminate )
- stat_PaintIndeterminatedSquare( dc, x, y, clrCheck );
- else
- stat_PaintCheckMark( dc, x, y, clrCheck );
- }
- else
- {
- ASSERT( !_pmid.m_bPushedCheck );
- stat_PaintRadioDot( dc, x, y, clrCheck );
- }
- }
- dc.Draw3dRect(
- rcIconFrame,
- GetColor( CLR_3DSHADOW_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- GetColor( CLR_3DHILIGHT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- }
- }
- void CExtPaintManager::PaintMenuItemInPlaceWnd(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty()
- || _pmid.m_rcInPlaceWnd.IsRectEmpty()
- )
- return;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CRect rcInPlaceWndOuterBorder( _pmid.m_rcInPlaceWnd );
- rcInPlaceWndOuterBorder.InflateRect( 2, 2, 2, 3 );
- INT nDD = GetDropDownButtonWidth( _pmid.m_pHelperSrc, _pmid.m_lParam );
- CRect rcBk( rcInPlaceWndOuterBorder );
- if( _pmid.m_bPopup )
- rcBk.right += nDD;
- dc.FillSolidRect(
- &rcBk,
- GetColor(
- _pmid.m_bEnabled ? COLOR_WINDOW : COLOR_3DFACE,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
- if( _pmid.m_bPopup )
- {
- rcInPlaceWndOuterBorder.right += nDD;
- if( _pmid.m_bEnabled )
- {
- PAINTCOMBOFRAMEDATA _pcfd(
- _pmid.m_pHelperSrc,
- rcInPlaceWndOuterBorder,
- _pmid.m_bSelected, // hover
- _pmid.m_bSelected && _pmid.m_bHelperPopupDropped, // pushed
- _pmid.m_bEnabled
- );
- _pcfd.m_bNoTopOuterBorder = true;
- PaintComboFrame( dc, _pcfd );
- }
- else
- {
- CRect rcBorder( rcInPlaceWndOuterBorder );
- rcBorder.DeflateRect( 2, 2 );
- COLORREF clrBorder =
- GetColor( COLOR_WINDOW, _pmid.m_pHelperSrc, _pmid.m_lParam );
- dc.Draw3dRect(
- &rcBorder,
- clrBorder,
- clrBorder
- );
- // paint arrow down
- CRect rcBtn( rcBorder );
- rcBtn.left = rcBtn.right - nDD;
- glyph_t * pGlyph = g_DockingCaptionGlyphs[ __DCBT_ARROW_SMALL_DOWN ];
- ASSERT( pGlyph != NULL );
- COLORREF ColorValues[2] =
- {
- RGB(0,0,0),
- GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- };
- PaintGlyphCentered(
- dc,
- rcBtn,
- *pGlyph,
- ColorValues
- );
- }
- rcInPlaceWndOuterBorder.DeflateRect( 1, 1 );
- rcInPlaceWndOuterBorder.right -= nDD;
- }
- else
- {
- if( _pmid.m_bEnabled )
- {
- COLORREF clrFace = GetColor( COLOR_3DFACE, _pmid.m_pHelperSrc, _pmid.m_lParam );
- dc.Draw3dRect(
- rcInPlaceWndOuterBorder,
- clrFace,
- clrFace
- );
- rcInPlaceWndOuterBorder.DeflateRect( 1, 1 );
- if( _pmid.m_bSelected )
- dc.Draw3dRect(
- rcInPlaceWndOuterBorder,
- GetColor( COLOR_3DSHADOW, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- GetColor( COLOR_3DHIGHLIGHT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- else
- dc.Draw3dRect(
- rcInPlaceWndOuterBorder,
- clrFace,
- clrFace
- );
- }
- else
- {
- CRect rcBorder( rcInPlaceWndOuterBorder );
- rcBorder.DeflateRect( 2, 2 );
- COLORREF clrBorder = GetColor( COLOR_WINDOW, _pmid.m_pHelperSrc, _pmid.m_lParam );
- dc.Draw3dRect(
- &rcBorder,
- clrBorder,
- clrBorder
- );
- }
- } // else from if( _pmid.m_bPopup )
- if( ! _pmid.m_strInPlaceText.IsEmpty() )
- {
- rcInPlaceWndOuterBorder.DeflateRect( 5, 2, 2, 2 );
-
- COLORREF clrOldText =
- dc.SetTextColor(
- GetColor(
- _pmid.m_bEnabled
- ? COLOR_WINDOWTEXT
- : COLOR_3DSHADOW,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
-
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
-
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- ASSERT( pOldFont != NULL );
-
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- dc.DrawText(
- _pmid.m_strInPlaceText,
- _pmid.m_strInPlaceText.GetLength(),
- &rcInPlaceWndOuterBorder,
- DT_SINGLELINE|DT_NOPREFIX|DT_TOP|dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- }
- }
- void CExtPaintManagerXP::PaintMenuItemLeftAreaMarginXP(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid,
- const RECT & rcFillLeftPart,
- const RECT & rcFillRightPart
- )
- {
- ASSERT_VALID( this );
- dc;
- _pmid;
- rcFillLeftPart;
- rcFillRightPart;
- }
- bool CExtPaintManagerXP::PaintMenuItemBackgroundXP(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid,
- const RECT & rcSelectionArea
- )
- {
- ASSERT_VALID( this );
- dc;
- _pmid;
- rcSelectionArea;
- return false;
- }
- bool CExtPaintManagerXP::PaintMenuItemSelectionAreaXP(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid,
- const RECT & rcSelectionArea
- )
- {
- ASSERT_VALID( this );
- dc;
- _pmid;
- rcSelectionArea;
- return false;
- }
- bool CExtPaintManagerXP::PaintMenuItemCheckMarkAreaXP(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid,
- const RECT & rcCheckMarkArea,
- CExtPaintManagerXP::e_CheckMarkAreaTypeXP eCMATXP
- )
- {
- ASSERT_VALID( this );
- dc;
- _pmid;
- rcCheckMarkArea;
- eCMATXP;
- return false;
- }
- void CExtPaintManagerXP::PaintMenuItem(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty() )
- return;
- CExtPopupMenuWnd * pPopup = NULL;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- pPopup = DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CExtSafeString _sText = (_pmid.m_sText==NULL) ? _T("") : _pmid.m_sText;
- CExtSafeString _sAccelText = (_pmid.m_sAccelText==NULL) ? _T("") : _pmid.m_sAccelText;
- COLORREF clr3dFace = GetColor( _pmid.m_bRarelyUsed ? XPCLR_RARELY_BORDER : CLR_3DFACE_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- COLORREF clrDkBorder = GetColor( XPCLR_HILIGHT_BORDER, _pmid.m_pHelperSrc, _pmid.m_lParam );
- COLORREF clrBk = clr3dFace;
- COLORREF clrText =
- GetColor(
- _pmid.m_bEnabled
- ? _pmid.m_bSelected
- ? CLR_MENUTEXT_IN
- : CLR_MENUTEXT_OUT
- : CLR_MENUTEXT_DISABLED,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- );
- COLORREF clrRight = GetColor( XPCLR_3DFACE_NORMAL, _pmid.m_pHelperSrc, _pmid.m_lParam );
- CRect rcBk( _pmid.m_rcItemWithIndents );
- CRect rcSelBk( _pmid.m_rcItem );
- // paint left area
- COLORREF clrGradientLeft = ((COLORREF)(-1L)),
- clrGradientMiddle((COLORREF)(-1L)),
- clrGradientRight((COLORREF)(-1L));
- if( ::GetDeviceCaps( dc.m_hDC, BITSPIXEL ) > 8 )
- {
- if( _pmid.m_bRarelyUsed )
- {
- if( m_nIdxClrMlaRarelyLeft >= 0
- && m_nIdxClrMlaRarelyMiddle >= 0
- && m_nIdxClrMlaRarelyRight >= 0
- )
- {
- // if paint gradient on rarely used item's left part
- clrGradientLeft = GetColor( m_nIdxClrMlaRarelyLeft, _pmid.m_pHelperSrc, _pmid.m_lParam );
- clrGradientMiddle = GetColor( m_nIdxClrMlaRarelyMiddle, _pmid.m_pHelperSrc, _pmid.m_lParam );
- clrGradientRight = GetColor( m_nIdxClrMlaRarelyRight, _pmid.m_pHelperSrc, _pmid.m_lParam );
- }
- }
- else
- {
- if( m_nIdxClrMlaNormLeft >= 0
- && m_nIdxClrMlaNormMiddle >= 0
- && m_nIdxClrMlaNormRight >= 0
- )
- {
- // if paint gradient on rarely used item's left part
- clrGradientLeft = GetColor( m_nIdxClrMlaNormLeft, _pmid.m_pHelperSrc, _pmid.m_lParam );
- clrGradientMiddle = GetColor( m_nIdxClrMlaNormMiddle, _pmid.m_pHelperSrc, _pmid.m_lParam );
- clrGradientRight = GetColor( m_nIdxClrMlaNormRight, _pmid.m_pHelperSrc, _pmid.m_lParam );
- }
- }
- }
-
- CRect rcGradient( rcBk );
- if( bRTL )
- rcGradient.left = rcGradient.right - _pmid.m_nIconAreaWidth;
- else
- rcGradient.right = rcGradient.left + _pmid.m_nIconAreaWidth;
- CRect rcFillRightPart( rcBk );
- if( ! _pmid.m_bForceNoLeftGradient )
- {
- if( (!_pmid.m_bForceNoLeftGradient)
- && clrGradientLeft != ((COLORREF)(-1L))
- )
- {
- ASSERT( clrGradientRight != ((COLORREF)(-1L)) );
- stat_PaintGradientRect2steps(
- dc,
- rcGradient,
- clrGradientLeft,
- clrGradientMiddle,
- clrGradientRight,
- false,
- 1,
- 2
- );
- } // if( (!_pmid.m_bForceNoLeftGradient) && clrGradientLeft != ((COLORREF)(-1L)) )
- else
- dc.FillSolidRect( &rcGradient, clrBk );
- if( bRTL )
- rcFillRightPart.right -= _pmid.m_nIconAreaWidth;
- else
- rcFillRightPart.left += _pmid.m_nIconAreaWidth;
- dc.FillSolidRect( &rcFillRightPart, clrRight );
- } // if( ! _pmid.m_bForceNoLeftGradient )
- PaintMenuItemLeftAreaMarginXP(
- dc,
- _pmid,
- rcGradient,
- rcFillRightPart
- );
- bool bCustomBackgroundDrawn =
- PaintMenuItemBackgroundXP( dc, _pmid, rcSelBk );
- bool bCustomSelectionDrawn = bCustomBackgroundDrawn;
- if( _pmid.m_bSelected && ( ! bCustomSelectionDrawn ) )
- {
- if( ! PaintMenuItemSelectionAreaXP( dc, _pmid, rcSelBk ) )
- {
- ASSERT( _pmid.m_bEnabled );
- dc.FillSolidRect(
- &rcSelBk,
- GetColor( CLR_3DFACE_IN, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- dc.Draw3dRect( &rcSelBk, clrDkBorder, clrDkBorder );
- }
- else
- bCustomSelectionDrawn = true;
- }
- // if( ! _pmid.m_bForceNoLeftGradient )
- // {
- if( bRTL )
- rcBk.right -= _pmid.m_nIconAreaWidth;
- else
- rcBk.left += _pmid.m_nIconAreaWidth;
- // }
- rcBk.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_IMG_RECT_OUT_GAP-1 );
- if( bRTL )
- rcBk.right -= 5;
- else
- rcBk.left += 5;
- COLORREF clrOldText =
- dc.SetTextColor(
- ( _pmid.m_clrForceMenuText != COLORREF(-1L) )
- ? _pmid.m_clrForceMenuText
- : clrText
- );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- //ASSERT( pOldFont != NULL );
- CRect rcMeasureText( 0, 0, 0, 0 );
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- dc.DrawText(
- _sText,
- _sText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- CRect rcDrawText( rcBk ), rcDrawTextExtended( rcBk );
- INT nLenTextExtended = ( _pmid.m_sExtendedText != NULL ) ? INT( _tcslen( _pmid.m_sExtendedText ) ) : 0;
-
- if( nLenTextExtended > 0 )
- {
- rcDrawText.bottom
- = rcDrawTextExtended.top
- = rcDrawText.top + rcMeasureText.Height();
- }
- else
- {
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- }
- if( bRTL )
- rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
-
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- dc.DrawText(
- _pmid.m_sExtendedText,
- nLenTextExtended,
- &rcDrawTextExtended,
- dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- }
- if( ! _sAccelText.IsEmpty() )
- {
- rcMeasureText.SetRect( 0, 0, 0, 0 );
- dc.DrawText(
- _sAccelText,
- _sAccelText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- rcDrawText = rcBk;
- rcDrawText.OffsetRect(
- bRTL ? 5 : (-5),
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
-
- if( bRTL )
- {
- rcDrawText.right =
- rcDrawText.left
- + rcMeasureText.Width()
- + __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.right = rcDrawText.right;
- }
- else
- {
- rcDrawText.left =
- rcDrawText.right
- - rcMeasureText.Width()
- - __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.left = rcDrawText.left;
- }
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- } // if( ! _sAccelText.IsEmpty() )
- if( _pmid.m_bPopup && (! bCustomBackgroundDrawn ) )
- {
- CRect rcPopupArrow( _pmid.m_rcItem );
- rcPopupArrow.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
-
- if( bRTL )
- rcPopupArrow.right =
- rcPopupArrow.left + __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcPopupArrow.left =
- rcPopupArrow.right - __EXT_MENU_POPUP_ARROW_AREA_DX;
-
- if( _pmid.m_bCustomizeListMode )
- {
- COLORREF ColorValues[2] =
- {
- RGB( 0, 0, 0 ),
- GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- };
- PaintGlyphCentered(
- dc,
- rcPopupArrow,
- _pmid.m_bSeparatedDropDown
- ? g_glyph_customize_dropdown_src
- : g_glyph_customize_popup_src,
- ColorValues
- );
- }
- else
- {
- COLORREF clrPopupArrow = clrText;
- if( _pmid.m_bSeparatedDropDown )
- {
- if( _pmid.m_bSelected )
- {
- clrPopupArrow = GetColor( CLR_MENUTEXT_IN, _pmid.m_pHelperSrc, _pmid.m_lParam );
- CRect rcButton = rcSelBk;
-
- if( bRTL )
- {
- rcButton.right = rcPopupArrow.right + 1;
- rcButton.DeflateRect( 1, 1, 0, 1 );
- }
- else
- {
- rcButton.left = rcPopupArrow.left - 1;
- rcButton.DeflateRect( 0, 1, 1, 1 );
- }
-
- if( _pmid.m_bHelperPopupDropped )
- {
- if( ! bCustomSelectionDrawn )
- dc.FillSolidRect(
- &rcButton,
- GetColor( XPCLR_HILIGHT, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- }
-
- if( bRTL )
- rcButton.left = rcButton.right - 1;
- else
- rcButton.right = rcButton.left + 1;
-
- dc.FillSolidRect(
- &rcButton,
- GetColor( XPCLR_HILIGHT_BORDER, _pmid.m_pHelperSrc, _pmid.m_lParam )
- );
- } // if( _pmid.m_bSelected )
- else
- {
- CRect rcSeparator(
- bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- rcBk.top,
- bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- rcBk.bottom
- );
- PaintSeparator(
- dc,
- rcSeparator,
- true,
- true,
- NULL
- );
- } // else from if( _pmid.m_bSelected )
- } // if( _pmid.m_bSeparatedDropDown )
-
- dc.SelectObject( &m_FontMarlett );
-
- CRect _rcPopupArrow( rcPopupArrow );
- _rcPopupArrow.left += 2;
- dc.SetTextColor( clrPopupArrow );
-
- dc.DrawText(
- bRTL ? _T("3") : _T("4"),
- _rcPopupArrow,
- DT_CENTER|DT_VCENTER|DT_SINGLELINE
- );
- } // else from if( _pmid.m_bCustomizeListMode )
- } // if( _pmid.m_bPopup && (! bCustomBackgroundDrawn ) )
-
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- // paint icon area
- PaintMenuItemIcon( dc, _pmid );
- // paint inplace control area
- PaintMenuItemInPlaceWnd( dc, _pmid );
- }
- void CExtPaintManagerXP::PaintMenuItemIcon(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty() )
- return;
- CExtPopupMenuWnd * pPopup = NULL;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- pPopup = DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- COLORREF clrBkHilight =
- GetColor( XPCLR_HILIGHT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- COLORREF clrIconBkHilight =
- ( _pmid.m_bSelected )
- // || ( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio )
- // || ( _pmid.m_bXtraMark || _pmid.m_bXtraChecked ) )
- ? clrBkHilight
- : GetColor( CLR_3DFACE_IN, _pmid.m_pHelperSrc, _pmid.m_lParam );
- COLORREF clrDkBorder = GetColor( XPCLR_HILIGHT_BORDER, _pmid.m_pHelperSrc, _pmid.m_lParam );
- COLORREF clrDkBorderSelected = GetColor( XPCLR_HILIGHT_BORDER_SELECTED, _pmid.m_pHelperSrc, _pmid.m_lParam );
- CSize sizeIcon( __EXT_MENU_ICON_CX, __EXT_MENU_ICON_CY );
- if( _pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()) )
- {
- sizeIcon = _pmid.m_pIcon->GetSize();
- if( sizeIcon.cx <= 18 && sizeIcon.cy < sizeIcon.cx )
- sizeIcon.cy = sizeIcon.cx;
- }
- CRect rcIcon( _pmid.m_rcItem.TopLeft(), sizeIcon );
- if( bRTL )
- rcIcon.OffsetRect( _pmid.m_rcItem.Width() - sizeIcon.cx, 0 );
- if( _pmid.m_bXtraMark )
- {
- rcIcon.OffsetRect(
- (( _pmid.m_nIconAreaWidth/2 - rcIcon.Width() ) / 2 + _pmid.m_nIconAreaWidth/2 - 2)
- * ( bRTL ? (-1) : 1 ),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- if( _pmid.m_bXtraChecked )
- {
- CRect rcXtraMark(
- bRTL ? (_pmid.m_rcItem.right - _pmid.m_rcItem.Height() - 1) : (_pmid.m_rcItem.left + 1),
- _pmid.m_rcItem.top + 1,
- bRTL ? (_pmid.m_rcItem.right - 1) : (_pmid.m_rcItem.left + _pmid.m_rcItem.Height() - 1),
- _pmid.m_rcItem.bottom - 1
- );
- bool bCustomBackgroundDrawn = false;
- if( pPopup != NULL
- && ( pPopup->TrackFlagsGet() & TPMX_RIBBON_MODE ) != 0
- )
- bCustomBackgroundDrawn =
- PaintMenuItemCheckMarkAreaXP(
- dc,
- _pmid,
- rcXtraMark,
- __ECMATXP_EXTRA_MARK_CHECKED
- );
- if( ! bCustomBackgroundDrawn )
- {
- int nIdxMainGradientLeft = -1;
- int nIdxMainGradientRight = -1;
-
- if( _pmid.m_bSelected )
- {
- nIdxMainGradientLeft = m_nIdxClrBtnHovPresLeft;
- nIdxMainGradientRight = m_nIdxClrBtnHovPresRight;
- }
- else
- {
- nIdxMainGradientLeft = m_nIdxClrBtnPressedLeft;
- nIdxMainGradientRight = m_nIdxClrBtnPressedRight;
- }
- if( nIdxMainGradientLeft >= 0 && nIdxMainGradientRight >= 0 )
- {
- stat_PaintGradientRect(
- dc,
- rcXtraMark,
- GetColor( nIdxMainGradientRight, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- GetColor( nIdxMainGradientLeft, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- true
- );
- }
- else
- {
- dc.FillSolidRect(
- rcXtraMark,
- clrIconBkHilight
- );
- }
- COLORREF clrCheck = GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- int x = rcXtraMark.left + rcXtraMark.Width()/2 - 3;
- int y = rcXtraMark.top + rcXtraMark.Height()/2 - 3;
- ASSERT( !_pmid.m_bPushedRadio );
- stat_PaintCheckMark( dc, x, y, clrCheck );
- COLORREF clrBorder = _pmid.m_bSelected ? clrDkBorderSelected : clrDkBorder;
- dc.Draw3dRect( rcXtraMark, clrBorder, clrBorder );
- }
- }
- }
- else
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth - rcIcon.Width() ) / 2 - 1 ) * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- }
- CRect rcIconFrame( rcIcon );
- rcIconFrame.InflateRect(__EXT_MENU_IMG_RECT_OUT_GAP,__EXT_MENU_IMG_RECT_OUT_GAP);
- if( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio )
- {
- bool bCustomBackgroundDrawn = false;
- if( pPopup != NULL
- && ( pPopup->TrackFlagsGet() & TPMX_RIBBON_MODE ) != 0
- )
- bCustomBackgroundDrawn =
- PaintMenuItemCheckMarkAreaXP(
- dc,
- _pmid,
- rcIconFrame,
- __ECMATXP_ICON_OR_CHECK_OR_RADIO_FRAME
- );
- if( ! bCustomBackgroundDrawn )
- {
- int nIdxMainGradientLeft = -1;
- int nIdxMainGradientRight = -1;
- if( _pmid.m_bSelected )
- {
- nIdxMainGradientLeft = m_nIdxClrBtnHovPresLeft;
- nIdxMainGradientRight = m_nIdxClrBtnHovPresRight;
- }
- else if( _pmid.m_bIndeterminate )
- {
- clrIconBkHilight =
- dc.GetNearestColor(
- stat_HLS_Adjust(
- clrIconBkHilight,
- 0.0,
- 0.85,
- 0.5
- )
- );
- }
- else
- {
- nIdxMainGradientLeft = m_nIdxClrBtnPressedLeft;
- nIdxMainGradientRight = m_nIdxClrBtnPressedRight;
- }
- if( nIdxMainGradientLeft >= 0 && nIdxMainGradientRight >= 0 )
- {
- stat_PaintGradientRect(
- dc,
- rcIconFrame,
- GetColor( nIdxMainGradientRight, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- GetColor( nIdxMainGradientLeft, _pmid.m_pHelperSrc, _pmid.m_lParam ),
- true
- );
- }
- else
- {
- dc.FillSolidRect(
- rcIconFrame,
- clrIconBkHilight
- );
- }
- }
- }
- if( _pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()) )
- {
- PaintIcon(
- dc,
- true,
- _pmid.m_pIcon,
- rcIcon,
- _pmid.m_bPushedCheck || _pmid.m_bPushedRadio,
- _pmid.m_bEnabled,
- _pmid.m_bSelected,
- __ALIGN_HORIZ_LEFT | __ALIGN_VERT_TOP,
- false,
- NULL,
- NULL,
- NULL,
- _pmid.m_clrCustomAccentEffectForIcon
- );
- }
- else
- {
- PaintSysCmdGlyph(
- dc,
- _pmid.m_nHelperSysCmdID,
- rcIcon,
- _pmid.m_bSelected,
- false,
- _pmid.m_bEnabled
- );
- }
- if( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio )
- {
- if( _pmid.m_pIcon == NULL || _pmid.m_pIcon->IsEmpty() )
- {
- COLORREF clrCheck = GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- int x = rcIcon.left + rcIcon.Width()/2 - 3;
- int y = rcIcon.top + rcIcon.Height()/2 - 3;
- if( _pmid.m_bPushedCheck )
- {
- ASSERT( !_pmid.m_bPushedRadio );
- if( _pmid.m_bIndeterminate )
- stat_PaintIndeterminatedSquare( dc, x, y, clrCheck );
- else
- stat_PaintCheckMark( dc, x, y, clrCheck );
- }
- else
- {
- ASSERT( !_pmid.m_bPushedCheck );
- stat_PaintRadioDot( dc, x, y, clrCheck );
- }
- }
- COLORREF clrBorder =
- _pmid.m_bSelected ? clrDkBorderSelected : clrDkBorder;
- dc.Draw3dRect(
- rcIconFrame,
- clrBorder,
- clrBorder
- );
- }
- }
- void CExtPaintManagerXP::PaintMenuItemInPlaceWnd(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty()
- || _pmid.m_rcInPlaceWnd.IsRectEmpty()
- )
- return;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CRect rcInPlaceWndOuterBorder( _pmid.m_rcInPlaceWnd );
- rcInPlaceWndOuterBorder.InflateRect( 1, 2 );
- if( _pmid.m_bPopup )
- {
- INT nDD = GetDropDownButtonWidth( _pmid.m_pHelperSrc, _pmid.m_lParam );
- rcInPlaceWndOuterBorder.right += nDD;
-
- dc.FillSolidRect(
- &rcInPlaceWndOuterBorder,
- ::GetSysColor( _pmid.m_bEnabled ? COLOR_WINDOW : COLOR_3DFACE )
- );
- PAINTCOMBOFRAMEDATA _pcfd(
- _pmid.m_pHelperSrc,
- rcInPlaceWndOuterBorder,
- _pmid.m_bSelected,
- _pmid.m_bHelperPopupDropped,
- _pmid.m_bEnabled
- );
- PaintComboFrame(
- dc,
- _pcfd
- );
- if( ! _pmid.m_bSelected )
- {
- COLORREF clrBorder =
- GetColor(
- _pmid.m_bEnabled
- ? XPCLR_TEXT_FIELD_BORDER_NORMAL
- : XPCLR_TEXT_FIELD_BORDER_DISABLED
- ,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- );
- dc.Draw3dRect(
- &rcInPlaceWndOuterBorder,
- clrBorder,
- clrBorder
- );
- }
- rcInPlaceWndOuterBorder.right -= nDD;
- }
- else
- {
- // paint text field
- dc.FillSolidRect(
- &rcInPlaceWndOuterBorder,
- ::GetSysColor( _pmid.m_bEnabled ? COLOR_WINDOW : COLOR_3DFACE )
- );
- COLORREF clrBorder =
- _pmid.m_bSelected
- ? GetColor( XPCLR_HILIGHT_BORDER, _pmid.m_pHelperSrc, _pmid.m_lParam )
- : GetColor(
- _pmid.m_bEnabled
- ? XPCLR_TEXT_FIELD_BORDER_NORMAL
- : XPCLR_TEXT_FIELD_BORDER_DISABLED,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- );
- dc.Draw3dRect(
- &rcInPlaceWndOuterBorder,
- clrBorder,
- clrBorder
- );
- }
- if( !_pmid.m_strInPlaceText.IsEmpty() )
- {
- rcInPlaceWndOuterBorder.DeflateRect( 5, 3, 2, 2 );
-
- COLORREF clrOldText =
- dc.SetTextColor(
- GetColor(
- _pmid.m_bEnabled
- ? COLOR_WINDOWTEXT
- : COLOR_3DSHADOW,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
-
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
-
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- ASSERT( pOldFont != NULL );
-
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- dc.DrawText(
- _pmid.m_strInPlaceText,
- _pmid.m_strInPlaceText.GetLength(),
- &rcInPlaceWndOuterBorder,
- DT_SINGLELINE|DT_NOPREFIX|DT_TOP|dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- }
- }
- bool CExtPaintManagerNativeXP::PaintMenuItem_UX(
- HWND hWnd,
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty() || hWnd == NULL || (! ::IsWindow( hWnd ) ) )
- return false;
- bool bThemedApproachOK = false;
- if( g_PaintManager.m_UxTheme.OpenThemeData( hWnd, VSCLASS_MENU ) == NULL )
- return false;
- bool bCloseTheme = true;
- try
- {
- HRESULT hr = S_OK;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CExtSafeString _sText = (_pmid.m_sText==NULL) ? _T("") : _pmid.m_sText;
- CExtSafeString _sAccelText = (_pmid.m_sAccelText==NULL) ? _T("") : _pmid.m_sAccelText;
- // COLORREF clrText =
- // _pmid.m_bSelected
- // ? ::GetSysColor( COLOR_HIGHLIGHTTEXT )
- // : ::GetSysColor( COLOR_MENUTEXT );
- CRect rcBk( _pmid.m_rcItem );
- // bool bSmallerSelRect =
- // ( (_pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()))
- // || _pmid.m_bPushedCheck
- // || _pmid.m_bPushedRadio
- // ) ? true : false;
- // if( bSmallerSelRect )
- // {
- // if( bRTL )
- // rcBk.right -= _pmid.m_nIconAreaWidth;
- // else
- // rcBk.left += _pmid.m_nIconAreaWidth;
- // }
- rcBk.DeflateRect( 1, 0, 1, 0 );
- CRect rcFillSelectedBk = rcBk;
- if( _pmid.m_rcInPlaceWnd.IsRectEmpty() )
- rcBk.DeflateRect( 0, 1 );
- if( _pmid.m_bSelected )
- {
- if( _pmid.m_bSeparatedDropDown
- && ( ! _pmid.m_bHelperPopupDropped )
- )
- {
- if( bRTL )
- rcFillSelectedBk.left += __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcFillSelectedBk.right -= __EXT_MENU_POPUP_ARROW_AREA_DX;
- }
- // dc.FillSolidRect(
- // rcFillSelectedBk,
- // ::GetSysColor( COLOR_HIGHLIGHT )
- // );
- }
- int nMenuItemStateID = ( _pmid.m_bEnabled ? ( _pmid.m_bSelected ? MPI_HOT : MPI_NORMAL ) : MPI_DISABLED );
- if( _pmid.m_nIconAreaWidth > 0 )
- {
- CRect rcLeftArea = rcFillSelectedBk;
- if( bRTL )
- rcLeftArea.left = rcLeftArea.right - _pmid.m_nIconAreaWidth;
- else
- rcLeftArea.right = rcLeftArea.left + _pmid.m_nIconAreaWidth;
- rcLeftArea.InflateRect( 0, 1 );
- hr =
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPGUTTER,
- nMenuItemStateID,
- &rcLeftArea,
- &rcLeftArea
- );
- if( hr != S_OK )
- ::AfxThrowUserException();
- }
- hr =
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPITEM,
- nMenuItemStateID,
- &rcFillSelectedBk,
- &rcFillSelectedBk
- );
- if( hr != S_OK )
- ::AfxThrowUserException();
- // if( ! bSmallerSelRect )
- // {
- // if( bRTL )
- // rcBk.right -= _pmid.m_nIconAreaWidth;
- // else
- // rcBk.left += _pmid.m_nIconAreaWidth;
- // }
- if( bRTL )
- rcBk.right -= _pmid.m_nIconAreaWidth;
- else
- rcBk.left += _pmid.m_nIconAreaWidth;
- rcBk.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
- // COLORREF clrOldText =
- // dc.SetTextColor(
- // ( _pmid.m_clrForceMenuText != COLORREF(-1L) )
- // ? _pmid.m_clrForceMenuText
- // : clrText
- // );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- rcBk.DeflateRect( __EXT_MENU_GAP, 0 );
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- ASSERT( pOldFont != NULL );
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- CRect rcMeasureText( 0, 0, 0, 0 );
- dc.DrawText(
- _sText,
- _sText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- // hr =
- // g_PaintManager.m_UxTheme.DrawThemeText(
- // dc.GetSafeHdc(),
- // MENU_POPUPITEM,
- // nMenuItemStateID,
- // LPCTSTR(_sText),
- // _sText.GetLength(),
- // DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags,
- // 0,
- // &rcMeasureText
- // );
- // if( hr != S_OK )
- // ::AfxThrowUserException();
- CRect rcDrawText( rcBk ), rcDrawTextExtended( rcBk );
- INT nLenTextExtended = ( _pmid.m_sExtendedText != NULL ) ? INT( _tcslen( _pmid.m_sExtendedText ) ) : 0;
- if( nLenTextExtended > 0 )
- {
- rcDrawText.bottom
- = rcDrawTextExtended.top
- = rcDrawText.top + rcMeasureText.Height();
- }
- else
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- // if( bRTL )
- // {
- // rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- // if( _pmid.m_bEnabled )
- // dc.DrawText(
- // LPCTSTR(_sText),
- // _sText.GetLength(),
- // &rcDrawText,
- // DT_SINGLELINE|dwDtAlignFlags
- // );
- // else
- // {
- // CRect rcDrawTextOffs = rcDrawText;
- // rcDrawTextOffs.OffsetRect( 1, 1 );
- // COLORREF clrTextRestore =
- // dc.SetTextColor(
- // ::GetSysColor( COLOR_3DHILIGHT )
- // );
- // dc.DrawText(
- // LPCTSTR(_sText),
- // _sText.GetLength(),
- // &rcDrawTextOffs,
- // DT_SINGLELINE|dwDtAlignFlags
- // );
- // dc.SetTextColor(
- // ::GetSysColor( COLOR_3DSHADOW )
- // );
- // dc.DrawText(
- // LPCTSTR(_sText),
- // _sText.GetLength(),
- // &rcDrawText,
- // DT_SINGLELINE|dwDtAlignFlags
- // );
- // dc.SetTextColor( clrTextRestore );
- // }
- // }
- // else
- // {
- // dc.DrawState(
- // rcDrawText.TopLeft(),
- // rcDrawText.Size(),
- // _sText,
- // (_pmid.m_bEnabled ? DSS_NORMAL : m_DSS_DISABLED_style),
- // TRUE,
- // 0,
- // (CBrush*)NULL
- // );
- // }
- hr =
- g_PaintManager.m_UxTheme.DrawThemeText(
- dc.GetSafeHdc(),
- MENU_POPUPITEM,
- nMenuItemStateID,
- LPCTSTR(_sText),
- _sText.GetLength(),
- DT_SINGLELINE|dwDtAlignFlags,
- 0,
- &rcDrawText
- );
- if( hr != S_OK )
- ::AfxThrowUserException();
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- // COLORREF clrOldTextColor = COLORREF(-1L);
- // if( ! _pmid.m_bEnabled )
- // clrOldTextColor = dc.SetTextColor( GetColor(COLOR_3DSHADOW) );
- // dc.DrawText(
- // _pmid.m_sExtendedText,
- // nLenTextExtended,
- // &rcDrawTextExtended,
- // dwDtAlignFlags
- // );
- hr =
- g_PaintManager.m_UxTheme.DrawThemeText(
- dc.GetSafeHdc(),
- MENU_POPUPITEM,
- nMenuItemStateID,
- LPCTSTR(_pmid.m_sExtendedText),
- nLenTextExtended,
- dwDtAlignFlags,
- 0,
- &rcDrawTextExtended
- );
- if( hr != S_OK )
- ::AfxThrowUserException();
- // if( ! _pmid.m_bEnabled )
- // dc.SetTextColor( clrOldTextColor );
- dc.SelectObject( pOldFont );
- }
- if( ! _sAccelText.IsEmpty() )
- {
- rcMeasureText.SetRect( 0, 0, 0, 0 );
- dc.DrawText(
- _sAccelText,
- _sAccelText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- rcDrawText = rcBk;
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- if( bRTL )
- {
- rcDrawText.right =
- rcDrawText.left
- + rcMeasureText.Width()
- + __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.right = rcDrawText.right;
- }
- else
- {
- rcDrawText.left =
- rcDrawText.right
- - rcMeasureText.Width()
- - __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.left = rcDrawText.left;
- }
- // if( bRTL )
- // {
- // rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- // if( _pmid.m_bEnabled )
- // dc.DrawText(
- // LPCTSTR(_sAccelText),
- // _sAccelText.GetLength(),
- // &rcDrawText,
- // DT_SINGLELINE|dwDtAlignFlags
- // );
- // else
- // {
- // CRect rcDrawTextOffs = rcDrawText;
- // rcDrawTextOffs.OffsetRect( 1, 1 );
- // COLORREF clrTextRestore =
- // dc.SetTextColor(
- // ::GetSysColor( COLOR_3DHILIGHT )
- // );
- // dc.DrawText(
- // LPCTSTR(_sAccelText),
- // _sAccelText.GetLength(),
- // &rcDrawTextOffs,
- // DT_SINGLELINE|dwDtAlignFlags
- // );
- // dc.SetTextColor(
- // ::GetSysColor( COLOR_3DSHADOW )
- // );
- // dc.DrawText(
- // LPCTSTR(_sAccelText),
- // _sAccelText.GetLength(),
- // &rcDrawText,
- // DT_SINGLELINE|dwDtAlignFlags
- // );
- // dc.SetTextColor( clrTextRestore );
- // }
- // } // if( bRTL )
- // else
- // dc.DrawState(
- // rcDrawText.TopLeft(),
- // rcDrawText.Size(),
- // _sAccelText,
- // (_pmid.m_bEnabled ? DSS_NORMAL : m_DSS_DISABLED_style),
- // TRUE,
- // 0,
- // (CBrush*)NULL
- // );
- hr =
- g_PaintManager.m_UxTheme.DrawThemeText(
- dc.GetSafeHdc(),
- MENU_POPUPITEM,
- nMenuItemStateID,
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- DT_SINGLELINE|dwDtAlignFlags,
- 0,
- &rcDrawText
- );
- if( hr != S_OK )
- ::AfxThrowUserException();
- } // if( ! _sAccelText.IsEmpty() )
- if( _pmid.m_bPopup )
- {
- CRect rcPopupArrow( _pmid.m_rcItem );
- rcPopupArrow.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
- if( bRTL )
- rcPopupArrow.right =
- rcPopupArrow.left + __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcPopupArrow.left =
- rcPopupArrow.right - __EXT_MENU_POPUP_ARROW_AREA_DX;
- if( _pmid.m_bCustomizeListMode )
- {
- COLORREF ColorValues[2] =
- {
- RGB(0,0,0),
- ::GetSysColor(
- //_pmid.m_bSelected ? COLOR_HIGHLIGHTTEXT :
- COLOR_MENUTEXT )
- };
- PaintGlyphCentered(
- dc,
- rcPopupArrow,
- _pmid.m_bSeparatedDropDown
- ? g_glyph_customize_dropdown_src
- : g_glyph_customize_popup_src,
- ColorValues
- );
- }
- else
- {
- // COLORREF clrPopupArrow = clrText;
- // if( _pmid.m_bSeparatedDropDown )
- // {
- // if( _pmid.m_bSelected )
- // {
- // clrPopupArrow = ::GetSysColor( _pmid.m_bHelperPopupDropped ? COLOR_HIGHLIGHTTEXT : COLOR_BTNTEXT );
- // }
- // else
- // {
- // CRect rcSeparator(
- // bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- // rcBk.top,
- // bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- // rcBk.bottom
- // );
- // PaintSeparator(
- // dc,
- // rcSeparator,
- // true,
- // true,
- // NULL
- // );
- // }
- // }
- //
- // dc.SelectObject( &m_FontMarlett );
- CRect _rcPopupArrow( rcPopupArrow );
- if( bRTL )
- _rcPopupArrow.right -= 2;
- else
- _rcPopupArrow.left += 2;
- // dc.SetTextColor( clrPopupArrow );
- // dc.DrawText(
- // bRTL ? _T("3") : _T("4"),
- // _rcPopupArrow,
- // DT_CENTER|DT_VCENTER|DT_SINGLELINE
- // );
- hr =
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPSUBMENU,
- _pmid.m_bEnabled ? MSM_NORMAL : MSM_DISABLED,
- &_rcPopupArrow,
- &_rcPopupArrow
- );
- if( hr != S_OK )
- ::AfxThrowUserException();
- } // else from if( _pmid.m_bCustomizeListMode )
- } // if( _pmid.m_bPopup )
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- // dc.SetTextColor( clrOldText );
- // paint icon area
- if( ! PaintMenuItemIcon_UX( hWnd, dc, _pmid ) )
- ::AfxThrowUserException();
- g_PaintManager.m_UxTheme.CloseThemeData();
- bCloseTheme = false;
- // paint inplace control area
- PaintMenuItemInPlaceWnd( dc, _pmid );
- bThemedApproachOK = true;
- } // try
- catch( CException * pException )
- {
- pException->Delete();
- bThemedApproachOK = false;
- }
- catch( ... )
- {
- bThemedApproachOK = false;
- }
- if( bCloseTheme )
- g_PaintManager.m_UxTheme.CloseThemeData();
- return bThemedApproachOK;
- }
- void CExtPaintManagerNativeXP::PaintMenuItem(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( _pmid.m_rcItem.IsRectEmpty() )
- return;
- if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- {
- CExtPaintManager::PaintMenuItem(
- dc,
- _pmid
- );
- return;
- } // if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- HWND hWnd = NULL;
- CWnd * pWnd = DYNAMIC_DOWNCAST( CWnd, _pmid.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- hWnd = pWnd->GetSafeHwnd();
- }
- if( PaintMenuItem_UX( hWnd, dc, _pmid ) )
- return;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CExtSafeString _sText = (_pmid.m_sText==NULL) ? _T("") : _pmid.m_sText;
- CExtSafeString _sAccelText = (_pmid.m_sAccelText==NULL) ? _T("") : _pmid.m_sAccelText;
- COLORREF clrText =
- _pmid.m_bSelected
- ? ::GetSysColor( COLOR_HIGHLIGHTTEXT )
- : ::GetSysColor( COLOR_MENUTEXT );
- CRect rcBk( _pmid.m_rcItem );
- bool bSmallerSelRect =
- ( (_pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()))
- || _pmid.m_bPushedCheck
- || _pmid.m_bPushedRadio
- ) ? true : false;
- if( bSmallerSelRect )
- {
- if( bRTL )
- rcBk.right -= _pmid.m_nIconAreaWidth;
- else
- rcBk.left += _pmid.m_nIconAreaWidth;
- }
- rcBk.DeflateRect( 1, 0, 1, 0 );
- if( _pmid.m_rcInPlaceWnd.IsRectEmpty() )
- rcBk.DeflateRect( 0, 1 );
- if( _pmid.m_bSelected )
- {
- CRect rcFillSelectedBk = rcBk;
- if( _pmid.m_bSeparatedDropDown
- && ( ! _pmid.m_bHelperPopupDropped )
- )
- {
- if( bRTL )
- rcFillSelectedBk.left += __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcFillSelectedBk.right -= __EXT_MENU_POPUP_ARROW_AREA_DX;
- }
- dc.FillSolidRect(
- rcFillSelectedBk,
- ::GetSysColor( COLOR_HIGHLIGHT )
- );
- }
- if( ! bSmallerSelRect )
- {
- if( bRTL )
- rcBk.right -= _pmid.m_nIconAreaWidth;
- else
- rcBk.left += _pmid.m_nIconAreaWidth;
- }
- rcBk.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
- COLORREF clrOldText =
- dc.SetTextColor(
- ( _pmid.m_clrForceMenuText != COLORREF(-1L) )
- ? _pmid.m_clrForceMenuText
- : clrText
- );
- int nOldBkMode = dc.SetBkMode( TRANSPARENT );
- rcBk.DeflateRect( __EXT_MENU_GAP, 0 );
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- ASSERT( pOldFont != NULL );
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- CRect rcMeasureText( 0, 0, 0, 0 );
- dc.DrawText(
- _sText,
- _sText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- CRect rcDrawText( rcBk ), rcDrawTextExtended( rcBk );
- INT nLenTextExtended = ( _pmid.m_sExtendedText != NULL ) ? INT( _tcslen( _pmid.m_sExtendedText ) ) : 0;
-
- if( nLenTextExtended > 0 )
- {
- rcDrawText.bottom
- = rcDrawTextExtended.top
- = rcDrawText.top + rcMeasureText.Height();
- }
- else
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- if( bRTL )
- {
- rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- if( _pmid.m_bEnabled )
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- else
- {
- CRect rcDrawTextOffs = rcDrawText;
- rcDrawTextOffs.OffsetRect( 1, 1 );
- COLORREF clrTextRestore =
- dc.SetTextColor(
- ::GetSysColor( COLOR_3DHILIGHT )
- );
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawTextOffs,
- DT_SINGLELINE|dwDtAlignFlags
- );
- dc.SetTextColor(
- ::GetSysColor( COLOR_3DSHADOW )
- );
- dc.DrawText(
- LPCTSTR(_sText),
- _sText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- dc.SetTextColor( clrTextRestore );
- }
- }
- else
- {
- dc.DrawState(
- rcDrawText.TopLeft(),
- rcDrawText.Size(),
- _sText,
- (_pmid.m_bEnabled ? DSS_NORMAL : m_DSS_DISABLED_style),
- TRUE,
- 0,
- (CBrush*)NULL
- );
- }
-
- if( nLenTextExtended > 0 )
- {
- CFont * pOldFont = dc.SelectObject( &m_FontNormal );
- COLORREF clrOldTextColor = COLORREF(-1L);
- if( ! _pmid.m_bEnabled )
- clrOldTextColor = dc.SetTextColor( GetColor(COLOR_3DSHADOW) );
- dc.DrawText(
- _pmid.m_sExtendedText,
- nLenTextExtended,
- &rcDrawTextExtended,
- dwDtAlignFlags
- );
- if( ! _pmid.m_bEnabled )
- dc.SetTextColor( clrOldTextColor );
- dc.SelectObject( pOldFont );
- }
- if( ! _sAccelText.IsEmpty() )
- {
- rcMeasureText.SetRect( 0, 0, 0, 0 );
- dc.DrawText(
- _sAccelText,
- _sAccelText.GetLength(),
- &rcMeasureText,
- DT_CALCRECT|DT_SINGLELINE|dwDtAlignFlags
- );
- rcDrawText = rcBk;
- rcDrawText.OffsetRect(
- 0,
- ( rcDrawText.Height() - rcMeasureText.Height() ) / 2
- );
- if( bRTL )
- {
- rcDrawText.right =
- rcDrawText.left
- + rcMeasureText.Width()
- + __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.right = rcDrawText.right;
- }
- else
- {
- rcDrawText.left =
- rcDrawText.right
- - rcMeasureText.Width()
- - __EXT_MENU_POPUP_ARROW_AREA_DX
- ;
- rcBk.left = rcDrawText.left;
- }
- if( bRTL )
- {
- rcDrawText.left = rcDrawText.right - rcMeasureText.Width();
- if( _pmid.m_bEnabled )
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- else
- {
- CRect rcDrawTextOffs = rcDrawText;
- rcDrawTextOffs.OffsetRect( 1, 1 );
- COLORREF clrTextRestore =
- dc.SetTextColor(
- ::GetSysColor( COLOR_3DHILIGHT )
- );
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawTextOffs,
- DT_SINGLELINE|dwDtAlignFlags
- );
- dc.SetTextColor(
- ::GetSysColor( COLOR_3DSHADOW )
- );
- dc.DrawText(
- LPCTSTR(_sAccelText),
- _sAccelText.GetLength(),
- &rcDrawText,
- DT_SINGLELINE|dwDtAlignFlags
- );
- dc.SetTextColor( clrTextRestore );
- }
- } // if( bRTL )
- else
- dc.DrawState(
- rcDrawText.TopLeft(),
- rcDrawText.Size(),
- _sAccelText,
- (_pmid.m_bEnabled ? DSS_NORMAL : m_DSS_DISABLED_style),
- TRUE,
- 0,
- (CBrush*)NULL
- );
- } // if( ! _sAccelText.IsEmpty() )
- if( _pmid.m_bPopup )
- {
- CRect rcPopupArrow( _pmid.m_rcItem );
- rcPopupArrow.DeflateRect( __EXT_MENU_GAP, __EXT_MENU_GAP );
- if( bRTL )
- rcPopupArrow.right =
- rcPopupArrow.left + __EXT_MENU_POPUP_ARROW_AREA_DX;
- else
- rcPopupArrow.left =
- rcPopupArrow.right - __EXT_MENU_POPUP_ARROW_AREA_DX;
- if( _pmid.m_bCustomizeListMode )
- {
- COLORREF ColorValues[2] =
- {
- RGB(0,0,0),
- ::GetSysColor( _pmid.m_bSelected ? COLOR_HIGHLIGHTTEXT : COLOR_MENUTEXT )
- };
- PaintGlyphCentered(
- dc,
- rcPopupArrow,
- _pmid.m_bSeparatedDropDown
- ? g_glyph_customize_dropdown_src
- : g_glyph_customize_popup_src,
- ColorValues
- );
- }
- else
- {
- COLORREF clrPopupArrow = clrText;
- if( _pmid.m_bSeparatedDropDown )
- {
- if( _pmid.m_bSelected )
- {
- clrPopupArrow = ::GetSysColor( _pmid.m_bHelperPopupDropped ? COLOR_HIGHLIGHTTEXT : COLOR_BTNTEXT );
- }
- else
- {
- CRect rcSeparator(
- bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- rcBk.top,
- bRTL ? rcPopupArrow.right : rcPopupArrow.left,
- rcBk.bottom
- );
- PaintSeparator(
- dc,
- rcSeparator,
- true,
- true,
- NULL
- );
- }
- }
- dc.SelectObject( &m_FontMarlett );
- CRect _rcPopupArrow( rcPopupArrow );
- if( bRTL )
- _rcPopupArrow.right -= 2;
- else
- _rcPopupArrow.left += 2;
- dc.SetTextColor( clrPopupArrow );
- dc.DrawText(
- bRTL ? _T("3") : _T("4"),
- _rcPopupArrow,
- DT_CENTER|DT_VCENTER|DT_SINGLELINE
- );
- } // else from if( _pmid.m_bCustomizeListMode )
- } // if( _pmid.m_bPopup )
-
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- // paint icon area
- PaintMenuItemIcon( dc, _pmid );
- // paint inplace control area
- PaintMenuItemInPlaceWnd( dc, _pmid );
- }
- void CExtPaintManagerNativeXP::PaintMenuItemIcon(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- {
- CExtPaintManager::PaintMenuItemIcon(
- dc,
- _pmid
- );
- return;
- }
-
- if( _pmid.m_rcItem.IsRectEmpty() )
- return;
- HWND hWnd = NULL;
- CWnd * pWnd = DYNAMIC_DOWNCAST( CWnd, _pmid.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- hWnd = pWnd->GetSafeHwnd();
- }
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- if( g_PaintManager.m_UxTheme.OpenThemeData( hWnd, VSCLASS_TOOLBAR ) != NULL )
- {
- CSize sizeIcon( __EXT_MENU_ICON_CX, __EXT_MENU_ICON_CY );
- if( _pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()) )
- {
- sizeIcon = _pmid.m_pIcon->GetSize();
- if( sizeIcon.cx <= 18
- && sizeIcon.cy < sizeIcon.cx
- )
- sizeIcon.cy = sizeIcon.cx;
- }
- CRect rcIcon( _pmid.m_rcItem.TopLeft(), sizeIcon );
- if( bRTL )
- rcIcon.OffsetRect( _pmid.m_rcItem.Width() - sizeIcon.cx, 0 );
- if( _pmid.m_bXtraMark )
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth/2 - rcIcon.Width() ) / 2 + _pmid.m_nIconAreaWidth/2 - 2 )
- * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- if( _pmid.m_bXtraChecked )
- {
- CRect rcXtraMark(
- bRTL ? (_pmid.m_rcItem.right - _pmid.m_rcItem.Height() - 1) : (_pmid.m_rcItem.left + 1),
- _pmid.m_rcItem.top + 1,
- bRTL ? (_pmid.m_rcItem.right - 1) : (_pmid.m_rcItem.left + _pmid.m_rcItem.Height() - 1),
- _pmid.m_rcItem.bottom - 1
- );
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- TP_BUTTON,
- _pmid.m_bSelected ? TS_HOTCHECKED : TS_CHECKED,
- &rcXtraMark,
- &rcXtraMark
- ) == S_OK
- );
- COLORREF clrCheck = ::GetSysColor( COLOR_BTNTEXT );
- int x = rcXtraMark.left + rcXtraMark.Width()/2 - 3;
- int y = rcXtraMark.top + rcXtraMark.Height()/2 - 3;
- ASSERT( !_pmid.m_bPushedRadio );
- stat_PaintCheckMark( dc, x, y, clrCheck );
- }
- }
- else
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth - rcIcon.Width() ) / 2 ) * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- }
- CRect rcIconFrame(rcIcon);
- rcIconFrame.InflateRect(
- __EXT_MENU_IMG_RECT_OUT_GAP,
- __EXT_MENU_IMG_RECT_OUT_GAP
- );
- if( _pmid.m_bPushedCheck || _pmid.m_bIndeterminate || _pmid.m_bPushedRadio )
- {
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- TP_BUTTON,
- _pmid.m_bSelected ? TS_HOTCHECKED : ( _pmid.m_bIndeterminate ? TS_PRESSED : TS_CHECKED ),
- &rcIconFrame,
- &rcIconFrame
- ) == S_OK
- );
- if( _pmid.m_pIcon == NULL || _pmid.m_pIcon->IsEmpty() )
- {
- COLORREF clrCheck = ::GetSysColor( COLOR_BTNTEXT );
- int x = rcIcon.left + rcIcon.Width()/2 - 3;
- int y = rcIcon.top + rcIcon.Height()/2 - 3;
- if( _pmid.m_bPushedCheck )
- {
- ASSERT( !_pmid.m_bPushedRadio );
- if( _pmid.m_bIndeterminate )
- stat_PaintIndeterminatedSquare( dc, x, y, clrCheck );
- else
- stat_PaintCheckMark( dc, x, y, clrCheck );
- }
- else
- {
- ASSERT( !_pmid.m_bPushedCheck );
- stat_PaintRadioDot( dc, x, y, clrCheck );
- }
- }
- }
- if( _pmid.m_pIcon != NULL
- && (! _pmid.m_pIcon->IsEmpty())
- )
- {
- if( _pmid.m_bSelected
- && _pmid.m_bEnabled
- && (! ( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio ) )
- )
- {
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- TP_BUTTON,
- TS_HOT,
- &rcIconFrame,
- &rcIconFrame
- ) == S_OK
- );
- }
- _pmid.m_pIcon->Paint(
- this,
- dc,
- rcIcon.left,
- rcIcon.top,
- -1,
- -1,
- _pmid.m_bEnabled
- ? CExtCmdIcon::__PAINT_NORMAL
- : CExtCmdIcon::__PAINT_DISABLED
- );
- }
- else
- {
- PaintSysCmdGlyph(
- dc,
- _pmid.m_nHelperSysCmdID,
- rcIcon,
- _pmid.m_bSelected,
- false,
- _pmid.m_bEnabled
- );
- }
-
- g_PaintManager.m_UxTheme.CloseThemeData();
- }
- }
- void CExtPaintManagerNativeXP::PaintMenuTearOffButton(
- CDC & dc,
- const RECT & rectButton,
- bool bPushed,
- bool bHover,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- if( IsHighContrast() )
- {
- CExtPaintManager::PaintMenuTearOffButton( dc, rectButton, bPushed, bHover, pHelperSrc, lParam );
- return;
- }
- bool bThemedApproachOK = false;
- HWND hWnd = NULL;
- CWnd * pWnd = DYNAMIC_DOWNCAST( CWnd, pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- hWnd = pWnd->GetSafeHwnd();
- }
- if( hWnd != NULL && g_PaintManager.m_UxTheme.OpenThemeData( hWnd, VSCLASS_REBAR ) != NULL )
- {
- CRect rc = rectButton;
- HRESULT hr =
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- RP_BACKGROUND,
- 0,
- &rc,
- &rc
- );
- bThemedApproachOK = ( hr == S_OK ) ? true : false;
- if( bThemedApproachOK )
- {
- rc.DeflateRect( rc.Width() / 8, 2 );
- if( rc.left < rc.right && rc.top < rc.bottom )
- {
- hr =
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- RP_GRIPPER,
- 0,
- &rc,
- &rc
- );
- bThemedApproachOK = ( hr == S_OK ) ? true : false;
- }
- }
- g_PaintManager.m_UxTheme.CloseThemeData();
- }
- if( bThemedApproachOK )
- return;
- CExtPaintManager::PaintMenuTearOffButton( dc, rectButton, bPushed, bHover, pHelperSrc, lParam );
- }
- bool CExtPaintManagerNativeXP::PaintSysCmdGlyph_UX(
- HWND hWnd,
- CDC & dc,
- UINT nHelperSysCmdID,
- const RECT & rcItem,
- bool bHover,
- bool bPushed,
- bool bEnabled,
- COLORREF clrForceGlyphColor // = COLORREF(-1L)
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( g_PaintManager.m_UxTheme.IsControlsThemed() );
- ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
- // ASSERT( g_PaintManager.m_UxTheme.m_hUxTheme != NULL ); // menu class should be already opened
- hWnd;
- bHover;
- bPushed;
- clrForceGlyphColor;
- if( ! ( rcItem.left < rcItem.right && rcItem.top < rcItem.bottom ) )
- return true;
- int nPartID = 0, nStateID = 0;
- switch( nHelperSysCmdID )
- {
- case SC_CLOSE:
- nPartID = MENU_SYSTEMCLOSE;
- nStateID = bEnabled ? MSYSC_NORMAL : MSYSC_DISABLED;
- break;
- case SC_RESTORE:
- nPartID = MENU_SYSTEMRESTORE;
- nStateID = bEnabled ? MSYSR_NORMAL : MSYSR_DISABLED;
- break;
- case SC_MINIMIZE:
- nPartID = MENU_SYSTEMMINIMIZE;
- nStateID = bEnabled ? MSYSMN_NORMAL : MSYSMN_DISABLED;
- break;
- case SC_MAXIMIZE:
- nPartID = MENU_SYSTEMMAXIMIZE;
- nStateID = bEnabled ? MSYSMX_NORMAL : MSYSMX_DISABLED;
- break;
- // case SC_CONTEXTHELP:
- // break;
- default:
- return false;
- } // switch( nHelperSysCmdID )
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- nPartID,
- nStateID,
- &rcItem,
- &rcItem
- ) == S_OK
- );
- return true;
- }
- bool CExtPaintManagerNativeXP::PaintMenuItemIcon_UX(
- HWND hWnd,
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( g_PaintManager.m_UxTheme.IsControlsThemed() );
- ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
- // ASSERT( g_PaintManager.m_UxTheme.m_hUxTheme != NULL ); // menu class should be already opened
- if( _pmid.m_rcItem.IsRectEmpty() )
- return true;
- CSize sizeIcon( __EXT_MENU_ICON_CX, __EXT_MENU_ICON_CY );
- if( _pmid.m_pIcon != NULL && (! _pmid.m_pIcon->IsEmpty()) )
- {
- sizeIcon = _pmid.m_pIcon->GetSize();
- if( sizeIcon.cx <= 18
- && sizeIcon.cy < sizeIcon.cx
- )
- sizeIcon.cy = sizeIcon.cx;
- }
- CRect rcIcon( _pmid.m_rcItem.TopLeft(), sizeIcon );
- CExtPopupMenuWnd * pPopup = NULL;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- pPopup = DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- if( bRTL )
- rcIcon.OffsetRect( _pmid.m_rcItem.Width() - sizeIcon.cx, 0 );
- if( _pmid.m_bXtraMark )
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth/2 - rcIcon.Width() ) / 2 + _pmid.m_nIconAreaWidth/2 - 2 )
- * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- if( _pmid.m_bXtraChecked )
- {
- CRect rcXtraMark(
- bRTL ? (_pmid.m_rcItem.right - _pmid.m_rcItem.Height() - 1) : (_pmid.m_rcItem.left + 1),
- _pmid.m_rcItem.top + 1,
- bRTL ? (_pmid.m_rcItem.right - 1) : (_pmid.m_rcItem.left + _pmid.m_rcItem.Height() - 1),
- _pmid.m_rcItem.bottom - 1
- );
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPCHECKBACKGROUND,
- _pmid.m_bEnabled ? MCB_NORMAL : MCB_DISABLED,
- &rcXtraMark,
- &rcXtraMark
- ) == S_OK
- );
- COLORREF clrCheck = ::GetSysColor( COLOR_BTNTEXT );
- int x = rcXtraMark.left + rcXtraMark.Width()/2 - 3;
- int y = rcXtraMark.top + rcXtraMark.Height()/2 - 3;
- ASSERT( !_pmid.m_bPushedRadio );
- stat_PaintCheckMark( dc, x, y, clrCheck );
- }
- }
- else
- {
- rcIcon.OffsetRect(
- ( ( _pmid.m_nIconAreaWidth - rcIcon.Width() ) / 2 ) * (bRTL ? (-1) : 1),
- ( _pmid.m_rcItem.Height() - rcIcon.Height() ) / 2
- );
- }
- CRect rcIconFrame(rcIcon);
- rcIconFrame.InflateRect(
- __EXT_MENU_IMG_RECT_OUT_GAP,
- __EXT_MENU_IMG_RECT_OUT_GAP
- );
- if( _pmid.m_bPushedCheck || _pmid.m_bIndeterminate || _pmid.m_bPushedRadio )
- {
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPCHECKBACKGROUND,
- _pmid.m_bEnabled ? MCB_NORMAL : MCB_DISABLED,
- &rcIconFrame,
- &rcIconFrame
- ) == S_OK
- );
- if( _pmid.m_pIcon == NULL || _pmid.m_pIcon->IsEmpty() )
- {
- if( ! _pmid.m_bIndeterminate )
- {
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPCHECK,
- _pmid.m_bPushedCheck
- ?
- //( _pmid.m_bIndeterminate
- // ? MC_BULLETDISABLED
- // :
- ( _pmid.m_bEnabled ? MC_CHECKMARKNORMAL : MC_CHECKMARKDISABLED )
- //)
- : ( _pmid.m_bEnabled ? MC_BULLETNORMAL : MC_BULLETDISABLED )
- ,
- &rcIcon,
- &rcIcon
- ) == S_OK
- );
- }
- else
- {
- COLORREF clrCheck = GetColor( CLR_MENUTEXT_OUT, _pmid.m_pHelperSrc, _pmid.m_lParam );
- int x = rcIcon.left + rcIcon.Width()/2 - 3;
- int y = rcIcon.top + rcIcon.Height()/2 - 3;
- stat_PaintIndeterminatedSquare( dc, x, y, clrCheck );
- }
- }
- }
- if( _pmid.m_pIcon != NULL
- && (! _pmid.m_pIcon->IsEmpty())
- )
- {
- if( _pmid.m_bSelected
- && _pmid.m_bEnabled
- && (! ( _pmid.m_bPushedCheck || _pmid.m_bPushedRadio ) )
- )
- {
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- MENU_POPUPCHECKBACKGROUND,
- _pmid.m_bEnabled ? MCB_NORMAL : MCB_DISABLED,
- &rcIconFrame,
- &rcIconFrame
- ) == S_OK
- );
- }
- _pmid.m_pIcon->Paint(
- this,
- dc,
- rcIcon.left,
- rcIcon.top,
- -1,
- -1,
- _pmid.m_bEnabled
- ? CExtCmdIcon::__PAINT_NORMAL
- : CExtCmdIcon::__PAINT_DISABLED
- );
- }
- else
- {
- if( ! PaintSysCmdGlyph_UX(
- hWnd,
- dc,
- _pmid.m_nHelperSysCmdID,
- rcIcon,
- _pmid.m_bSelected,
- false,
- _pmid.m_bEnabled
- )
- )
- PaintSysCmdGlyph(
- dc,
- _pmid.m_nHelperSysCmdID,
- rcIcon,
- _pmid.m_bSelected,
- false,
- _pmid.m_bEnabled
- );
- }
- return true;
- }
- void CExtPaintManagerNativeXP::PaintMenuItemInPlaceWnd(
- CDC & dc,
- CExtPaintManager::PAINTMENUITEMDATA & _pmid
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- {
- CExtPaintManager::PaintMenuItemInPlaceWnd(
- dc,
- _pmid
- );
- return;
- }
-
- if( _pmid.m_rcItem.IsRectEmpty()
- || _pmid.m_rcInPlaceWnd.IsRectEmpty()
- )
- return;
- bool bRTL = false;
- if( _pmid.m_pHelperSrc != NULL )
- {
- ASSERT_VALID( _pmid.m_pHelperSrc );
- CExtPopupMenuWnd * pPopup =
- DYNAMIC_DOWNCAST( CExtPopupMenuWnd, _pmid.m_pHelperSrc );
- if( pPopup != NULL )
- bRTL = pPopup->OnQueryLayoutRTL();
- }
- CRect rcInPlaceWndOuterBorder( _pmid.m_rcInPlaceWnd );
- rcInPlaceWndOuterBorder.InflateRect( 2, 2, 1, 2 );
- INT nDD = GetDropDownButtonWidth( _pmid.m_pHelperSrc, _pmid.m_lParam );
- CRect rcBk( rcInPlaceWndOuterBorder );
- if( _pmid.m_bPopup )
- rcBk.right += nDD;
- dc.FillSolidRect(
- &rcBk,
- ::GetSysColor( _pmid.m_bEnabled ? COLOR_WINDOW : COLOR_3DFACE )
- );
- if( _pmid.m_bPopup )
- {
- rcInPlaceWndOuterBorder.right += nDD;
- if( _pmid.m_bEnabled )
- {
- PAINTCOMBOFRAMEDATA _pcfd(
- _pmid.m_pHelperSrc,
- rcInPlaceWndOuterBorder,
- _pmid.m_bSelected, // hover
- _pmid.m_bSelected && _pmid.m_bHelperPopupDropped, // pushed
- _pmid.m_bEnabled
- );
- _pcfd.m_bNoTopOuterBorder = true;
- PaintComboFrame( dc, _pcfd );
- }
- else
- {
- CRect rcBorder( rcInPlaceWndOuterBorder );
- rcBorder.DeflateRect( 2, 2 );
- COLORREF clrBorder = ::GetSysColor( COLOR_WINDOW );
- dc.Draw3dRect(
- &rcBorder,
- clrBorder,
- clrBorder
- );
- // paint arrow down
- CRect rcBtn( rcBorder );
- rcBtn.left = rcBtn.right - nDD;
- glyph_t * pGlyph = g_DockingCaptionGlyphs[ __DCBT_ARROW_SMALL_DOWN ];
- ASSERT( pGlyph != NULL );
- COLORREF ColorValues[2] =
- {
- RGB(0,0,0),
- ::GetSysColor( COLOR_BTNTEXT )
- };
- PaintGlyphCentered(
- dc,
- rcBtn,
- *pGlyph,
- ColorValues
- );
- } // else from if( _pmid.m_bEnabled )
- rcInPlaceWndOuterBorder.DeflateRect( 1, 1 );
- rcInPlaceWndOuterBorder.right -= nDD;
- } // if( _pmid.m_bPopup )
- else
- {
- if( _pmid.m_bEnabled )
- {
- CRect rcItem( rcInPlaceWndOuterBorder );
- rcItem.DeflateRect(3,3);
- PAINTCONTROLFRAMEDATA _pcfd(
- _pmid.m_pHelperSrc,
- rcItem,
- true,
- _pmid.m_bSelected,
- _pmid.m_bEnabled,
- false,
- false
- );
- PaintControlFrame( dc, _pcfd );
- }
- else
- {
- CRect rcBorder( rcInPlaceWndOuterBorder );
- rcBorder.DeflateRect( 2, 2 );
- COLORREF clrBorder = ::GetSysColor( COLOR_WINDOW );
- dc.Draw3dRect(
- &rcBorder,
- clrBorder,
- clrBorder
- );
- }
- } // else from if( _pmid.m_bPopup )
- if( !_pmid.m_strInPlaceText.IsEmpty() )
- {
- rcInPlaceWndOuterBorder.DeflateRect( 5, 2, 2, 2 );
-
- COLORREF clrOldText =
- dc.SetTextColor(
- GetColor(
- _pmid.m_bEnabled
- ? COLOR_WINDOWTEXT
- : COLOR_3DSHADOW,
- _pmid.m_pHelperSrc,
- _pmid.m_lParam
- )
- );
-
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
-
- CFont * pRenderFont =
- ( _pmid.m_hCustomFont == NULL )
- ? (&m_FontNormal)
- : CFont::FromHandle(_pmid.m_hCustomFont)
- ;
- CFont * pOldFont = dc.SelectObject( pRenderFont );
- ASSERT( pOldFont != NULL );
-
- DWORD dwDtAlignFlags = bRTL ? (DT_RIGHT|DT_RTLREADING) : DT_LEFT;
- dc.DrawText(
- _pmid.m_strInPlaceText,
- _pmid.m_strInPlaceText.GetLength(),
- &rcInPlaceWndOuterBorder,
- DT_SINGLELINE|DT_NOPREFIX|DT_TOP|dwDtAlignFlags
- );
- dc.SelectObject( pOldFont );
- dc.SetBkMode( nOldBkMode );
- dc.SetTextColor( clrOldText );
- }
- }
- CSize CExtPaintManager::GetToolBarButtonOffset( BOOL bHorz ) const
- {
- ASSERT_VALID( this );
- bHorz;
- return
- CSize(
- 0, // bHorz ? 0 : 1,
- 0
- );
- }
- CSize CExtPaintManagerOffice2003::GetToolBarButtonOffset( BOOL bHorz ) const
- {
- ASSERT_VALID( this );
- if( IsHighContrast() )
- return CExtPaintManagerXP::GetToolBarButtonOffset( bHorz );
- return
- CSize( 0, bHorz ? -1 : 0 );
- }
- void CExtPaintManager::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;
- 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->PaintAccentEmboss(
- 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;
- }
- void CExtPaintManagerOffice2003::PaintSeparator(
- CDC & dc,
- const RECT & rectItem,
- bool bHorz,
- bool bTransparentBk,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManagerXP::PaintSeparator(
- dc,
- rectItem,
- bHorz,
- bTransparentBk,
- pHelperSrc,
- lParam
- );
- return;
- }
- if( pHelperSrc == NULL
- || (!( pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtToolControlBar))
- || pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtBarButton))
- #ifndef __EXT_MFC_NO_STATUSBAR
- || pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtStatusControlBar))
- #endif // __EXT_MFC_NO_STATUSBAR
- ))
- || ::GetDeviceCaps( dc.m_hDC, BITSPIXEL ) <= 8
- )
- {
- CExtPaintManagerXP::PaintSeparator(
- dc,
- rectItem,
- bHorz,
- bTransparentBk,
- pHelperSrc,
- lParam
- );
- return;
- }
- CRect rectItem2(rectItem);
- if( !bTransparentBk )
- dc.FillSolidRect(
- rectItem2,
- GetColor( CLR_3DFACE_OUT, pHelperSrc, lParam )
- );
- COLORREF clrBtnShadow = GetColor( _2003CLR_SEPARATOR_DARK, pHelperSrc, lParam );
- COLORREF clrBtnHilight = GetColor( _2003CLR_SEPARATOR_LIGHT, pHelperSrc, lParam );
- if( bHorz )
- {
- int x = (rectItem2.left + rectItem2.right) / 2;
- rectItem2.left = x-1; rectItem2.right = x+1;
- if( pHelperSrc == NULL
- #ifndef __EXT_MFC_NO_STATUSBAR
- || (! pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtStatusControlBar)) )
- #endif // __EXT_MFC_NO_STATUSBAR
- )
- rectItem2.DeflateRect( 0, 2, 0, 2 );
- dc.Draw3dRect(
- rectItem2,
- clrBtnShadow,
- clrBtnHilight
- );
- } // if( bHorz )
- else
- {
- int y = (rectItem2.top+rectItem2.bottom)/2;
- rectItem2.top = y-1; rectItem2.bottom = y+1;
- if( pHelperSrc == NULL
- #ifndef __EXT_MFC_NO_STATUSBAR
- || (! pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtStatusControlBar)) )
- #endif // __EXT_MFC_NO_STATUSBAR
- )
- rectItem2.DeflateRect( 3, 0, 3, 0 );
- dc.Draw3dRect(
- rectItem2,
- clrBtnShadow,
- clrBtnHilight
- );
- } // else from if( bHorz )
- }
- void CExtPaintManagerStudio2005::PaintSeparator(
- CDC & dc,
- const RECT & rectItem,
- bool bHorz,
- bool bTransparentBk,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManagerOffice2003::PaintSeparator(
- dc,
- rectItem,
- bHorz,
- bTransparentBk,
- pHelperSrc,
- lParam
- );
- return;
- }
- if( pHelperSrc == NULL
- || (! pHelperSrc->IsKindOf(RUNTIME_CLASS(CExtToolControlBar)) )
- || ::GetDeviceCaps( dc.m_hDC, BITSPIXEL ) <= 8
- )
- {
- CExtPaintManagerOffice2003::PaintSeparator(
- dc,
- rectItem,
- bHorz,
- bTransparentBk,
- pHelperSrc,
- lParam
- );
- return;
- }
- CRect rectItem2(rectItem);
- if( !bTransparentBk )
- dc.FillSolidRect(
- rectItem2,
- GetColor( CLR_3DFACE_OUT, pHelperSrc, lParam )
- );
- COLORREF clrSeparator =
- CExtBitmap::stat_RGB_Blend(
- GetColor( COLOR_3DFACE, pHelperSrc, lParam ),
- GetColor( COLOR_3DSHADOW, pHelperSrc, lParam ),
- 144
- );
- CPen _pen( PS_SOLID, 1, clrSeparator );
- CPen * pOldPen = dc.SelectObject( &_pen );
- if( bHorz )
- {
- rectItem2.DeflateRect( 0, 1 );
- int x = ( rectItem2.left + rectItem2.right ) / 2;
- dc.MoveTo( x, rectItem2.top );
- dc.LineTo( x, rectItem2.bottom );
- }
- else
- {
- rectItem2.DeflateRect( 1, 0, 3, 0 );
- int y = ( rectItem2.top + rectItem2.bottom ) / 2;
- dc.MoveTo( rectItem2.left, y );
- dc.LineTo( rectItem2.right, y );
- } // else from if( bHorz )
- dc.SelectObject( pOldPen );
- }
- void CExtPaintManagerXP::PaintSeparator(
- CDC & dc,
- const RECT & rectItem,
- bool bHorz,
- bool bTransparentBk,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CRect rectItem2(rectItem);
- if( !bTransparentBk )
- dc.FillSolidRect(
- rectItem2,
- GetColor( CLR_3DFACE_OUT, pHelperSrc, lParam )
- );
- if( bHorz )
- {
- rectItem2.left =
- rectItem2.left + rectItem2.Width()/2 - 1;
- rectItem2.right =
- rectItem2.left + 1;
- rectItem2.DeflateRect( 0, 1 );
- }
- else
- {
- rectItem2.top =
- rectItem2.top + rectItem2.Height()/2 - 1;
- rectItem2.bottom =
- rectItem2.top + 1;
- rectItem2.DeflateRect( 1, 0 );
- }
- dc.FillSolidRect(
- &rectItem2,
- GetColor( XPCLR_SEPARATOR, pHelperSrc, lParam )
- );
- }
- void CExtPaintManager::PaintSeparator(
- CDC & dc,
- const RECT & rectItem,
- bool bHorz,
- bool bTransparentBk,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CRect rectItem2(rectItem);
- if( !bTransparentBk )
- dc.FillSolidRect(
- rectItem2,
- GetColor( CLR_3DFACE_OUT, pHelperSrc, lParam )
- );
- COLORREF clrBtnShadow = GetColor( CLR_3DSHADOW_OUT, pHelperSrc, lParam );
- COLORREF clrBtnHilight = GetColor( CLR_3DHILIGHT_OUT, pHelperSrc, lParam );
- if( bHorz )
- {
- int x = (rectItem2.left + rectItem2.right) / 2;
- rectItem2.left = x-1; rectItem2.right = x+1;
- rectItem2.DeflateRect( 0, 0, 0, 1 );
- dc.Draw3dRect(
- rectItem2,
- clrBtnShadow,
- clrBtnHilight
- );
- } // if( bHorz )
- else
- {
- int y = (rectItem2.top+rectItem2.bottom)/2;
- rectItem2.top = y-1; rectItem2.bottom = y+1;
- rectItem2.DeflateRect( 0, 0, 1, 0 );
- dc.Draw3dRect(
- rectItem2,
- clrBtnShadow,
- clrBtnHilight
- );
- } // else from if( bHorz )
- }
- void CExtPaintManagerNativeXP::PaintSeparator(
- CDC & dc,
- const RECT & rectItem,
- bool bHorz,
- bool bTransparentBk,
- CObject * pHelperSrc,
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- {
- CExtPaintManager::PaintSeparator(
- dc,
- rectItem,
- bHorz,
- bTransparentBk,
- pHelperSrc,
- lParam
- );
- return;
- } // if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- HWND hWnd = NULL;
- CWnd * pWnd =
- DYNAMIC_DOWNCAST(
- CWnd,
- pHelperSrc
- );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- hWnd = pWnd->GetSafeHwnd();
- }
- if( g_PaintManager.m_UxTheme.OpenThemeData( hWnd, VSCLASS_TOOLBAR ) != NULL )
- {
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- bHorz ? TP_SEPARATOR : TP_SEPARATORVERT,
- TS_NORMAL,
- &rectItem,
- &rectItem
- ) == S_OK
- );
- g_PaintManager.m_UxTheme.CloseThemeData();
- }
- }
- CExtPaintManager::PAINTCONTROLFRAMEDATA::PAINTCONTROLFRAMEDATA()
- : m_pHelperSrc( NULL )
- , m_lParam( 0L )
- , m_rcClient( 0,0,0,0 )
- , m_bFlat( false )
- , m_bHover( false )
- , m_bEnabled( false )
- , m_bFocus( false )
- , m_bReadOnly( false )
- {
- }
- CExtPaintManager::PAINTCONTROLFRAMEDATA::PAINTCONTROLFRAMEDATA(
- CObject * pHelperSrc,
- const RECT & rcClient,
- bool bFlat,
- bool bHover,
- bool bEnabled,
- bool bFocus,
- bool bReadOnly
- )
- : m_pHelperSrc( pHelperSrc )
- , m_lParam( 0L )
- , m_rcClient( rcClient )
- , m_bFlat( bFlat )
- , m_bHover( bHover )
- , m_bEnabled( bEnabled )
- , m_bFocus( bFocus )
- , m_bReadOnly( bReadOnly )
- {
- }
- void CExtPaintManager::PaintControlFrame(
- CDC & dc,
- CExtPaintManager::PAINTCONTROLFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- COLORREF clrForceInner = COLORREF( -1L );
- COLORREF clrForceOuter = COLORREF( -1L );
- if( _pcfd.m_pHelperSrc != NULL )
- {
- #ifndef __EXT_MFC_NO_DURATIONWND
- if( _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtDurationWnd ) ) )
- {
- CExtDurationWnd * pWnd = DYNAMIC_DOWNCAST( CExtDurationWnd, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- clrForceInner = pWnd->GetBkColor();
- }
- }
- #endif // __EXT_MFC_NO_DURATIONWND
- if( _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtEdit ) ) )
- {
- CExtEdit * pWnd = DYNAMIC_DOWNCAST( CExtEdit, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- clrForceInner = pWnd->GetBkColor();
- CWnd * pWndParent = pWnd->GetParent();
- if( pWndParent != NULL )
- {
- ASSERT_VALID( pWndParent );
- if( pWndParent->IsKindOf( RUNTIME_CLASS( CExtResizableDialog ) ) )
- {
- CExtResizableDialog * pDlg = DYNAMIC_DOWNCAST( CExtResizableDialog, pWndParent );
- if( pDlg != NULL )
- clrForceOuter = pDlg->GetBkColor();
- }
- else if( pWndParent->IsKindOf( RUNTIME_CLASS( CDialog ) ) )
- {
- clrForceOuter = ::GetSysColor( COLOR_3DFACE );
- }
- }
- }
- }
- } // if( _pcfd.m_pHelperSrc != NULL )
- COLORREF clrInner =
- ( clrForceInner != COLORREF( -1L ) )
- ? clrForceInner
- : GetColor( COLOR_WINDOW, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- COLORREF clrIn1, clrIn2;
- clrIn1 = clrIn2 = GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- COLORREF clrOut1, clrOut2;
- clrOut1 = clrOut2 =
- ( clrForceOuter != COLORREF( -1L ) )
- ? clrForceOuter
- : GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam )
- ;
- if( _pcfd.m_bEnabled )
- {
- if( _pcfd.m_bHover && _pcfd.m_bFocus )
- {
- clrIn1 = GetColor( COLOR_3DFACE, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- clrIn2 = GetColor( COLOR_3DDKSHADOW, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- clrOut1 = GetColor( COLOR_3DHILIGHT, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- clrOut2 = GetColor( COLOR_3DSHADOW, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- }
- else
- {
- if( _pcfd.m_bHover || _pcfd.m_bFocus )
- {
- clrIn1 = GetColor( COLOR_3DHILIGHT, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- clrIn2 = GetColor( COLOR_3DSHADOW, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- }
- else
- clrIn1 = clrIn2 =
- dc.GetNearestColor(
- stat_HLS_Adjust(
- GetColor( COLOR_3DFACE, _pcfd.m_pHelperSrc, _pcfd.m_lParam ),
- 0.0, -0.1, 0.0
- )
- );
- }
- }
- CRect rectItem( _pcfd.m_rcClient );
- rectItem.DeflateRect( 1, 1 );
- dc.Draw3dRect( rectItem, clrInner, clrInner );
- if( ! (_pcfd.m_bHover || _pcfd.m_bFocus ) )
- rectItem.InflateRect( 1, 1 );
- dc.Draw3dRect( rectItem, clrIn2, clrIn1 );
- rectItem.InflateRect( 1, 1 );
- dc.Draw3dRect( rectItem, clrOut2, clrOut1 );
- }
- void CExtPaintManagerXP::PaintControlFrame(
- CDC & dc,
- CExtPaintManager::PAINTCONTROLFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- COLORREF clrForceInner = COLORREF( -1L );
- COLORREF clrForceOuter = COLORREF( -1L );
- if( _pcfd.m_pHelperSrc != NULL )
- {
- #ifndef __EXT_MFC_NO_DURATIONWND
- if( _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtDurationWnd ) ) )
- {
- CExtDurationWnd * pWnd = DYNAMIC_DOWNCAST( CExtDurationWnd, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- clrForceInner = pWnd->GetBkColor();
- }
- }
- #endif // __EXT_MFC_NO_DURATIONWND
- if( _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtEdit ) ) )
- {
- CExtEdit * pWnd = DYNAMIC_DOWNCAST( CExtEdit, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- clrForceInner = pWnd->GetBkColor();
- CWnd * pWndParent = pWnd->GetParent();
- if( pWndParent != NULL )
- {
- ASSERT_VALID( pWndParent );
- if( pWndParent->IsKindOf( RUNTIME_CLASS( CExtResizableDialog ) ) )
- {
- CExtResizableDialog * pDlg = DYNAMIC_DOWNCAST( CExtResizableDialog, pWndParent );
- if( pDlg != NULL )
- clrForceOuter = pDlg->GetBkColor();
- }
- else if( pWndParent->IsKindOf( RUNTIME_CLASS( CDialog ) ) )
- {
- clrForceOuter = ::GetSysColor( COLOR_3DFACE );
- }
- }
- }
- }
- } // if( _pcfd.m_pHelperSrc != NULL )
- COLORREF clrInner =
- ( clrForceInner != COLORREF( -1L ) )
- ? clrForceInner
- : GetColor( COLOR_WINDOW, _pcfd.m_pHelperSrc, _pcfd.m_lParam )
- ;
- COLORREF clrIn =
- GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- COLORREF clrOut =
- ( clrForceOuter != COLORREF( -1L ) )
- ? clrForceOuter
- : GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam )
- ;
- if( _pcfd.m_bEnabled )
- {
- if( _pcfd.m_bHover )
- {
- if( _pcfd.m_bFocus )
- clrIn = clrOut = GetColor( XPCLR_HILIGHT_BORDER, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- else
- clrIn = GetColor( XPCLR_HILIGHT_BORDER, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- } // if( _pcfd.m_bHover )
- else
- {
- if( _pcfd.m_bFocus )
- clrIn = GetColor( XPCLR_HILIGHT_BORDER, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- else
- clrIn = dc.GetNearestColor( stat_HLS_Adjust( clrIn, 0.0, -0.1, 0.0 ) );
- } // else from if( _pcfd.m_bHover )
- } // else from if( _pcfd.m_bEnabled )
- CRect rectItem( _pcfd.m_rcClient );
- rectItem.DeflateRect( 1, 1 );
- dc.Draw3dRect( rectItem, clrInner, clrInner );
- if( !(_pcfd.m_bHover || _pcfd.m_bFocus) )
- rectItem.InflateRect( 1, 1 );
- dc.Draw3dRect( rectItem, clrIn, clrIn );
- rectItem.InflateRect( 1, 1 );
- dc.Draw3dRect( rectItem, clrOut, clrOut );
- }
- void CExtPaintManagerOffice2003::PaintControlFrame(
- CDC & dc,
- CExtPaintManager::PAINTCONTROLFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( IsHighContrast() )
- {
- CExtPaintManagerXP::PaintControlFrame( dc, _pcfd );
- return;
- }
- CRect rcItem( _pcfd.m_rcClient );
- CRect rcClip( _pcfd.m_rcClient );
- rcClip.DeflateRect(1,1);
- if( _pcfd.m_bHover || _pcfd.m_bFocus )
- rcClip.DeflateRect(1,1);
- COLORREF clrForceInner = COLORREF( -1L );
- COLORREF clrForceOuter = COLORREF( -1L );
- if( _pcfd.m_pHelperSrc != NULL )
- {
- #ifndef __EXT_MFC_NO_DURATIONWND
- if( _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtDurationWnd ) ) )
- {
- CExtDurationWnd * pWnd = DYNAMIC_DOWNCAST( CExtDurationWnd, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- clrForceInner = pWnd->GetBkColor();
- }
- }
- #endif // __EXT_MFC_NO_DURATIONWND
- if( _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtEdit ) ) )
- {
- CExtEdit * pWnd = DYNAMIC_DOWNCAST( CExtEdit, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- clrForceInner = pWnd->GetBkColor();
- CWnd * pWndParent = pWnd->GetParent();
- if( pWndParent != NULL )
- {
- ASSERT_VALID( pWndParent );
- if( pWndParent->IsKindOf( RUNTIME_CLASS( CExtResizableDialog ) ) )
- {
- CExtResizableDialog * pDlg = DYNAMIC_DOWNCAST( CExtResizableDialog, pWndParent );
- if( pDlg != NULL )
- clrForceOuter = pDlg->GetBkColor();
- }
- else if( pWndParent->IsKindOf( RUNTIME_CLASS( CDialog ) ) )
- {
- clrForceOuter = ::GetSysColor( COLOR_3DFACE );
- }
- }
- }
- }
- } // if( _pcfd.m_pHelperSrc != NULL )
- COLORREF clrInner =
- ( clrForceInner != COLORREF( -1L ) )
- ? clrForceInner
- : GetColor( COLOR_WINDOW, _pcfd.m_pHelperSrc, _pcfd.m_lParam )
- ;
- COLORREF clrIn =
- GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- COLORREF clrOut =
- ( clrForceOuter != COLORREF( -1L ) )
- ? clrForceOuter
- : COLORREF( -1L ) // GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- ;
- if( _pcfd.m_bEnabled )
- {
- rcClip.InflateRect( 1, 1 );
- if( _pcfd.m_bHover )
- {
- clrIn = GetColor( XPCLR_HILIGHT_BORDER, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- if( _pcfd.m_bFocus )
- {
- rcClip.InflateRect( 1, 1 );
- clrOut = GetColor( XPCLR_HILIGHT_BORDER, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- }
- } // if( _pcfd.m_bHover )
- else
- {
- if( _pcfd.m_bFocus )
- clrIn = GetColor( XPCLR_HILIGHT_BORDER, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- else
- clrIn = dc.GetNearestColor( stat_HLS_Adjust( clrIn, 0.0, -0.1, 0.0 ) );
- } // else from if( _pcfd.m_bHover )
- } // else from if( _pcfd.m_bEnabled )
- rcItem.DeflateRect( 1, 1 );
- dc.Draw3dRect( rcItem, clrInner, clrInner );
- if( !(_pcfd.m_bHover || _pcfd.m_bFocus) )
- rcItem.InflateRect( 1, 1 );
- dc.Draw3dRect( rcItem, clrIn, clrIn );
- rcItem.InflateRect( 1, 1 );
- dc.Draw3dRect( rcItem, clrOut, clrOut );
- if( clrOut != COLORREF( -1L ) )
- rcClip.InflateRect(1,1);
- CWnd * pWnd = DYNAMIC_DOWNCAST( CWnd, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- dc.ExcludeClipRect( &rcClip );
- PaintDockerBkgnd( true, dc, pWnd );
- dc.SelectClipRgn( NULL );
- }
- }
- void CExtPaintManagerNativeXP::PaintControlFrame(
- CDC & dc,
- CExtPaintManager::PAINTCONTROLFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- {
- CExtPaintManager::PaintControlFrame( dc, _pcfd );
- return;
- } // if( ! g_PaintManager.m_UxTheme.IsControlsThemed() )
- HWND hWnd = NULL;
- CWnd * pWnd = DYNAMIC_DOWNCAST( CWnd, _pcfd.m_pHelperSrc );
- if( pWnd != NULL )
- {
- ASSERT_VALID( pWnd );
- hWnd = pWnd->GetSafeHwnd();
- }
- if( g_PaintManager.m_UxTheme.OpenThemeData( hWnd, VSCLASS_EDIT ) != NULL )
- {
- CRect rcItem( _pcfd.m_rcClient );
- INT nStateID =
- (!_pcfd.m_bEnabled)
- ? ETS_DISABLED
- : _pcfd.m_bReadOnly
- ? ETS_READONLY
- : _pcfd.m_bFocus
- ? ETS_FOCUSED
- : _pcfd.m_bHover
- ? ETS_HOT
- : ETS_NORMAL;
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- EP_EDITTEXT,
- nStateID,
- &rcItem,
- &rcItem
- ) == S_OK
- );
- g_PaintManager.m_UxTheme.CloseThemeData();
- }
- }
- CExtPaintManager::PAINTCOMBOFRAMEDATA::PAINTCOMBOFRAMEDATA()
- : m_pHelperSrc( NULL )
- , m_lParam( 0L )
- , m_rcClient( 0,0,0,0 )
- , m_bHover( false )
- , m_bPushed( false )
- , m_bEnabled( false )
- , m_clrForceNABorder( COLORREF(-1L) )
- , m_clrForceNAContent( COLORREF(-1L) )
- , m_clrForceActiveOuterBorder( COLORREF(-1L) )
- , m_bNoTopOuterBorder( false )
- , m_bRightText( false )
- {
- }
- CExtPaintManager::PAINTCOMBOFRAMEDATA::PAINTCOMBOFRAMEDATA(
- CObject * pHelperSrc,
- const RECT & rcClient,
- bool bHover,
- bool bPushed,
- bool bEnabled,
- bool bRightText // = false
- )
- : m_pHelperSrc( pHelperSrc )
- , m_lParam( 0L )
- , m_rcClient( rcClient )
- , m_bHover( bHover )
- , m_bPushed( bPushed )
- , m_bEnabled( bEnabled )
- , m_clrForceNABorder( COLORREF(-1L) )
- , m_clrForceNAContent( COLORREF(-1L) )
- , m_clrForceActiveOuterBorder( COLORREF(-1L) )
- , m_bNoTopOuterBorder( false )
- , m_bRightText( bRightText )
- {
- }
- void CExtPaintManager::PaintComboFrame(
- CDC & dc,
- CExtPaintManager::PAINTCOMBOFRAMEDATA & _pcfd
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CExtComboBoxBase * pWndCombo = NULL;
- if( _pcfd.m_pHelperSrc != NULL
- && _pcfd.m_pHelperSrc->IsKindOf( RUNTIME_CLASS( CExtComboBoxBase ) )
- )
- {
- pWndCombo = STATIC_DOWNCAST( CExtComboBoxBase, _pcfd.m_pHelperSrc );
- ASSERT_VALID( pWndCombo );
- }
- COLORREF clrHilightOut =
- ( _pcfd.m_clrForceNABorder == COLORREF(-1L) || _pcfd.m_bPushed || _pcfd.m_bHover )
- ? GetColor( CLR_3DHILIGHT_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam )
- : _pcfd.m_clrForceNABorder
- ;
- COLORREF clrFaceOut =
- ( _pcfd.m_clrForceNABorder == COLORREF(-1L) || _pcfd.m_bPushed || _pcfd.m_bHover )
- ? GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam )
- : _pcfd.m_clrForceNABorder
- ;
- COLORREF clrTopLeft, clrBottomRight;
- if( _pcfd.m_clrForceNAContent == COLORREF(-1L) )
- {
- clrTopLeft = clrBottomRight = clrFaceOut;
- clrFaceOut = dc.GetNearestColor( stat_HLS_Adjust( GetColor( CLR_3DFACE_OUT, _pcfd.m_pHelperSrc, _pcfd.m_lParam ), 0.0, -0.1, 0.0 ) );
- }
- else
- clrTopLeft = clrBottomRight = _pcfd.m_clrForceNAContent;
- if( _pcfd.m_bPushed || _pcfd.m_bHover )
- {
- clrTopLeft = GetColor( CLR_3DSHADOW_IN, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- clrBottomRight = GetColor( CLR_3DHILIGHT_IN, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- }
- COLORREF clrWindow = COLORREF( -1L );
- if( _pcfd.m_clrForceNABorder == COLORREF(-1L)
- || _pcfd.m_bPushed
- || _pcfd.m_bHover
- )
- {
- if( pWndCombo != NULL )
- clrWindow = pWndCombo->GetBkColor();
- if( clrWindow == COLORREF(-1L) )
- {
- COLORREF clrSysBk = GetColor( _pcfd.m_bEnabled ? COLOR_WINDOW : COLOR_3DFACE, _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- clrWindow = clrSysBk;
- }
- }
- else
- clrWindow = _pcfd.m_clrForceNABorder;
- CRect rectClient( _pcfd.m_rcClient );
- dc.Draw3dRect( &rectClient, clrTopLeft, clrBottomRight );
- rectClient.DeflateRect(1,1);
- dc.Draw3dRect(
- &rectClient,
- _pcfd.m_bEnabled ? clrFaceOut : clrHilightOut,
- _pcfd.m_bEnabled ? clrFaceOut : clrHilightOut
- );
- INT nDD = GetDropDownButtonWidth( _pcfd.m_pHelperSrc, _pcfd.m_lParam );
- CRect rcDDButton( rectClient );
- if( _pcfd.m_bRightText )
- rcDDButton.right = rcDDButton.left + nDD;
- else
- rcDDButton.left = rcDDButton.right - nDD;
- if( _pcfd.m_bHover || _pcfd.m_bPushed )
- dc.Draw3dRect( &rcDDButton, clrFaceOut, clrFaceOut );
- rcDDButton.DeflateRect(1,1);
- PAINTPUSHBUTTONDATA _ppbd(
- _pcfd.m_pHelperSrc,
- true,
- rcDDButton,
- NULL,
- NULL,
- true,
- ( _pcfd.m_bHover && (!_pcfd.m_bPushed) ) ? true : false,
- _pcfd.m_bPushed ? true : false,
- false,
- _pcfd.m_bEnabled,
- true,
- false,
- false,
- 0,
- NULL
- );
- PaintPushButton( dc, _ppbd );
- if( !(_pcfd.m_bHover || _pcfd.m_bPushed) )
- dc.Draw3dRect( &rcDDButton, clrWindow, clrWindow );
- CRect rcDDButtonGlyph( rcDDButton );
- if( _pcfd.m_bPushed )
- rcDDButtonGlyph.OffsetRect( 1, 1 );
- // paint arrow down
- glyph_t* pGlyph = g_DockingCaptionGlyphs[ __DCBT_ARROW_SMALL_DOWN ];
- ASSERT( pGlyph != NULL );
- COLORREF ColorValues[2] = { RGB(0,0,0), ::GetSysColor( COLOR_BTNTEXT ) };
- PaintGlyphCentered( dc, rcDDButtonGlyph, *pGlyph, ColorValues );
- }
- #if (!defined __EXT_MFC_NO_TAB_CTRL)
- void CExtPaintManager::GetThemeAccentTabColors(
- COLORREF * pClrSetectedTabItemText,
- COLORREF * pClrSetectedTabItemFace, // = NULL
- COLORREF * pClrSetectedTabItemBorderLight, // = NULL
- COLORREF * pClrSetectedTabItemBorderDark, // = NULL
- CObject * pHelperSrc, // = NULL
- LPARAM lParam // = 0L
- )
- {
- ASSERT_VALID( this );
- if( pClrSetectedTabItemText != NULL )
- (*pClrSetectedTabItemText) = GetColor( COLOR_BTNTEXT, pHelperSrc, lParam );
- if( pClrSetectedTabItemFace != NULL )
- (*pClrSetectedTabItemFace) = GetColor( CLR_3DFACE_OUT, pHelperSrc, lParam );
- if( pClrSetectedTabItemBorderLight != NULL )
- (*pClrSetectedTabItemBorderLight) = GetColor( COLOR_3DHILIGHT, pHelperSrc, lParam );
- if( pClrSetectedTabItemBorderDark != NULL )
- (*pClrSetectedTabItemBorderDark) = GetColor( COLOR_3DDKSHADOW, pHelperSrc, lParam );
- }
- void CExtPaintManager::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)