]>
Commit | Line | Data |
---|---|---|
32b8ec41 | 1 | ///////////////////////////////////////////////////////////////////////////// |
7520f3da | 2 | // Name: src/mgl/fontenum.cpp |
32b8ec41 VZ |
3 | // Purpose: wxFontEnumerator class for MGL |
4 | // Author: Vaclav Slavik | |
5 | // RCS-ID: $Id$ | |
c41c20a5 | 6 | // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) |
65571936 | 7 | // Licence: wxWindows licence |
32b8ec41 VZ |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
7520f3da WS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #ifdef __BORLANDC__ | |
14 | #pragma hdrstop | |
15 | #endif | |
16 | ||
32b8ec41 VZ |
17 | // ============================================================================ |
18 | // declarations | |
19 | // ============================================================================ | |
20 | ||
21 | // ---------------------------------------------------------------------------- | |
22 | // headers | |
23 | // ---------------------------------------------------------------------------- | |
24 | ||
32b8ec41 VZ |
25 | #include "wx/dynarray.h" |
26 | #include "wx/string.h" | |
27 | #include "wx/utils.h" | |
28 | ||
29 | #include "wx/fontenum.h" | |
3af1a9f8 | 30 | #include "wx/encinfo.h" |
32b8ec41 VZ |
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 | { | |
7520f3da | 47 | bool found = false; |
32b8ec41 VZ |
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); | |
7520f3da | 55 | |
32b8ec41 VZ |
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 | { | |
7520f3da | 63 | found = true; |
32b8ec41 | 64 | if ( !OnFacename(f->GetName()) ) |
7520f3da | 65 | return true; |
32b8ec41 VZ |
66 | } |
67 | } | |
68 | ||
69 | return found; | |
70 | } | |
71 | ||
72 | bool wxFontEnumerator::EnumerateEncodings(const wxString& family) | |
73 | { | |
7520f3da | 74 | static wxFontEncoding encodings[] = |
32b8ec41 VZ |
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, | |
7520f3da | 100 | |
32b8ec41 VZ |
101 | wxFONTENCODING_SYSTEM |
102 | }; | |
7520f3da WS |
103 | |
104 | static const char *encodingNames[] = | |
32b8ec41 VZ |
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 | }; | |
7520f3da | 130 | |
32b8ec41 VZ |
131 | wxNativeEncodingInfo info; |
132 | info.facename = family; | |
7520f3da | 133 | |
32b8ec41 VZ |
134 | for (size_t i = 0; encodings[i] != wxFONTENCODING_SYSTEM; i++) |
135 | { | |
136 | if ( !wxGetNativeFontEncoding(encodings[i], &info) || | |
7520f3da | 137 | !wxTestFontEncoding(info) ) |
32b8ec41 VZ |
138 | continue; |
139 | if ( !OnFontEncoding(family, encodingNames[i]) ) | |
140 | break; | |
141 | } | |
142 | ||
7520f3da | 143 | return true; |
32b8ec41 | 144 | } |