]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/fontutil.cpp
Add virtual ~wxAnyScrollHelperBase() to fix compiler warning.
[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
a24aff65 7// Copyright: (c) Vadim Zeitlin
526954c5 8// Licence: wxWindows licence
a24aff65
DE
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
a24aff65
DE
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
02761f6c
WS
26#include "wx/fontutil.h"
27
a24aff65 28#ifndef WX_PRECOMP
32d4c30a 29 #include "wx/hash.h"
de6185e2 30 #include "wx/utils.h"
02761f6c 31 #include "wx/module.h"
a24aff65
DE
32#endif // PCH
33
a24aff65
DE
34#include "wx/fontmap.h"
35#include "wx/tokenzr.h"
9c6e197f 36#include "wx/encinfo.h"
a24aff65
DE
37
38#ifdef __WXGTK20__
39
40#include "wx/gtk/private.h"
41
42// ----------------------------------------------------------------------------
43// wxNativeFontInfo
44// ----------------------------------------------------------------------------
45
46void wxNativeFontInfo::Init()
47{
48 description = NULL;
49}
50
51int wxNativeFontInfo::GetPointSize() const
52{
53 return pango_font_description_get_size( description ) / PANGO_SCALE;
54}
55
56wxFontStyle 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 }
32d4c30a 72
a24aff65
DE
73 return m_style;
74}
75
76wxFontWeight 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 }
32d4c30a 101
a24aff65
DE
102 return m_weight;
103}
104
105bool wxNativeFontInfo::GetUnderlined() const
106{
32d4c30a 107 return false;
a24aff65
DE
108}
109
110wxString wxNativeFontInfo::GetFaceName() const
111{
112 wxString tmp = wxGTK_CONV_BACK( pango_font_description_get_family( description ) );
32d4c30a 113
a24aff65
DE
114 return tmp;
115}
116
117wxFontFamily wxNativeFontInfo::GetFamily() const
118{
119 return wxFONTFAMILY_SWISS;
120}
121
122wxFontEncoding wxNativeFontInfo::GetEncoding() const
123{
124 return wxFONTENCODING_SYSTEM;
125}
126
127// ----------------------------------------------------------------------------
128// wxNativeEncodingInfo
129// ----------------------------------------------------------------------------
130
131bool wxNativeEncodingInfo::FromString(const wxString& s)
132{
32d4c30a 133 return false;
a24aff65
DE
134}
135
136wxString wxNativeEncodingInfo::ToString() const
137{
138 return wxEmptyString;
139}
140
141bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
142{
32d4c30a 143 return true;
a24aff65
DE
144}
145
146bool wxGetNativeFontEncoding(wxFontEncoding encoding,
147 wxNativeEncodingInfo *info)
148{
32d4c30a 149 return false;
a24aff65
DE
150}
151
32d4c30a 152#else
a24aff65
DE
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
a24aff65
DE
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
d3b9f782 181static wxHashTable *g_fontHash = NULL;
a24aff65
DE
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]
197bool wxNativeEncodingInfo::FromString(const wxString& s)
198{
199return false;
200}
201
202wxString wxNativeEncodingInfo::ToString() const
203{
204return wxEmptyString;
205}
206
207// ----------------------------------------------------------------------------
208// common functions
209// ----------------------------------------------------------------------------
210
211bool wxGetNativeFontEncoding(wxFontEncoding encoding,
212 wxNativeEncodingInfo *info)
213{
32d4c30a 214 return false;
a24aff65
DE
215}
216
217bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
218{
219return false;
220}
221
222// ----------------------------------------------------------------------------
223// private functions
224// ----------------------------------------------------------------------------
225
226// ----------------------------------------------------------------------------
227// wxFontModule
228// ----------------------------------------------------------------------------
229
230class wxFontModule : public wxModule
231{
232public:
233 bool OnInit();
234 void OnExit();
235
236private:
237 DECLARE_DYNAMIC_CLASS(wxFontModule)
238};
239
240IMPLEMENT_DYNAMIC_CLASS(wxFontModule, wxModule)
241
242bool wxFontModule::OnInit()
243{
244 g_fontHash = new wxHashTable( wxKEY_STRING );
245
32d4c30a 246 return true;
a24aff65
DE
247}
248
249void wxFontModule::OnExit()
250{
5276b0a5 251 wxDELETE(g_fontHash);
a24aff65
DE
252}
253
254#endif
255 // not GTK 2.0