]>
Commit | Line | Data |
---|---|---|
a24aff65 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: font.cpp | |
3 | // Purpose: wxFont class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "font.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/defs.h" | |
17 | #include "wx/string.h" | |
18 | #include "wx/font.h" | |
19 | #include "wx/gdicmn.h" | |
20 | ||
21 | #if !USE_SHARED_LIBRARIES | |
22 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) | |
23 | #endif | |
24 | ||
25 | void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) | |
26 | { | |
27 | m_family = family; | |
28 | m_style = style; | |
29 | m_weight = weight; | |
30 | m_underlined = underlined; | |
31 | m_faceName = faceName; | |
32 | m_encoding = encoding; | |
33 | } | |
34 | ||
35 | wxFontRefData::~wxFontRefData() | |
36 | { | |
37 | // TODO: delete font data | |
38 | } | |
39 | ||
40 | void wxFont::Init() | |
41 | { | |
42 | } | |
43 | ||
44 | bool wxFont::Create(const wxNativeFontInfo&) | |
45 | { | |
46 | return FALSE; | |
47 | } | |
48 | ||
49 | void wxFont::SetEncoding(wxFontEncoding) | |
50 | { | |
51 | } | |
52 | ||
53 | wxFontEncoding wxFont::GetEncoding() const | |
54 | { | |
55 | return wxFontEncoding(); | |
56 | } | |
57 | ||
58 | int wxFont::GetPointSize() const | |
59 | { | |
60 | return 0; | |
61 | } | |
62 | ||
63 | bool wxFont::GetUnderlined() const | |
64 | { | |
65 | return FALSE; | |
66 | } | |
67 | ||
68 | int wxFont::GetStyle() const | |
69 | { | |
70 | return 0; | |
71 | } | |
72 | ||
73 | int wxFont::GetFamily() const | |
74 | { | |
75 | return 0; | |
76 | } | |
77 | ||
78 | int wxFont::GetWeight() const | |
79 | { | |
80 | return 0; | |
81 | } | |
82 | ||
3bf5a59b VZ |
83 | const wxNativeFontInfo *wxFont::GetNativeFontInfo() const |
84 | { | |
85 | return NULL; | |
86 | } | |
87 | ||
a24aff65 DE |
88 | void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*); |
89 | ||
90 | bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) | |
91 | { | |
92 | UnRef(); | |
93 | m_refData = new wxFontRefData; | |
94 | ||
95 | M_FONTDATA->m_family = family; | |
96 | M_FONTDATA->m_style = style; | |
97 | M_FONTDATA->m_weight = weight; | |
98 | M_FONTDATA->m_pointSize = pointSize; | |
99 | M_FONTDATA->m_underlined = underlined; | |
100 | M_FONTDATA->m_faceName = faceName; | |
101 | ||
102 | RealizeResource(); | |
103 | ||
104 | return TRUE; | |
105 | } | |
106 | ||
107 | wxFont::~wxFont() | |
108 | { | |
109 | if (wxTheFontList) | |
110 | wxTheFontList->DeleteObject(this); | |
111 | } | |
112 | ||
113 | bool wxFont::RealizeResource() | |
114 | { | |
115 | // TODO: create the font (if there is a native font object) | |
116 | return FALSE; | |
117 | } | |
118 | ||
119 | void wxFont::Unshare() | |
120 | { | |
121 | // Don't change shared data | |
122 | if (!m_refData) | |
123 | { | |
124 | m_refData = new wxFontRefData(); | |
125 | } | |
126 | else | |
127 | { | |
128 | wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); | |
129 | UnRef(); | |
130 | m_refData = ref; | |
131 | } | |
132 | } | |
133 | ||
134 | void wxFont::SetPointSize(int pointSize) | |
135 | { | |
136 | Unshare(); | |
137 | ||
138 | M_FONTDATA->m_pointSize = pointSize; | |
139 | ||
140 | RealizeResource(); | |
141 | } | |
142 | ||
143 | void wxFont::SetFamily(int family) | |
144 | { | |
145 | Unshare(); | |
146 | ||
147 | M_FONTDATA->m_family = family; | |
148 | ||
149 | RealizeResource(); | |
150 | } | |
151 | ||
152 | void wxFont::SetStyle(int style) | |
153 | { | |
154 | Unshare(); | |
155 | ||
156 | M_FONTDATA->m_style = style; | |
157 | ||
158 | RealizeResource(); | |
159 | } | |
160 | ||
161 | void wxFont::SetWeight(int weight) | |
162 | { | |
163 | Unshare(); | |
164 | ||
165 | M_FONTDATA->m_weight = weight; | |
166 | ||
167 | RealizeResource(); | |
168 | } | |
169 | ||
170 | void wxFont::SetFaceName(const wxString& faceName) | |
171 | { | |
172 | Unshare(); | |
173 | ||
174 | M_FONTDATA->m_faceName = faceName; | |
175 | ||
176 | RealizeResource(); | |
177 | } | |
178 | ||
179 | void wxFont::SetUnderlined(bool underlined) | |
180 | { | |
181 | Unshare(); | |
182 | ||
183 | M_FONTDATA->m_underlined = underlined; | |
184 | ||
185 | RealizeResource(); | |
186 | } | |
187 | ||
188 | /* New font system */ | |
189 | wxString wxFont::GetFaceName() const | |
190 | { | |
191 | wxString str(""); | |
192 | if (M_FONTDATA) | |
193 | str = M_FONTDATA->m_faceName ; | |
194 | return str; | |
195 | } | |
196 | ||
197 | // vim:sts=4:sw=4:et |