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