]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/fontenum.cpp
Fixed OS/2 compilation after wxDC changes
[wxWidgets.git] / src / mgl / fontenum.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/fontenum.cpp
3 // Purpose: wxFontEnumerator class for MGL
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 // ============================================================================
18 // declarations
19 // ============================================================================
20
21 // ----------------------------------------------------------------------------
22 // headers
23 // ----------------------------------------------------------------------------
24
25 #include "wx/fontenum.h"
26
27 #ifndef WX_PRECOMP
28 #include "wx/dynarray.h"
29 #include "wx/string.h"
30 #include "wx/utils.h"
31 #endif
32
33 #include "wx/encinfo.h"
34 #include "wx/fontutil.h"
35 #include "wx/private/fontmgr.h"
36
37 #include <mgraph.h>
38
39 // ============================================================================
40 // implementation
41 // ============================================================================
42
43
44 // ----------------------------------------------------------------------------
45 // wxFontEnumerator
46 // ----------------------------------------------------------------------------
47
48 bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
49 bool fixedWidthOnly)
50 {
51 bool found = false;
52 const wxFontBundleList& list = wxFontsManager::Get()->GetBundles();
53 wxFontBundleList::Node *node;
54 wxFontBundle *f = NULL;
55 wxNativeEncodingInfo info;
56
57 if ( encoding != wxFONTENCODING_SYSTEM )
58 wxGetNativeFontEncoding(encoding, &info);
59
60 for (node = list.GetFirst(); node; node = node->GetNext())
61 {
62 f = node->GetData();
63 info.facename = f->GetName();
64 if ( (!fixedWidthOnly || f->IsFixed()) &&
65 (encoding == wxFONTENCODING_SYSTEM || wxTestFontEncoding(info)) )
66 {
67 found = true;
68 if ( !OnFacename(f->GetName()) )
69 return true;
70 }
71 }
72
73 return found;
74 }
75
76 bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
77 {
78 static wxFontEncoding encodings[] =
79 {
80 wxFONTENCODING_ISO8859_1,
81 wxFONTENCODING_ISO8859_2,
82 wxFONTENCODING_ISO8859_3,
83 wxFONTENCODING_ISO8859_4,
84 wxFONTENCODING_ISO8859_5,
85 wxFONTENCODING_ISO8859_6,
86 wxFONTENCODING_ISO8859_7,
87 wxFONTENCODING_ISO8859_8,
88 wxFONTENCODING_ISO8859_9,
89 wxFONTENCODING_ISO8859_10,
90 //wxFONTENCODING_ISO8859_11,
91 //wxFONTENCODING_ISO8859_12,
92 wxFONTENCODING_ISO8859_13,
93 wxFONTENCODING_ISO8859_14,
94 wxFONTENCODING_ISO8859_15,
95 wxFONTENCODING_CP1250,
96 wxFONTENCODING_CP1251,
97 wxFONTENCODING_CP1252,
98 wxFONTENCODING_CP1253,
99 wxFONTENCODING_CP1254,
100 wxFONTENCODING_CP1255,
101 wxFONTENCODING_CP1256,
102 wxFONTENCODING_CP1257,
103 wxFONTENCODING_KOI8,
104
105 wxFONTENCODING_SYSTEM
106 };
107
108 static const char *encodingNames[] =
109 {
110 "iso88590-1",
111 "iso88590-2",
112 "iso88590-3",
113 "iso88590-4",
114 "iso88590-5",
115 "iso88590-6",
116 "iso88590-7",
117 "iso88590-8",
118 "iso88590-9",
119 "iso88590-10",
120 "iso88590-13",
121 "iso88590-14",
122 "iso88590-15",
123 "windows-1250",
124 "windows-1251",
125 "windows-1252",
126 "windows-1253",
127 "windows-1254",
128 "windows-1255",
129 "windows-1256",
130 "windows-1257",
131 "koi-8",
132 NULL
133 };
134
135 wxNativeEncodingInfo info;
136 info.facename = family;
137
138 for (size_t i = 0; encodings[i] != wxFONTENCODING_SYSTEM; i++)
139 {
140 if ( !wxGetNativeFontEncoding(encodings[i], &info) ||
141 !wxTestFontEncoding(info) )
142 continue;
143 if ( !OnFontEncoding(family, encodingNames[i]) )
144 break;
145 }
146
147 return true;
148 }