ExtPaintManager2.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:328k
- }
- if( hWnd == NULL )
- hWnd = ::GetDesktopWindow();
- if( hWnd != NULL )
- {
- bool bVistaThemeMode =
- ( g_PaintManager.m_bIsWinVistaOrLater
- && g_PaintManager.m_UxTheme.IsControlsThemed()
- ) ? true : false;
- if( g_PaintManager.m_UxTheme.OpenThemeData( hWnd, VSCLASS_SCROLLBAR ) != NULL )
- {
- if( (! m_rcButtonUp.IsRectEmpty() )
- && dc.RectVisible( &m_rcButtonUp )
- )
- {
- INT nStateID = 0;
- if( m_bHorzBar )
- {
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_BUTTON_UP )
- nStateID =
- m_bHoveredAreaIsPressed
- ? ABS_LEFTPRESSED
- : ABS_LEFTHOT
- ;
- else
- nStateID =
- ( bVistaThemeMode && m_eSBMHT != __ESBMHT_NOWHERE )
- ? ABS_LEFTHOVER
- : ABS_LEFTNORMAL
- ;
- }
- else
- nStateID = ABS_LEFTDISABLED;
- }
- else
- {
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_BUTTON_UP )
- nStateID =
- m_bHoveredAreaIsPressed
- ? ABS_UPPRESSED
- : ABS_UPHOT
- ;
- else
- nStateID =
- ( bVistaThemeMode && m_eSBMHT != __ESBMHT_NOWHERE )
- ? ABS_UPHOVER
- : ABS_UPNORMAL
- ;
- }
- else
- nStateID = ABS_UPDISABLED;
- }
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- SBP_ARROWBTN,
- nStateID,
- &m_rcButtonUp,
- &m_rcButtonUp
- ) == S_OK
- );
- }
- if( (! m_rcButtonDown.IsRectEmpty() )
- && dc.RectVisible( &m_rcButtonDown )
- )
- {
- INT nStateID = 0;
- if( m_bHorzBar )
- {
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_BUTTON_DOWN )
- nStateID =
- m_bHoveredAreaIsPressed
- ? ABS_RIGHTPRESSED
- : ABS_RIGHTHOT
- ;
- else
- nStateID =
- ( bVistaThemeMode && m_eSBMHT != __ESBMHT_NOWHERE )
- ? ABS_RIGHTHOVER
- : ABS_RIGHTNORMAL
- ;
- }
- else
- nStateID = ABS_RIGHTDISABLED;
- }
- else
- {
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_BUTTON_DOWN )
- nStateID =
- m_bHoveredAreaIsPressed
- ? ABS_DOWNPRESSED
- : ABS_DOWNHOT
- ;
- else
- nStateID =
- ( bVistaThemeMode && m_eSBMHT != __ESBMHT_NOWHERE )
- ? ABS_DOWNHOVER
- : ABS_DOWNNORMAL
- ;
- }
- else
- nStateID = ABS_DOWNDISABLED;
- }
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- SBP_ARROWBTN,
- nStateID,
- &m_rcButtonDown,
- &m_rcButtonDown
- ) == S_OK
- );
- }
- if( (! m_rcPageDown.IsRectEmpty() )
- && dc.RectVisible( &m_rcPageDown )
- )
- {
- INT nPartID =
- m_bHorzBar
- ? SBP_LOWERTRACKHORZ
- : SBP_LOWERTRACKVERT
- ;
- INT nStateID = 0;
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_PAGE_DOWN )
- nStateID =
- m_bHoveredAreaIsPressed
- ? SCRBS_PRESSED
- : SCRBS_HOT
- ;
- else
- nStateID = SCRBS_NORMAL;
- }
- else
- nStateID = SCRBS_DISABLED;
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- nPartID,
- nStateID,
- &m_rcPageDown,
- &m_rcPageDown
- ) == S_OK
- );
- }
- if( (! m_rcPageUp.IsRectEmpty() )
- && dc.RectVisible( &m_rcPageUp )
- )
- {
- INT nPartID =
- m_bHorzBar
- ? SBP_UPPERTRACKHORZ
- : SBP_UPPERTRACKVERT
- ;
- INT nStateID = 0;
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_PAGE_UP )
- nStateID =
- m_bHoveredAreaIsPressed
- ? SCRBS_PRESSED
- : SCRBS_HOT
- ;
- else
- nStateID = SCRBS_NORMAL;
- }
- else
- nStateID = SCRBS_DISABLED;
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- nPartID,
- nStateID,
- &m_rcPageUp,
- &m_rcPageUp
- ) == S_OK
- );
- }
- if( (! m_rcThumb.IsRectEmpty() )
- && dc.RectVisible( &m_rcThumb )
- )
- {
- INT nPartID =
- m_bHorzBar
- ? SBP_THUMBBTNHORZ
- : SBP_THUMBBTNVERT
- ;
- INT nStateID = 0;
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_THUMB )
- nStateID =
- m_bHoveredAreaIsPressed
- ? SCRBS_PRESSED
- : SCRBS_HOT
- ;
- else
- nStateID = SCRBS_NORMAL;
- }
- else
- nStateID = SCRBS_DISABLED;
- if( m_bEnabled )
- {
- CRect rcXpGrip = m_rcThumb;
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- nPartID,
- nStateID,
- &m_rcThumb,
- &m_rcThumb
- ) == S_OK
- );
- VERIFY(
- g_PaintManager.m_UxTheme.DrawBackground(
- hWnd,
- dc.GetSafeHdc(),
- m_bHorzBar ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT,
- 0,
- &rcXpGrip,
- &rcXpGrip
- ) == S_OK
- );
- } // if( m_bEnabled )
- }
- g_PaintManager.m_UxTheme.CloseThemeData();
- return;
- }
- } // if( hWnd != NULL )
- } // if( g_PaintManager.m_UxTheme.IsControlsThemed() )
- UINT nStateBase = 0;
- if( m_bEnabled )
- {
- if( m_eSBMHT == __ESBMHT_NOWHERE )
- {
- if( pPM->m_bScrollBarsHaveHoverEffectIn2kStyle )
- nStateBase = DFCS_FLAT;
- }
- }
- else
- nStateBase = DFCS_INACTIVE;
- if( (! m_rcButtonUp.IsRectEmpty() )
- && dc.RectVisible( &m_rcButtonUp )
- )
- {
- UINT nState = m_bHorzBar ? DFCS_SCROLLLEFT : DFCS_SCROLLUP;
- if( m_bEnabled
- && m_bHoveredAreaIsPressed
- && m_eSBMHT == __ESBMHT_BUTTON_UP
- )
- nState |= DFCS_PUSHED|DFCS_FLAT;
- dc.DrawFrameControl(
- m_rcButtonUp,
- DFC_SCROLL,
- nState | nStateBase
- );
- }
- if( (! m_rcButtonDown.IsRectEmpty() )
- && dc.RectVisible( &m_rcButtonDown )
- )
- {
- UINT nState = m_bHorzBar ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN;
- if( m_bEnabled
- && m_bHoveredAreaIsPressed
- && m_eSBMHT == __ESBMHT_BUTTON_DOWN
- )
- nState |= DFCS_PUSHED|DFCS_FLAT;
- dc.DrawFrameControl(
- m_rcButtonDown,
- DFC_SCROLL,
- nState | nStateBase
- );
- }
- if( m_bEnabled
- && m_eSBMHT == __ESBMHT_PAGE_UP
- && (! m_rcPageUp.IsRectEmpty() )
- && dc.RectVisible( &m_rcPageUp )
- && ( m_bHoveredAreaIsPressed
- || pPM->m_bScrollBarsHaveHoverEffectIn2kStyle
- )
- )
- dc.FillRect(
- &m_rcPageUp,
- m_bHoveredAreaIsPressed
- ? (&(pPM->m_brushDarkestSystem))
- : (&(pPM->m_brushDarkSystem))
- );
- if( m_bEnabled
- && m_eSBMHT == __ESBMHT_PAGE_DOWN
- && (! m_rcPageDown.IsRectEmpty() )
- && dc.RectVisible( &m_rcPageDown )
- && ( m_bHoveredAreaIsPressed
- || pPM->m_bScrollBarsHaveHoverEffectIn2kStyle
- )
- )
- dc.FillRect(
- &m_rcPageDown,
- m_bHoveredAreaIsPressed
- ? (&(pPM->m_brushDarkestSystem))
- : (&(pPM->m_brushDarkSystem))
- );
- if( m_bEnabled
- && (! m_rcThumb.IsRectEmpty() )
- && dc.RectVisible( &m_rcThumb )
- )
- {
- UINT nState = DFCS_BUTTONPUSH;
- if( m_bHoveredAreaIsPressed
- && pPM->m_bScrollBarsHaveHoverEffectIn2kStyle
- && m_eSBMHT == __ESBMHT_THUMB
- )
- nState |= DFCS_PUSHED|DFCS_FLAT;
- dc.DrawFrameControl(
- m_rcThumb,
- DFC_BUTTON,
- nState | nStateBase
- );
- }
- }
- void CExtPaintManager::PAINTSCROLLBARDATA::PaintSkinned(
- CDC & dc,
- CExtPaintManager * pPM,
- const SCROLLBARSKINDATA & _sbsd,
- BYTE nConstantAlpha // = 0x0FF
- )
- {
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT_VALID( pPM );
- pPM;
- if( m_rcBar.IsRectEmpty()
- || (! dc.RectVisible( &m_rcBar ) )
- )
- return;
- //CExtScrollBar * pExtScrollBar = DYNAMIC_DOWNCAST( CExtScrollBar, m_pHelperSrc );
- CExtZoomScrollBar * pZoomer = DYNAMIC_DOWNCAST( CExtZoomScrollBar, m_pHelperSrc );
- if( pZoomer != NULL )
- { // zoom scroll bar background and lines
- ASSERT_VALID( pZoomer );
- if( pPM == NULL )
- {
- pPM = pZoomer->PmBridge_GetPM();
- ASSERT_VALID( pPM );
- } // if( pPM == NULL )
- bool bTransparent = false;
- #if (!defined __EXT_MFC_NO_STATUSBAR)
- CExtStatusControlBar * pWndParent = DYNAMIC_DOWNCAST( CExtStatusControlBar, pZoomer->GetParent() );
- if( pWndParent != NULL )
- {
- CRect rcPaint, _rcClient;
- pWndParent->GetWindowRect( &rcPaint );
- pZoomer->ScreenToClient( &rcPaint );
- pZoomer->GetClientRect( &_rcClient );
- pZoomer->ClientToScreen( &_rcClient );
- pWndParent->ScreenToClient( &_rcClient );
- if( pWndParent->m_bCompleteRepaint )
- {
- dc.OffsetViewportOrg( _rcClient.left, 0 );
- bool bRet = pPM->StatusBar_EraseBackground( dc, rcPaint, pWndParent );
- dc.OffsetViewportOrg( - _rcClient.left, 0 );
- if( ! bRet )
- {
- bool bTransparent = false;
- if( pPM->GetCb2DbTransparentMode(pWndParent) )
- {
- if( pPM->PaintDockerBkgnd( true, dc, pZoomer ) )
- bTransparent = true;
- }
- if( ! bTransparent )
- dc.FillSolidRect(
- &rcPaint,
- pPM->GetColor( CExtPaintManager::CLR_3DFACE_OUT, pWndParent )
- );
- }
- INT nIndex = pWndParent->CommandToIndex( pZoomer->GetDlgCtrlID() );
- if( nIndex >= 0 )
- {
- dc.OffsetViewportOrg( _rcClient.left, 0 );
- pPM->StatusBar_ErasePaneBackground( dc, nIndex, rcPaint, pWndParent );
- dc.OffsetViewportOrg( -_rcClient.left, 0 );
- bTransparent = true;
- }
- } // if( pWndParent->m_bCompleteRepaint )
- } // if( pWndParent != NULL )
- #endif // (!defined __EXT_MFC_NO_STATUSBAR)
- if( ! bTransparent )
- {
- if( (! bTransparent )
- && pPM->GetCb2DbTransparentMode( m_pHelperSrc )
- )
- {
- CExtPaintManager::stat_ExcludeChildAreas(
- dc,
- pZoomer->GetSafeHwnd(),
- CExtPaintManager::stat_DefExcludeChildAreaCallback
- );
- if( pPM->PaintDockerBkgnd( true, dc, pZoomer ) )
- bTransparent = true;
- }
- if( ! bTransparent )
- dc.FillSolidRect(
- &m_rcBar,
- pPM->GetColor( CExtPaintManager::CLR_3DFACE_OUT, pZoomer )
- );
- } // if( ! bTransparent )
- CRect rcLineH( m_rcScrollableArea );
- CRect rcLineV( m_rcScrollableArea );
- if( m_bHorzBar )
- {
- rcLineH.bottom = rcLineH.top + 1;
- rcLineH.OffsetRect( 0, m_rcScrollableArea.Height() / 2 + 1 );
- rcLineV.right = rcLineV.left + 1;
- rcLineV.OffsetRect( m_rcScrollableArea.Width() / 2, 0 );
- rcLineV.bottom = rcLineV.top + 7;
- rcLineV.OffsetRect( 0, (m_rcScrollableArea.Height() - 7 ) / 2 + 2 );
- }
- else
- {
- rcLineH.right = rcLineH.left + 1;
- rcLineH.OffsetRect( m_rcScrollableArea.Width() / 2 + 1, 0 );
- rcLineV.right = rcLineV.left + 7;
- rcLineV.OffsetRect( (m_rcScrollableArea.Width() - 7 ) / 2 + 1 , 0 );
- rcLineV.bottom = rcLineV.top + 1;
- rcLineV.OffsetRect( 0, m_rcScrollableArea.Height() / 2 );
- }
- COLORREF clrZsLineLight =
- m_bEnabled
- ? _sbsd.m_clrZsLineLightEnabled
- : _sbsd.m_clrZsLineLightDisabled;
- COLORREF clrZsLineDark =
- m_bEnabled
- ? _sbsd.m_clrZsLineDarkEnabled
- : _sbsd.m_clrZsLineDarkDisabled;
- rcLineH.OffsetRect(
- m_bHorzBar ? 0 : -1,
- m_bHorzBar ? -1 : 0
- );
- rcLineV.OffsetRect(
- m_bHorzBar ? -2 : 0,
- m_bHorzBar ? -2 : -1
- );
- if( m_bHorzBar )
- rcLineV.OffsetRect( _sbsd.m_arrPartBmp[INT(__ESBSPT_NORMAL)][INT(__ESBMHT_THUMB)].GetSize().cx / 2 - 2, 0 );
- else
- rcLineV.OffsetRect( 0, _sbsd.m_arrPartBmp[INT(__ESBSPT_NORMAL)][INT(__ESBMHT_THUMB)].GetSize().cy / 2 - 2 );
- if( clrZsLineDark != COLORREF(-1L) )
- {
- dc.FillSolidRect( &rcLineH, clrZsLineDark );
- dc.FillSolidRect( &rcLineV, clrZsLineDark );
- } // if( clrZsLineDark != COLORREF(-1L) )
- if( clrZsLineLight != COLORREF(-1L) )
- {
- rcLineH.OffsetRect( 1, 1 );
- rcLineV.OffsetRect( 1, 1 );
- dc.FillSolidRect( &rcLineH, clrZsLineLight );
- dc.FillSolidRect( &rcLineV, clrZsLineLight );
- } // if( clrZsLineLight != COLORREF(-1L) )
- } // zoom scroll bar background and lines
- if( ! _sbsd.m_bmpEntireArea.IsEmpty() )
- _sbsd.m_bmpEntireArea.DrawSkinParts(
- dc.m_hDC,
- m_rcBar,
- _sbsd.m_rcEntirePaddingR,
- CExtBitmap::__EDM_STRETCH,
- true,
- true
- );
- INT nDefaultStateIndex = INT(__ESBSPT_DISABLED);
- if( m_bEnabled )
- nDefaultStateIndex =
- ( m_eSBMHT == __ESBMHT_NOWHERE )
- ? INT(__ESBSPT_COLD)
- : INT(__ESBSPT_NORMAL)
- ;
- INT nPartNumberEffective, nPartNumber, nPartCount = INT(__ESBMHT_PART_COUNT);
- // if( pPM == NULL && pExtScrollBar != NULL )
- // {
- // pPM = pExtScrollBar->PmBridge_GetPM();
- // ASSERT_VALID( pPM );
- // } // if( pPM == NULL && pExtScrollBar != NULL )
- for( nPartNumber = 0; nPartNumber < nPartCount; nPartNumber ++ )
- {
- bool bForceNoFillColor = false;
- CRect rcPart( 0, 0, 0, 0 );
- CExtBitmap::e_DrawMethod_t eDM = CExtBitmap::__EDM_STRETCH;
- nPartNumberEffective = nPartNumber;
- switch( nPartNumber )
- {
- case INT(__ESBMHT_BUTTON_UP):
- nPartNumberEffective = INT(__ESBMHT_PAGE_UP);
- break;
- case INT(__ESBMHT_BUTTON_DOWN):
- nPartNumberEffective = INT(__ESBMHT_PAGE_DOWN);
- break;
- case INT(__ESBMHT_THUMB):
- nPartNumberEffective = INT(__ESBMHT_BUTTON_UP);
- break;
- case INT(__ESBMHT_PAGE_UP):
- nPartNumberEffective = INT(__ESBMHT_BUTTON_DOWN);
- break;
- case INT(__ESBMHT_PAGE_DOWN):
- nPartNumberEffective = INT(__ESBMHT_THUMB);
- break;
- } // switch( nPartNumber )
- INT nCheckHoverPartNumber = nPartNumberEffective;
- switch( nPartNumberEffective )
- {
- case __ESBMHT_SOLID_SCROLLABLE_AREA:
- rcPart = m_rcScrollableArea;
- break;
- case __ESBMHT_GLYPH_ARROW_UP:
- eDM = CExtBitmap::__EDM_CENTER;
- bForceNoFillColor = true;
- case __ESBMHT_BUTTON_UP:
- if( pZoomer != NULL )
- eDM = CExtBitmap::__EDM_CENTER;
- nCheckHoverPartNumber = __ESBMHT_BUTTON_UP;
- rcPart = m_rcButtonUp;
- if( m_bHorzBar )
- rcPart.DeflateRect(
- _sbsd.m_rcEntirePaddingC.left,
- _sbsd.m_rcEntirePaddingC.top,
- 0,
- _sbsd.m_rcEntirePaddingC.bottom
- );
- else
- rcPart.DeflateRect(
- _sbsd.m_rcEntirePaddingC.left,
- _sbsd.m_rcEntirePaddingC.top,
- _sbsd.m_rcEntirePaddingC.right,
- 0
- );
- break;
- case __ESBMHT_GLYPH_ARROW_DOWN:
- eDM = CExtBitmap::__EDM_CENTER;
- bForceNoFillColor = true;
- case __ESBMHT_BUTTON_DOWN:
- if( pZoomer != NULL )
- eDM = CExtBitmap::__EDM_CENTER;
- nCheckHoverPartNumber = __ESBMHT_BUTTON_DOWN;
- rcPart = m_rcButtonDown;
- if( m_bHorzBar )
- rcPart.DeflateRect(
- 0,
- _sbsd.m_rcEntirePaddingC.top,
- _sbsd.m_rcEntirePaddingC.right,
- _sbsd.m_rcEntirePaddingC.bottom
- );
- else
- rcPart.DeflateRect(
- _sbsd.m_rcEntirePaddingC.left,
- 0,
- _sbsd.m_rcEntirePaddingC.right,
- _sbsd.m_rcEntirePaddingC.bottom
- );
- break;
- case __ESBMHT_GLYPH_THUMB_GRIPPER:
- eDM = CExtBitmap::__EDM_CENTER;
- bForceNoFillColor = true;
- case __ESBMHT_THUMB:
- if( pZoomer != NULL )
- eDM = CExtBitmap::__EDM_CENTER;
- nCheckHoverPartNumber = __ESBMHT_THUMB;
- rcPart = m_rcThumb;
- if( m_bHorzBar )
- rcPart.DeflateRect(
- 0,
- _sbsd.m_rcEntirePaddingC.top,
- 0,
- _sbsd.m_rcEntirePaddingC.bottom
- );
- else
- rcPart.DeflateRect(
- _sbsd.m_rcEntirePaddingC.left,
- 0,
- _sbsd.m_rcEntirePaddingC.right,
- 0
- );
- break;
- case __ESBMHT_PAGE_UP:
- rcPart = m_rcPageUp;
- break;
- case __ESBMHT_PAGE_DOWN:
- rcPart = m_rcPageDown;
- break;
- } // switch( nPartNumberEffective )
- INT nStateIndex = nDefaultStateIndex;
- if( m_bEnabled
- && INT(m_eSBMHT) == nCheckHoverPartNumber
- )
- nStateIndex =
- m_bHoveredAreaIsPressed
- ? INT(__ESBSPT_PRESSED)
- : INT(__ESBSPT_HOT)
- ;
- if( rcPart.left >= rcPart.right
- || rcPart.top >= rcPart.bottom
- )
- continue;
- COLORREF clrSolidBackground = COLORREF(-1L);
- CRect rcPadding( 0, 0, 0, 0 );
- const CExtBitmap & _bmp =
- _sbsd.GetPart(
- e_scroll_bar_skin_part_t(nStateIndex),
- e_scroll_bar_mouse_hover_type_t(nPartNumberEffective),
- &rcPadding,
- &clrSolidBackground
- );
- if( (! bForceNoFillColor ) && clrSolidBackground != COLORREF(-1L) )
- dc.FillSolidRect( &rcPart, clrSolidBackground );
- if( ! _bmp.IsEmpty() )
- {
- bool bDraw = true;
- if( eDM == CExtBitmap::__EDM_CENTER
- && ( m_pHelperSrc == NULL
- || pZoomer == NULL
- )
- )
- {
- CSize _sizeBmp = _bmp.GetSize();
- CSize _sizeMin = rcPart.Size();
- _sizeMin.cx -= rcPadding.left + rcPadding.right;
- _sizeMin.cy -= rcPadding.top + rcPadding.bottom;
- if( _sizeBmp.cx >= _sizeMin.cx
- || _sizeBmp.cy >= _sizeMin.cy
- )
- bDraw = false;
- }
- if( bDraw && nPartNumberEffective == __ESBMHT_GLYPH_THUMB_GRIPPER )
- {
- if( ! m_rcThumb.IsRectEmpty() )
- {
- CSize _sizeBmp = _bmp.GetSize();
- if( m_bHorzBar )
- {
- if( _sizeBmp.cx >= m_rcThumb.Width()-4 )
- bDraw = false;
- } // if( m_bHorzBar )
- else
- {
- if( _sizeBmp.cy >= m_rcThumb.Height()-4 )
- bDraw = false;
- } // if( m_bHorzBar )
- } // if( ! m_rcThumb.IsRectEmpty() )
- } // if( bDraw && nPartNumberEffective == __ESBMHT_GLYPH_THUMB_GRIPPER )
- if( bDraw )
- {
- if( pZoomer != NULL )
- {
- ASSERT( pPM != NULL );
- if( pPM->UiScalingIsEnabled( CExtPaintManager::__EUIST_X )
- && pPM->UiScalingIsEnabled( CExtPaintManager::__EUIST_Y )
- && g_PaintManager.m_nLPX > 96
- && g_PaintManager.m_nLPY > 96
- )
- {
- CSize _sizeOld = _bmp.GetSize(); // rcPart.Size();
- CSize _sizeNew(
- pPM->UiScalingDo( _sizeOld.cx, CExtPaintManager::__EUIST_X ),
- pPM->UiScalingDo( _sizeOld.cy, CExtPaintManager::__EUIST_Y )
- );
- _sizeNew.cx = ::MulDiv( _sizeNew.cx, 7, 8 );
- _sizeNew.cy = ::MulDiv( _sizeNew.cy, 7, 8 );
- if( _sizeNew != _sizeOld )
- {
- CRect rcPartNew(
- rcPart.left,
- rcPart.top,
- rcPart.left + _sizeNew.cx,
- rcPart.top + _sizeNew.cy
- );
- rcPartNew.OffsetRect(
- - ( _sizeNew.cx - _sizeOld.cx ) / 2,
- - ( _sizeNew.cy - _sizeOld.cy ) / 2
- );
- rcPart = rcPartNew;
- eDM = CExtBitmap::__EDM_STRETCH;
- } // if( _sizeNew != _sizeOld )
- }
- } // if( pZoomer != NULL )
- _bmp.AlphaBlendSkinParts(
- dc.m_hDC,
- rcPart,
- rcPadding,
- eDM,
- true,
- true,
- nConstantAlpha
- );
- } // if( bDraw )
- } // if( ! _bmp.IsEmpty() )
- } // for( nPartNumber = 0; nPartNumber < nPartCount; nPartNumber ++ )
- }
- CExtPaintManager::e_scroll_bar_mouse_hover_type_t
- CExtPaintManager::PAINTSCROLLBARDATA::GetHT(
- const POINT & pt
- ) const
- {
- if( m_rcBar.IsRectEmpty() )
- return __ESBMHT_NOWHERE;
- if( (! m_rcButtonUp.IsRectEmpty() )
- && m_rcButtonUp.PtInRect( pt )
- )
- return __ESBMHT_BUTTON_UP;
- if( (! m_rcButtonDown.IsRectEmpty() )
- && m_rcButtonDown.PtInRect( pt )
- )
- return __ESBMHT_BUTTON_DOWN;
- if( (! m_rcThumb.IsRectEmpty() )
- && m_rcThumb.PtInRect( pt )
- )
- return __ESBMHT_THUMB;
- if( (! m_rcPageUp.IsRectEmpty() )
- && m_rcPageUp.PtInRect( pt )
- )
- return __ESBMHT_PAGE_UP;
- if( (! m_rcPageDown.IsRectEmpty() )
- && m_rcPageDown.PtInRect( pt )
- )
- return __ESBMHT_PAGE_DOWN;
- return __ESBMHT_NOWHERE;
- }
- CExtPaintManager::e_scroll_bar_mouse_hover_type_t
- CExtPaintManager::PAINTSCROLLBARDATA::AdjustHT(
- const POINT & pt
- )
- {
- m_eSBMHT = GetHT( pt );
- return m_eSBMHT;
- }
- CRect CExtPaintManager::PAINTSCROLLBARDATA::GetAreaRect(
- CExtPaintManager::e_scroll_bar_mouse_hover_type_t eSBMHT
- ) const
- {
- switch( eSBMHT )
- {
- case __ESBMHT_BUTTON_UP:
- return m_rcButtonUp;
- case __ESBMHT_BUTTON_DOWN:
- return m_rcButtonDown;
- case __ESBMHT_THUMB:
- return m_rcThumb;
- case __ESBMHT_PAGE_UP:
- return m_rcPageUp;
- case __ESBMHT_PAGE_DOWN:
- return m_rcPageDown;
- } // switch( eSBMHT )
- return CRect( 0, 0, 0, 0 );
- }
- CRect CExtPaintManager::PAINTSCROLLBARDATA::GetAreaRectHT() const
- {
- return GetAreaRect( m_eSBMHT );
- }
- LONG CExtPaintManager::stat_PassPaintMessages(
- bool bPassNcPaint, // = true
- bool bPassEraseBkgnd, // = true
- bool bPassPaint // = true
- )
- {
- return
- stat_PassPaintMessages(
- (HWND)NULL,
- bPassNcPaint,
- bPassEraseBkgnd,
- bPassPaint
- );
- }
- LONG CExtPaintManager::stat_PassPaintMessages(
- HWND hWnd,
- bool bPassNcPaint, // = true
- bool bPassEraseBkgnd, // = true
- bool bPassPaint // = true
- )
- {
- LONG nCountPassed = 0L;
- MSG msg;
- if( bPassNcPaint )
- {
- while( ::PeekMessage( &msg, hWnd, WM_NCPAINT, WM_NCPAINT, PM_NOREMOVE ) )
- {
- if( ! ::PeekMessage( &msg, hWnd, WM_NCPAINT, WM_NCPAINT, PM_REMOVE ) )
- break;
- ::DispatchMessage( &msg );
- nCountPassed ++;
- } // while( ::PeekMessage( &msg, NULL, WM_NCPAINT, WM_NCPAINT, PM_NOREMOVE ) )
- } // if( bPassNcPaint )
- if( bPassEraseBkgnd )
- {
- while( ::PeekMessage( &msg, hWnd, WM_ERASEBKGND, WM_ERASEBKGND, PM_NOREMOVE ) )
- {
- if( ! ::PeekMessage( &msg, hWnd, WM_ERASEBKGND, WM_ERASEBKGND, PM_REMOVE ) )
- break;
- ::DispatchMessage( &msg );
- nCountPassed ++;
- } // while( ::PeekMessage( &msg, NULL, WM_ERASEBKGND, WM_ERASEBKGND, PM_NOREMOVE ) )
- } // if( bPassEraseBkgnd )
- if( bPassPaint )
- {
- while( ::PeekMessage( &msg, hWnd, WM_PAINT, WM_PAINT, PM_NOREMOVE ) )
- {
- if( ! ::PeekMessage( &msg, hWnd, WM_PAINT, WM_PAINT, PM_REMOVE ) )
- break;
- ::DispatchMessage( &msg );
- nCountPassed ++;
- } // while( ::PeekMessage( &msg, NULL, WM_PAINT, WM_PAINT, PM_NOREMOVE ) )
- } // if( bPassPaint )
- return nCountPassed;
- }
- #if (defined __EXT_PM_BACK_COMPATIBILITY_BITMAP_API)
- bool CExtPaintManager::stat_ResizeBitmap(
- CBitmap & bmpSrc,
- CSize _size,
- CBrush & brushFill
- )
- {
- ASSERT( bmpSrc.GetSafeHandle() != NULL );
- CDC dcSrc, dcDst;
- CBitmap * pBmpOldSrc, *pBmpOldDst, bmpNew;
- { // block
- if( (! dcSrc.CreateCompatibleDC( NULL ) )
- || (! dcDst.CreateCompatibleDC( NULL ) )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- pBmpOldSrc = dcSrc.SelectObject( &bmpSrc );
- if( !bmpNew.CreateCompatibleBitmap(
- &dcSrc,
- _size.cx,
- _size.cy
- )
- )
- {
- ASSERT( FALSE );
- dcSrc.SelectObject( pBmpOldSrc );
- return false;
- }
- pBmpOldDst = dcSrc.SelectObject( &bmpNew );
- } // block
- CRect rcFill( 0, 0, _size.cx, _size.cy );
- dcDst.FillRect( &rcFill, &brushFill );
- VERIFY(
- dcDst.BitBlt(
- 0, 0, _size.cx, _size.cy,
- &dcSrc,
- 0, 0,
- SRCCOPY
- )
- );
- dcSrc.SelectObject( pBmpOldSrc );
- dcDst.SelectObject( pBmpOldDst );
- bmpSrc.DeleteObject();
- bmpSrc.Attach( bmpNew.Detach() );
- return true;
- }
- HICON CExtPaintManager::stat_HBITMAPtoHICON(
- HBITMAP hBmpSrc,
- COLORREF clrTransparent,
- const RECT * pRcPart, // = NULL
- bool bReplaceSysColors // = true
- )
- {
- if( hBmpSrc == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- BITMAP bmpDescription;
- ::memset( &bmpDescription, 0, sizeof(BITMAP) );
- ::GetObject( hBmpSrc, sizeof(BITMAP), &bmpDescription );
- ASSERT( bmpDescription.bmWidth > 0 && bmpDescription.bmHeight > 0 );
- CImageList _il;
- if( !_il.Create(
- bmpDescription.bmWidth,
- bmpDescription.bmHeight,
- ILC_COLOR32|ILC_MASK,
- 0,
- 1
- )
- )
- {
- ASSERT( FALSE );
- return NULL;
- }
- COLORREF * pSurface = NULL;
- HBITMAP hBmpExtracted = stat_CloneBitmap( hBmpSrc, pRcPart, &pSurface );
- if( hBmpExtracted == NULL || pSurface == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- CBitmap bmpExtracted;
- bmpExtracted.Attach( hBmpExtracted );
- if( bReplaceSysColors )
- {
- COLORREF quadClrTransparent =
- RGB(
- GetBValue(clrTransparent),
- GetGValue(clrTransparent),
- GetRValue(clrTransparent)
- );
- struct
- {
- COLORREF m_quadClrSrc;
- COLORREF m_quadClrDst;
- INT m_nDstSysColorIdx;
- bool m_bReplace;
- } _repl_arr[] =
- {
- { RGB(128,128,128), RGB(0,0,0), COLOR_3DSHADOW, true },
- { RGB(192,192,192), RGB(0,0,0), COLOR_3DFACE, true },
- { RGB(223,223,223), RGB(0,0,0), COLOR_3DLIGHT, true },
- };
- const int nReplCount =
- sizeof(_repl_arr) / sizeof(_repl_arr[0]);
- int nReplReal = 0;
- for( int n = 0; n < nReplCount; n++ )
- {
- if( _repl_arr[n].m_quadClrSrc == quadClrTransparent )
- {
- _repl_arr[n].m_bReplace = false;
- continue;
- }
- _repl_arr[n].m_quadClrDst =
- ::GetSysColor( _repl_arr[n].m_nDstSysColorIdx );
- _repl_arr[n].m_quadClrDst =
- RGB(
- GetBValue(_repl_arr[n].m_quadClrDst),
- GetGValue(_repl_arr[n].m_quadClrDst),
- GetRValue(_repl_arr[n].m_quadClrDst)
- );
- if( _repl_arr[n].m_quadClrDst == _repl_arr[n].m_quadClrSrc )
- {
- _repl_arr[n].m_bReplace = false;
- continue;
- }
- nReplReal++;
- } // for( int n = 0; n < nReplCount; n++ )
- if( nReplReal > 0 )
- {
- LONG nPixelCount =
- bmpDescription.bmWidth * bmpDescription.bmHeight;
- for( LONG nPos = 0; nPos < nPixelCount; nPos++ )
- {
- if( pSurface[nPos] == quadClrTransparent )
- continue;
- for( int n = 0; n < nReplCount; n++ )
- {
- if( ! (_repl_arr[n].m_bReplace) )
- continue;
- if( pSurface[nPos] != _repl_arr[n].m_quadClrSrc )
- continue;
- pSurface[nPos] = _repl_arr[n].m_quadClrDst;
- } // for( int n = 0; n < nReplCount; n++ )
- } // for( LONG nPos = 0; nPos < nPixelCount; nPos++ )
- } // if( nReplReal > 0 )
- } // if( bReplaceSysColors )
- // first method creates icon indirect
- // (this way is needed for older Windows OS versions)
- if( g_PaintManager.m_bIsWin9x || (!g_PaintManager.m_bIsWin2000orLater) )
- {
- ICONINFO ii;
- ::memset( &ii, 0, sizeof(ICONINFO) );
- ii.fIcon = TRUE;
- ii.xHotspot = bmpDescription.bmWidth;
- ii.yHotspot = bmpDescription.bmHeight;
- ii.hbmColor = (HBITMAP)bmpExtracted.GetSafeHandle();
- ii.hbmMask =
- ::CreateBitmap(
- bmpDescription.bmWidth,
- bmpDescription.bmHeight,
- 1,
- 1,
- NULL
- );
- ASSERT( ii.hbmMask != NULL );
- if( ii.hbmMask != NULL )
- {
- HICON hIcon = NULL;
- CDC dcMask, dcColor;
- if( dcMask.CreateCompatibleDC( NULL )
- && dcColor.CreateCompatibleDC( NULL )
- )
- {
- HGDIOBJ hBmpMaskOld =
- ::SelectObject( dcMask.m_hDC, ii.hbmMask );
- HGDIOBJ hBmpColorOld =
- ::SelectObject( dcColor.m_hDC, ii.hbmColor );
- HBRUSH hStockWhiteBrush = (HBRUSH)
- ::GetStockObject( WHITE_BRUSH );
- CRect rcSurface(
- 0,
- 0,
- bmpDescription.bmWidth,
- bmpDescription.bmHeight
- );
- ::FillRect( dcMask.m_hDC, &rcSurface, hStockWhiteBrush );
- int x, y;
- for( x = 0; x < bmpDescription.bmWidth; x++ )
- {
- for( y = 0; y < bmpDescription.bmHeight; y++ )
- {
- COLORREF clr = dcColor.GetPixel( x, y );
- if( clr != clrTransparent )
- dcMask.SetPixel( x, y, RGB(0,0,0) );
- else
- dcColor.SetPixel( x, y, RGB(0,0,0) );
- } // for( y = 0; y < bmpDescription.bmHeight; y++ )
- } // for( x = 0; x < bmpDescription.bmWidth; x++ )
- ::SelectObject( dcMask.m_hDC, hBmpMaskOld );
- ::SelectObject( dcColor.m_hDC, hBmpColorOld );
- hIcon = ::CreateIconIndirect( &ii );
- ASSERT( hIcon != NULL );
- } // if( dcMask.CreateCompatibleDC( NULL ) ...
- #ifdef _DEBUG
- else
- {
- ASSERT( FALSE );
- } // else from if( dcMask.CreateCompatibleDC( NULL ) )
- #endif // _DEBUG
- ::DeleteObject( ii.hbmColor );
- ::DeleteObject( ii.hbmMask );
- if( hIcon != NULL )
- return hIcon;
- } // if( ii.hbmMask != NULL )
- } // if( g_PaintManager.m_bIsWin9x || (!g_PaintManager.m_bIsWin2000orLater) )
- // second method creates icon via image list
- // (this way is better for Windows 2000 or higher NT OS branch)
- int nImgIdx =
- _il.Add( &bmpExtracted, clrTransparent );
- if( nImgIdx < 0 )
- {
- ASSERT( FALSE );
- return NULL;
- }
- HICON hIcon = _il.ExtractIcon( nImgIdx );
- ASSERT( hIcon != NULL );
- return hIcon;
- }
- HBITMAP CExtPaintManager::stat_CloneBitmap(
- HBITMAP hBmpSrc,
- const RECT * pRcPart, // = NULL
- COLORREF ** ppSurface // = NULL // if not NULL - create 32 bit surface
- )
- {
- return
- CExtBitmap::stat_CloneBitmap(
- hBmpSrc,
- pRcPart,
- ppSurface
- );
- }
- bool CExtPaintManager::stat_CloneBitmap(
- CBitmap & bmpDst,
- const CBitmap & bmpSrc,
- const RECT * pRcPart, // = NULL
- COLORREF ** ppSurface // = NULL // if not NULL - create 32 bit surface
- )
- {
- return
- CExtBitmap::stat_CloneBitmap(
- bmpDst,
- bmpSrc,
- pRcPart,
- ppSurface
- );
- }
- INT CExtPaintManager::stat_GetBitmapColorMap( // returns bitmap's color bit count or zero if error
- HBITMAP hBmpSrc,
- CMap < COLORREF, COLORREF, DWORD, DWORD > & _map // key is color, value is count of color entries in bitmap
- )
- {
- _map.RemoveAll();
- if( hBmpSrc == NULL )
- {
- ASSERT( FALSE );
- return 0;
- }
- BITMAP bmpSrcDescription;
- ::memset( &bmpSrcDescription, 0, sizeof(BITMAP) );
- ::GetObject( hBmpSrc, sizeof(BITMAP), &bmpSrcDescription );
- ASSERT( bmpSrcDescription.bmWidth > 0 && bmpSrcDescription.bmHeight > 0 );
- HDC hSrcDC = ::CreateCompatibleDC( NULL );
- if( hSrcDC == NULL )
- {
- ASSERT( FALSE );
- return 0;
- }
- LONG nPixelCount =
- bmpSrcDescription.bmWidth*bmpSrcDescription.bmHeight;
- HGDIOBJ hBmpSrcOld = ::SelectObject( hSrcDC, (HGDIOBJ)hBmpSrc );
- BITMAPINFOHEADER bih;
- ::memset( &bih, 0, sizeof(BITMAPINFOHEADER) );
- bih.biSize = sizeof(BITMAPINFOHEADER);
- bih.biWidth = bmpSrcDescription.bmWidth;
- bih.biHeight = bmpSrcDescription.bmHeight;
- bih.biPlanes = 1;
- bih.biBitCount = 32;
- bih.biCompression = BI_RGB;
- bih.biSizeImage = nPixelCount;
- RGBQUAD * pColor = NULL;
- HBITMAP hBmpDst =
- ::CreateDIBSection(
- hSrcDC,
- (LPBITMAPINFO)&bih,
- DIB_RGB_COLORS,
- (void **)&pColor,
- NULL,
- NULL
- );
- if( hBmpDst == NULL )
- {
- ASSERT( FALSE );
- ::SelectObject( hSrcDC, (HGDIOBJ)hBmpSrcOld );
- ::DeleteDC( hSrcDC );
- return 0;
- }
- ASSERT( pColor != NULL );
- HDC hDstDC = ::CreateCompatibleDC( NULL );
- if( hDstDC == NULL )
- {
- ASSERT( FALSE );
- ::DeleteObject( hBmpDst );
- ::SelectObject( hSrcDC, (HGDIOBJ)hBmpSrcOld );
- ::DeleteDC( hSrcDC );
- return NULL;
- }
- HGDIOBJ hBmpDstOld = ::SelectObject( hDstDC, (HGDIOBJ)hBmpDst );
- VERIFY(
- ::BitBlt(
- hDstDC,
- 0, 0,
- bmpSrcDescription.bmWidth, bmpSrcDescription.bmHeight,
- hSrcDC,
- 0, 0,
- SRCCOPY
- )
- );
- for( ; nPixelCount > 0; pColor++, nPixelCount-- )
- {
- COLORREF clrToInsert =
- RGB(
- pColor->rgbRed,
- pColor->rgbGreen,
- pColor->rgbBlue
- );
- DWORD dwEntries = 0;
- if( _map.Lookup( clrToInsert, dwEntries ) )
- {
- ASSERT( dwEntries > 0 );
- dwEntries++;
- _map.SetAt( clrToInsert, dwEntries );
- } // if( _map.Lookup( clrToInsert, dwEntries ) )
- else
- _map.SetAt( clrToInsert, 1 );
- } // for( ; nPixelCount > 0; pColor++, nPixelCount-- )
- ::SelectObject( hDstDC, (HGDIOBJ)hBmpDstOld );
- ::DeleteDC( hDstDC );
- ::SelectObject( hSrcDC, (HGDIOBJ)hBmpSrcOld );
- ::DeleteDC( hSrcDC );
- ::DeleteObject( hBmpDst );
- return bmpSrcDescription.bmBitsPixel;
- }
- INT CExtPaintManager::stat_GetBitmapColorArray( // returns bitmap's color bit count or zero if error
- HBITMAP hBmpSrc,
- CArray < COLORREF, COLORREF > & arr,
- bool bMakeUniqueColors // = true // used only if bit count <= 8
- )
- {
- arr.RemoveAll();
- if( hBmpSrc == NULL )
- {
- ASSERT( FALSE );
- return 0;
- }
- BITMAP bmpSrcDescription;
- ::memset( &bmpSrcDescription, 0, sizeof(BITMAP) );
- ::GetObject( hBmpSrc, sizeof(BITMAP), &bmpSrcDescription );
- ASSERT( bmpSrcDescription.bmWidth > 0 && bmpSrcDescription.bmHeight > 0 );
- if( bmpSrcDescription.bmBitsPixel <= 8 )
- {
- HGLOBAL hGlobalDst = stat_HBITMAPtoHGLOBAL( hBmpSrc );
- if( hGlobalDst == NULL )
- {
- ASSERT( FALSE );
- return 0;
- }
- INT nBitCount = (INT) ((LPBITMAPINFOHEADER)hGlobalDst)->biBitCount;
- ASSERT( nBitCount <= 8 );
- INT nColorCount = 1L << nBitCount;
- RGBQUAD * pColor = (RGBQUAD *)
- ( ((LPBYTE)hGlobalDst)
- + ((LPBITMAPINFOHEADER)hGlobalDst)->biSize
- );
- for( INT i = 0; i < nColorCount; i++ )
- {
- COLORREF clrToInsert =
- RGB(
- pColor[i].rgbRed,
- pColor[i].rgbGreen,
- pColor[i].rgbBlue
- );
- arr.Add( clrToInsert );
- } // for( INT i = 0; i < nColorCount; i++ )
- ::GlobalFree( hGlobalDst );
- if( bMakeUniqueColors )
- {
- INT nCount = (INT)arr.GetSize();
- if( nCount < 2 )
- return bmpSrcDescription.bmBitsPixel;
- for( INT i = 0; i < (nCount-1); i++ )
- {
- COLORREF clrTest = arr[i];
- for( INT j = i+1; j < nCount; )
- {
- COLORREF clrToCmp = arr[j];
- if( clrTest == clrToCmp )
- {
- arr.RemoveAt( j, 1 );
- nCount --;
- } // if( clrTest == clrToCmp )
- else
- j++;
- } // for( INT j = i+1; j < nCount; )
- } // for( INT i = 0; i < (nCount-1); i++ )
- } // if( bMakeUniqueColors )
- return bmpSrcDescription.bmBitsPixel;
- } // if( bmpSrcDescription.bmBitsPixel <= 8 )
- CMap < COLORREF, COLORREF, DWORD, DWORD > _map;
- INT nVal = stat_GetBitmapColorMap( hBmpSrc, _map );
- if( nVal == 0 )
- {
- ASSERT( FALSE );
- return 0;
- }
- ASSERT( nVal == bmpSrcDescription.bmBitsPixel );
- #ifdef _DEBUG
- INT nCount = (INT)_map.GetCount();
- #endif // _DEBUG
- ASSERT( nCount > 0 );
- POSITION pos = _map.GetStartPosition();
- ASSERT( pos != NULL );
- for( ; pos != NULL; )
- {
- COLORREF clrToInsert = RGB(0,0,0);
- DWORD dwEntries = 0;
- _map.GetNextAssoc( pos, clrToInsert, dwEntries );
- ASSERT( dwEntries > 0 );
- arr.Add( clrToInsert );
- } // for( ; pos != NULL; )
- ASSERT( nCount == arr.GetSize() );
- return bmpSrcDescription.bmBitsPixel;
- }
- HGLOBAL CExtPaintManager::stat_HBITMAPtoHGLOBAL(
- HBITMAP hBmpSrc,
- HPALETTE hPalDst // = NULL
- )
- {
- return CExtBitmap::stat_HBITMAPtoHGLOBAL( hBmpSrc, hPalDst );
- }
- HBITMAP CExtPaintManager::stat_LoadBitmapFromMemoryData(
- const BYTE * pDataBmp,
- DWORD dwSizeDataBmp
- )
- {
- if( pDataBmp == NULL || dwSizeDataBmp == 0 )
- {
- ASSERT( FALSE );
- return NULL;
- } // if( pDataBmp == NULL || dwSizeDataBmp == 0 )
- try
- {
- CMemFile _file( (BYTE *)pDataBmp, UINT(dwSizeDataBmp), 0 );
- CArchive ar( &_file, CArchive::load );
- HBITMAP hBmp = NULL;
- if( ! stat_SerializeBitmap( ar, &hBmp ) )
- {
- ASSERT( FALSE );
- return NULL;
- } // if( ! stat_SerializeBitmap( ar, &hBmp ) )
- ASSERT( hBmp != NULL );
- return hBmp;
- } // try
- catch( CException * pException )
- {
- ASSERT( FALSE );
- pException->Delete();
- } // catch( CException * pException )
- catch( ... )
- {
- ASSERT( FALSE );
- } // catch( ... )
- return NULL;
- }
- bool CExtPaintManager::stat_SerializeBitmap(
- CArchive & ar,
- HBITMAP * p_hBmp,
- DWORD dwResourceSize // = 0L // not 0 only if loaded from resources
- )
- {
- ASSERT( p_hBmp != NULL );
- if( ar.IsStoring() )
- {
- ASSERT( (*p_hBmp) != NULL );
- CExtBitmap _bitmap;
- if( ! _bitmap.FromBitmap( *p_hBmp ) )
- return false;
- if( ! _bitmap.SaveBMP( ar, false, false ) )
- return false;
- } // if( ar.IsStoring() )
- else
- {
- ASSERT( (*p_hBmp) == NULL );
- CExtBitmap _bitmap;
- if( ! _bitmap.LoadBMP( ar, true, false, dwResourceSize ? true : false ) )
- return false;
- (*p_hBmp) = _bitmap.CreateBitmap( false );
- } // else from if( ar.IsStoring() )
- return true;
- }
- bool CExtPaintManager::stat_SerializeBitmap(
- __EXT_MFC_SAFE_LPCTSTR strFileName,
- bool bRead,
- HBITMAP * p_hBmp
- )
- {
- ASSERT( strFileName != NULL );
- if( strFileName == NULL )
- return false;
- bool bRetVal = true;
- try
- {
- CFile _file(
- strFileName,
- bRead
- ? (CFile::modeRead | CFile::typeBinary)
- : (CFile::modeWrite | CFile::modeCreate | CFile::typeBinary)
- );
- CArchive ar(
- &_file,
- bRead ? CArchive::load : CArchive::store
- );
- bRetVal = stat_SerializeBitmap( ar, p_hBmp );
- ASSERT( bRetVal );
- if( !bRead )
- ar.Flush();
- ar.Close();
- _file.Close();
- } // try
- catch( CException * pXept )
- {
- ASSERT( FALSE );
- pXept->Delete();
- return false;
- } // catch( CException * pXept )
- catch( ... )
- {
- ASSERT( FALSE );
- return false;
- } // catch( ... )
- return bRetVal;
- }
- HBITMAP CExtPaintManager::stat_LoadBitmapResource(
- HINSTANCE hInst,
- HRSRC hRsrc
- )
- {
- if( hInst == NULL || hRsrc == NULL )
- return NULL;
- HGLOBAL hGlobal = ::LoadResource( hInst, hRsrc );
- if( hGlobal == NULL )
- return NULL;
- LPBYTE pData = (LPBYTE)::LockResource( hGlobal );
- if( pData == NULL )
- {
- ::FreeResource( hGlobal );
- return NULL;
- } // if( pData == NULL )
- DWORD dwResourceSize = ::SizeofResource( hInst, hRsrc );
- ASSERT( dwResourceSize > 0 );
- CMemFile _file;
- _file.Attach( pData, dwResourceSize );
- _file.Seek( 0, CFile::begin );
- CArchive ar( &_file, CArchive::load );
- HBITMAP hBmp = NULL;
- bool bSerializationPassed =
- stat_SerializeBitmap( ar, &hBmp, dwResourceSize );
- ASSERT( bSerializationPassed );
- ar.Close();
- _file.Detach();
- ::UnlockResource( hGlobal );
- ::FreeResource( hGlobal );
- if( !bSerializationPassed )
- return NULL;
- ASSERT( hBmp != NULL );
- return hBmp;
- }
- HBITMAP CExtPaintManager::stat_LoadBitmapResource(
- __EXT_MFC_SAFE_LPCTSTR sResourceID,
- __EXT_MFC_SAFE_LPCTSTR sResourceType, // = RT_BITMAP, // default bitmap section
- HINSTANCE hInst // = NULL // find it automatically
- )
- {
- if( hInst == NULL )
- {
- hInst =
- ::AfxFindResourceHandle(
- sResourceID,
- sResourceType
- );
- if( hInst == NULL )
- return NULL;
- } // if( hInst == NULL )
- HRSRC hRsrc =
- ::FindResource(
- hInst,
- sResourceID,
- sResourceType
- );
- if( hRsrc == NULL )
- return NULL;
- return stat_LoadBitmapResource( hInst, hRsrc );
- }
- #endif // __EXT_PM_BACK_COMPATIBILITY_BITMAP_API
- void CExtPaintManager::stat_GetMonitorParms(
- CExtPaintManager::monitor_parms_t & _mp
- )
- {
- VERIFY(
- ::GetWindowRect(
- ::GetDesktopWindow(),
- &_mp.m_rcMonitor
- )
- );
- VERIFY(
- ::SystemParametersInfo(
- SPI_GETWORKAREA,
- 0,
- PVOID(&_mp.m_rcWorkArea),
- 0
- )
- );
- _mp.m_bPrimaryMonitor = true;
- }
- void CExtPaintManager::stat_GetMonitorParms(
- CExtPaintManager::monitor_parms_t & _mp,
- const POINT & _ptScreenFrom
- )
- {
- MONITORINFO _MonitorInfo;
- ::memset( &_MonitorInfo, 0, sizeof(MONITORINFO) );
- _MonitorInfo.cbSize = sizeof(MONITORINFO);
- if( !::GetMonitorInfo(
- MonitorFromPoint(
- _ptScreenFrom,
- MONITOR_DEFAULTTONEAREST
- ),
- &_MonitorInfo
- )
- )
- {
- ASSERT( FALSE );
- stat_GetMonitorParms( _mp );
- return;
- }
- _mp.m_rcMonitor = _MonitorInfo.rcMonitor;
- _mp.m_rcWorkArea = _MonitorInfo.rcWork;
- _mp.m_bPrimaryMonitor =
- ( (_MonitorInfo.dwFlags&MONITORINFOF_PRIMARY) != 0 )
- ? true
- : false
- ;
- }
- void CExtPaintManager::stat_GetMonitorParms(
- CExtPaintManager::monitor_parms_t & _mp,
- const RECT & _rcScreenFrom
- )
- {
- MONITORINFO _MonitorInfo;
- ::memset( &_MonitorInfo, 0, sizeof(MONITORINFO) );
- _MonitorInfo.cbSize = sizeof(MONITORINFO);
- if( !::GetMonitorInfo(
- MonitorFromRect(
- &_rcScreenFrom,
- MONITOR_DEFAULTTONEAREST
- ),
- &_MonitorInfo
- )
- )
- {
- ASSERT( FALSE );
- stat_GetMonitorParms( _mp );
- return;
- }
- _mp.m_rcMonitor = _MonitorInfo.rcMonitor;
- _mp.m_rcWorkArea = _MonitorInfo.rcWork;
- _mp.m_bPrimaryMonitor =
- ( (_MonitorInfo.dwFlags&MONITORINFOF_PRIMARY) != 0 )
- ? true
- : false
- ;
- }
- void CExtPaintManager::stat_GetMonitorParms(
- monitor_parms_t & _mp,
- HWND hWndFrom
- )
- {
- ASSERT( hWndFrom != NULL && ::IsWindow(hWndFrom) );
- RECT rcWnd = { 0, 0, 0, 0 };
- if( ::IsIconic( hWndFrom ) )
- {
- WINDOWPLACEMENT _wp;
- ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- _wp.length = sizeof(WINDOWPLACEMENT);
- if( ::GetWindowPlacement( hWndFrom, &_wp ) )
- ::memcpy( &rcWnd, &_wp.rcNormalPosition, sizeof(RECT) );
- else
- VERIFY(
- ::GetWindowRect(
- ::GetDesktopWindow(),
- &rcWnd
- )
- );
- }
- else
- {
- VERIFY( ::GetWindowRect( hWndFrom, &rcWnd ) );
- }
- stat_GetMonitorParms( _mp, rcWnd );
- }
- void CExtPaintManager::stat_GetMonitorParms(
- monitor_parms_t & _mp,
- CWnd * pWndFrom
- )
- {
- ASSERT_VALID( pWndFrom );
- stat_GetMonitorParms( _mp, pWndFrom->GetSafeHwnd() );
- }
- CRect CExtPaintManager::stat_AlignWndRectToMonitor(
- CRect rcInitial,
- bool bUseWorkArea, // = true // if false - use all monitor area
- bool bNoPartialVisibility // = false
- )
- {
- monitor_parms_t _mp;
- stat_GetMonitorParms( _mp, rcInitial );
- CRect rcDesktop = bUseWorkArea ? _mp.m_rcWorkArea : _mp.m_rcMonitor;
- if( rcInitial.left >= rcDesktop.right )
- rcInitial.OffsetRect( rcDesktop.right - rcInitial.right, 0 );
- if( rcInitial.top >= rcDesktop.bottom )
- rcInitial.OffsetRect( 0, rcDesktop.bottom - rcInitial.bottom );
- if( rcInitial.right <= rcDesktop.left )
- rcInitial.OffsetRect( rcDesktop.left - rcInitial.left, 0 );
- if( rcInitial.bottom <= rcDesktop.top )
- rcInitial.OffsetRect( 0, rcDesktop.top - rcInitial.top );
- if( bNoPartialVisibility )
- {
- if( rcInitial.right > rcDesktop.right )
- rcInitial.OffsetRect( rcDesktop.right - rcInitial.right, 0 );
- if( rcInitial.bottom > rcDesktop.bottom )
- rcInitial.OffsetRect( 0, rcDesktop.bottom - rcInitial.bottom );
- if( rcInitial.left < rcDesktop.left )
- rcInitial.OffsetRect( rcDesktop.left - rcInitial.left, 0 );
- if( rcInitial.top < rcDesktop.top )
- rcInitial.OffsetRect( 0, rcDesktop.top - rcInitial.top );
- } // if( bNoPartialVisibility )
- return rcInitial;
- }
- void CExtPaintManager::stat_DrawDotLineH(
- CDC & dc,
- int x1,
- int x2,
- int y,
- COLORREF clrDots
- )
- {
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( (x1&1) != 0 )
- x1++;
- for( ; x1 < x2; x1 += 2 )
- dc.SetPixel( x1, y, clrDots );
- }
- void CExtPaintManager::stat_DrawDotLineV(
- CDC & dc,
- int x,
- int y1,
- int y2,
- COLORREF clrDots
- )
- {
- ASSERT_VALID( (&dc) );
- ASSERT( dc.GetSafeHdc() != NULL );
- if( (y1&1) != 0 )
- y1++;
- for( ; y1 < y2; y1 += 2 )
- dc.SetPixel( x, y1, clrDots );
- }
- #if (defined __EXT_PM_BACK_COMPATIBILITY_COLOR_API)
- COLORREF CExtPaintManager::stat_RGBtoCMY( COLORREF clr )
- {
- return CExtBitmap::stat_RGBtoCMY( clr );
- }
- COLORREF CExtPaintManager::stat_CMYtoRGB( COLORREF clr )
- {
- return CExtBitmap::stat_CMYtoRGB( clr );
- }
- //----------------------------------------------------------------------
- // Conversion between the HSL (Hue, Saturation, and Luminosity)
- // and RBG color model.
- //----------------------------------------------------------------------
- // The conversion algorithms presented here come from the book by
- // Fundamentals of Interactive Computer Graphics by Foley and van Dam.
- // In the example code, HSL values are represented as floating point
- // number in the range 0 to 1. RGB tridrants use the Windows convention
- // of 0 to 255 of each element.
- //----------------------------------------------------------------------
- double CExtPaintManager::stat_HuetoRGB(double m1, double m2, double h )
- {
- return CExtBitmap::stat_HuetoRGB( m1, m2, h );
- }
- COLORREF CExtPaintManager::stat_HLStoRGB( double H, double L, double S )
- {
- return CExtBitmap::stat_HLStoRGB( H, L, S );
- }
- void CExtPaintManager::stat_RGBtoHSL( COLORREF rgb, double *H, double *S, double *L )
- {
- CExtBitmap::stat_RGBtoHSL( rgb, H, S, L );
- }
- BYTE CExtPaintManager::stat_GetRGBFromHue(float rm1, float rm2, float rh)
- {
- return CExtBitmap::stat_GetRGBFromHue( rm1, rm2, rh );
- }
- COLORREF CExtPaintManager::stat_GetRGBFromHLSExtend( double H, double L, double S )
- {
- return CExtBitmap::stat_GetRGBFromHLSExtend( H, L, S );
- }
- COLORREF CExtPaintManager::stat_HLS_Adjust(
- COLORREF clr,
- double percentH, // = 0.0
- double percentL, // = 0.0
- double percentS // = 0.0
- )
- {
- return CExtBitmap::stat_HLS_Adjust( clr, percentH, percentL, percentS );
- }
- COLORREF CExtPaintManager::stat_RGB_Enlight(
- COLORREF clrLight,
- COLORREF clrDark,
- INT nEnlighten
- )
- {
- return CExtBitmap::stat_RGB_Enlight( clrLight, clrDark, nEnlighten );
- }
- COLORREF CExtPaintManager::stat_RGB_Blend(
- COLORREF clrFrom,
- COLORREF clrTo,
- INT nAlpha
- )
- {
- return CExtBitmap::stat_RGB_Blend( clrFrom, clrTo, nAlpha );
- }
- #endif // (defined __EXT_PM_BACK_COMPATIBILITY_COLOR_API)
- BOOL CExtPaintManager::stat_PaintParentBk(
- HWND hWnd,
- HDC hDC,
- LPCRECT rectClip // = NULL
- )
- {
- ASSERT( hDC != NULL );
- ASSERT( ::IsWindow(hWnd) );
- if( rectClip != NULL )
- {
- CRgn rgn;
- rgn.CreateRectRgnIndirect( rectClip );
- ::SelectClipRgn( hDC, (HRGN)rgn.GetSafeHandle() );
- }
- HWND hWndParent = ::GetParent( hWnd );
- ASSERT( ::IsWindow(hWndParent) );
- CPoint pt( 0, 0 );
- ::MapWindowPoints(hWnd,hWndParent,&pt,1);
- VERIFY(
- ::OffsetWindowOrgEx(
- hDC,
- pt.x,
- pt.y,
- &pt
- )
- );
- LRESULT lRes =
- ::SendMessage(
- hWndParent,
- WM_ERASEBKGND,
- (WPARAM)hDC,
- 0
- );
- VERIFY(
- ::SetWindowOrgEx(
- hDC,
- pt.x,
- pt.y,
- &pt
- )
- );
- ::SelectClipRgn( hDC, NULL );
- return (BOOL)lRes;
- }
- bool CExtPaintManager::stat_DefIsHwndNeedsDirectRepaint(
- HWND hWndChild
- )
- {
- DWORD dwChildStyle =
- DWORD( ::__EXT_MFC_GetWindowLong( hWndChild, GWL_STYLE ) );
- CExtSafeString sClassName;
- ::GetClassName(
- hWndChild,
- sClassName.GetBuffer( _MAX_PATH + 1 ),
- _MAX_PATH
- );
- sClassName.ReleaseBuffer();
- if( sClassName.CompareNoCase( __EXT_SIZE_GRIPPER_CLASS_NAME ) == 0
- || sClassName.CompareNoCase( WC_TABCONTROL ) == 0
- || sClassName.CompareNoCase( TRACKBAR_CLASS ) == 0
- || sClassName.CompareNoCase( _T("Static") ) == 0
- )
- return true;
- if( sClassName.CompareNoCase( _T("Button") ) == 0
- && ( g_PaintManager.m_bUxValidColorsExtracted
- || (dwChildStyle&0x0F) == BS_DEFPUSHBUTTON
- || (dwChildStyle&0x0F) == BS_PUSHBUTTON
- || (dwChildStyle&0x0F) == BS_CHECKBOX
- || (dwChildStyle&0x0F) == BS_AUTOCHECKBOX
- || (dwChildStyle&0x0F) == BS_RADIOBUTTON
- || (dwChildStyle&0x0F) == BS_3STATE
- || (dwChildStyle&0x0F) == BS_AUTO3STATE
- || (dwChildStyle&0x0F) == BS_GROUPBOX
- || (dwChildStyle&0x0F) == BS_AUTORADIOBUTTON
- )
- )
- return true;
- return false;
- }
- bool CExtPaintManager::stat_DefExcludeChildAreaCallback(
- HDC hDC,
- HWND hWnd,
- HWND hWndChild,
- LPVOID pCookie
- )
- {
- ASSERT( hDC != NULL );
- ASSERT( hWnd != NULL );
- ASSERT( IsWindow(hWnd) );
- ASSERT( hWndChild != NULL );
- ASSERT( IsWindow(hWndChild) );
- hDC;
- hWnd;
- hWndChild;
- pCookie;
- return stat_DefIsHwndNeedsDirectRepaint( hWndChild );
- }
- int CExtPaintManager::stat_GetBPP()
- {
- CWindowDC dc_desktop( NULL );
- int nBitsPerPixel = ::GetDeviceCaps( dc_desktop.m_hDC, BITSPIXEL );
- return nBitsPerPixel;
- }
- static const UINT stat_pixels_glyph_btn_expand_bottom[] =
- {
- 1,1,1,1,1,
- 0,1,1,1,0,
- 0,0,1,0,0,
- };
- static const UINT stat_pixels_glyph_btn_expand_bottom_2003[] =
- {
- 1,1,1,1,1,
- 0,0,0,0,0,
- 0,0,0,0,0,
- 1,1,1,1,1,
- 0,1,1,1,0,
- 0,0,1,0,0,
- };
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_bottom(
- 5,3,2,
- stat_pixels_glyph_btn_expand_bottom
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_bottom_2003(
- 5,6,2,
- stat_pixels_glyph_btn_expand_bottom_2003
- );
- static const UINT stat_pixels_glyph_btn_expand_right2[] =
- {
- 1,1,0,0,1,1,0,0,
- 0,1,1,0,0,1,1,0,
- 0,0,1,1,0,0,1,1,
- 0,1,1,0,0,1,1,0,
- 1,1,0,0,1,1,0,0,
- };
- static const UINT stat_pixels_glyph_btn_expand_right2_2003[] =
- {
- 0,0,0,0,0,0,
- 1,0,0,0,1,0,
- 1,1,0,0,1,1,
- 1,0,0,0,1,0,
- 0,0,0,0,0,0,
- };
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_right2(
- 8,5,2,
- stat_pixels_glyph_btn_expand_right2
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_right2_2003(
- 6,5,2,
- stat_pixels_glyph_btn_expand_right2_2003
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_left(
- CExtPaintManager::g_glyph_btn_expand_bottom,
- 90
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_left_2003(
- CExtPaintManager::g_glyph_btn_expand_bottom_2003,
- 90
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_right(
- CExtPaintManager::g_glyph_btn_expand_bottom,
- 270
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_right_2003(
- CExtPaintManager::g_glyph_btn_expand_bottom_2003,
- 270
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_bottom2(
- CExtPaintManager::g_glyph_btn_expand_right2,
- 90
- );
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_btn_expand_bottom2_2003(
- CExtPaintManager::g_glyph_btn_expand_right2_2003,
- 90
- );
- static const UINT stat_pixels_glyph_customize_popup_src[] =
- {
- 0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,1,0,0,0,0,0,
- 0,0,0,0,0,0,1,1,0,0,0,0,
- 0,0,0,0,0,0,1,1,1,0,0,0,
- 0,0,0,0,0,0,1,1,1,1,0,0,
- 0,0,0,0,0,0,1,1,1,1,1,0,
- 0,0,0,0,0,0,1,1,1,1,1,1,
- 0,0,0,0,0,0,1,1,1,1,1,0,
- 0,0,0,0,0,0,1,1,1,1,0,0,
- 0,0,0,0,0,0,1,1,1,0,0,0,
- 0,0,0,0,0,0,1,1,0,0,0,0,
- 0,0,0,0,0,0,1,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,
- };
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_customize_popup_src(
- 12,16,2,
- stat_pixels_glyph_customize_popup_src
- );
- static const UINT stat_pixels_glyph_customize_dropdown_src[] =
- {
- 1,0,0,0,0,0,0,0,0,0,0,0,
- 1,0,0,0,0,0,0,0,0,0,0,0,
- 1,0,0,0,0,0,0,0,0,0,0,0,
- 1,0,0,0,0,0,1,0,0,0,0,0,
- 1,0,0,0,0,0,1,1,0,0,0,0,
- 1,0,0,0,0,0,1,1,1,0,0,0,
- 1,0,0,0,0,0,1,1,1,1,0,0,
- 1,0,0,0,0,0,1,1,1,1,1,0,
- 1,0,0,0,0,0,1,1,1,1,1,1,
- 1,0,0,0,0,0,1,1,1,1,1,0,
- 1,0,0,0,0,0,1,1,1,1,0,0,
- 1,0,0,0,0,0,1,1,1,0,0,0,
- 1,0,0,0,0,0,1,1,0,0,0,0,
- 1,0,0,0,0,0,1,0,0,0,0,0,
- 1,0,0,0,0,0,0,0,0,0,0,0,
- 1,0,0,0,0,0,0,0,0,0,0,0,
- };
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_customize_dropdown_src(
- 12,16,2,
- stat_pixels_glyph_customize_dropdown_src
- );
- static const UINT stat_pixels_glyph_task_pane_btn_expand_up[] =
- {
- 0,0,0,1,0,0,0,
- 0,0,1,1,1,0,0,
- 0,1,1,0,1,1,0,
- 1,1,0,0,0,1,1,
- 0,0,0,1,0,0,0,
- 0,0,1,1,1,0,0,
- 0,1,1,0,1,1,0,
- 1,1,0,0,0,1,1,
- };
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_task_pane_btn_expand_up(
- 7,8,2,
- stat_pixels_glyph_task_pane_btn_expand_up
- );
- static const UINT stat_pixels_glyph_task_pane_btn_expand_down[] =
- {
- 1,1,0,0,0,1,1,
- 0,1,1,0,1,1,0,
- 0,0,1,1,1,0,0,
- 0,0,0,1,0,0,0,
- 1,1,0,0,0,1,1,
- 0,1,1,0,1,1,0,
- 0,0,1,1,1,0,0,
- 0,0,0,1,0,0,0,
- };
- const CExtPaintManager::glyph_t
- CExtPaintManager::g_glyph_task_pane_btn_expand_down(
- 7,8,2,
- stat_pixels_glyph_task_pane_btn_expand_down
- );
- void CExtPaintManager::PaintGlyph(
- CDC & dc,
- POINT ptDest,
- const glyph_t & glyph,
- COLORREF * pColorValues
- )
- {
- ASSERT( dc.GetSafeHdc() != NULL );
- ASSERT( pColorValues != NULL );
- ASSERT( glyph.Size().cx > 0 );
- ASSERT( glyph.Size().cy > 0 );
- CRect rcTestVisiblity(ptDest,glyph.Size());
- if( !dc.RectVisible(&rcTestVisiblity) )
- return;
- int x_dest = ptDest.x + glyph.Size().cx;
- int y_dest = ptDest.y + glyph.Size().cy;
- const UINT * pColorIndex = glyph.GetSurface();
- ASSERT( pColorIndex != NULL );
- for( int y = ptDest.y; y < y_dest; y++ )
- {
- for( int x = ptDest.x; x < x_dest; x++, pColorIndex++ )
- {
- UINT nColorIndex = *pColorIndex;
- ASSERT( nColorIndex < glyph.GetColorsCount() );
- if( nColorIndex == 0 )
- continue;
- COLORREF clr = pColorValues[nColorIndex];
- dc.SetPixel( x, y, clr );
- }
- }
- }
- void CExtPaintManager::PaintGlyphCentered(
- CDC & dc,
- const RECT & rect,
- const glyph_t & glyph,
- COLORREF * pColorValues
- )
- {
- ASSERT_VALID( this );
- ASSERT( dc.GetSafeHdc() != NULL );
- CRect _rect(rect);
- _rect.NormalizeRect();
- if( _rect.IsRectEmpty() )
- return;
- ASSERT( glyph.Size().cx > 0 );
- ASSERT( glyph.Size().cy > 0 );
- if( glyph.Size().cx > _rect.Width()
- || glyph.Size().cy > _rect.Height()
- )
- return;
- CPoint ptDest = _rect.TopLeft();
- ptDest.x +=
- (_rect.Width() - glyph.Size().cx) / 2;
- ptDest.y +=
- (_rect.Height() - glyph.Size().cy) / 2;
- PaintGlyph(
- dc,
- ptDest,
- glyph,
- pColorValues
- );
- }
- void CExtPaintManager::stat_ExcludeChildAreas(
- HDC hDC,
- HWND hWnd,
- CExtPaintManager::pfnExcludeChildAreaCallback pCallback, // = NULL
- LPVOID pCallbackCookie // = NULL
- )
- {
- if( hDC == NULL || !IsWindow(hWnd) )
- return;
- HWND hWndChild = GetWindow( hWnd, GW_CHILD );
- for( ; hWndChild != NULL; hWndChild = GetWindow( hWndChild, GW_HWNDNEXT ) )
- {
- if( !IsWindowVisible(hWndChild) )
- continue;
- __EXT_MFC_LONG_PTR dwChildStyle = __EXT_MFC_GetWindowLong( hWndChild, GWL_STYLE );
- if( (dwChildStyle & WS_CHILD) == 0 )
- continue;
- RECT rc;
- if( !::GetWindowRect(hWndChild,&rc) )
- continue;
- if( !::ScreenToClient(hWnd, (LPPOINT)(&rc)) )
- continue;
- if( !::ScreenToClient(hWnd, ((LPPOINT)(&rc))+1) )
- continue;
- if( pCallback != NULL )
- {
- if( pCallback(
- hDC,
- hWnd,
- hWndChild,
- pCallbackCookie
- )
- )
- continue;
- }
- ExcludeClipRect(
- hDC,
- rc.left,rc.top,
- rc.right,rc.bottom
- );
- } // for( ; hWndChild != NULL; hWndChild = GetWindow( hWndChild, GW_HWNDNEXT ) )
- }
- void CExtPaintManager::stat_TransparentBlt(
- HDC hdcDest, // handle to destination DC
- int nXOriginDest, // x-coord of destination upper-left corner
- int nYOriginDest, // y-coord of destination upper-left corner
- int nWidthDest, // width of destination rectangle
- int hHeightDest, // height of destination rectangle
- HDC hdcSrc, // handle to source DC
- int nXOriginSrc, // x-coord of source upper-left corner
- int nYOriginSrc, // y-coord of source upper-left corner
- int nWidthSrc, // width of source rectangle
- int nHeightSrc, // height of source rectangle
- UINT crTransparent // color to make transparent
- )
- {
- ASSERT( hdcDest != NULL && hdcSrc != NULL );
- // if( g_PaintManager.m_pfnMsImgTransparentBlt != NULL )
- // {
- // g_PaintManager.m_pfnMsImgTransparentBlt(
- // hdcDest,
- // nXOriginDest,
- // nYOriginDest,
- // nWidthDest,
- // hHeightDest,
- // hdcSrc,
- // nXOriginSrc,
- // nYOriginSrc,
- // nWidthSrc,
- // nHeightSrc,
- // crTransparent
- // );
- // return;
- // } // if( g_PaintManager.m_pfnMsImgTransparentBlt != NULL )
- CDC * pDcDest = CDC::FromHandle( hdcDest );
- ASSERT( pDcDest != NULL );
- CExtMemoryDC
- dcmm( pDcDest ),
- dcmsk(
- pDcDest,
- NULL,
- /// CExtMemoryDC::MDCOPT_RTL_COMPATIBILITY
- /// |
- CExtMemoryDC::MDCOPT_TO_MEMORY
- |CExtMemoryDC::MDCOPT_FORCE_BLACK
- )
- ;
- if( ( nWidthDest != nWidthSrc || hHeightDest != nHeightSrc )
- && nWidthDest >= 0
- && hHeightDest >= 0
- )
- {
- VERIFY(
- ::StretchBlt(
- dcmm.GetSafeHdc(),
- 0,
- 0,
- nWidthDest,
- hHeightDest,
- hdcSrc,
- nXOriginSrc,
- nYOriginSrc,
- nWidthSrc,
- nHeightSrc,
- SRCCOPY
- )
- );
- }
- else
- {
- VERIFY(
- ::BitBlt(
- dcmm.GetSafeHdc(),
- 0,
- 0,
- nWidthSrc,
- nHeightSrc,
- hdcSrc,
- nXOriginSrc,
- nYOriginSrc,
- SRCCOPY
- )
- );
- }
- int nRealWidthDest =
- (nWidthDest < 0) ? nWidthSrc : nWidthDest;
- int nRealHeightDest =
- (hHeightDest < 0) ? nHeightSrc : hHeightDest;
- dcmm.SetBkColor( crTransparent );
- VERIFY(
- dcmsk.BitBlt(
- 0,
- 0,
- nRealWidthDest,
- nRealHeightDest,
- &dcmm,
- 0,
- 0,
- SRCCOPY
- )
- );
- dcmm.SetBkColor( RGB(0,0,0) );
- dcmm.SetTextColor( RGB(255,255,255) );
- VERIFY(
- dcmm.BitBlt(
- 0,
- 0,
- nRealWidthDest,
- nRealHeightDest,
- &dcmsk,
- 0,
- 0,
- SRCAND
- )
- );
- COLORREF clrBkOld = ::SetBkColor( hdcDest, RGB(255,255,255) );
- COLORREF clrTextOld = ::SetTextColor( hdcDest, RGB(0,0,0) );
- VERIFY(
- ::BitBlt(
- hdcDest,
- nXOriginDest,
- nYOriginDest,
- nRealWidthDest,
- nRealHeightDest,
- dcmsk.GetSafeHdc(),
- 0,
- 0,
- SRCAND
- )
- );
- VERIFY(
- ::BitBlt(
- hdcDest,
- nXOriginDest,
- nYOriginDest,
- nRealWidthDest,
- nRealHeightDest,
- dcmm.GetSafeHdc(),
- 0,
- 0,
- SRCPAINT
- )
- );
- dcmm.__Flush( FALSE );
- dcmsk.__Flush( FALSE );
- ::SetBkColor( hdcDest, clrBkOld );
- ::SetTextColor( hdcDest, clrTextOld );
- }
- // generate DIB for UI light brush (when BPP <= 8 )
- HBITMAP CExtPaintManager::stat_GenLBDIB(
- COLORREF clrDarker, // = COLORREF(-1) // by default COLORREF(-1) is changed to ::GetSysColor(COLOR_BTNFACE)
- COLORREF clrLighter, // = COLORREF(-1) // by default COLORREF(-1) is changed to ::GetSysColor(COLOR_BTNHIGHLIGHT)
- int nColorMaskHorz, // = 1
- int nColorMaskVert, // = 1
- int nSkipMaskHorz, // = 0
- int nSkipMaskVert, // = 0
- COLORREF clrSkip // = COLORREF(-1L) // // default COLORREF(-1) is changed to clrDarker
- )
- {
- if( clrSkip == COLORREF(-1L) )
- clrSkip = clrDarker;
- CWindowDC dcAlign( NULL );
- CDC dc;
- if( !dc.CreateCompatibleDC( &dcAlign ) )
- {
- ASSERT( FALSE );
- return NULL;
- }
- CBitmap bmp;
- if( !bmp.CreateCompatibleBitmap( &dcAlign, 16, 16 ) )
- {
- ASSERT( FALSE );
- return NULL;
- }
- CBitmap * pOldBmp = dc.SelectObject( &bmp );
- COLORREF clrEffectiveDarker =
- ( clrDarker == COLORREF(-1) )
- ? ( ::GetSysColor( COLOR_BTNFACE ) )
- : clrDarker
- ;
- COLORREF clrEffectiveLighter =
- ( clrLighter == COLORREF(-1) )
- ? ( ::GetSysColor( COLOR_BTNHIGHLIGHT ) )
- : clrLighter
- ;
- for( int nY = 0; nY < 16; nY++ )
- {
- for( int nX = 0; nX < 16; nX++ )
- {
- if( (nX & nSkipMaskHorz) != 0
- || (nY & nSkipMaskVert) != 0
- )
- {
- dc.SetPixel( nX, nY, clrSkip );
- continue;
- }
- COLORREF clr = ( (nY&nColorMaskVert) != 0 )
- ? ( ( (nX&nColorMaskHorz) != 0 ) ? clrEffectiveDarker : clrEffectiveLighter )
- : ( ( (nX&nColorMaskHorz) != 0 ) ? clrEffectiveLighter : clrEffectiveDarker )
- ;
- dc.SetPixel( nX, nY, clr );
- }
- }
- dc.SelectObject( pOldBmp );
- return (HBITMAP)bmp.Detach();
- }
- void CExtPaintManager::stat_PaintGradientRect(
- CDC & dc,
- const CRect & rcPaintGradient,
- COLORREF clrLeft,
- COLORREF clrRight,
- bool bHorz, // = false
- UINT nCountOfSteps // = 256
- )
- {
- if( g_PaintManager.m_pfnMsImgGradientFill != NULL && g_PaintManager.m_bIsWinNT )
- {
- COLORREF clr1 = bHorz ? clrRight : clrLeft;
- COLORREF clr2 = bHorz ? clrLeft : clrRight;
- TRIVERTEX vert[2];
- vert[0].x = rcPaintGradient.left;
- vert[0].y = rcPaintGradient.top;
- vert[0].Red = (COLOR16)(GetRValue(clr1) << 8);
- vert[0].Green = (COLOR16)(GetGValue(clr1) << 8);
- vert[0].Blue = (COLOR16)(GetBValue(clr1) << 8);
- vert[0].Alpha = 0x0000;
- vert[1].x = rcPaintGradient.right;
- vert[1].y = rcPaintGradient.bottom;
- vert[1].Red = (COLOR16)(GetRValue(clr2) << 8);
- vert[1].Green = (COLOR16)(GetGValue(clr2) << 8);
- vert[1].Blue = (COLOR16)(GetBValue(clr2) << 8);
- vert[1].Alpha = 0x0000;
- GRADIENT_RECT gRect = { 0, 1 };
- g_PaintManager.m_pfnMsImgGradientFill(
- dc,
- vert,
- 2,
- &gRect,
- 1,
- (!bHorz) ? GRADIENT_FILL_RECT_H : GRADIENT_FILL_RECT_V
- );
- }
- else
- {
- if( rcPaintGradient.left >= rcPaintGradient.right
- || rcPaintGradient.top >= rcPaintGradient.bottom
- )
- return;
- ASSERT( nCountOfSteps > 0 && nCountOfSteps <= 256 );
- UINT nWidth = rcPaintGradient.Width();
- UINT nHeight = rcPaintGradient.Height();
- if( bHorz )
- {
- if( nCountOfSteps > nHeight )
- nCountOfSteps = nHeight;
- } // if( bHorz )
- else
- {
- if( nCountOfSteps > nWidth )
- nCountOfSteps = nWidth;
- } // else from if( bHorz )
- int nBitsPerPixel = ::GetDeviceCaps( dc.m_hDC, BITSPIXEL );
- if( nBitsPerPixel <= 8 )
- {
- UINT nCalcStepSize =
- bHorz
- ? nHeight / nCountOfSteps
- : nWidth / nCountOfSteps
- ;
- static const UINT nLowColorStepMinSize = 4;
- if( nCalcStepSize < nLowColorStepMinSize )
- nCountOfSteps =
- bHorz
- ? nHeight / nLowColorStepMinSize
- : nWidth / nLowColorStepMinSize
- ;
- } // if( nBitsPerPixel <= 8 )
- CRect rcItem = rcPaintGradient;
- for( UINT nStep = 0, nBackStep = nCountOfSteps;
- nStep < nCountOfSteps;
- nStep++, nBackStep--
- )
- {
- COLORREF clrItem =
- RGB(
- ( GetRValue(clrLeft)*nBackStep
- + GetRValue(clrRight)*nStep
- ) / nCountOfSteps,
- ( GetGValue(clrLeft)*nBackStep
- + GetGValue(clrRight)*nStep
- ) / nCountOfSteps,
- ( GetBValue(clrLeft)*nBackStep
- + GetBValue(clrRight)*nStep
- ) / nCountOfSteps
- );
- if( bHorz )
- {
- rcItem.top =
- rcPaintGradient.bottom -
- MulDiv( nStep, nHeight, nCountOfSteps )
- ;
- rcItem.top--;
- if( nStep == (nCountOfSteps - 1) )
- {
- rcItem.top = rcPaintGradient.top;
- if( rcItem.top > rcItem.bottom )
- break;
- } // if( nStep == (nCountOfSteps - 1) )
- ASSERT( rcItem.Height() >= 1 );
- if( nBitsPerPixel <= 8 )
- {
- CBrush _brushStepRect( clrItem );
- dc.FillRect( rcItem, &_brushStepRect );
- } // if( nBitsPerPixel <= 8 )
- else
- dc.FillSolidRect( rcItem, clrItem );
- rcItem.bottom = rcItem.top;
- } // if( bHorz )
- else
- {
- rcItem.right =
- MulDiv( nStep, nWidth, nCountOfSteps )
- + rcPaintGradient.left
- ;
- rcItem.right++;
- if( nStep == (nCountOfSteps - 1) )
- {
- rcItem.right = rcPaintGradient.right;
- if( rcItem.right < rcItem.left )
- break;
- } // if( nStep == (nCountOfSteps - 1) )
- ASSERT( rcItem.Width() >= 1 );
- if( nBitsPerPixel <= 8 )
- {
- CBrush _brushStepRect( clrItem );
- dc.FillRect( rcItem, &_brushStepRect );
- } // if( nBitsPerPixel <= 8 )
- else
- dc.FillSolidRect( rcItem, clrItem );
- rcItem.left = rcItem.right;
- } // else from if( bHorz )
- }
- }
- }
- #if (!defined __EXT_MFC_NO_TAB_CTRL)
- void CExtPaintManager::stat_PaintTabItemImpl(
- CDC & dc,
- CRect & rcTabItemsArea,
- bool bTopLeft,
- bool bHorz,
- bool bSelected,
- bool bEnabled,
- bool bCenteredText,
- bool bGroupedMode,
- bool bInGroupActive,
- bool bInvertedVerticalMode,
- bool bDrawIcon,
- const CRect & rcEntireItem,
- CSize sizeTextMeasured,
- CFont * pFont,
- __EXT_MFC_SAFE_LPCTSTR sText,
- bool bNoPrefix,
- CExtCmdIcon * pIcon,
- CExtCmdIcon * pIconTabItemCloseButton,
- INT nPaintStateITICB,
- CRect & rcTabItemCloseButton,
- COLORREF clrText,
- COLORREF clrTabBk,
- COLORREF clrTabBorderLT,
- COLORREF clrTabBorderRB,
- COLORREF clrTabSeparator,
- bool bEnableEndEllipsis, // = true
- CObject * pHelperSrc, // = NULL
- bool bDwmMode // = false
- )
- {
- ASSERT( dc.GetSafeHdc() != NULL );
- pHelperSrc;
- rcTabItemsArea;
- sizeTextMeasured;
- bInGroupActive;
- CRect rcItem( rcEntireItem );
- CRect rcTabSel( rcItem );
- if( bGroupedMode )
- {
- CRect rcTabMargin( rcItem );
- rcTabMargin.InflateRect(
- 0,
- 0,
- bHorz ? 1 : 0,
- bHorz ? 0 : 1
- );
- rcTabMargin.InflateRect(
- bHorz ? 0 : 2,
- bHorz ? 2 : 0
- );
- if( clrTabBk != COLORREF(-1L) )
- dc.FillSolidRect(
- &rcTabMargin,
- clrTabBk
- );
- if( clrTabBorderLT != COLORREF(-1L)
- && clrTabBorderRB != COLORREF(-1L)
- )
- dc.Draw3dRect(
- rcTabMargin,
- clrTabBorderLT,
- clrTabBorderRB
- );
- } // if( bGroupedMode )
- else
- {
- if( bSelected )
- {
- rcTabSel.InflateRect(
- bHorz ? __EXTTAB_SEPARATOR_DX : 0,
- bHorz ? 0 : __EXTTAB_SEPARATOR_DY,
- 0,
- 0
- );
- CRect rcSetMargins(
- ( (!bHorz) && (!bTopLeft) ) ? 1 : 0,
- ( bHorz && (!bTopLeft) ) ? 1 : 0,
- ( (!bHorz) && bTopLeft ) ? 1 : 0,
- ( bHorz && bTopLeft ) ? 1 : 0
- );
- rcTabSel.InflateRect(
- rcSetMargins.left,
- rcSetMargins.top,
- rcSetMargins.right,
- rcSetMargins.bottom
- );
-
- if( clrTabBorderLT != COLORREF(-1L)
- && clrTabBorderRB != COLORREF(-1L)
- )
- {
- CPen penTabBorderLT(PS_SOLID,1,clrTabBorderLT);
- CPen penTabBorderRB(PS_SOLID,1,clrTabBorderRB);
- if( bHorz )
- {
- if( bTopLeft )
- {
- CPen * pOldPen = dc.SelectObject( &penTabBorderLT );
- dc.MoveTo( rcTabSel.left, rcTabSel.bottom );
- dc.LineTo( rcTabSel.left, rcTabSel.top );
- dc.LineTo( rcTabSel.right, rcTabSel.top );
- dc.SelectObject( &penTabBorderRB );
- dc.MoveTo( rcTabSel.right-1, rcTabSel.top );
- dc.LineTo( rcTabSel.right-1, rcTabSel.bottom-1 );
- dc.SelectObject( pOldPen );
- }
- else
- {
- CPen * pOldPen = dc.SelectObject( &penTabBorderLT );
- dc.MoveTo( rcTabSel.left, rcTabSel.top-1 );
- dc.LineTo( rcTabSel.left, rcTabSel.bottom );
- dc.SelectObject( &penTabBorderRB );
- dc.MoveTo( rcTabSel.left, rcTabSel.bottom-1 );
- dc.LineTo( rcTabSel.right-1, rcTabSel.bottom-1 );
- dc.LineTo( rcTabSel.right-1, rcTabSel.top-1 );
- dc.SelectObject( pOldPen );
- }
- }
- else
- {
- if( bTopLeft )
- {
- CPen * pOldPen = dc.SelectObject( &penTabBorderLT );
- dc.MoveTo( rcTabSel.right-1, rcTabSel.top );
- dc.LineTo( rcTabSel.left, rcTabSel.top );
- dc.LineTo( rcTabSel.left, rcTabSel.bottom );
- dc.SelectObject( &penTabBorderRB );
- dc.MoveTo( rcTabSel.left, rcTabSel.bottom-1 );
- dc.LineTo( rcTabSel.right-1, rcTabSel.bottom-1 );
- dc.SelectObject( pOldPen );
- }
- else
- {
- CPen * pOldPen = dc.SelectObject( &penTabBorderLT );
- dc.MoveTo( rcTabSel.left, rcTabSel.top );
- dc.LineTo( rcTabSel.right, rcTabSel.top );
- dc.SelectObject( &penTabBorderRB );
- dc.MoveTo( rcTabSel.right-1, rcTabSel.top );
- dc.LineTo( rcTabSel.right-1, rcTabSel.bottom-1 );
- dc.LineTo( rcTabSel.left, rcTabSel.bottom-1 );
- dc.SelectObject( pOldPen );
- }
- }
- }
- rcTabSel.DeflateRect(
- (rcSetMargins.left == 0) ? 1 : 0,
- (rcSetMargins.top == 0) ? 1 : 0,
- (rcSetMargins.right == 0) ? 1 : 0,
- (rcSetMargins.bottom == 0) ? 1 : 0
- );
- if( clrTabBk != COLORREF(-1L) )
- dc.FillSolidRect( &rcTabSel, clrTabBk );
- } // if( bSelected )
- else
- {
- CRect rcSeparator( rcItem );
- if( bHorz )
- {
- rcSeparator.left = rcSeparator.right - 1;
- rcSeparator.DeflateRect( 0, __EXTTAB_SEPARATOR_GAP_HORZ );
- }
- else
- {
- rcSeparator.top = rcSeparator.bottom - 1;
- rcSeparator.DeflateRect( __EXTTAB_SEPARATOR_GAP_VERT, 0 );
- }
- if( clrTabSeparator != COLORREF(-1L) )
- dc.FillSolidRect( &rcSeparator, clrTabSeparator );
- } // else from if( bSelected )
- } // else from if( bGroupedMode )
- rcItem.DeflateRect(
- bHorz ? __EXTTAB_MARGIN_BORDER_HX : __EXTTAB_MARGIN_BORDER_VX,
- bHorz ? __EXTTAB_MARGIN_BORDER_HY : __EXTTAB_MARGIN_BORDER_VY
- );
- CSize _sizeIcon( 0, 0 );
- if( bDrawIcon )
- {
- _sizeIcon = pIcon->GetSize();
- ASSERT( _sizeIcon.cx > 0 && _sizeIcon.cy > 0 );
- } // if( bDrawIcon )
- CExtSafeString sItemText( (sText == NULL) ? _T("") : sText );
- // IMPORTANT: the rcText calculation fixed by Genka
- CRect rcText(
- rcItem.left
- + ( bHorz
- ? (_sizeIcon.cx +
- ((_sizeIcon.cx > 0) ? __EXTTAB_MARGIN_ICON2TEXT_X : 0)
- )
- : 0
- ),
- rcItem.top
- + ( bHorz
- ? 0
- : (_sizeIcon.cy +
- ((_sizeIcon.cy > 0) ? __EXTTAB_MARGIN_ICON2TEXT_Y : 0)
- )
- ),
- rcItem.right,
- rcItem.bottom
- );
- if( !bHorz )
- {
- if( pIconTabItemCloseButton != NULL )
- rcText.bottom = min( rcText.bottom, rcTabItemCloseButton.top );
- int nWidth0 = rcText.Width();
- int nWidth1 = rcItem.Width() + __EXTTAB_MARGIN_ICON2TEXT_X*2;
- if( nWidth1 > nWidth0 )
- {
- if( bInvertedVerticalMode )
- {
- //rcText.right -= __EXTTAB_MARGIN_ICON2TEXT_X;
- rcText.left = rcText.right - nWidth1;
- } // if( bInvertedVerticalMode )
- else
- {
- //rcText.left += __EXTTAB_MARGIN_ICON2TEXT_X;
- rcText.right = rcText.left + nWidth1;
- } // else from if( bInvertedVerticalMode )
- } // if( nWidth1 > nWidth0 )
- } // if( !bHorz )
- else
- {
- if( pIconTabItemCloseButton != NULL )
- rcText.right = min( rcText.right, rcTabItemCloseButton.left );
- }
- bool bDrawText = ( ( ! sItemText.IsEmpty() ) && rcText.Width() > 0 && rcText.Height() > 0 ) ? true : false;
- if( bDrawIcon )
- {
- INT nIconAlignment = __ALIGN_VERT_TOP;
- if( (!bDrawText) && !( bGroupedMode && (!bInGroupActive) ) )
- {
- if( bCenteredText )
- nIconAlignment = __ALIGN_HORIZ_CENTER|__ALIGN_VERT_CENTER;
- else
- nIconAlignment |= __ALIGN_HORIZ_CENTER;
- }
- if( (bHorz && rcItem.Width() >= _sizeIcon.cx )
- || (!bHorz && rcItem.Height() >= _sizeIcon.cy)
- )
- {
- g_PaintManager->PaintIcon(
- dc,
- bHorz,
- pIcon,
- rcItem,
- false,
- bEnabled,
- false,
- nIconAlignment
- );
- }
- } // if( bDrawIcon )
- if( bDrawText )
- { // if we have sense to paint text on tab item
- ASSERT( pFont != NULL );
- ASSERT( pFont->GetSafeHandle() != NULL );
- COLORREF clrOldText = dc.SetTextColor( clrText );
- INT nOldBkMode = dc.SetBkMode( TRANSPARENT );
- CFont * pOldFont = dc.SelectObject( pFont );
- if( ! bHorz )
- {
- CExtSafeString _sRederedTextV = sItemText;
- if( ! bNoPrefix )
- _sRederedTextV.Replace( _T("&"), _T("") );
- if( bCenteredText )
- {
- UINT nOldTA = dc.SetTextAlign(
- TA_CENTER | TA_BASELINE
- );
- rcText.OffsetRect(
- bInvertedVerticalMode
- ? sizeTextMeasured.cy/2
- : - sizeTextMeasured.cy/2
- ,
- 0
- );
- CPoint ptCenter = rcText.CenterPoint();
- dc.ExtTextOut(
- ptCenter.x,
- ptCenter.y,
- ETO_CLIPPED,
- &rcText,
- _sRederedTextV,
- _sRederedTextV.GetLength(),
- NULL
- );
- dc.SetTextAlign( nOldTA );
- } // if( bCenteredText )
- else
- {
- UINT nOldTA = dc.SetTextAlign(
- TA_TOP | TA_BASELINE
- );
- rcText.OffsetRect(
- bInvertedVerticalMode
- ? sizeTextMeasured.cy/2
- : - sizeTextMeasured.cy/2
- ,
- 0
- );
- CPoint ptCenter = rcText.CenterPoint();
- if( bInvertedVerticalMode )
- ptCenter.y =
- rcText.bottom - 4
- - (rcText.Height() - sizeTextMeasured.cx)
- ;
- else
- ptCenter.y =
- rcText.top + 4
- ;
- dc.ExtTextOut(
- ptCenter.x,
- ptCenter.y,
- ETO_CLIPPED,
- &rcText,
- _sRederedTextV,
- _sRederedTextV.GetLength(),
- NULL
- );
- dc.SetTextAlign( nOldTA );
- } // else from if( bCenteredText )
- if( bCenteredText )
- rcText.OffsetRect(
- 0,
- ( rcText.Height() - sizeTextMeasured.cx ) / 2
- );
- if( ! bNoPrefix )
- {
- int nTextLength = sItemText.GetLength();
- int nAmpIndex = bNoPrefix ? (-1) : int( sItemText.Find( _T('&') ) );
- if( nAmpIndex >= 0 )
- {
- CExtSafeString sBtn =
- sItemText.Left( nAmpIndex )
- + sItemText.Right( nTextLength - ( nAmpIndex + 1 ) );
- static TCHAR stat_strDummyAmpSeq[] = _T("