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