1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/font.cpp
3 // Purpose: wxFont implementation
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
18 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
31 #include "wx/dfb/private.h"
32 #include "wx/private/fontmgr.h"
34 typedef wxFontMgrFontRefData wxFontRefData
;
35 #define M_FONTDATA ((wxFontRefData*)m_refData)
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 bool wxFont::Create(const wxNativeFontInfo
& info
)
43 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
44 info
.underlined
, info
.faceName
, info
.encoding
);
47 bool wxFont::Create(int pointSize
,
53 wxFontEncoding encoding
)
55 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
56 underlined
, face
, encoding
);
60 wxGDIRefData
*wxFont::CreateGDIRefData() const
62 return new wxFontRefData
;
65 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
67 return new wxFontRefData(*(wxFontRefData
*)data
);
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 wxIDirectFBFontPtr
wxFont::GetDirectFBFont(bool antialiased
) const
77 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
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
->GetDirectFBFont() : wxIDirectFBFontPtr();
84 int wxFont::GetPointSize() const
86 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
88 return M_FONTDATA
->GetPointSize();
91 wxString
wxFont::GetFaceName() const
93 wxCHECK_MSG( IsOk(), wxEmptyString
, wxT("invalid font") );
95 return M_FONTDATA
->GetFaceName();
98 wxFontFamily
wxFont::DoGetFamily() const
100 return M_FONTDATA
->GetFamily();
103 wxFontStyle
wxFont::GetStyle() const
105 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX
, wxT("invalid font") );
107 return M_FONTDATA
->GetStyle();
110 wxFontWeight
wxFont::GetWeight() const
112 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX
, wxT("invalid font") );
114 return M_FONTDATA
->GetWeight();
117 bool wxFont::GetUnderlined() const
119 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
121 return M_FONTDATA
->GetUnderlined();
125 wxFontEncoding
wxFont::GetEncoding() const
127 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
129 return M_FONTDATA
->GetEncoding();
132 bool wxFont::IsFixedWidth() const
134 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
136 return M_FONTDATA
->IsFixedWidth();
139 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
141 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
143 return M_FONTDATA
->GetNativeFontInfo();
146 // ----------------------------------------------------------------------------
147 // change font attributes
148 // ----------------------------------------------------------------------------
150 void wxFont::SetPointSize(int pointSize
)
153 M_FONTDATA
->SetPointSize(pointSize
);
156 void wxFont::SetFamily(wxFontFamily family
)
159 M_FONTDATA
->SetFamily(family
);
162 void wxFont::SetStyle(wxFontStyle style
)
165 M_FONTDATA
->SetStyle(style
);
168 void wxFont::SetWeight(wxFontWeight weight
)
171 M_FONTDATA
->SetWeight(weight
);
174 bool wxFont::SetFaceName(const wxString
& faceName
)
177 M_FONTDATA
->SetFaceName(faceName
);
178 return wxFontBase::SetFaceName(faceName
);
181 void wxFont::SetUnderlined(bool underlined
)
184 M_FONTDATA
->SetUnderlined(underlined
);
187 void wxFont::SetEncoding(wxFontEncoding encoding
)
190 M_FONTDATA
->SetEncoding(encoding
);