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