]> git.saurik.com Git - wxWidgets.git/blob - src/dfb/font.cpp
Don't document wxSortedArrayString as deriving from wxArrayString.
[wxWidgets.git] / src / dfb / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/font.cpp
3 // Purpose: wxFont implementation
4 // Author: Vaclav Slavik
5 // Created: 2006-08-08
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
31 #include "wx/dfb/private.h"
32 #include "wx/private/fontmgr.h"
33
34 typedef wxFontMgrFontRefData wxFontRefData;
35 #define M_FONTDATA ((wxFontRefData*)m_refData)
36
37 // ----------------------------------------------------------------------------
38 // wxFont
39 // ----------------------------------------------------------------------------
40
41 bool 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
47 bool wxFont::Create(int pointSize,
48 wxFontFamily family,
49 wxFontStyle style,
50 wxFontWeight weight,
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
60 wxGDIRefData *wxFont::CreateGDIRefData() const
61 {
62 return new wxFontRefData;
63 }
64
65 wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
66 {
67 return new wxFontRefData(*(wxFontRefData *)data);
68 }
69
70
71 // ----------------------------------------------------------------------------
72 // accessors
73 // ----------------------------------------------------------------------------
74
75 wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const
76 {
77 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
78
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();
82 }
83
84 int wxFont::GetPointSize() const
85 {
86 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
87
88 return M_FONTDATA->GetPointSize();
89 }
90
91 wxString wxFont::GetFaceName() const
92 {
93 wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
94
95 return M_FONTDATA->GetFaceName();
96 }
97
98 wxFontFamily wxFont::DoGetFamily() const
99 {
100 return M_FONTDATA->GetFamily();
101 }
102
103 wxFontStyle wxFont::GetStyle() const
104 {
105 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX, wxT("invalid font") );
106
107 return M_FONTDATA->GetStyle();
108 }
109
110 wxFontWeight wxFont::GetWeight() const
111 {
112 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
113
114 return M_FONTDATA->GetWeight();
115 }
116
117 bool wxFont::GetUnderlined() const
118 {
119 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
120
121 return M_FONTDATA->GetUnderlined();
122 }
123
124
125 wxFontEncoding wxFont::GetEncoding() const
126 {
127 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
128
129 return M_FONTDATA->GetEncoding();
130 }
131
132 bool wxFont::IsFixedWidth() const
133 {
134 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
135
136 return M_FONTDATA->IsFixedWidth();
137 }
138
139 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
140 {
141 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
142
143 return M_FONTDATA->GetNativeFontInfo();
144 }
145
146 // ----------------------------------------------------------------------------
147 // change font attributes
148 // ----------------------------------------------------------------------------
149
150 void wxFont::SetPointSize(int pointSize)
151 {
152 AllocExclusive();
153 M_FONTDATA->SetPointSize(pointSize);
154 }
155
156 void wxFont::SetFamily(wxFontFamily family)
157 {
158 AllocExclusive();
159 M_FONTDATA->SetFamily(family);
160 }
161
162 void wxFont::SetStyle(wxFontStyle style)
163 {
164 AllocExclusive();
165 M_FONTDATA->SetStyle(style);
166 }
167
168 void wxFont::SetWeight(wxFontWeight weight)
169 {
170 AllocExclusive();
171 M_FONTDATA->SetWeight(weight);
172 }
173
174 bool wxFont::SetFaceName(const wxString& faceName)
175 {
176 AllocExclusive();
177 M_FONTDATA->SetFaceName(faceName);
178 return wxFontBase::SetFaceName(faceName);
179 }
180
181 void wxFont::SetUnderlined(bool underlined)
182 {
183 AllocExclusive();
184 M_FONTDATA->SetUnderlined(underlined);
185 }
186
187 void wxFont::SetEncoding(wxFontEncoding encoding)
188 {
189 AllocExclusive();
190 M_FONTDATA->SetEncoding(encoding);
191 }
192