]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/font.cpp
Use unsigned char for XBM bitmaps data.
[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::DoGetFamily() const
99 {
100 return M_FONTDATA->GetFamily();
101 }
102
103 wxFontStyle wxFont::GetStyle() const
104 {
105 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") );
106
107 return M_FONTDATA->GetStyle();
108 }
109
110 wxFontWeight wxFont::GetWeight() const
111 {
112 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") );
113
114 return M_FONTDATA->GetWeight();
115 }
116
117 bool wxFont::GetUnderlined() const
118 {
119 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
120
121 return M_FONTDATA->GetUnderlined();
122 }
123
124
125 wxFontEncoding wxFont::GetEncoding() const
126 {
127 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
128
129 return M_FONTDATA->GetEncoding();
130 }
131
132 bool wxFont::IsFixedWidth() const
133 {
134 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
135
136 return M_FONTDATA->IsFixedWidth();
137 }
138
139 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
140 {
141 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
142
143 return M_FONTDATA->GetNativeFontInfo();
144 }
145
146 // ----------------------------------------------------------------------------
147 // change font attributes
148 // ----------------------------------------------------------------------------
149
150 void wxFont::SetPointSize(int pointSize)
151 {
152 AllocExclusive();
153 M_FONTDATA->SetPointSize(pointSize);
154 }
155
156 void wxFont::SetFamily(wxFontFamily family)
157 {
158 AllocExclusive();
159 M_FONTDATA->SetFamily(family);
160 }
161
162 void wxFont::SetStyle(wxFontStyle style)
163 {
164 AllocExclusive();
165 M_FONTDATA->SetStyle(style);
166 }
167
168 void wxFont::SetWeight(wxFontWeight weight)
169 {
170 AllocExclusive();
171 M_FONTDATA->SetWeight(weight);
172 }
173
174 bool wxFont::SetFaceName(const wxString& faceName)
175 {
176 AllocExclusive();
177 M_FONTDATA->SetFaceName(faceName);
178 return wxFontBase::SetFaceName(faceName);
179 }
180
181 void wxFont::SetUnderlined(bool underlined)
182 {
183 AllocExclusive();
184 M_FONTDATA->SetUnderlined(underlined);
185 }
186
187 void wxFont::SetEncoding(wxFontEncoding encoding)
188 {
189 AllocExclusive();
190 M_FONTDATA->SetEncoding(encoding);
191 }
192