]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/fontenum.cpp
Fix Refresh() problem.
[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/dynarray.h"
26 #include "wx/string.h"
27 #include "wx/utils.h"
28
29 #include "wx/fontenum.h"
30 #include "wx/encinfo.h"
31 #include "wx/fontutil.h"
32
33 #include <mgraph.h>
34
35 // ============================================================================
36 // implementation
37 // ============================================================================
38
39
40 // ----------------------------------------------------------------------------
41 // wxFontEnumerator
42 // ----------------------------------------------------------------------------
43
44 bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
45 bool fixedWidthOnly)
46 {
47 bool found = false;
48 wxMGLFontFamilyList *list = wxTheFontsManager->GetFamilyList();
49 wxMGLFontFamilyList::Node *node;
50 wxMGLFontFamily *f = NULL;
51 wxNativeEncodingInfo info;
52
53 if ( encoding != wxFONTENCODING_SYSTEM )
54 wxGetNativeFontEncoding(encoding, &info);
55
56 for (node = list->GetFirst(); node; node = node->GetNext())
57 {
58 f = node->GetData();
59 info.facename = f->GetName();
60 if ( (!fixedWidthOnly || f->GetInfo()->isFixed) &&
61 (encoding == wxFONTENCODING_SYSTEM || wxTestFontEncoding(info)) )
62 {
63 found = true;
64 if ( !OnFacename(f->GetName()) )
65 return true;
66 }
67 }
68
69 return found;
70 }
71
72 bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
73 {
74 static wxFontEncoding encodings[] =
75 {
76 wxFONTENCODING_ISO8859_1,
77 wxFONTENCODING_ISO8859_2,
78 wxFONTENCODING_ISO8859_3,
79 wxFONTENCODING_ISO8859_4,
80 wxFONTENCODING_ISO8859_5,
81 wxFONTENCODING_ISO8859_6,
82 wxFONTENCODING_ISO8859_7,
83 wxFONTENCODING_ISO8859_8,
84 wxFONTENCODING_ISO8859_9,
85 wxFONTENCODING_ISO8859_10,
86 //wxFONTENCODING_ISO8859_11,
87 //wxFONTENCODING_ISO8859_12,
88 wxFONTENCODING_ISO8859_13,
89 wxFONTENCODING_ISO8859_14,
90 wxFONTENCODING_ISO8859_15,
91 wxFONTENCODING_CP1250,
92 wxFONTENCODING_CP1251,
93 wxFONTENCODING_CP1252,
94 wxFONTENCODING_CP1253,
95 wxFONTENCODING_CP1254,
96 wxFONTENCODING_CP1255,
97 wxFONTENCODING_CP1256,
98 wxFONTENCODING_CP1257,
99 wxFONTENCODING_KOI8,
100
101 wxFONTENCODING_SYSTEM
102 };
103
104 static const char *encodingNames[] =
105 {
106 "iso88590-1",
107 "iso88590-2",
108 "iso88590-3",
109 "iso88590-4",
110 "iso88590-5",
111 "iso88590-6",
112 "iso88590-7",
113 "iso88590-8",
114 "iso88590-9",
115 "iso88590-10",
116 "iso88590-13",
117 "iso88590-14",
118 "iso88590-15",
119 "windows-1250",
120 "windows-1251",
121 "windows-1252",
122 "windows-1253",
123 "windows-1254",
124 "windows-1255",
125 "windows-1256",
126 "windows-1257",
127 "koi-8",
128 NULL
129 };
130
131 wxNativeEncodingInfo info;
132 info.facename = family;
133
134 for (size_t i = 0; encodings[i] != wxFONTENCODING_SYSTEM; i++)
135 {
136 if ( !wxGetNativeFontEncoding(encodings[i], &info) ||
137 !wxTestFontEncoding(info) )
138 continue;
139 if ( !OnFontEncoding(family, encodingNames[i]) )
140 break;
141 }
142
143 return true;
144 }