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