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