]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/font.cpp
Use the data scheme to load resources in the WebKitGTK+ implementation, rather than...
[wxWidgets.git] / src / mgl / font.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
5536310d 2// Name: src/mgl/font.cpp
32b8ec41
VZ
3// Author: Vaclav Slavik
4// Id: $Id$
c41c20a5 5// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
65571936 6// Licence: wxWindows licence
32b8ec41
VZ
7/////////////////////////////////////////////////////////////////////////////
8
9// ============================================================================
10// declarations
11// ============================================================================
12
13// ----------------------------------------------------------------------------
14// headers
15// ----------------------------------------------------------------------------
16
a246f95e
VS
17// For compilers that support precompilation, includes "wx.h".
18#include "wx/wxprec.h"
19
20#ifdef __BORLANDC__
21 #pragma hdrstop
22#endif
23
32b8ec41 24#include "wx/font.h"
e4db172a 25
d04f9b8e 26#include "wx/private/fontmgr.h"
873fd4af 27
32b8ec41
VZ
28// ============================================================================
29// implementation
30// ============================================================================
31
d04f9b8e
VS
32typedef wxFontMgrFontRefData wxFontRefData;
33#define M_FONTDATA ((wxFontRefData*)m_refData)
32b8ec41
VZ
34
35// ----------------------------------------------------------------------------
36// wxFont
37// ----------------------------------------------------------------------------
38
32b8ec41
VZ
39bool wxFont::Create(const wxNativeFontInfo& info)
40{
41 return Create(info.pointSize, info.family, info.style, info.weight,
42 info.underlined, info.faceName, info.encoding);
43}
44
45bool wxFont::Create(int pointSize,
0c14b6c3
FM
46 wxFontFamily family,
47 wxFontStyle style,
48 wxFontWeight weight,
32b8ec41
VZ
49 bool underlined,
50 const wxString& face,
51 wxFontEncoding encoding)
52{
53 m_refData = new wxFontRefData(pointSize, family, style, weight,
54 underlined, face, encoding);
de6185e2 55 return true;
32b8ec41
VZ
56}
57
8f884a0d 58wxGDIRefData *wxFont::CreateGDIRefData() const
32b8ec41 59{
6d7ee9e8 60 return new wxFontRefData;
32b8ec41
VZ
61}
62
8f884a0d 63wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
6d7ee9e8
VS
64{
65 return new wxFontRefData(*(wxFontRefData *)data);
66}
67
68
32b8ec41
VZ
69// ----------------------------------------------------------------------------
70// accessors
71// ----------------------------------------------------------------------------
72
d04f9b8e
VS
73struct font_t *wxFont::GetMGLfont_t(float scale, bool antialiased)
74{
a1b806b9 75 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
d04f9b8e
VS
76
77 // we don't support DC scaling yet, so use scale=1
78 wxFontInstance *i = M_FONTDATA->GetFontInstance(1.0, antialiased);
79 return i ? i->GetMGLfont_t() : NULL;
80}
81
32b8ec41
VZ
82int wxFont::GetPointSize() const
83{
a1b806b9 84 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
32b8ec41 85
d04f9b8e 86 return M_FONTDATA->GetPointSize();
32b8ec41
VZ
87}
88
89wxString wxFont::GetFaceName() const
90{
a1b806b9 91 wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
32b8ec41 92
d04f9b8e 93 return M_FONTDATA->GetFaceName();
32b8ec41
VZ
94}
95
59b7da02 96wxFontFamily wxFont::DoGetFamily() const
32b8ec41 97{
d04f9b8e 98 return M_FONTDATA->GetFamily();
32b8ec41
VZ
99}
100
0c14b6c3 101wxFontStyle wxFont::GetStyle() const
32b8ec41 102{
a1b806b9 103 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX, wxT("invalid font") );
32b8ec41 104
d04f9b8e 105 return M_FONTDATA->GetStyle();
32b8ec41
VZ
106}
107
0c14b6c3 108wxFontWeight wxFont::GetWeight() const
32b8ec41 109{
a1b806b9 110 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
32b8ec41 111
d04f9b8e 112 return M_FONTDATA->GetWeight();
32b8ec41
VZ
113}
114
115bool wxFont::GetUnderlined() const
116{
a1b806b9 117 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
32b8ec41 118
d04f9b8e 119 return M_FONTDATA->GetUnderlined();
32b8ec41
VZ
120}
121
122
123wxFontEncoding wxFont::GetEncoding() const
124{
a1b806b9 125 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
32b8ec41 126
d04f9b8e 127 return M_FONTDATA->GetEncoding();
32b8ec41
VZ
128}
129
f3437beb
VS
130bool wxFont::IsFixedWidth() const
131{
a1b806b9 132 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
f3437beb 133
d04f9b8e 134 return M_FONTDATA->IsFixedWidth();
f3437beb
VS
135}
136
3bf5a59b
VZ
137const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
138{
a1b806b9 139 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
3bf5a59b 140
d04f9b8e
VS
141 return M_FONTDATA->GetNativeFontInfo();
142}
3bf5a59b 143
32b8ec41
VZ
144// ----------------------------------------------------------------------------
145// change font attributes
146// ----------------------------------------------------------------------------
147
148void wxFont::SetPointSize(int pointSize)
149{
6d7ee9e8 150 AllocExclusive();
d04f9b8e 151 M_FONTDATA->SetPointSize(pointSize);
32b8ec41
VZ
152}
153
0c14b6c3 154void wxFont::SetFamily(wxFontFamily family)
32b8ec41 155{
6d7ee9e8 156 AllocExclusive();
d04f9b8e 157 M_FONTDATA->SetFamily(family);
32b8ec41
VZ
158}
159
0c14b6c3 160void wxFont::SetStyle(wxFontStyle style)
32b8ec41 161{
6d7ee9e8 162 AllocExclusive();
d04f9b8e 163 M_FONTDATA->SetStyle(style);
32b8ec41
VZ
164}
165
0c14b6c3 166void wxFont::SetWeight(wxFontWeight weight)
32b8ec41 167{
6d7ee9e8 168 AllocExclusive();
d04f9b8e 169 M_FONTDATA->SetWeight(weight);
32b8ec41
VZ
170}
171
85ab460e 172bool wxFont::SetFaceName(const wxString& faceName)
32b8ec41 173{
6d7ee9e8 174 AllocExclusive();
d04f9b8e 175 M_FONTDATA->SetFaceName(faceName);
85ab460e 176 return wxFontBase::SetFaceName(faceName);
32b8ec41
VZ
177}
178
179void wxFont::SetUnderlined(bool underlined)
180{
6d7ee9e8 181 AllocExclusive();
d04f9b8e 182 M_FONTDATA->SetUnderlined(underlined);
32b8ec41
VZ
183}
184
185void wxFont::SetEncoding(wxFontEncoding encoding)
186{
6d7ee9e8 187 AllocExclusive();
d04f9b8e
VS
188 M_FONTDATA->SetEncoding(encoding);
189}
32b8ec41 190