]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/font.cpp
Fix wxHtmlHelpData::SetTempDir() to behave correctly without trailing slash.
[wxWidgets.git] / src / dfb / font.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/font.cpp
3// Purpose: wxFont implementation
4// Author: Vaclav Slavik
5// Created: 2006-08-08
b3c86150
VS
6// Copyright: (c) 2006 REA Elektronik GmbH
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10// ============================================================================
11// declarations
12// ============================================================================
13
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
18// For compilers that support precompilation, includes "wx.h".
19#include "wx/wxprec.h"
20
21#ifdef __BORLANDC__
22 #pragma hdrstop
23#endif
24
25#include "wx/font.h"
26
27#ifndef WX_PRECOMP
28 #include "wx/app.h"
29#endif
30
b3c86150 31#include "wx/dfb/private.h"
d04f9b8e 32#include "wx/private/fontmgr.h"
b3c86150 33
d04f9b8e 34typedef wxFontMgrFontRefData wxFontRefData;
68c95704 35#define M_FONTDATA ((wxFontRefData*)m_refData)
873fd4af 36
b3c86150
VS
37// ----------------------------------------------------------------------------
38// wxFont
39// ----------------------------------------------------------------------------
40
b3c86150
VS
41bool wxFont::Create(const wxNativeFontInfo& info)
42{
43 return Create(info.pointSize, info.family, info.style, info.weight,
44 info.underlined, info.faceName, info.encoding);
45}
46
47bool wxFont::Create(int pointSize,
0c14b6c3
FM
48 wxFontFamily family,
49 wxFontStyle style,
50 wxFontWeight weight,
b3c86150
VS
51 bool underlined,
52 const wxString& face,
53 wxFontEncoding encoding)
54{
55 m_refData = new wxFontRefData(pointSize, family, style, weight,
56 underlined, face, encoding);
57 return true;
58}
59
8f884a0d 60wxGDIRefData *wxFont::CreateGDIRefData() const
b3c86150
VS
61{
62 return new wxFontRefData;
63}
64
8f884a0d 65wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
66{
67 return new wxFontRefData(*(wxFontRefData *)data);
68}
69
70
71// ----------------------------------------------------------------------------
72// accessors
73// ----------------------------------------------------------------------------
74
d04f9b8e 75wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const
b3c86150 76{
a1b806b9 77 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
b3c86150 78
d04f9b8e
VS
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();
b3c86150
VS
82}
83
84int wxFont::GetPointSize() const
85{
a1b806b9 86 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
b3c86150 87
d04f9b8e 88 return M_FONTDATA->GetPointSize();
b3c86150
VS
89}
90
91wxString wxFont::GetFaceName() const
92{
a1b806b9 93 wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
b3c86150 94
d04f9b8e 95 return M_FONTDATA->GetFaceName();
b3c86150
VS
96}
97
59b7da02 98wxFontFamily wxFont::DoGetFamily() const
b3c86150 99{
d04f9b8e 100 return M_FONTDATA->GetFamily();
b3c86150
VS
101}
102
0c14b6c3 103wxFontStyle wxFont::GetStyle() const
b3c86150 104{
a1b806b9 105 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX, wxT("invalid font") );
b3c86150 106
d04f9b8e 107 return M_FONTDATA->GetStyle();
b3c86150
VS
108}
109
0c14b6c3 110wxFontWeight wxFont::GetWeight() const
b3c86150 111{
a1b806b9 112 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
b3c86150 113
d04f9b8e 114 return M_FONTDATA->GetWeight();
b3c86150
VS
115}
116
117bool wxFont::GetUnderlined() const
118{
a1b806b9 119 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
b3c86150 120
d04f9b8e 121 return M_FONTDATA->GetUnderlined();
b3c86150
VS
122}
123
124
125wxFontEncoding wxFont::GetEncoding() const
126{
a1b806b9 127 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
b3c86150 128
d04f9b8e 129 return M_FONTDATA->GetEncoding();
b3c86150
VS
130}
131
132bool wxFont::IsFixedWidth() const
133{
a1b806b9 134 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
b3c86150 135
d04f9b8e 136 return M_FONTDATA->IsFixedWidth();
b3c86150
VS
137}
138
139const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
140{
a1b806b9 141 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
b3c86150 142
d04f9b8e
VS
143 return M_FONTDATA->GetNativeFontInfo();
144}
145
b3c86150
VS
146// ----------------------------------------------------------------------------
147// change font attributes
148// ----------------------------------------------------------------------------
149
150void wxFont::SetPointSize(int pointSize)
151{
152 AllocExclusive();
d04f9b8e 153 M_FONTDATA->SetPointSize(pointSize);
b3c86150
VS
154}
155
0c14b6c3 156void wxFont::SetFamily(wxFontFamily family)
b3c86150
VS
157{
158 AllocExclusive();
d04f9b8e 159 M_FONTDATA->SetFamily(family);
b3c86150
VS
160}
161
0c14b6c3 162void wxFont::SetStyle(wxFontStyle style)
b3c86150
VS
163{
164 AllocExclusive();
d04f9b8e 165 M_FONTDATA->SetStyle(style);
b3c86150
VS
166}
167
0c14b6c3 168void wxFont::SetWeight(wxFontWeight weight)
b3c86150
VS
169{
170 AllocExclusive();
d04f9b8e 171 M_FONTDATA->SetWeight(weight);
b3c86150
VS
172}
173
174bool wxFont::SetFaceName(const wxString& faceName)
175{
176 AllocExclusive();
d04f9b8e 177 M_FONTDATA->SetFaceName(faceName);
b3c86150
VS
178 return wxFontBase::SetFaceName(faceName);
179}
180
181void wxFont::SetUnderlined(bool underlined)
182{
183 AllocExclusive();
d04f9b8e 184 M_FONTDATA->SetUnderlined(underlined);
b3c86150
VS
185}
186
187void wxFont::SetEncoding(wxFontEncoding encoding)
188{
189 AllocExclusive();
d04f9b8e
VS
190 M_FONTDATA->SetEncoding(encoding);
191}
b3c86150 192