Пример #1
0
void SjOscTitle::Draw(wxDC& dc, const wxSize& clientSize, bool titleChanged, const wxString& newTitle)
{
	// client size changed?
	if( m_clientSize != clientSize )
	{
		m_clientSize = clientSize;

		// create new font
		int pt = clientSize.y / 20; if( pt < 7 ) pt = 7;
		m_font.SetPointSize(pt);

		// calculate new size
		CalcCurrTitleSize(dc);
	}

	// title changed?
	if( titleChanged )
	{
		if( m_currTitle.IsEmpty() )
		{
			m_currTitle = newTitle;
			CalcCurrTitleSize(dc);
			m_titleOp = TITLEOP_WIPEIN;
			m_titleWipe = 0.0F;
		}
		else if( m_titleOp == TITLEOP_WIPEIN )
		{
			m_nextTitle = newTitle; // fast switch - however, this only happens for very short tracks
			CalcCurrTitleSize(dc);
		}
		else if( newTitle != m_currTitle )
		{
			m_nextTitle = newTitle;
			CalcCurrTitleSize(dc);
			if( m_titleOp == TITLEOP_NOP )
			{
				m_titleOp = TITLEOP_WIPEOUT;
				m_titleWipe = 0.0F;
			}
		}
	}

	// draw the title
	dc.SetFont(m_font);

	// scroll?
	#define SCROLL_PIX 8
	#define SCROLL_INITIAL_WAIT_MS 2000
	#define SCROLL_LEFT_END_WAIT_MS 2000
	#define SCROLL_RIGHT_END_WAIT_MS 12000
	if( m_scroll == SCROLL_WAIT )
	{
		m_scrollCnt--;
		if( m_scrollCnt <= 0 )
		{
			m_scroll = m_currTitleX<0? SCROLL_RIGHT : SCROLL_LEFT;
		}
	}
	else if( m_scroll == SCROLL_LEFT )
	{
		m_currTitleX -= SCROLL_PIX;
		if( m_currTitleX+m_currTitleW <= m_clientSize.x )
		{
			m_scroll = SCROLL_WAIT;
			m_scrollCnt = (SCROLL_LEFT_END_WAIT_MS / SLEEP_MS);
		}
	}
	else if( m_scroll == SCROLL_RIGHT )
	{
		m_currTitleX += SCROLL_PIX;
		if( m_currTitleX >= 0 )
		{
			m_scroll = SCROLL_WAIT;
			m_scrollCnt = (SCROLL_RIGHT_END_WAIT_MS / SLEEP_MS);
		}
	}

	// apply our wipe effect
	if( m_titleOp )
	{
		m_titleWipe += 1.0L/(double)SLEEP_MS;

		wxRect wipeRect(0, m_currTitleY, m_clientSize.x, m_currTitleH);

		if( m_titleOp == TITLEOP_WIPEIN )
		{
			wipeRect.width = (int) ( wipeRect.width * m_titleWipe );
		}
		else
		{
			wipeRect.x = (int) ( wipeRect.width * m_titleWipe );
		}

		// clip out the wipe rectangle and draw the text
		//dc.DrawRectangle(wipeRect);
		dc.SetClippingRegion(wipeRect);
		dc.DrawText(m_currTitle, m_currTitleX, m_currTitleY);
		dc.DestroyClippingRegion();

		// this wipe done?
		if( m_titleWipe >= 1.0 )
		{
			if( m_titleOp == TITLEOP_WIPEOUT )
			{
				m_currTitle = m_nextTitle;
				CalcCurrTitleSize(dc);
				m_titleOp = TITLEOP_WIPEIN;
				m_titleWipe = 0.0F;
			}
			else
			{
				m_titleOp = TITLEOP_NOP;
			}
		}
	}
	else
	{
		// just draw the text, no wiping currently needed
		dc.DrawText(m_currTitle, m_currTitleX, m_currTitleY);
	}
}
Пример #2
0
void wxMenuItem::GetFontToUse(wxFont& font) const
{
    font = GetFont();
    if ( !font.IsOk() )
        font = MenuDrawData::Get()->Font;
}
Пример #3
0
// Get attributes from font.
bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
{
    if (!font.IsOk())
        return false;

    // If we pass both pixel and point size attributes, this is an indication
    // to choose the most appropriate units.
    if ((flags & wxTEXT_ATTR_FONT) == wxTEXT_ATTR_FONT)
    {
        if (font.IsUsingSizeInPixels())
        {
            m_fontSize = font.GetPixelSize().y;
            flags &= ~wxTEXT_ATTR_FONT_POINT_SIZE;
        }
        else
        {
            m_fontSize = font.GetPointSize();
            flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE;
        }
    }
    else if (flags & wxTEXT_ATTR_FONT_POINT_SIZE)
    {
        m_fontSize = font.GetPointSize();
        flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE;
    }
    else if (flags & wxTEXT_ATTR_FONT_PIXEL_SIZE)
    {
        m_fontSize = font.GetPixelSize().y;
    }

    if (flags & wxTEXT_ATTR_FONT_ITALIC)
        m_fontStyle = font.GetStyle();

    if (flags & wxTEXT_ATTR_FONT_WEIGHT)
        m_fontWeight = font.GetWeight();

    if (flags & wxTEXT_ATTR_FONT_UNDERLINE)
        m_fontUnderlined = font.GetUnderlined();

    if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH)
        m_fontStrikethrough = font.GetStrikethrough();

    if (flags & wxTEXT_ATTR_FONT_FACE)
        m_fontFaceName = font.GetFaceName();

    if (flags & wxTEXT_ATTR_FONT_ENCODING)
        m_fontEncoding = font.GetEncoding();

    if (flags & wxTEXT_ATTR_FONT_FAMILY)
    {
        // wxFont might not know its family, avoid setting m_fontFamily to an
        // invalid value and rather pretend that we don't have any font family
        // information at all in this case
        const wxFontFamily fontFamily = font.GetFamily();
        if ( fontFamily == wxFONTFAMILY_UNKNOWN )
            flags &= ~wxTEXT_ATTR_FONT_FAMILY;
        else
            m_fontFamily = fontFamily;
    }

    m_flags |= flags;

    return true;
}
Пример #4
0
// Transform function for metadata fonts
wxFont scale_metadata_font(const wxFont & font)
{
    return font.Scaled(.9);
}
Пример #5
0
void sysSettings::SetSQLFont(const wxFont &font)
{
    wxString fontName = font.GetNativeFontInfoDesc();

    Write(wxT("frmQuery/Font"), fontName);
}
Пример #6
0
// Transform function for headingFont
wxFont scale_heading_font(const wxFont & font)
{
    return font.Scaled(1.2);
}
Пример #7
0
void GetTextExtent( const wxFont& font, const wxString& str, wxCoord *width, wxCoord *height,
                            wxCoord *descent, wxCoord *externalLeading )
{
    HDC dc = GetDC(0);
    WXHFONT hFont = font.GetHFONT();
    ::SelectObject(dc, hFont);

    HFONT hfontOld;
    if ( font != wxNullFont )
    {
        wxASSERT_MSG( font.Ok(), _T("invalid font in wxDC::GetTextExtent") );

        hfontOld = (HFONT)::SelectObject(dc, hFont);
    }
    else // don't change the font
    {
        hfontOld = 0;
    }

    SIZE sizeRect;
    const size_t len = str.length();
    if ( !::GetTextExtentPoint32(dc, str, len, &sizeRect) )
    {
        wxLogLastError(_T("GetTextExtentPoint32()"));
    }

#if !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
    // the result computed by GetTextExtentPoint32() may be too small as it
    // accounts for under/overhang of the first/last character while we want
    // just the bounding rect for this string so adjust the width as needed
    // (using API not available in 2002 SDKs of WinCE)
    if ( len > 1 )
    {
        ABC width;
        const wxChar chFirst = *str.begin();
        if ( ::GetCharABCWidths(dc, chFirst, chFirst, &width) )
        {
            if ( width.abcA < 0 )
                sizeRect.cx -= width.abcA;

            if ( len > 1 )
            {
                const wxChar chLast = *str.rbegin();
                ::GetCharABCWidths(dc, chLast, chLast, &width);
            }
            //else: we already have the width of the last character

            if ( width.abcC < 0 )
                sizeRect.cx -= width.abcC;
        }
        //else: GetCharABCWidths() failed, not a TrueType font?
    }
#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)

    TEXTMETRIC tm;
    ::GetTextMetrics(dc, &tm);

    if (width)
        *width = sizeRect.cx;
    if (height)
        *height = sizeRect.cy;
    if (descent)
        *descent = tm.tmDescent;
    if (externalLeading)
        *externalLeading = tm.tmExternalLeading;

    if ( hfontOld )
    {
        ::SelectObject(dc, hfontOld);
    }
    
    ReleaseDC(0, dc);
}
Пример #8
0
 // wxFont
 static wxString FontToString(const wxFont & font)
     { return font.GetNativeFontInfoUserDesc(); }
Пример #9
0
void wxQtDCImpl::SetFont(const wxFont& font)
{
    m_font = font;
    
    m_qtPainter->setFont(font.GetHandle());
}
Пример #10
0
bool wxWindowQt::SetFont( const wxFont &font )
{
    GetHandle()->setFont( font.GetHandle() );
    
    return ( true );
}