]>
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 | ||
42 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) | |
43 | ||
44 | bool wxFont::Create(const wxNativeFontInfo& info) | |
45 | { | |
46 | return Create(info.pointSize, info.family, info.style, info.weight, | |
47 | info.underlined, info.faceName, info.encoding); | |
48 | } | |
49 | ||
50 | bool wxFont::Create(int pointSize, | |
0c14b6c3 FM |
51 | wxFontFamily family, |
52 | wxFontStyle style, | |
53 | wxFontWeight weight, | |
b3c86150 VS |
54 | bool underlined, |
55 | const wxString& face, | |
56 | wxFontEncoding encoding) | |
57 | { | |
58 | m_refData = new wxFontRefData(pointSize, family, style, weight, | |
59 | underlined, face, encoding); | |
60 | return true; | |
61 | } | |
62 | ||
8f884a0d | 63 | wxGDIRefData *wxFont::CreateGDIRefData() const |
b3c86150 VS |
64 | { |
65 | return new wxFontRefData; | |
66 | } | |
67 | ||
8f884a0d | 68 | wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const |
b3c86150 VS |
69 | { |
70 | return new wxFontRefData(*(wxFontRefData *)data); | |
71 | } | |
72 | ||
73 | ||
74 | // ---------------------------------------------------------------------------- | |
75 | // accessors | |
76 | // ---------------------------------------------------------------------------- | |
77 | ||
d04f9b8e | 78 | wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const |
b3c86150 VS |
79 | { |
80 | wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); | |
81 | ||
d04f9b8e VS |
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(); | |
b3c86150 VS |
85 | } |
86 | ||
87 | int wxFont::GetPointSize() const | |
88 | { | |
89 | wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); | |
90 | ||
d04f9b8e | 91 | return M_FONTDATA->GetPointSize(); |
b3c86150 VS |
92 | } |
93 | ||
94 | wxString wxFont::GetFaceName() const | |
95 | { | |
96 | wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") ); | |
97 | ||
d04f9b8e | 98 | return M_FONTDATA->GetFaceName(); |
b3c86150 VS |
99 | } |
100 | ||
0c14b6c3 | 101 | wxFontFamily wxFont::GetFamily() const |
b3c86150 | 102 | { |
0c14b6c3 | 103 | wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") ); |
b3c86150 | 104 | |
d04f9b8e | 105 | return M_FONTDATA->GetFamily(); |
b3c86150 VS |
106 | } |
107 | ||
0c14b6c3 | 108 | wxFontStyle wxFont::GetStyle() const |
b3c86150 | 109 | { |
0c14b6c3 | 110 | wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") ); |
b3c86150 | 111 | |
d04f9b8e | 112 | return M_FONTDATA->GetStyle(); |
b3c86150 VS |
113 | } |
114 | ||
0c14b6c3 | 115 | wxFontWeight wxFont::GetWeight() const |
b3c86150 | 116 | { |
0c14b6c3 | 117 | wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") ); |
b3c86150 | 118 | |
d04f9b8e | 119 | return M_FONTDATA->GetWeight(); |
b3c86150 VS |
120 | } |
121 | ||
122 | bool wxFont::GetUnderlined() const | |
123 | { | |
124 | wxCHECK_MSG( Ok(), false, wxT("invalid font") ); | |
125 | ||
d04f9b8e | 126 | return M_FONTDATA->GetUnderlined(); |
b3c86150 VS |
127 | } |
128 | ||
129 | ||
130 | wxFontEncoding wxFont::GetEncoding() const | |
131 | { | |
132 | wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); | |
133 | ||
d04f9b8e | 134 | return M_FONTDATA->GetEncoding(); |
b3c86150 VS |
135 | } |
136 | ||
137 | bool wxFont::IsFixedWidth() const | |
138 | { | |
139 | wxCHECK_MSG( Ok(), false, wxT("invalid font") ); | |
140 | ||
d04f9b8e | 141 | return M_FONTDATA->IsFixedWidth(); |
b3c86150 VS |
142 | } |
143 | ||
144 | const wxNativeFontInfo *wxFont::GetNativeFontInfo() const | |
145 | { | |
146 | wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); | |
147 | ||
d04f9b8e VS |
148 | return M_FONTDATA->GetNativeFontInfo(); |
149 | } | |
150 | ||
b3c86150 VS |
151 | // ---------------------------------------------------------------------------- |
152 | // change font attributes | |
153 | // ---------------------------------------------------------------------------- | |
154 | ||
155 | void wxFont::SetPointSize(int pointSize) | |
156 | { | |
157 | AllocExclusive(); | |
d04f9b8e | 158 | M_FONTDATA->SetPointSize(pointSize); |
b3c86150 VS |
159 | } |
160 | ||
0c14b6c3 | 161 | void wxFont::SetFamily(wxFontFamily family) |
b3c86150 VS |
162 | { |
163 | AllocExclusive(); | |
d04f9b8e | 164 | M_FONTDATA->SetFamily(family); |
b3c86150 VS |
165 | } |
166 | ||
0c14b6c3 | 167 | void wxFont::SetStyle(wxFontStyle style) |
b3c86150 VS |
168 | { |
169 | AllocExclusive(); | |
d04f9b8e | 170 | M_FONTDATA->SetStyle(style); |
b3c86150 VS |
171 | } |
172 | ||
0c14b6c3 | 173 | void wxFont::SetWeight(wxFontWeight weight) |
b3c86150 VS |
174 | { |
175 | AllocExclusive(); | |
d04f9b8e | 176 | M_FONTDATA->SetWeight(weight); |
b3c86150 VS |
177 | } |
178 | ||
179 | bool wxFont::SetFaceName(const wxString& faceName) | |
180 | { | |
181 | AllocExclusive(); | |
d04f9b8e | 182 | M_FONTDATA->SetFaceName(faceName); |
b3c86150 VS |
183 | return wxFontBase::SetFaceName(faceName); |
184 | } | |
185 | ||
186 | void wxFont::SetUnderlined(bool underlined) | |
187 | { | |
188 | AllocExclusive(); | |
d04f9b8e | 189 | M_FONTDATA->SetUnderlined(underlined); |
b3c86150 VS |
190 | } |
191 | ||
192 | void wxFont::SetEncoding(wxFontEncoding encoding) | |
193 | { | |
194 | AllocExclusive(); | |
d04f9b8e VS |
195 | M_FONTDATA->SetEncoding(encoding); |
196 | } | |
b3c86150 | 197 |