Beispiel #1
0
	void CButtonUI::PaintText(HDC hDC)
	{
		if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED;
		else m_uButtonState &= ~ UISTATE_FOCUSED;
		if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED;
		else m_uButtonState &= ~ UISTATE_DISABLED;

		if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor();
		if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor();

		if( m_sText.IsEmpty() ) return;
		int nLinks = 0;
		RECT rc = m_rcItem;
		rc.left += m_rcTextPadding.left;
		rc.right -= m_rcTextPadding.right;
		rc.top += m_rcTextPadding.top;
		rc.bottom -= m_rcTextPadding.bottom;

		DWORD clrColor = IsEnabled()?m_dwTextColor:m_dwDisabledTextColor;

		if( ((m_uButtonState & UISTATE_PUSHED) != 0) && (GetPushedTextColor() != 0) )
			clrColor = GetPushedTextColor();
		else if( ((m_uButtonState & UISTATE_HOT) != 0) && (GetHotTextColor() != 0) )
			clrColor = GetHotTextColor();
		else if( ((m_uButtonState & UISTATE_FOCUSED) != 0) && (GetFocusedTextColor() != 0) )
			clrColor = GetFocusedTextColor();

		if( m_bShowHtml )
			CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, clrColor, \
			NULL, NULL, nLinks, m_uTextStyle);
		else
			CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, clrColor, \
			m_iFont, m_uTextStyle);
	}
Beispiel #2
0
void CUIButton::PaintText(cairo_t *cr)
{
	if(IsFocused())
        m_uButtonState |= UISTATE_FOCUSED;
	else
        m_uButtonState &= ~ UISTATE_FOCUSED;
	if(!IsEnabled())
        m_uButtonState |= UISTATE_DISABLED;
	else
        m_uButtonState &= ~ UISTATE_DISABLED;

    //
    // TODO: default color
    //

	if(m_dwTextColor == 0)
        m_dwTextColor = 0xFF000000/*m_pManager->GetDefaultFontColor()*/;
	if(m_dwDisabledTextColor == 0)
        m_dwDisabledTextColor = 0xFFA7A6AA/*m_pManager->GetDefaultDisabledColor()*/;

	if(m_strText.IsEmpty())
        return;

	int nLinks = 0;
	RECT rc = m_rcItem;
	rc.left += m_rcTextPadding.left;
	rc.right -= m_rcTextPadding.right;
	rc.top += m_rcTextPadding.top;
	rc.bottom -= m_rcTextPadding.bottom;

	DWORD clrColor = IsEnabled() ? m_dwTextColor : m_dwDisabledTextColor;

	if(((m_uButtonState & UISTATE_PUSHED) != 0) && (GetPushedTextColor() != 0))
		clrColor = GetPushedTextColor();
	else if(((m_uButtonState & UISTATE_HOT) != 0) && (GetHotTextColor() != 0))
		clrColor = GetHotTextColor();
	else if(((m_uButtonState & UISTATE_FOCUSED) != 0) && (GetFocusedTextColor() != 0))
		clrColor = GetFocusedTextColor();

    CUIRender::DrawText(cr, rc, m_strText, DT_SINGLELINE | m_uTextStyle,
        m_strFontName, clrColor, m_bShowHtml);
}