]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/fontutil.cpp
Digital Mars compilation warnings and Unicode fixes (patch 884587)
[wxWidgets.git] / src / cocoa / fontutil.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: unix/fontutil.cpp
3 // Purpose: Font helper functions for X11 (GDK/X)
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 05.11.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #ifdef __GNUG__
21 #pragma implementation "fontutil.h"
22 #endif
23
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
26
27 #ifdef __BORLANDC__
28 #pragma hdrstop
29 #endif
30
31 #ifndef WX_PRECOMP
32 #endif // PCH
33
34 #include "wx/fontutil.h"
35 #include "wx/fontmap.h"
36 #include "wx/tokenzr.h"
37 #include "wx/hash.h"
38 #include "wx/module.h"
39 #include "wx/encinfo.h"
40
41 #ifdef __WXGTK20__
42
43 #include "wx/gtk/private.h"
44
45 // ----------------------------------------------------------------------------
46 // wxNativeFontInfo
47 // ----------------------------------------------------------------------------
48
49 void wxNativeFontInfo::Init()
50 {
51 description = NULL;
52 }
53
54 int wxNativeFontInfo::GetPointSize() const
55 {
56 return pango_font_description_get_size( description ) / PANGO_SCALE;
57 }
58
59 wxFontStyle wxNativeFontInfo::GetStyle() const
60 {
61 wxFontStyle m_style = wxFONTSTYLE_NORMAL;
62
63 switch (pango_font_description_get_style( description ))
64 {
65 case PANGO_STYLE_NORMAL:
66 m_style = wxFONTSTYLE_NORMAL;
67 break;
68 case PANGO_STYLE_ITALIC:
69 m_style = wxFONTSTYLE_ITALIC;
70 break;
71 case PANGO_STYLE_OBLIQUE:
72 m_style = wxFONTSTYLE_SLANT;
73 break;
74 }
75
76 return m_style;
77 }
78
79 wxFontWeight wxNativeFontInfo::GetWeight() const
80 {
81 wxFontWeight m_weight = wxFONTWEIGHT_NORMAL;
82
83 switch (pango_font_description_get_weight( description ))
84 {
85 case PANGO_WEIGHT_ULTRALIGHT:
86 m_weight = wxFONTWEIGHT_LIGHT;
87 break;
88 case PANGO_WEIGHT_LIGHT:
89 m_weight = wxFONTWEIGHT_LIGHT;
90 break;
91 case PANGO_WEIGHT_NORMAL:
92 m_weight = wxFONTWEIGHT_NORMAL;
93 break;
94 case PANGO_WEIGHT_BOLD:
95 m_weight = wxFONTWEIGHT_BOLD;
96 break;
97 case PANGO_WEIGHT_ULTRABOLD:
98 m_weight = wxFONTWEIGHT_BOLD;
99 break;
100 case PANGO_WEIGHT_HEAVY:
101 m_weight = wxFONTWEIGHT_BOLD;
102 break;
103 }
104
105 return m_weight;
106 }
107
108 bool wxNativeFontInfo::GetUnderlined() const
109 {
110 return FALSE;
111 }
112
113 wxString wxNativeFontInfo::GetFaceName() const
114 {
115 wxString tmp = wxGTK_CONV_BACK( pango_font_description_get_family( description ) );
116
117 return tmp;
118 }
119
120 wxFontFamily wxNativeFontInfo::GetFamily() const
121 {
122 return wxFONTFAMILY_SWISS;
123 }
124
125 wxFontEncoding wxNativeFontInfo::GetEncoding() const
126 {
127 return wxFONTENCODING_SYSTEM;
128 }
129
130 // ----------------------------------------------------------------------------
131 // wxNativeEncodingInfo
132 // ----------------------------------------------------------------------------
133
134 bool wxNativeEncodingInfo::FromString(const wxString& s)
135 {
136 return FALSE;
137 }
138
139 wxString wxNativeEncodingInfo::ToString() const
140 {
141 return wxEmptyString;
142 }
143
144 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
145 {
146 return TRUE;
147 }
148
149 bool wxGetNativeFontEncoding(wxFontEncoding encoding,
150 wxNativeEncodingInfo *info)
151 {
152 return FALSE;
153 }
154
155 #else
156 // __WXGTK20__
157
158 #ifdef __X__
159 #ifdef __VMS__
160 #pragma message disable nosimpint
161 #endif
162
163 #include <X11/Xlib.h>
164
165 #ifdef __VMS__
166 #pragma message enable nosimpint
167 #endif
168
169 #include "wx/utils.h" // for wxGetDisplay()
170 #elif defined(__WXGTK__)
171 // we have to declare struct tm to avoid problems with first forward
172 // declaring it in C code (glib.h included from gdk.h does it) and then
173 // defining it when time.h is included from the headers below - this is
174 // known not to work at least with Sun CC 6.01
175 #include <time.h>
176
177 #include <gdk/gdk.h>
178 #endif
179
180
181 // ----------------------------------------------------------------------------
182 // private data
183 // ----------------------------------------------------------------------------
184
185 static wxHashTable *g_fontHash = (wxHashTable*) NULL;
186
187 // ----------------------------------------------------------------------------
188 // private functions
189 // ----------------------------------------------------------------------------
190
191 // ============================================================================
192 // implementation
193 // ============================================================================
194
195 // ----------------------------------------------------------------------------
196 // wxNativeEncodingInfo
197 // ----------------------------------------------------------------------------
198
199 // convert to/from the string representation: format is
200 // encodingid;registry;encoding[;facename]
201 bool wxNativeEncodingInfo::FromString(const wxString& s)
202 {
203 return false;
204 }
205
206 wxString wxNativeEncodingInfo::ToString() const
207 {
208 return wxEmptyString;
209 }
210
211 // ----------------------------------------------------------------------------
212 // common functions
213 // ----------------------------------------------------------------------------
214
215 bool wxGetNativeFontEncoding(wxFontEncoding encoding,
216 wxNativeEncodingInfo *info)
217 {
218 return FALSE;
219 }
220
221 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
222 {
223 return false;
224 }
225
226 // ----------------------------------------------------------------------------
227 // private functions
228 // ----------------------------------------------------------------------------
229
230 // ----------------------------------------------------------------------------
231 // wxFontModule
232 // ----------------------------------------------------------------------------
233
234 class wxFontModule : public wxModule
235 {
236 public:
237 bool OnInit();
238 void OnExit();
239
240 private:
241 DECLARE_DYNAMIC_CLASS(wxFontModule)
242 };
243
244 IMPLEMENT_DYNAMIC_CLASS(wxFontModule, wxModule)
245
246 bool wxFontModule::OnInit()
247 {
248 g_fontHash = new wxHashTable( wxKEY_STRING );
249
250 return TRUE;
251 }
252
253 void wxFontModule::OnExit()
254 {
255 delete g_fontHash;
256
257 g_fontHash = (wxHashTable *)NULL;
258 }
259
260 #endif
261 // not GTK 2.0