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