X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/142b3bc26a6e93f5857bc053c7748b2c845c4a8e..0e05227246cc99b2f8133ae639f38c508351afa0:/src/mac/carbon/fontenum.cpp?ds=inline diff --git a/src/mac/carbon/fontenum.cpp b/src/mac/carbon/fontenum.cpp index 4720cc4a75..adb3957eca 100644 --- a/src/mac/carbon/fontenum.cpp +++ b/src/mac/carbon/fontenum.cpp @@ -1,32 +1,18 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: mac/fontenum.cpp +// Name: src/mac/carbon/fontenum.cpp // Purpose: wxFontEnumerator class for MacOS // Author: Stefan Csomor -// Modified by: +// Modified by: // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#ifdef __GNUG__ - #pragma implementation "fontenum.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#ifdef __BORLANDC__ - #pragma hdrstop -#endif +#if wxUSE_FONTMAP #ifndef WX_PRECOMP #include "wx/font.h" @@ -36,12 +22,11 @@ #include "wx/fontutil.h" #include "wx/fontmap.h" #include "wx/fontutil.h" +#include "wx/encinfo.h" +#include "wx/intl.h" #include "wx/mac/private.h" -// ---------------------------------------------------------------------------- -// private classes -// ---------------------------------------------------------------------------- class wxFontEnumeratorHelper { @@ -66,9 +51,10 @@ private: // if not empty, enum only the fonts with this facename wxString m_facename; - // if TRUE, enum only fixed fonts + // if true, enum only fixed fonts bool m_fixedOnly; }; + // ============================================================================ // implementation // ============================================================================ @@ -81,72 +67,72 @@ wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum) { m_fontEnum = fontEnum; m_charset = -1; - m_fixedOnly = FALSE; + m_fixedOnly = false; } bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding) { wxNativeEncodingInfo info; - if ( !wxGetNativeFontEncoding(encoding, &info) ) + if ( !wxGetNativeFontEncoding( encoding, &info ) ) { - if ( !wxFontMapper::Get()->GetAltForEncoding(encoding, &info) ) - { + if ( !wxFontMapper::Get()->GetAltForEncoding( encoding, &info ) ) // no such encodings at all - return FALSE; - } + return false; } + m_charset = info.charset; m_facename = info.facename; - return TRUE; + return true; } void wxFontEnumeratorHelper::DoEnumerate() { - MenuHandle menu ; - Str255 p_name ; - char c_name[256] ; - 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 ) ; -#if TARGET_CARBON - p2cstrcpy( c_name, p_name ) ; + 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 - p2cstr( p_name ) ; - strcpy( c_name, (char *)p_name ) ; + Str255 p_name; + GetMenuItemText( menu, i, p_name ); + c_name = wxMacMakeStringFromPascal( p_name ); +#endif + +#if 0 + 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; + } #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 ) ; + + m_fontEnum->OnFacename( c_name ); + } + + DisposeMenu( menu ); } // ---------------------------------------------------------------------------- @@ -165,12 +151,14 @@ bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding, } // else: no such fonts, unknown encoding - return TRUE; + return true; } bool wxFontEnumerator::EnumerateEncodings(const wxString& family) { - wxFAIL_MSG(wxT("TODO")); + wxFAIL_MSG(wxT("wxFontEnumerator::EnumerateEncodings() not yet implemented")); - return TRUE; + return true; } + +#endif