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