]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/font.cpp
remove streams tests: they're very basic and already-existing CppUnit stream tests...
[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
39IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
40
32b8ec41
VZ
41bool wxFont::Create(const wxNativeFontInfo& info)
42{
43 return Create(info.pointSize, info.family, info.style, info.weight,
44 info.underlined, info.faceName, info.encoding);
45}
46
47bool wxFont::Create(int pointSize,
0c14b6c3
FM
48 wxFontFamily family,
49 wxFontStyle style,
50 wxFontWeight weight,
32b8ec41
VZ
51 bool underlined,
52 const wxString& face,
53 wxFontEncoding encoding)
54{
55 m_refData = new wxFontRefData(pointSize, family, style, weight,
56 underlined, face, encoding);
de6185e2 57 return true;
32b8ec41
VZ
58}
59
8f884a0d 60wxGDIRefData *wxFont::CreateGDIRefData() const
32b8ec41 61{
6d7ee9e8 62 return new wxFontRefData;
32b8ec41
VZ
63}
64
8f884a0d 65wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
6d7ee9e8
VS
66{
67 return new wxFontRefData(*(wxFontRefData *)data);
68}
69
70
32b8ec41
VZ
71// ----------------------------------------------------------------------------
72// accessors
73// ----------------------------------------------------------------------------
74
d04f9b8e
VS
75struct font_t *wxFont::GetMGLfont_t(float scale, bool antialiased)
76{
77 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
78
79 // we don't support DC scaling yet, so use scale=1
80 wxFontInstance *i = M_FONTDATA->GetFontInstance(1.0, antialiased);
81 return i ? i->GetMGLfont_t() : NULL;
82}
83
32b8ec41
VZ
84int wxFont::GetPointSize() const
85{
86 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
87
d04f9b8e 88 return M_FONTDATA->GetPointSize();
32b8ec41
VZ
89}
90
91wxString wxFont::GetFaceName() const
92{
5536310d 93 wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
32b8ec41 94
d04f9b8e 95 return M_FONTDATA->GetFaceName();
32b8ec41
VZ
96}
97
0c14b6c3 98wxFontFamily wxFont::GetFamily() const
32b8ec41 99{
0c14b6c3 100 wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") );
32b8ec41 101
d04f9b8e 102 return M_FONTDATA->GetFamily();
32b8ec41
VZ
103}
104
0c14b6c3 105wxFontStyle wxFont::GetStyle() const
32b8ec41 106{
0c14b6c3 107 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") );
32b8ec41 108
d04f9b8e 109 return M_FONTDATA->GetStyle();
32b8ec41
VZ
110}
111
0c14b6c3 112wxFontWeight wxFont::GetWeight() const
32b8ec41 113{
0c14b6c3 114 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") );
32b8ec41 115
d04f9b8e 116 return M_FONTDATA->GetWeight();
32b8ec41
VZ
117}
118
119bool wxFont::GetUnderlined() const
120{
de6185e2 121 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
32b8ec41 122
d04f9b8e 123 return M_FONTDATA->GetUnderlined();
32b8ec41
VZ
124}
125
126
127wxFontEncoding wxFont::GetEncoding() const
128{
129 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
130
d04f9b8e 131 return M_FONTDATA->GetEncoding();
32b8ec41
VZ
132}
133
f3437beb
VS
134bool wxFont::IsFixedWidth() const
135{
de6185e2 136 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
f3437beb 137
d04f9b8e 138 return M_FONTDATA->IsFixedWidth();
f3437beb
VS
139}
140
3bf5a59b
VZ
141const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
142{
143 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
144
d04f9b8e
VS
145 return M_FONTDATA->GetNativeFontInfo();
146}
3bf5a59b 147
32b8ec41
VZ
148// ----------------------------------------------------------------------------
149// change font attributes
150// ----------------------------------------------------------------------------
151
152void wxFont::SetPointSize(int pointSize)
153{
6d7ee9e8 154 AllocExclusive();
d04f9b8e 155 M_FONTDATA->SetPointSize(pointSize);
32b8ec41
VZ
156}
157
0c14b6c3 158void wxFont::SetFamily(wxFontFamily family)
32b8ec41 159{
6d7ee9e8 160 AllocExclusive();
d04f9b8e 161 M_FONTDATA->SetFamily(family);
32b8ec41
VZ
162}
163
0c14b6c3 164void wxFont::SetStyle(wxFontStyle style)
32b8ec41 165{
6d7ee9e8 166 AllocExclusive();
d04f9b8e 167 M_FONTDATA->SetStyle(style);
32b8ec41
VZ
168}
169
0c14b6c3 170void wxFont::SetWeight(wxFontWeight weight)
32b8ec41 171{
6d7ee9e8 172 AllocExclusive();
d04f9b8e 173 M_FONTDATA->SetWeight(weight);
32b8ec41
VZ
174}
175
85ab460e 176bool wxFont::SetFaceName(const wxString& faceName)
32b8ec41 177{
6d7ee9e8 178 AllocExclusive();
d04f9b8e 179 M_FONTDATA->SetFaceName(faceName);
85ab460e 180 return wxFontBase::SetFaceName(faceName);
32b8ec41
VZ
181}
182
183void wxFont::SetUnderlined(bool underlined)
184{
6d7ee9e8 185 AllocExclusive();
d04f9b8e 186 M_FONTDATA->SetUnderlined(underlined);
32b8ec41
VZ
187}
188
189void wxFont::SetEncoding(wxFontEncoding encoding)
190{
6d7ee9e8 191 AllocExclusive();
d04f9b8e
VS
192 M_FONTDATA->SetEncoding(encoding);
193}
32b8ec41 194