]>
Commit | Line | Data |
---|---|---|
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 |
32 | typedef wxFontMgrFontRefData wxFontRefData; |
33 | #define M_FONTDATA ((wxFontRefData*)m_refData) | |
32b8ec41 VZ |
34 | |
35 | // ---------------------------------------------------------------------------- | |
36 | // wxFont | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
39 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) | |
40 | ||
32b8ec41 VZ |
41 | bool 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 | ||
47 | bool wxFont::Create(int pointSize, | |
48 | int family, | |
49 | int style, | |
50 | int weight, | |
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 | ||
6d7ee9e8 | 60 | wxObjectRefData *wxFont::CreateRefData() const |
32b8ec41 | 61 | { |
6d7ee9e8 | 62 | return new wxFontRefData; |
32b8ec41 VZ |
63 | } |
64 | ||
6d7ee9e8 VS |
65 | wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const |
66 | { | |
67 | return new wxFontRefData(*(wxFontRefData *)data); | |
68 | } | |
69 | ||
70 | ||
32b8ec41 VZ |
71 | // ---------------------------------------------------------------------------- |
72 | // accessors | |
73 | // ---------------------------------------------------------------------------- | |
74 | ||
d04f9b8e VS |
75 | struct 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 |
84 | int wxFont::GetPointSize() const |
85 | { | |
86 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); | |
87 | ||
d04f9b8e | 88 | return M_FONTDATA->GetPointSize(); |
32b8ec41 VZ |
89 | } |
90 | ||
91 | wxString 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 | ||
98 | int wxFont::GetFamily() const | |
99 | { | |
100 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); | |
101 | ||
d04f9b8e | 102 | return M_FONTDATA->GetFamily(); |
32b8ec41 VZ |
103 | } |
104 | ||
105 | int wxFont::GetStyle() const | |
106 | { | |
107 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); | |
108 | ||
d04f9b8e | 109 | return M_FONTDATA->GetStyle(); |
32b8ec41 VZ |
110 | } |
111 | ||
112 | int wxFont::GetWeight() const | |
113 | { | |
114 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); | |
115 | ||
d04f9b8e | 116 | return M_FONTDATA->GetWeight(); |
32b8ec41 VZ |
117 | } |
118 | ||
119 | bool 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 | ||
127 | wxFontEncoding 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 |
134 | bool 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 |
141 | const wxNativeFontInfo *wxFont::GetNativeFontInfo() const |
142 | { | |
143 | wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); | |
144 | ||
d04f9b8e VS |
145 | return M_FONTDATA->GetNativeFontInfo(); |
146 | } | |
3bf5a59b | 147 | |
d04f9b8e VS |
148 | bool wxFont::GetNoAntiAliasing() const |
149 | { | |
150 | wxCHECK_MSG( Ok(), false, wxT("invalid font") ); | |
151 | ||
152 | return M_FONTDATA->GetNoAntiAliasing(); | |
3bf5a59b | 153 | } |
32b8ec41 VZ |
154 | |
155 | // ---------------------------------------------------------------------------- | |
156 | // change font attributes | |
157 | // ---------------------------------------------------------------------------- | |
158 | ||
159 | void wxFont::SetPointSize(int pointSize) | |
160 | { | |
6d7ee9e8 | 161 | AllocExclusive(); |
d04f9b8e | 162 | M_FONTDATA->SetPointSize(pointSize); |
32b8ec41 VZ |
163 | } |
164 | ||
165 | void wxFont::SetFamily(int family) | |
166 | { | |
6d7ee9e8 | 167 | AllocExclusive(); |
d04f9b8e | 168 | M_FONTDATA->SetFamily(family); |
32b8ec41 VZ |
169 | } |
170 | ||
171 | void wxFont::SetStyle(int style) | |
172 | { | |
6d7ee9e8 | 173 | AllocExclusive(); |
d04f9b8e | 174 | M_FONTDATA->SetStyle(style); |
32b8ec41 VZ |
175 | } |
176 | ||
177 | void wxFont::SetWeight(int weight) | |
178 | { | |
6d7ee9e8 | 179 | AllocExclusive(); |
d04f9b8e | 180 | M_FONTDATA->SetWeight(weight); |
32b8ec41 VZ |
181 | } |
182 | ||
85ab460e | 183 | bool wxFont::SetFaceName(const wxString& faceName) |
32b8ec41 | 184 | { |
6d7ee9e8 | 185 | AllocExclusive(); |
d04f9b8e | 186 | M_FONTDATA->SetFaceName(faceName); |
85ab460e | 187 | return wxFontBase::SetFaceName(faceName); |
32b8ec41 VZ |
188 | } |
189 | ||
190 | void wxFont::SetUnderlined(bool underlined) | |
191 | { | |
6d7ee9e8 | 192 | AllocExclusive(); |
d04f9b8e | 193 | M_FONTDATA->SetUnderlined(underlined); |
32b8ec41 VZ |
194 | } |
195 | ||
196 | void wxFont::SetEncoding(wxFontEncoding encoding) | |
197 | { | |
6d7ee9e8 | 198 | AllocExclusive(); |
d04f9b8e VS |
199 | M_FONTDATA->SetEncoding(encoding); |
200 | } | |
32b8ec41 | 201 | |
d04f9b8e VS |
202 | void wxFont::SetNoAntiAliasing(bool no) |
203 | { | |
204 | AllocExclusive(); | |
205 | M_FONTDATA->SetNoAntiAliasing(no); | |
32b8ec41 | 206 | } |