1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/font.cpp
3 // Purpose: wxFont implementation
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
32 #include "wx/dfb/private.h"
33 #include "wx/private/fontmgr.h"
35 typedef wxFontMgrFontRefData wxFontRefData
;
36 #define M_FONTDATA ((wxFontRefData*)m_refData)
38 // ----------------------------------------------------------------------------
40 // ----------------------------------------------------------------------------
42 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
44 bool wxFont::Create(const wxNativeFontInfo
& info
)
46 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
47 info
.underlined
, info
.faceName
, info
.encoding
);
50 bool wxFont::Create(int pointSize
,
56 wxFontEncoding encoding
)
58 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
59 underlined
, face
, encoding
);
63 wxObjectRefData
*wxFont::CreateRefData() const
65 return new wxFontRefData
;
68 wxObjectRefData
*wxFont::CloneRefData(const wxObjectRefData
*data
) const
70 return new wxFontRefData(*(wxFontRefData
*)data
);
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 wxIDirectFBFontPtr
wxFont::GetDirectFBFont(bool antialiased
) const
80 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
82 // we don't support DC scaling yet, so use scale=1
83 wxFontInstance
*i
= M_FONTDATA
->GetFontInstance(1.0, antialiased
);
84 return i
? i
->GetDirectFBFont() : wxIDirectFBFontPtr();
87 int wxFont::GetPointSize() const
89 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
91 return M_FONTDATA
->GetPointSize();
94 wxString
wxFont::GetFaceName() const
96 wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") );
98 return M_FONTDATA
->GetFaceName();
101 int wxFont::GetFamily() const
103 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
105 return M_FONTDATA
->GetFamily();
108 int wxFont::GetStyle() const
110 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
112 return M_FONTDATA
->GetStyle();
115 int wxFont::GetWeight() const
117 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
119 return M_FONTDATA
->GetWeight();
122 bool wxFont::GetUnderlined() const
124 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
126 return M_FONTDATA
->GetUnderlined();
130 wxFontEncoding
wxFont::GetEncoding() const
132 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
134 return M_FONTDATA
->GetEncoding();
137 bool wxFont::IsFixedWidth() const
139 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
141 return M_FONTDATA
->IsFixedWidth();
144 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
146 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
148 return M_FONTDATA
->GetNativeFontInfo();
151 bool wxFont::GetNoAntiAliasing() const
153 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
155 return M_FONTDATA
->GetNoAntiAliasing();
158 // ----------------------------------------------------------------------------
159 // change font attributes
160 // ----------------------------------------------------------------------------
162 void wxFont::SetPointSize(int pointSize
)
165 M_FONTDATA
->SetPointSize(pointSize
);
168 void wxFont::SetFamily(int family
)
171 M_FONTDATA
->SetFamily(family
);
174 void wxFont::SetStyle(int style
)
177 M_FONTDATA
->SetStyle(style
);
180 void wxFont::SetWeight(int weight
)
183 M_FONTDATA
->SetWeight(weight
);
186 bool wxFont::SetFaceName(const wxString
& faceName
)
189 M_FONTDATA
->SetFaceName(faceName
);
190 return wxFontBase::SetFaceName(faceName
);
193 void wxFont::SetUnderlined(bool underlined
)
196 M_FONTDATA
->SetUnderlined(underlined
);
199 void wxFont::SetEncoding(wxFontEncoding encoding
)
202 M_FONTDATA
->SetEncoding(encoding
);
205 void wxFont::SetNoAntiAliasing(bool no
)
208 M_FONTDATA
->SetNoAntiAliasing(no
);