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