📄 bcgpvisualmanager2003.cpp
字号:
//----------------------
// Draw rounded corners:
//----------------------
pDC->SetPixel (rectClient.left + 1, rectClient.top, m_colorToolBarCornerTop);
pDC->SetPixel (rectClient.left, rectClient.top + 1, m_colorToolBarCornerTop);
pDC->SetPixel (rectClient.right - 2, rectClient.top, m_colorToolBarCornerTop);
pDC->SetPixel (rectClient.right - 1, rectClient.top + 1, m_colorToolBarCornerTop);
pDC->SetPixel (rectClient.left + 1, rectClient.bottom - 2, m_colorToolBarCornerBottom);
pDC->SetPixel (rectClient.right - 2, rectClient.bottom - 2, m_colorToolBarCornerBottom);
}
if (pToolBar != NULL && pToolBar->GetCount () > 0)
{
CCustomizeButton* pButton =
DYNAMIC_DOWNCAST (CCustomizeButton, pToolBar->GetButton (pToolBar->GetCount () - 1));
if (pButton != NULL && !pButton->Rect ().IsRectEmpty ())
{
//----------------------------------------
// Special drawing for "Customize" button:
//----------------------------------------
CRect rectWindow;
pBar->GetWindowRect (rectWindow);
CRect rectCustomizeButton = pButton->Rect ();
pBar->ClientToScreen (&rectCustomizeButton);
CRect rectButton = rectClient;
if (pToolBar->IsHorizontal ())
{
rectButton.left = rectButton.right - pButton->Rect ().Width () -
rectWindow.right + rectCustomizeButton.right;
pButton->SetExtraSize (
0,
rectWindow.bottom - rectCustomizeButton.bottom);
}
else
{
rectButton.top = rectButton.bottom - pButton->Rect ().Height () -
rectWindow.bottom + rectCustomizeButton.bottom;
pButton->SetExtraSize (
rectWindow.right - rectCustomizeButton.right,
0);
}
BCGBUTTON_STATE state = ButtonsIsRegular;
if (pToolBar->IsButtonHighlighted (pToolBar->GetCount () - 1) ||
pButton->IsDroppedDown ())
{
state = ButtonsIsHighlighted;
}
else if (pButton->m_nStyle & (TBBS_PRESSED | TBBS_CHECKED))
{
//-----------------------
// Pressed in or checked:
//-----------------------
state = ButtonsIsPressed;
}
DrawCustomizeButton (pDC, rectButton,
pToolBar->IsHorizontal (), state,
(int) pButton->GetCustomizeCmdId () > 0,
!pButton->GetInvisibleButtons ().IsEmpty ());
}
}
}
}
//****************************************************************************************
void CBCGPVisualManager2003::OnDrawBarBorder (CDC* pDC, CBCGPBaseControlBar* pBar, CRect& rect)
{
ASSERT_VALID (pBar);
if (pBar->IsDialogControl () || globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnDrawBarBorder (pDC, pBar, rect);
}
}
//***************************************************************************************
void CBCGPVisualManager2003::OnDrawBarGripper (CDC* pDC, CRect rectGripper, BOOL bHorz,
CBCGPBaseControlBar* pBar)
{
ASSERT_VALID (pDC);
if (pBar != NULL && pBar->IsDialogControl () ||
globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnDrawBarGripper (pDC, rectGripper, bHorz, pBar);
return;
}
const int nBoxSize = 4;
if (bHorz)
{
rectGripper.left = rectGripper.right - nBoxSize;
}
else
{
rectGripper.top = rectGripper.bottom - nBoxSize;
}
CBCGPToolBar* pToolBar = DYNAMIC_DOWNCAST (CBCGPToolBar, pBar);
if (pToolBar != NULL)
{
if (bHorz)
{
const int nDelta = max (0, (pToolBar->GetButtonSize ().cy - pToolBar->GetImageSize ().cy) / 2);
rectGripper.DeflateRect (0, nDelta);
}
else
{
const int nDelta = max (0, (pToolBar->GetButtonSize ().cx - pToolBar->GetImageSize ().cx) / 2);
rectGripper.DeflateRect (nDelta, 0);
}
}
const int nBoxesNumber = bHorz ?
(rectGripper.Height () - nBoxSize) / nBoxSize :
(rectGripper.Width () - nBoxSize) / nBoxSize;
int nOffset = bHorz ?
(rectGripper.Height () - nBoxesNumber * nBoxSize) / 2 :
(rectGripper.Width () - nBoxesNumber * nBoxSize) / 2;
for (int nBox = 0; nBox < nBoxesNumber; nBox++)
{
int x = bHorz ?
rectGripper.left :
rectGripper.left + nOffset;
int y = bHorz ?
rectGripper.top + nOffset :
rectGripper.top;
pDC->FillSolidRect (x + 1, y + 1, nBoxSize / 2, nBoxSize / 2,
globalData.clrBtnHilite);
pDC->FillSolidRect (x, y, nBoxSize / 2, nBoxSize / 2,
m_clrGripper);
nOffset += nBoxSize;
}
}
//**************************************************************************************
void CBCGPVisualManager2003::OnDrawComboBorder (CDC* pDC, CRect rect,
BOOL bDisabled,
BOOL bIsDropped,
BOOL bIsHighlighted,
CBCGPToolbarComboBoxButton* pButton)
{
if (globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnDrawComboBorder (pDC, rect,
bDisabled,
bIsDropped,
bIsHighlighted,
pButton);
return;
}
if (bIsHighlighted || bIsDropped || bDisabled)
{
rect.DeflateRect (1, 1);
COLORREF colorBorder = bDisabled ? globalData.clrBtnShadow : m_clrMenuItemBorder;
pDC->Draw3dRect (&rect, colorBorder, colorBorder);
}
}
//*********************************************************************************
void CBCGPVisualManager2003::OnFillOutlookPageButton (CDC* pDC, const CRect& rect,
BOOL bIsHighlighted, BOOL bIsPressed,
COLORREF& clrText)
{
if (globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnFillOutlookPageButton (pDC, rect,
bIsHighlighted, bIsPressed,
clrText);
return;
}
ASSERT_VALID (pDC);
CBCGPDrawManager dm (*pDC);
if (bIsPressed)
{
dm.FillGradient (rect, m_clrHighlightDnGradientDark,
m_clrHighlightDnGradientLight,
TRUE);
}
else if (bIsHighlighted)
{
dm.FillGradient (rect, m_clrHighlightGradientDark,
m_clrHighlightGradientLight,
TRUE);
}
else
{
dm.FillGradient (rect, m_clrBarGradientDark,
m_clrBarGradientLight,
TRUE);
}
clrText = globalData.clrBtnText;
}
//****************************************************************************************
void CBCGPVisualManager2003::OnDrawOutlookPageButtonBorder (CDC* pDC,
CRect& rectBtn, BOOL bIsHighlighted, BOOL bIsPressed)
{
if (globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnDrawOutlookPageButtonBorder (pDC,
rectBtn, bIsHighlighted, bIsPressed);
return;
}
ASSERT_VALID (pDC);
pDC->Draw3dRect (rectBtn, globalData.clrBtnHilite, m_clrGripper);
}
//**********************************************************************************
void CBCGPVisualManager2003::OnFillButtonInterior (CDC* pDC,
CBCGPToolbarButton* pButton, CRect rect, CBCGPVisualManager::BCGBUTTON_STATE state)
{
ASSERT_VALID (pDC);
ASSERT_VALID (pButton);
CCustomizeButton* pCustButton = DYNAMIC_DOWNCAST (CCustomizeButton, pButton);
if (pCustButton == NULL || globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnFillButtonInterior (pDC, pButton, rect, state);
return;
}
CBCGPToolBar* pToolBar = pCustButton->GetParentToolbar ();
if (pToolBar != NULL)
{
ASSERT_VALID (pToolBar);
CRect rectToolbar;
pToolBar->GetClientRect (rectToolbar);
if (pToolBar->IsHorizontal ())
{
rect.right = rectToolbar.right;
}
else
{
rect.bottom = rectToolbar.bottom;
}
}
CSize sizeExtra = pCustButton->GetExtraSize ();
rect.InflateRect (sizeExtra);
DrawCustomizeButton (pDC, rect, pToolBar->IsHorizontal (), state,
(int) pCustButton->GetCustomizeCmdId () > 0,
!pCustButton->GetInvisibleButtons ().IsEmpty ());
pCustButton->SetDefaultDraw (FALSE);
}
//**************************************************************************************
void CBCGPVisualManager2003::OnDrawButtonBorder (CDC* pDC,
CBCGPToolbarButton* pButton, CRect rect, BCGBUTTON_STATE state)
{
CCustomizeButton* pCustButton = DYNAMIC_DOWNCAST (CCustomizeButton, pButton);
if (pCustButton == NULL || globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnDrawButtonBorder (pDC, pButton, rect, state);
}
// Do nothing - the border is already painted in OnFillButtonInterior
}
//**************************************************************************************
void CBCGPVisualManager2003::OnDrawSeparator (CDC* pDC, CBCGPBaseControlBar* pBar,
CRect rect, BOOL bHorz)
{
ASSERT_VALID (pBar);
if (pBar->IsDialogControl () ||
pBar->IsKindOf (RUNTIME_CLASS (CBCGPPopupMenuBar)) ||
globalData.m_nBitsPerPixel <= 8)
{
CBCGPVisualManagerXP::OnDrawSeparator (pDC, pBar, rect, bHorz);
return;
}
CBCGPToolBar* pToolBar = DYNAMIC_DOWNCAST (CBCGPToolBar, pBar);
if (pToolBar == NULL)
{
CBCGPVisualManagerXP::OnDrawSeparator (pDC, pBar, rect, bHorz);
return;
}
CPen* pOldPen = pDC->SelectObject (&m_penSeparator);
ASSERT (pOldPen != NULL);
if (bHorz)
{
const int nDelta = max (0, (pToolBar->GetButtonSize ().cy - pToolBar->GetImageSize ().cy) / 2);
rect.DeflateRect (0, nDelta);
int x = rect.left += rect.Width () / 2 - 1;
pDC->MoveTo (x, rect.top);
pDC->LineTo (x, rect.bottom - 1);
pDC->SelectObject (&m_penSeparatorLight);
pDC->MoveTo (x + 1, rect.top + 1);
pDC->LineTo (x + 1, rect.bottom);
}
else
{
const int nDelta = max (0, (pToolBar->GetButtonSize ().cx - pToolBar->GetImageSize ().cx) / 2);
rect.DeflateRect (nDelta, 0);
int y = rect.top += rect.Height () / 2 - 1;
pDC->MoveTo (rect.left, y);
pDC->LineTo (rect.right - 1, y);
pDC->SelectObject (&m_penSeparatorLight);
pDC->MoveTo (rect.left + 1, y + 1);
pDC->LineTo (rect.right, y + 1);
}
pDC->SelectObject (pOldPen);
}
//***********************************************************************************
void CBCGPVisualManager2003::OnUpdateSystemColors ()
{
CBCGPWinXPThemeManager::UpdateSystemColors ();
m_bIsStandardWinXPTheme = FALSE;
m_strWinXPThemeColor.Empty ();
BOOL bIsOliveGreenTheme = FALSE;
BOOL bIsSilverTheme = FALSE;
BOOL bIsAppThemed = m_bUseGlobalTheme || (m_pfGetWindowTheme != NULL &&
(*m_pfGetWindowTheme) (AfxGetMainWnd ()->GetSafeHwnd ()) != NULL);
//------------------------
// Get current theme name:
//------------------------
if (m_pfGetCurrentThemeName != NULL && bIsAppThemed)
{
WCHAR szName [256];
WCHAR szColor [256];
if ((*m_pfGetCurrentThemeName) (szName, 255, szColor, 255, NULL, 0) == S_OK)
{
CString strThemeName = szName;
m_strWinXPThemeColor = szColor;
TCHAR fname[_MAX_FNAME];
_tsplitpath (strThemeName, NULL, NULL, fname, NULL);
strThemeName = fname;
m_bIsStandardWinXPTheme = (strThemeName.CompareNoCase (_T("Luna")) == 0);
bIsOliveGreenTheme = m_bIsStandardWinXPTheme &&
m_strWinXPThemeColor.CompareNoCase (_T("homestead")) == 0;
bIsSilverTheme = m_bIsStandardWinXPTheme &&
m_strWinXPThemeColor.CompareNoCase (_T("metallic")) == 0;
}
}
//----------------------
// Modify global colors:
//----------------------
ModifyGlobalColors ();
CBCGPVisualManagerXP::OnUpdateSystemColors ();
if (globalData.m_nBitsPerPixel <= 8)
{
m_clrTaskPaneGradientDark = globalData.clrWindow;
m_clrTaskPaneGradientLight = globalData.clrWindow;
m_clrTaskPaneGroupCaptionDark = globalData.clrBarFace;
m_clrTaskPaneGroupCaptionLight = globalData.clrBarFace;
m_clrTaskPaneGroupCaptionSpecDark = globalData.clrBarFace;
m_clrTaskPaneGroupCaptionSpecLight = globalData.clrBarFace;
m_clrTaskPaneGroupAreaLight = globalData.clrWindow;
m_clrTaskPaneGroupAreaDark = globalData.clrWindow;
m_clrTaskPaneGroupAreaSpecLight = globalData.clrWindow;
m_clrTaskPaneGroupAreaSpecDark = globalData.clrWindow;
m_clrTaskPaneGroupBorder = globalData.clrBtnShadow;
m_clrBarGradientLight = m_clrToolBarGradientLight = globalData.clrBarLight;
return;
}
//--------------------------------------------------
// Calculate control bars bakground gradient colors:
//--------------------------------------------------
COLORREF clrBase = GetThemeColor (m_hThemeWindow, /*COLOR_MENUHILIGHT*/29);
if (!m_bIsStandardWinXPTheme)
{
clrBase = globalData.clrBarFace;
}
if (bIsOliveGreenTheme)
{
m_clrToolBarGradientDark = CBCGPDrawManager::PixelAlpha (
clrBase, 120);
m_clrBarGradientDark = CBCGPDrawManager::SmartMixColors (
clrBase,
GetThemeColor (m_hThemeWindow, COLOR_3DFACE),
.87, 1, 3);
m_clrToolBarGradientLight = CBCGPDrawManager::SmartMixColors (
clrBase,
GetThemeColor (m_hThemeWindow, COLOR_WINDOW),
1., 2, 1);
m_clrBarGradientLight = CBCGPDrawManager::SmartMixColors (
clrBase,
GetThemeColor (m_hThemeWindow, COLOR_WINDOW),
1.03);
}
else if (bIsSilverTheme)
{
m_clrToolBarGradientDark = CBCGPDrawManager::SmartMixColors (
clrBase,
GetThemeColor (m_hThemeWindow, COLOR_3DFACE),
0.75, 2);
m_clrBarGradientDark = CBCGPDrawManager::PixelAlpha (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -