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