]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/font.cpp
Do not use wxS in array of const wxChar*
[wxWidgets.git] / src / mgl / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/font.cpp
3 // Author: Vaclav Slavik
4 // Id: $Id$
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // ============================================================================
10 // declarations
11 // ============================================================================
12
13 // ----------------------------------------------------------------------------
14 // headers
15 // ----------------------------------------------------------------------------
16
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #include "wx/font.h"
25
26 #include "wx/private/fontmgr.h"
27
28 // ============================================================================
29 // implementation
30 // ============================================================================
31
32 typedef wxFontMgrFontRefData wxFontRefData;
33 #define M_FONTDATA ((wxFontRefData*)m_refData)
34
35 // ----------------------------------------------------------------------------
36 // wxFont
37 // ----------------------------------------------------------------------------
38
39 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
40
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 wxFontFamily family,
49 wxFontStyle style,
50 wxFontWeight 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);
57 return true;
58 }
59
60 wxGDIRefData *wxFont::CreateGDIRefData() const
61 {
62 return new wxFontRefData;
63 }
64
65 wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
66 {
67 return new wxFontRefData(*(wxFontRefData *)data);
68 }
69
70
71 // ----------------------------------------------------------------------------
72 // accessors
73 // ----------------------------------------------------------------------------
74
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
84 int wxFont::GetPointSize() const
85 {
86 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
87
88 return M_FONTDATA->GetPointSize();
89 }
90
91 wxString wxFont::GetFaceName() const
92 {
93 wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
94
95 return M_FONTDATA->GetFaceName();
96 }
97
98 wxFontFamily wxFont::GetFamily() const
99 {
100 wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") );
101
102 return M_FONTDATA->GetFamily();
103 }
104
105 wxFontStyle wxFont::GetStyle() const
106 {
107 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") );
108
109 return M_FONTDATA->GetStyle();
110 }
111
112 wxFontWeight wxFont::GetWeight() const
113 {
114 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") );
115
116 return M_FONTDATA->GetWeight();
117 }
118
119 bool wxFont::GetUnderlined() const
120 {
121 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
122
123 return M_FONTDATA->GetUnderlined();
124 }
125
126
127 wxFontEncoding wxFont::GetEncoding() const
128 {
129 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
130
131 return M_FONTDATA->GetEncoding();
132 }
133
134 bool wxFont::IsFixedWidth() const
135 {
136 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
137
138 return M_FONTDATA->IsFixedWidth();
139 }
140
141 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
142 {
143 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
144
145 return M_FONTDATA->GetNativeFontInfo();
146 }
147
148 bool wxFont::GetNoAntiAliasing() const
149 {
150 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
151
152 return M_FONTDATA->GetNoAntiAliasing();
153 }
154
155 // ----------------------------------------------------------------------------
156 // change font attributes
157 // ----------------------------------------------------------------------------
158
159 void wxFont::SetPointSize(int pointSize)
160 {
161 AllocExclusive();
162 M_FONTDATA->SetPointSize(pointSize);
163 }
164
165 void wxFont::SetFamily(wxFontFamily family)
166 {
167 AllocExclusive();
168 M_FONTDATA->SetFamily(family);
169 }
170
171 void wxFont::SetStyle(wxFontStyle style)
172 {
173 AllocExclusive();
174 M_FONTDATA->SetStyle(style);
175 }
176
177 void wxFont::SetWeight(wxFontWeight weight)
178 {
179 AllocExclusive();
180 M_FONTDATA->SetWeight(weight);
181 }
182
183 bool wxFont::SetFaceName(const wxString& faceName)
184 {
185 AllocExclusive();
186 M_FONTDATA->SetFaceName(faceName);
187 return wxFontBase::SetFaceName(faceName);
188 }
189
190 void wxFont::SetUnderlined(bool underlined)
191 {
192 AllocExclusive();
193 M_FONTDATA->SetUnderlined(underlined);
194 }
195
196 void wxFont::SetEncoding(wxFontEncoding encoding)
197 {
198 AllocExclusive();
199 M_FONTDATA->SetEncoding(encoding);
200 }
201
202 void wxFont::SetNoAntiAliasing(bool no)
203 {
204 AllocExclusive();
205 M_FONTDATA->SetNoAntiAliasing(no);
206 }