1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: mac/fontenum.cpp
3 // Purpose: wxFontEnumerator class for MacOS
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "fontenum.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #include "wx/fontenum.h"
36 #include "wx/fontutil.h"
37 #include "wx/fontmap.h"
38 #include "wx/fontutil.h"
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 class wxFontEnumeratorHelper
47 wxFontEnumeratorHelper(wxFontEnumerator
*fontEnum
);
49 // control what exactly are we enumerating
50 bool SetEncoding(wxFontEncoding encoding
);
51 void SetFixedOnly(bool fixedOnly
)
52 { m_fixedOnly
= fixedOnly
; }
54 // call to start enumeration
58 // the object we forward calls to OnFont() to
59 wxFontEnumerator
*m_fontEnum
;
61 // if != -1, enum only fonts which have this encoding
64 // if not empty, enum only the fonts with this facename
67 // if TRUE, enum only fixed fonts
70 // ============================================================================
72 // ============================================================================
74 // ----------------------------------------------------------------------------
75 // wxFontEnumeratorHelper
76 // ----------------------------------------------------------------------------
78 wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator
*fontEnum
)
80 m_fontEnum
= fontEnum
;
85 bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding
)
87 wxNativeEncodingInfo info
;
88 if ( !wxGetNativeFontEncoding(encoding
, &info
) )
90 if ( !wxTheFontMapper
->GetAltForEncoding(encoding
, &info
) )
92 // no such encodings at all
96 m_charset
= info
.charset
;
97 m_facename
= info
.facename
;
102 void wxFontEnumeratorHelper::DoEnumerate()
108 menu
= NewMenu( 32000 , "\pFont" ) ;
109 AppendResMenu( menu
, 'FONT' ) ;
110 lines
= CountMenuItems( menu
) ;
112 for ( int i
= 1 ; i
< lines
+1 ; i
++ )
114 GetMenuItemText( menu
, i
, name
) ;
120 // check that it's a fixed pitch font (there is *no* error here, the
121 // flag name is misleading!)
122 if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
124 // not a fixed pitch font
129 if ( m_charset != -1 )
131 // check that we have the right encoding
132 if ( lf->lfCharSet != m_charset )
139 m_fontEnum
->OnFacename( name
) ;
141 DisposeMenu( menu
) ;
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
148 bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding
,
151 wxFontEnumeratorHelper
fe(this);
152 if ( fe
.SetEncoding(encoding
) )
154 fe
.SetFixedOnly(fixedWidthOnly
);
158 // else: no such fonts, unknown encoding
163 bool wxFontEnumerator::EnumerateEncodings(const wxString
& family
)
165 wxFAIL_MSG(wxT("TODO"));