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()
109 menu
= NewMenu( 32000 , "\pFont" ) ;
110 AppendResMenu( menu
, 'FONT' ) ;
111 lines
= CountMenuItems( menu
) ;
113 for ( int i
= 1 ; i
< lines
+1 ; i
++ )
115 GetMenuItemText( menu
, i
, p_name
) ;
117 p2cstrcpy( c_name
, p_name
) ;
120 strcpy( c_name
, (char *)p_name
) ;
126 // check that it's a fixed pitch font (there is *no* error here, the
127 // flag name is misleading!)
128 if ( tm->tmPitchAndFamily & TMPF_FIXED_PITCH )
130 // not a fixed pitch font
135 if ( m_charset != -1 )
137 // check that we have the right encoding
138 if ( lf->lfCharSet != m_charset )
145 m_fontEnum
->OnFacename( c_name
) ;
147 DisposeMenu( menu
) ;
150 // ----------------------------------------------------------------------------
152 // ----------------------------------------------------------------------------
154 bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding
,
157 wxFontEnumeratorHelper
fe(this);
158 if ( fe
.SetEncoding(encoding
) )
160 fe
.SetFixedOnly(fixedWidthOnly
);
164 // else: no such fonts, unknown encoding
169 bool wxFontEnumerator::EnumerateEncodings(const wxString
& family
)
171 wxFAIL_MSG(wxT("TODO"));