Repository navigation
Expand file tree
/
Copy pathfont.cpp
More file actions
206 lines (158 loc) · 5.09 KB
/
Copy pathfont.cpp
File metadata and controls
206 lines (158 loc) · 5.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/////////////////////////////////////////////////////////////////////////////
// Name: src/mgl/font.cpp
// Author: Vaclav Slavik
// Id: $Id$
// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/font.h"
#include "wx/private/fontmgr.h"
// ============================================================================
// implementation
// ============================================================================
typedef wxFontMgrFontRefData wxFontRefData;
#define M_FONTDATA ((wxFontRefData*)m_refData)
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
bool wxFont::Create(const wxNativeFontInfo& info)
{
return Create(info.pointSize, info.family, info.style, info.weight,
info.underlined, info.faceName, info.encoding);
}
bool wxFont::Create(int pointSize,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
const wxString& face,
wxFontEncoding encoding)
{
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, face, encoding);
return true;
}
wxGDIRefData *wxFont::CreateGDIRefData() const
{
return new wxFontRefData;
}
wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
{
return new wxFontRefData(*(wxFontRefData *)data);
}
// ----------------------------------------------------------------------------
// accessors
// ----------------------------------------------------------------------------
struct font_t *wxFont::GetMGLfont_t(float scale, bool antialiased)
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
// we don't support DC scaling yet, so use scale=1
wxFontInstance *i = M_FONTDATA->GetFontInstance(1.0, antialiased);
return i ? i->GetMGLfont_t() : NULL;
}
int wxFont::GetPointSize() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->GetPointSize();
}
wxString wxFont::GetFaceName() const
{
wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
return M_FONTDATA->GetFaceName();
}
wxFontFamily wxFont::GetFamily() const
{
wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") );
return M_FONTDATA->GetFamily();
}
wxFontStyle wxFont::GetStyle() const
{
wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") );
return M_FONTDATA->GetStyle();
}
wxFontWeight wxFont::GetWeight() const
{
wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") );
return M_FONTDATA->GetWeight();
}
bool wxFont::GetUnderlined() const
{
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->GetUnderlined();
}
wxFontEncoding wxFont::GetEncoding() const
{
wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
return M_FONTDATA->GetEncoding();
}
bool wxFont::IsFixedWidth() const
{
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->IsFixedWidth();
}
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
return M_FONTDATA->GetNativeFontInfo();
}
bool wxFont::GetNoAntiAliasing() const
{
wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->GetNoAntiAliasing();
}
// ----------------------------------------------------------------------------
// change font attributes
// ----------------------------------------------------------------------------
void wxFont::SetPointSize(int pointSize)
{
AllocExclusive();
M_FONTDATA->SetPointSize(pointSize);
}
void wxFont::SetFamily(wxFontFamily family)
{
AllocExclusive();
M_FONTDATA->SetFamily(family);
}
void wxFont::SetStyle(wxFontStyle style)
{
AllocExclusive();
M_FONTDATA->SetStyle(style);
}
void wxFont::SetWeight(wxFontWeight weight)
{
AllocExclusive();
M_FONTDATA->SetWeight(weight);
}
bool wxFont::SetFaceName(const wxString& faceName)
{
AllocExclusive();
M_FONTDATA->SetFaceName(faceName);
return wxFontBase::SetFaceName(faceName);
}
void wxFont::SetUnderlined(bool underlined)
{
AllocExclusive();
M_FONTDATA->SetUnderlined(underlined);
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
AllocExclusive();
M_FONTDATA->SetEncoding(encoding);
}
void wxFont::SetNoAntiAliasing(bool no)
{
AllocExclusive();
M_FONTDATA->SetNoAntiAliasing(no);
}