]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/fontenum.cpp
wxADJUST_MIN definition (forgot to ci last time)
[wxWidgets.git] / src / mac / fontenum.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: mac/fontenum.cpp
3// Purpose: wxFontEnumerator class for MacOS
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
21 #pragma implementation "fontenum.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
31#ifndef WX_PRECOMP
32 #include "wx/font.h"
33#endif
34
35#include "wx/fontenum.h"
36#include "wx/fontutil.h"
37#include "wx/fontmap.h"
38#include "wx/fontutil.h"
39
40// ----------------------------------------------------------------------------
41// private classes
42// ----------------------------------------------------------------------------
43
44class wxFontEnumeratorHelper
45{
46public:
47 wxFontEnumeratorHelper(wxFontEnumerator *fontEnum);
48
49 // control what exactly are we enumerating
50 bool SetEncoding(wxFontEncoding encoding);
51 void SetFixedOnly(bool fixedOnly)
52 { m_fixedOnly = fixedOnly; }
53
54 // call to start enumeration
55 void DoEnumerate();
56
57private:
58 // the object we forward calls to OnFont() to
59 wxFontEnumerator *m_fontEnum;
60
61 // if != -1, enum only fonts which have this encoding
62 int m_charset;
63
64 // if not empty, enum only the fonts with this facename
65 wxString m_facename;
66
67 // if TRUE, enum only fixed fonts
68 bool m_fixedOnly;
69};
70// ============================================================================
71// implementation
72// ============================================================================
73
74// ----------------------------------------------------------------------------
75// wxFontEnumeratorHelper
76// ----------------------------------------------------------------------------
77
78wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum)
79{
80 m_fontEnum = fontEnum;
81 m_charset = -1;
82 m_fixedOnly = FALSE;
83}
84
85bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
86{
87 wxNativeEncodingInfo info;
88 if ( !wxGetNativeFontEncoding(encoding, &info) )
89 {
90 if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
91 {
92 // no such encodings at all
93 return FALSE;
94 }
95 }
96 m_charset = info.charset;
97 m_facename = info.facename;
98
99 return TRUE;
100}
101
102void wxFontEnumeratorHelper::DoEnumerate()
103{
104 MenuHandle menu ;
105 Str255 name ;
106 short lines ;
107
108 menu = NewMenu( 32000 , "\pFont" ) ;
109 AppendResMenu( menu , 'FONT' ) ;
110 lines = CountMenuItems( menu ) ;
111
112 for ( int i = 1 ; i < lines+1 ; i ++ )
113 {
114 GetMenuItemText( menu , i , name ) ;
115 p2cstr( name ) ;
116 /*
117
118 if ( m_fixedOnly )
119 {
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 )
123 {
124 // not a fixed pitch font
125 return TRUE;
126 }
127 }
128
129 if ( m_charset != -1 )
130 {
131 // check that we have the right encoding
132 if ( lf->lfCharSet != m_charset )
133 {
134 return TRUE;
135 }
136 }
137
138 */
139 m_fontEnum->OnFacename( name ) ;
140 }
141 DisposeMenu( menu ) ;
142}
143
144// ----------------------------------------------------------------------------
145// wxFontEnumerator
146// ----------------------------------------------------------------------------
147
148bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
149 bool fixedWidthOnly)
150{
151 wxFontEnumeratorHelper fe(this);
152 if ( fe.SetEncoding(encoding) )
153 {
154 fe.SetFixedOnly(fixedWidthOnly);
155
156 fe.DoEnumerate();
157 }
158 // else: no such fonts, unknown encoding
159
160 return TRUE;
161}
162
163bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
164{
165 wxFAIL_MSG(wxT("TODO"));
166
167 return TRUE;
168}