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 wxGDIRefData
*wxFont::CreateGDIRefData() const
65 return new wxFontRefData
;
68 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*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 wxFontFamily
wxFont::DoGetFamily() const
103 return M_FONTDATA
->GetFamily();
106 wxFontStyle
wxFont::GetStyle() const
108 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX
, wxT("invalid font") );
110 return M_FONTDATA
->GetStyle();
113 wxFontWeight
wxFont::GetWeight() const
115 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX
, wxT("invalid font") );
117 return M_FONTDATA
->GetWeight();
120 bool wxFont::GetUnderlined() const
122 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
124 return M_FONTDATA
->GetUnderlined();
128 wxFontEncoding
wxFont::GetEncoding() const
130 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
132 return M_FONTDATA
->GetEncoding();
135 bool wxFont::IsFixedWidth() const
137 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
139 return M_FONTDATA
->IsFixedWidth();
142 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
144 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
146 return M_FONTDATA
->GetNativeFontInfo();
149 // ----------------------------------------------------------------------------
150 // change font attributes
151 // ----------------------------------------------------------------------------
153 void wxFont::SetPointSize(int pointSize
)
156 M_FONTDATA
->SetPointSize(pointSize
);
159 void wxFont::SetFamily(wxFontFamily family
)
162 M_FONTDATA
->SetFamily(family
);
165 void wxFont::SetStyle(wxFontStyle style
)
168 M_FONTDATA
->SetStyle(style
);
171 void wxFont::SetWeight(wxFontWeight weight
)
174 M_FONTDATA
->SetWeight(weight
);
177 bool wxFont::SetFaceName(const wxString
& faceName
)
180 M_FONTDATA
->SetFaceName(faceName
);
181 return wxFontBase::SetFaceName(faceName
);
184 void wxFont::SetUnderlined(bool underlined
)
187 M_FONTDATA
->SetUnderlined(underlined
);
190 void wxFont::SetEncoding(wxFontEncoding encoding
)
193 M_FONTDATA
->SetEncoding(encoding
);