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