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 bool wxFont::Create(const wxNativeFontInfo
& info
)
44 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
45 info
.underlined
, info
.faceName
, info
.encoding
);
48 bool wxFont::Create(int pointSize
,
54 wxFontEncoding encoding
)
56 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
57 underlined
, face
, encoding
);
61 wxGDIRefData
*wxFont::CreateGDIRefData() const
63 return new wxFontRefData
;
66 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
68 return new wxFontRefData(*(wxFontRefData
*)data
);
72 // ----------------------------------------------------------------------------
74 // ----------------------------------------------------------------------------
76 wxIDirectFBFontPtr
wxFont::GetDirectFBFont(bool antialiased
) const
78 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
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();
85 int wxFont::GetPointSize() const
87 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
89 return M_FONTDATA
->GetPointSize();
92 wxString
wxFont::GetFaceName() const
94 wxCHECK_MSG( IsOk(), wxEmptyString
, wxT("invalid font") );
96 return M_FONTDATA
->GetFaceName();
99 wxFontFamily
wxFont::DoGetFamily() const
101 return M_FONTDATA
->GetFamily();
104 wxFontStyle
wxFont::GetStyle() const
106 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX
, wxT("invalid font") );
108 return M_FONTDATA
->GetStyle();
111 wxFontWeight
wxFont::GetWeight() const
113 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX
, wxT("invalid font") );
115 return M_FONTDATA
->GetWeight();
118 bool wxFont::GetUnderlined() const
120 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
122 return M_FONTDATA
->GetUnderlined();
126 wxFontEncoding
wxFont::GetEncoding() const
128 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
130 return M_FONTDATA
->GetEncoding();
133 bool wxFont::IsFixedWidth() const
135 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
137 return M_FONTDATA
->IsFixedWidth();
140 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
142 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
144 return M_FONTDATA
->GetNativeFontInfo();
147 // ----------------------------------------------------------------------------
148 // change font attributes
149 // ----------------------------------------------------------------------------
151 void wxFont::SetPointSize(int pointSize
)
154 M_FONTDATA
->SetPointSize(pointSize
);
157 void wxFont::SetFamily(wxFontFamily family
)
160 M_FONTDATA
->SetFamily(family
);
163 void wxFont::SetStyle(wxFontStyle style
)
166 M_FONTDATA
->SetStyle(style
);
169 void wxFont::SetWeight(wxFontWeight weight
)
172 M_FONTDATA
->SetWeight(weight
);
175 bool wxFont::SetFaceName(const wxString
& faceName
)
178 M_FONTDATA
->SetFaceName(faceName
);
179 return wxFontBase::SetFaceName(faceName
);
182 void wxFont::SetUnderlined(bool underlined
)
185 M_FONTDATA
->SetUnderlined(underlined
);
188 void wxFont::SetEncoding(wxFontEncoding encoding
)
191 M_FONTDATA
->SetEncoding(encoding
);