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
::GetFamily() const
103 wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX
, wxT("invalid font") );
105 return M_FONTDATA
->GetFamily();
108 wxFontStyle wxFont
::GetStyle() const
110 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX
, wxT("invalid font") );
112 return M_FONTDATA
->GetStyle();
115 wxFontWeight wxFont
::GetWeight() const
117 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX
, 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 // ----------------------------------------------------------------------------
152 // change font attributes
153 // ----------------------------------------------------------------------------
155 void wxFont
::SetPointSize(int pointSize
)
158 M_FONTDATA
->SetPointSize(pointSize
);
161 void wxFont
::SetFamily(wxFontFamily family
)
164 M_FONTDATA
->SetFamily(family
);
167 void wxFont
::SetStyle(wxFontStyle style
)
170 M_FONTDATA
->SetStyle(style
);
173 void wxFont
::SetWeight(wxFontWeight weight
)
176 M_FONTDATA
->SetWeight(weight
);
179 bool wxFont
::SetFaceName(const wxString
& faceName
)
182 M_FONTDATA
->SetFaceName(faceName
);
183 return wxFontBase
::SetFaceName(faceName
);
186 void wxFont
::SetUnderlined(bool underlined
)
189 M_FONTDATA
->SetUnderlined(underlined
);
192 void wxFont
::SetEncoding(wxFontEncoding encoding
)
195 M_FONTDATA
->SetEncoding(encoding
);