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/fontmap.h"
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 class wxFontEnumeratorHelper
45 wxFontEnumeratorHelper(wxFontEnumerator
*fontEnum
);
47 // control what exactly are we enumerating
48 bool SetEncoding(wxFontEncoding encoding
);
49 void SetFixedOnly(bool fixedOnly
)
50 { m_fixedOnly
= fixedOnly
; }
52 // call to start enumeration
56 // the object we forward calls to OnFont() to
57 wxFontEnumerator
*m_fontEnum
;
59 // if != -1, enum only fonts which have this encoding
62 // if not empty, enum only the fonts with this facename
65 // if TRUE, enum only fixed fonts
68 // ============================================================================
70 // ============================================================================
72 // ----------------------------------------------------------------------------
73 // wxFontEnumeratorHelper
74 // ----------------------------------------------------------------------------
76 wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator
*fontEnum
)
78 m_fontEnum
= fontEnum
;
83 bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding
)
85 wxNativeEncodingInfo info
;
86 if ( !wxGetNativeFontEncoding(encoding
, &info
) )
88 if ( !wxTheFontMapper
->GetAltForEncoding(encoding
, &info
) )
90 // no such encodings at all
94 m_charset
= info
.charset
;
95 m_facename
= info
.facename
;
100 void wxFontEnumeratorHelper::DoEnumerate()
106 menu
= NewMenu( 32000 , "\pFont" ) ;
107 AppendResMenu( menu
, 'FONT' ) ;
108 lines
= CountMenuItems( menu
) ;
110 for ( int i
= 1 ; i
< lines
+1 ; i
++ )
112 GetMenuItemText( menu
, i
, name
) ;
118 // check that it's a fixed pitch font (there is *no* error here, the
119 // flag name is misleading!)
120 if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
122 // not a fixed pitch font
127 if ( m_charset != -1 )
129 // check that we have the right encoding
130 if ( lf->lfCharSet != m_charset )
137 m_fontEnum
->OnFacename( name
) ;
139 DisposeMenu( menu
) ;
142 // ----------------------------------------------------------------------------
144 // ----------------------------------------------------------------------------
146 bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding
,
149 wxFontEnumeratorHelper
fe(this);
150 if ( fe
.SetEncoding(encoding
) )
152 fe
.SetFixedOnly(fixedWidthOnly
);
156 // else: no such fonts, unknown encoding
161 bool wxFontEnumerator::EnumerateEncodings(const wxString
& family
)
163 wxFAIL_MSG(wxT("TODO"));