]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/font.cpp
Have to implement wxPGProperty::DeleteChildren() differently so that it will work...
[wxWidgets.git] / src / mgl / font.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/font.cpp
3 // Author: Vaclav Slavik
4 // Id: $Id$
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 // ============================================================================
10 // declarations
11 // ============================================================================
12
13 // ----------------------------------------------------------------------------
14 // headers
15 // ----------------------------------------------------------------------------
16
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
19
20 #ifdef __BORLANDC__
21 #pragma hdrstop
22 #endif
23
24 #include "wx/font.h"
25
26 #include "wx/private/fontmgr.h"
27
28 // ============================================================================
29 // implementation
30 // ============================================================================
31
32 typedef wxFontMgrFontRefData wxFontRefData;
33 #define M_FONTDATA ((wxFontRefData*)m_refData)
34
35 // ----------------------------------------------------------------------------
36 // wxFont
37 // ----------------------------------------------------------------------------
38
39 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
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 struct font_t *wxFont::GetMGLfont_t(float scale, bool antialiased)
76 {
77 wxCHECK_MSG( Ok(), 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->GetMGLfont_t() : NULL;
82 }
83
84 int wxFont::GetPointSize() const
85 {
86 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
87
88 return M_FONTDATA->GetPointSize();
89 }
90
91 wxString wxFont::GetFaceName() const
92 {
93 wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
94
95 return M_FONTDATA->GetFaceName();
96 }
97
98 wxFontFamily wxFont::GetFamily() const
99 {
100 wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX, wxT("invalid font") );
101
102 return M_FONTDATA->GetFamily();
103 }
104
105 wxFontStyle wxFont::GetStyle() const
106 {
107 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX, wxT("invalid font") );
108
109 return M_FONTDATA->GetStyle();
110 }
111
112 wxFontWeight wxFont::GetWeight() const
113 {
114 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX, wxT("invalid font") );
115
116 return M_FONTDATA->GetWeight();
117 }
118
119 bool wxFont::GetUnderlined() const
120 {
121 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
122
123 return M_FONTDATA->GetUnderlined();
124 }
125
126
127 wxFontEncoding wxFont::GetEncoding() const
128 {
129 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
130
131 return M_FONTDATA->GetEncoding();
132 }
133
134 bool wxFont::IsFixedWidth() const
135 {
136 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
137
138 return M_FONTDATA->IsFixedWidth();
139 }
140
141 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
142 {
143 wxCHECK_MSG( Ok(), NULL, wxT("invalid font") );
144
145 return M_FONTDATA->GetNativeFontInfo();
146 }
147
148 // ----------------------------------------------------------------------------
149 // change font attributes
150 // ----------------------------------------------------------------------------
151
152 void wxFont::SetPointSize(int pointSize)
153 {
154 AllocExclusive();
155 M_FONTDATA->SetPointSize(pointSize);
156 }
157
158 void wxFont::SetFamily(wxFontFamily family)
159 {
160 AllocExclusive();
161 M_FONTDATA->SetFamily(family);
162 }
163
164 void wxFont::SetStyle(wxFontStyle style)
165 {
166 AllocExclusive();
167 M_FONTDATA->SetStyle(style);
168 }
169
170 void wxFont::SetWeight(wxFontWeight weight)
171 {
172 AllocExclusive();
173 M_FONTDATA->SetWeight(weight);
174 }
175
176 bool wxFont::SetFaceName(const wxString& faceName)
177 {
178 AllocExclusive();
179 M_FONTDATA->SetFaceName(faceName);
180 return wxFontBase::SetFaceName(faceName);
181 }
182
183 void wxFont::SetUnderlined(bool underlined)
184 {
185 AllocExclusive();
186 M_FONTDATA->SetUnderlined(underlined);
187 }
188
189 void wxFont::SetEncoding(wxFontEncoding encoding)
190 {
191 AllocExclusive();
192 M_FONTDATA->SetEncoding(encoding);
193 }
194