Ejemplo n.º 1
0
void CXTPEditListBoxToolBar::OnNcPaint()
{
	CXTPWinThemeWrapper wrpTreeView;
	wrpTreeView.OpenTheme(0, L"LISTBOX");
	if (wrpTreeView.IsAppThemed() && wrpTreeView.IsAppThemeReady() && (GetOwner()->GetExStyle() & WS_EX_CLIENTEDGE))
	{
		CXTPWindowRect rc(this);
		CXTPClientRect rcClient(this);

		COLORREF clr = GetXtremeColor(COLOR_BTNSHADOW);
		if (rc.Width() == rcClient.Width() + 2 &&
			SUCCEEDED(wrpTreeView.GetThemeColor(0, 0, TMT_BORDERCOLOR, &clr)))
		{
			CWindowDC dc(this);

			dc.FillSolidRect(0, 0, rc.Width(), 1, clr);
			dc.FillSolidRect(0, 0, 1, rc.Height(), clr);
			dc.FillSolidRect(rc.Width() - 1, 0, 1, rc.Height(), clr);
			dc.FillSolidRect(1, rc.Height() - 1, rc.Width() - 2, 1, GetXtremeColor(COLOR_3DFACE));
			return;
		}
	}

	Default();
}
Ejemplo n.º 2
0
void CXTPPropertyPage::OnNcPaint()
{
	Default();

	if (!m_pSheet)
		return;

	CWindowDC dc(this);
	CXTPWindowRect rcPage(this);
	rcPage.OffsetRect(-rcPage.TopLeft());

	if (m_pSheet->GetPageBorderStyle() == xtpPageBorderFrame)
	{
		BOOL bFrame = FALSE;
		CXTPWinThemeWrapper wrpTreeView;
		wrpTreeView.OpenTheme(0, L"LISTBOX");
		if (wrpTreeView.IsAppThemed())
		{
			COLORREF clr;
			if (SUCCEEDED(wrpTreeView.GetThemeColor(0, 0, TMT_BORDERCOLOR, &clr)))
			{
				dc.Draw3dRect(rcPage, clr, clr);
				rcPage.DeflateRect(1, 1);
				dc.Draw3dRect(rcPage, GetXtremeColor(COLOR_WINDOW), GetXtremeColor(COLOR_WINDOW));
				rcPage.DeflateRect(1, 1);
				bFrame = TRUE;
			}
		}
		if (!bFrame)
		{
			dc.DrawEdge(rcPage, EDGE_SUNKEN, BF_RECT);
			rcPage.DeflateRect(2, 2);
		}
	}
	else if (m_pSheet->GetPageBorderStyle() == xtpPageBorderBottomLine)
	{
		dc.FillSolidRect(rcPage.left, rcPage.bottom - 2, rcPage.Width(), 1, GetXtremeColor(COLOR_BTNSHADOW));
		dc.FillSolidRect(rcPage.left, rcPage.bottom - 1, rcPage.Width(), 1, GetXtremeColor(COLOR_BTNHIGHLIGHT));
		rcPage.DeflateRect(0, 0, 0, 2);
	}

	if ((GetStyle() & (WS_HSCROLL | WS_VSCROLL)) == (WS_HSCROLL | WS_VSCROLL))
	{
		CRect rcSizeIcon(rcPage.right - GetSystemMetrics(SM_CXVSCROLL),
			rcPage.bottom - GetSystemMetrics(SM_CYHSCROLL), rcPage.right, rcPage.bottom);

		HBRUSH hBrush = m_pSheet->GetNavigator()->GetPageBrush(&dc, this);
		if (hBrush)
		{
			CXTPClientRect rc(this);
			::FillRect(dc, rcSizeIcon, hBrush);
		}
		else
		{
			dc.FillSolidRect(rcSizeIcon, GetXtremeColor(COLOR_3DFACE));
		}

	}
}
HBRUSH CXTPPropertyPageTabNavigator::GetPageBrush(CDC* pDC, CXTPPropertyPage* pPage)
{
	COLORREF clrClient = COLORREF_NULL;

	if (GetPaintManager()->GetColor() == xtpTabColorWinNative)
	{
		clrClient = COLOR_WINXP;
	}
	else
	{
		CXTPTabManagerItem* pItem = GetSelectedItem();
		if (!pItem)
			return NULL;

		clrClient = GetPaintManager()->GetColorSet()->GetItemColor(pItem);
	}

	if (m_clrBrush != clrClient)
	{
		m_brushPage.DeleteObject();
		m_clrBrush = clrClient;
	}

	if (m_brushPage.GetSafeHandle())
		return m_brushPage;

	if (m_clrBrush == GetXtremeColor(COLOR_3DFACE))
		return 0;

	if (m_clrBrush != COLOR_WINXP)
	{
		m_brushPage.CreateSolidBrush(m_clrBrush);
		return m_brushPage;

	}

	if (m_brushPage.GetSafeHandle() == 0)
	{
		CXTPClientRect rc(pPage);
		if (rc.IsRectEmpty())
			 return 0;

		CXTPWinThemeWrapper wrapper;
		wrapper.OpenTheme(0, L"TAB");

		if (!wrapper.IsAppThemed())
			return 0;

		CBitmap bmp;
		bmp.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());
		{
			CRect   rectContent(0, 0, 0, 0);
			if (FAILED(wrapper.GetThemeBackgroundContentRect(pDC->GetSafeHdc(), TABP_PANE, 0, rc, rectContent)))
			{
				rectContent = rc;
				rectContent.DeflateRect(2, 2, 4, 4);
			}

			CRect rcPane(-rectContent.left, -rectContent.top, rc.right + (rc.right - rectContent.right),
				rc.bottom + (rc.bottom - rectContent.bottom));

			CXTPCompatibleDC dc(pDC, bmp);
			wrapper.DrawThemeBackground(dc, TABP_PANE, 0, rcPane, 0);
		}

		m_brushPage.Attach( ::CreatePatternBrush(bmp));
	}

	return m_brushPage;
}