Ejemplo n.º 1
0
bool wxFontEnumeratorHelper::OnFont(const LPLOGFONT lf,
                                    const LPTEXTMETRIC tm) const
{
    if ( m_enumEncodings )
    {
        // is this a new charset?
        int cs = lf->lfCharSet;
        if ( m_charsets.Index(cs) == wxNOT_FOUND )
        {
            wxConstCast(this, wxFontEnumeratorHelper)->m_charsets.Add(cs);

            wxFontEncoding enc = wxGetFontEncFromCharSet(cs);
            return m_fontEnum->OnFontEncoding(lf->lfFaceName,
                                              wxFontMapper::GetEncodingName(enc));
        }
        else
        {
            // continue enumeration
            return true;
        }
    }

    if ( m_fixedOnly )
    {
        // check that it's a fixed pitch font (there is *no* error here, the
        // flag name is misleading!)
        if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
        {
            // not a fixed pitch font
            return true;
        }
    }

    if ( m_charset != DEFAULT_CHARSET )
    {
        // check that we have the right encoding
        if ( lf->lfCharSet != m_charset )
        {
            return true;
        }
    }
    else // enumerating fonts in all charsets
    {
        // we can get the same facename twice or more in this case because it
        // may exist in several charsets but we only want to return one copy of
        // it (note that this can't happen for m_charset != DEFAULT_CHARSET)
        if ( m_facenames.Index(lf->lfFaceName) != wxNOT_FOUND )
        {
            // continue enumeration
            return true;
        }

        wxConstCast(this, wxFontEnumeratorHelper)->
            m_facenames.Add(lf->lfFaceName);
    }

    return m_fontEnum->OnFacename(lf->lfFaceName);
}
Ejemplo n.º 2
0
void wxFontEnumeratorHelper::DoEnumerate()
{
    MenuHandle    menu ;

    short         lines ;
    
    menu = NewMenu( 32000 , "\pFont" )  ;
    AppendResMenu( menu , 'FONT' ) ;
    lines = CountMenuItems( menu ) ;

    for ( int i = 1 ; i < lines+1  ; i ++ )
    {
        wxString c_name ;
#if TARGET_API_MAC_CARBON
        CFStringRef menutext ;
        c_name = wxEmptyString ;
        if ( CopyMenuItemTextAsCFString (menu, i, &menutext) == noErr )
        {
            c_name = wxMacCFStringHolder(menutext).AsString(wxLocale::GetSystemEncoding());
        }
#else
        Str255        p_name;
        GetMenuItemText( menu , i , p_name ) ;
        c_name = wxMacMakeStringFromPascal( p_name );
#endif
        /*
          
          if ( m_fixedOnly )
        {
            // check that it's a fixed pitch font (there is *no* error here, the
            // flag name is misleading!)
            if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
            {
                // not a fixed pitch font
                return TRUE;
            }
        }
    
        if ( m_charset != -1 )
        {
            // check that we have the right encoding
            if ( lf->lfCharSet != m_charset )
            {
                return TRUE;
            }
        }
    
        */
        m_fontEnum->OnFacename( c_name ) ;
    }
    DisposeMenu( menu ) ;
}
Ejemplo n.º 3
0
void wxFontEnumeratorHelper::DoEnumerate()
{
    MenuHandle    menu ;
    Str255        p_name ;

    short         lines ;

    menu = NewMenu( 32000 , "\pFont" )  ;
    AppendResMenu( menu , 'FONT' ) ;
    lines = CountMenuItems( menu ) ;

    for ( int i = 1 ; i < lines+1  ; i ++ )
    {
        GetMenuItemText( menu , i , p_name ) ;
        wxString c_name = wxMacMakeStringFromPascal(p_name) ;

        /*

          if ( m_fixedOnly )
        {
            // check that it's a fixed pitch font (there is *no* error here, the
            // flag name is misleading!)
            if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
            {
                // not a fixed pitch font
                return TRUE;
            }
        }

        if ( m_charset != -1 )
        {
            // check that we have the right encoding
            if ( lf->lfCharSet != m_charset )
            {
                return TRUE;
            }
        }

        */
        m_fontEnum->OnFacename( c_name ) ;
    }
    DisposeMenu( menu ) ;
}