I just added Visual Studio 2015 theming support to CXTPTabCtrl.
To do it, add this lines to VisualStudio2015Blue.ini:
[TabCtrl] BackSelected = 255 255 255 Back = 91 113 153 Border = 142 155 188 TextSelected = 0 0 0 Text = 255 255 255
Add this lines to VisualStudio2015Dark.ini
[TabCtrl] BackSelected = 37 37 38 Back = 45 45 48 Border = 63 63 70 TextSelected = 51 153 255 Text = 241 241 241
and add this lines to VisualStudio2015Light.ini
[TabCtrl] BackSelected = 245 245 245 Back = 238 238 242 Border = 204 206 219 TextSelected = 51 153 255 Text = 0 0 0
and compile the VisualStudio2015 solution.
Then, add the next lines to XTPTabBase.cpp in method BOOL CXTPTabBase::SetTheme(XTPControlTheme eTheme):
case xtpControlThemeVisualStudio2015: m_pTheme = new CXTPTabCtrlThemeVisualStudio2015; break;
Add this lines in XTPTabBaseTheme.h, after declaration of CXTPTTabBaseTheme:
class _XTP_EXT_CLASS CXTPTabCtrlThemeVisualStudio2015 : public CXTPTabBaseTheme { private: CXTPPaintManagerColor back; CXTPPaintManagerColor backSelected; CXTPPaintManagerColor text; CXTPPaintManagerColor textSelected; CXTPPaintManagerColor border; public: CXTPTabCtrlThemeVisualStudio2015();
protected: virtual void RefreshMetrics(CTabCtrl* pTab); virtual void DrawBorders(CDC* pDC, const CRect& rcClient); virtual void DrawTabCtrl(CDC* pDC, CXTPTabBase* pTabCtrl); virtual void FillTabFace(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected); virtual void DrawTabText(CDC* pDC, CTabCtrl* pTabCtrl, CRect& rcItem, int iItem, BOOL bSelected, BOOL bBoldFont); };
and finally add this lines to XTPTabBaseTheme.cpp:
CXTPTabCtrlThemeVisualStudio2015::CXTPTabCtrlThemeVisualStudio2015() { m_bUseWinThemes = FALSE; m_bSystemDrawing = FALSE; }
void CXTPTabCtrlThemeVisualStudio2015::RefreshMetrics(CTabCtrl* pTab) { __super::RefreshMetrics(pTab);
backSelected = XTPIniColor(_T("TabCtrl"), _T("BackSelected"), RGB(253, 253, 253)); back = XTPIniColor(_T("TabCtrl"), _T("Back"), RGB(253, 253, 253)); border = XTPIniColor(_T("TabCtrl"), _T("Border"), RGB(253, 253, 253)); textSelected = XTPIniColor(_T("TabCtrl"), _T("TextSelected"), RGB(253, 253, 253)); text = XTPIniColor(_T("TabCtrl"), _T("Text"), RGB(253, 253, 253)); }
void CXTPTabCtrlThemeVisualStudio2015::DrawTabCtrl(CDC* pDC, CXTPTabBase* pTabCtrlBase) { CTabCtrl* pTabCtrl = pTabCtrlBase->GetTabCtrlImpl();
CXTPClientRect rcClient(pTabCtrl); pDC->FillSolidRect(rcClient, back);
DrawBorders(pDC, rcClient);
if (pTabCtrl->GetItemCount() != 0) { for (int iItem = 0; iItem < pTabCtrl->GetItemCount(); ++iItem) DrawTab(pDC, pTabCtrlBase, iItem);
DrawTab(pDC, pTabCtrlBase, pTabCtrl->GetCurSel());
ShowButtons(pTabCtrlBase);
if (pTabCtrlBase->m_bXPBorder) { CRect rcChild; pTabCtrlBase->GetChildRect(rcChild); rcChild.InflateRect(1, 1); DrawBorder(pDC, rcChild); } } else { ShowButtons(pTabCtrlBase); } }
void CXTPTabCtrlThemeVisualStudio2015::DrawBorders(CDC* pDC, const CRect& rcClient) { CRect rcBorder = rcClient;
if (m_bUseWinThemes && m_themeTab->IsAppThemeReady()) { } else { VerticalLine(pDC, rcBorder.left, rcBorder.top, rcBorder.Height(), border); VerticalLine(pDC, rcBorder.right - XTP_DPI_X(1), rcBorder.top, rcBorder.Height(), border); HorizontalLine(pDC, rcBorder.left, rcBorder.top, rcBorder.Width(), border); HorizontalLine(pDC, rcBorder.left, rcBorder.bottom - XTP_DPI_Y(1), rcBorder.Width(), border); } }
void CXTPTabCtrlThemeVisualStudio2015::FillTabFace(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected) { DWORD dwStyle = GetTabStyle(pTabCtrl);
if (IsRight(dwStyle)) { if (bSelected) pDC->FillSolidRect(&rcItem, backSelected); else pDC->FillSolidRect(&rcItem, back);
HorizontalLine(pDC, rcItem.left, rcItem.top, rcItem.Width(), border); VerticalLine(pDC, rcItem.right, rcItem.top, rcItem.Height(), border); HorizontalLine(pDC, rcItem.left, rcItem.bottom, rcItem.Width(), border); } else if (IsLeft(dwStyle)) { if (bSelected) pDC->FillSolidRect(&rcItem, backSelected); else pDC->FillSolidRect(&rcItem, back);
HorizontalLine(pDC, rcItem.left, rcItem.top, rcItem.Width(), border); VerticalLine(pDC, rcItem.left, rcItem.top, rcItem.Height(), border); HorizontalLine(pDC, rcItem.left, rcItem.bottom, rcItem.Width(), border); } else if (IsBottom(dwStyle)) { if (bSelected) pDC->FillSolidRect(&rcItem, backSelected); else pDC->FillSolidRect(&rcItem, back);
VerticalLine(pDC, rcItem.left, rcItem.top, rcItem.Height(), border); HorizontalLine(pDC, rcItem.left, rcItem.bottom, rcItem.Width(), border); VerticalLine(pDC, rcItem.right, rcItem.top, rcItem.Height(), border); } else { if (bSelected) pDC->FillSolidRect(&rcItem, backSelected); else pDC->FillSolidRect(&rcItem, back);
VerticalLine(pDC, rcItem.left - XTP_DPI_X(2), rcItem.top - XTP_DPI_Y(2), rcItem.Height(), border); HorizontalLine(pDC, rcItem.left, rcItem.top - XTP_DPI_Y(2), rcItem.Width(), border); VerticalLine(pDC, rcItem.right - XTP_DPI_X(2), rcItem.top - XTP_DPI_Y(2), rcItem.Height(), border); } }
void CXTPTabCtrlThemeVisualStudio2015::DrawTabText(CDC* pDC, CTabCtrl* pTabCtrl, CRect& rcItem, int iItem, BOOL bSelected, BOOL bBoldFont) { TCHAR szLabel[256]; szLabel[0] = 0;
TC_ITEM tci; tci.mask = TCIF_TEXT; tci.pszText = szLabel; tci.cchTextMax = _countof(szLabel);
if (pTabCtrl->GetItem(iItem, &tci)) { int nLen = (int)_tcslen(szLabel); if (nLen > 0) { pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor(bSelected ? textSelected : text);
// Set the font for the tab label. DWORD dwStyle = GetTabStyle(pTabCtrl); CXTPFontDC font(pDC, (bBoldFont && bSelected) ? (IsHorz(dwStyle) ? &XTPAuxData().fontBold : &XTPAuxData().fontVertBold) : (IsHorz(dwStyle) ? &XTPAuxData().font : &XTPAuxData().fontVert));
// Draw the tab label. if (IsHorz(dwStyle)) { pDC->DrawText(szLabel, nLen, rcItem, DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS); } else { CSize sz = pDC->GetTextExtent(szLabel, nLen); rcItem.left = rcItem.right - (rcItem.Width() - sz.cy + XTP_DPI_Y(1)) / 2; rcItem.top = rcItem.top + (rcItem.Height() - sz.cx + XTP_DPI_X(1)) / 2;
pDC->DrawText(szLabel, nLen, &rcItem, DT_SINGLELINE | DT_NOCLIP); } } } }
Then, you'll have something like this:
|