Esempio n. 1
0
void CRichEditNcBorder::VerifyThemedBorderState()
{
	BOOL bHadThemedBorder = m_bThemedBorder;
	m_bThemedBorder = FALSE;
	
	// First, check if the control is supposed to have a border
	if (bHadThemedBorder || HasStyle(WS_BORDER) || HasExStyle(WS_EX_CLIENTEDGE))
	{
		// Check if a theme is presently active
		if (CThemed().AreControlsThemed())
		{
			// Remove the border style, we don't want the control to draw its own border
			m_bThemedBorder = TRUE;
			
			CWnd::ModifyStyle(GetHwnd(), WS_BORDER, 0, 0);
			CWnd::ModifyStyleEx(GetHwnd(), WS_EX_CLIENTEDGE, 0, 0);
		}
		else // restore the border
			CWnd::ModifyStyleEx(GetHwnd(), 0, WS_EX_CLIENTEDGE, 0);
	}

	// Recalculate the NC area and repaint the window
	SetWindowPos(GetHwnd(), NULL, NULL, NULL, NULL, NULL, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
	RedrawWindow(GetHwnd(), NULL, NULL, RDW_INVALIDATE | RDW_NOCHILDREN | RDW_UPDATENOW | RDW_FRAME);
}
Esempio n. 2
0
LRESULT CRRECToolBar::OnItemPostPaint(LPNMTBCUSTOMDRAW lpNMCustomDraw)
{
    UINT nBtnID = lpNMCustomDraw->nmcd.dwItemSpec;

    switch (nBtnID)
    {
    case BUTTON_BACKCOLOR:
    case BUTTON_TEXTCOLOR:
    {
        // paint the lowest 3 lines with the appropriate colour
        // but only as far as the beginning of the drop button
        CRect rColor(lpNMCustomDraw->nmcd.rc);

        if (CThemed().AreControlsThemed())
            rColor.bottom++;
        else
            rColor.DeflateRect(2, 2);

        rColor.top = rColor.bottom - 3;
        rColor.right = rColor.left + m_sizeImage.cx;

        CDC* pDC = CDC::FromHandle(lpNMCustomDraw->nmcd.hdc);
        COLORREF color = GetFontColor(nBtnID == BUTTON_TEXTCOLOR, TRUE);

        pDC->FillSolidRect(rColor, color);
    }
    break;
    }

    return CDRF_DODEFAULT;
}
Esempio n. 3
0
BOOL CEnEdit::InitializeTooltips()
{
	// create tooltip
	if (!m_tooltip.GetSafeHwnd() && m_tooltip.Create(this))
	{
		// add any existing buttons
		int nBtn = m_aButtons.GetSize();

		while (nBtn--)
		{
			const EDITBTN& eb = m_aButtons[nBtn];
			m_tooltip.AddTool(this, eb.sTip, CRect(), eb.nID);
		}

		// hot tracking
		if (CThemed().AreControlsThemed())
			m_hotTrack.Initialize(this);
	}

	return (m_tooltip.GetSafeHwnd() != NULL);
}
Esempio n. 4
0
void CEnEdit::DrawButton(CDC* pDC, const CRect& rWindow, int nBtn, const CPoint& ptCursor) const
{
	const EDITBTN& eb = m_aButtons[nBtn];

	CRect rBtn = GetButtonRectByIndex(nBtn);

	if (rBtn.IsRectEmpty())
		return;

	int nSaveDC = pDC->SaveDC();

	BOOL bThemed = CThemed().AreControlsThemed();
	BOOL bHot = rBtn.PtInRect(ptCursor);
	BOOL bEnabled = (IsWindowEnabled() && eb.bEnabled);
	BOOL bDown = (m_nButtonDown == nBtn || eb.bChecked);

	rBtn.OffsetRect(-rWindow.TopLeft());

	// nasty business here because the API function DrawThemeEdge() is not theme aware!
	// and drawing a themed combostyle button will also draw the arrow which we don't want
	if (!m_bComboStyle || bThemed)	// draw as button type (for now)
	{
		UINT nFlags = DFCS_ADJUSTRECT | DFCS_BUTTONPUSH;
		
		// note: we do not take account of ES_READONLY as the effect of this
		// is not deterministic at this level so we assume derived classes or 
		// parents have handled it
		if (!bEnabled)
			nFlags |= DFCS_INACTIVE;
		
		else if (bDown)
			nFlags |= DFCS_PUSHED;
		
		else if (bHot)
			nFlags |= DFCS_HOT;
		
		// clip the drawing rect to prevent window getting the parent bkgnd color wrong
		CRect rClip(rBtn);

		if (bThemed)
			rBtn.InflateRect(1, 1);
		
		// for now
		CThemed::DrawFrameControl(this, pDC, rBtn, DFC_BUTTON, nFlags, rClip);
	}
	else // unthemed combo style
	{
		if (bEnabled && bDown)
			pDC->DrawEdge(rBtn, BDR_RAISEDOUTER, BF_RECT | BF_MIDDLE | BF_FLAT);
		else
		{
			pDC->DrawEdge(rBtn, BDR_RAISEDOUTER, BF_ADJUST | BF_RECT | BF_MIDDLE);
			pDC->DrawEdge(rBtn, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
		}
	}

	// drop menu arrow
	if (eb.bDropMenu)
	{
		CRect rArrow(rBtn);
		
		if (bDown)
			rArrow.OffsetRect(1, 1);

		UINT nFlags = DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP;

		if (eb.sCaption.IsEmpty())
			nFlags |= DT_CENTER;
		else
		{
			nFlags |= DT_RIGHT;
			rArrow.right -= 2;
		}

		pDC->SetTextColor(GetSysColor(bEnabled ? COLOR_BTNTEXT : COLOR_3DSHADOW));
		GraphicsMisc::DrawSymbol(pDC, MENU_DROPBTN, rArrow, nFlags, &GraphicsMisc::Marlett());
	}
	
	if (!eb.sCaption.IsEmpty())
	{
		// draw custom caption
		if (m_nButtonDown == nBtn || eb.bChecked)
			rBtn.OffsetRect(1, 1);

		CFont* pOld = NULL;
		
		if (eb.hFont)
			pOld = pDC->SelectObject(CFont::FromHandle(eb.hFont));
		else
		{
			CFont* pFont = GetFont();
			pOld = (CFont*)pDC->SelectObject(pFont);
		}
		
		pDC->SetTextAlign((eb.bSymbol ? TA_LEFT : TA_CENTER) | TA_TOP);
		pDC->SetBkMode(TRANSPARENT);
		
		int nCharHeight = pDC->GetTextExtent("A").cy;
		int nVOffset = ((rBtn.Height() - nCharHeight + 1) / 2) - (bThemed ? 0 : 1);
		int nHOffset = eb.bSymbol ? -2 : (rBtn.Width() + 1) / 2;

		// if the button has a drop menu position the text in the 
		// center of what remains
		if (eb.bDropMenu)
			nHOffset = (rBtn.Width() - MENUSIZE + 4) / 2; 

		CPoint ptText(rBtn.left + nHOffset, rBtn.top + nVOffset);
		DrawEnabledText(pDC, ptText, eb.sCaption, rBtn, bEnabled, eb.bSymbol);

		// cleanup
		if (pOld)
			pDC->SelectObject(pOld);
	}

	pDC->RestoreDC(nSaveDC);
}