]>
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 | ||
83 | void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*); | |
84 | ||
85 | bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) | |
86 | { | |
87 | UnRef(); | |
88 | m_refData = new wxFontRefData; | |
89 | ||
90 | M_FONTDATA->m_family = family; | |
91 | M_FONTDATA->m_style = style; | |
92 | M_FONTDATA->m_weight = weight; | |
93 | M_FONTDATA->m_pointSize = pointSize; | |
94 | M_FONTDATA->m_underlined = underlined; | |
95 | M_FONTDATA->m_faceName = faceName; | |
96 | ||
97 | RealizeResource(); | |
98 | ||
99 | return TRUE; | |
100 | } | |
101 | ||
102 | wxFont::~wxFont() | |
103 | { | |
104 | if (wxTheFontList) | |
105 | wxTheFontList->DeleteObject(this); | |
106 | } | |
107 | ||
108 | bool wxFont::RealizeResource() | |
109 | { | |
110 | // TODO: create the font (if there is a native font object) | |
111 | return FALSE; | |
112 | } | |
113 | ||
114 | void wxFont::Unshare() | |
115 | { | |
116 | // Don't change shared data | |
117 | if (!m_refData) | |
118 | { | |
119 | m_refData = new wxFontRefData(); | |
120 | } | |
121 | else | |
122 | { | |
123 | wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); | |
124 | UnRef(); | |
125 | m_refData = ref; | |
126 | } | |
127 | } | |
128 | ||
129 | void wxFont::SetPointSize(int pointSize) | |
130 | { | |
131 | Unshare(); | |
132 | ||
133 | M_FONTDATA->m_pointSize = pointSize; | |
134 | ||
135 | RealizeResource(); | |
136 | } | |
137 | ||
138 | void wxFont::SetFamily(int family) | |
139 | { | |
140 | Unshare(); | |
141 | ||
142 | M_FONTDATA->m_family = family; | |
143 | ||
144 | RealizeResource(); | |
145 | } | |
146 | ||
147 | void wxFont::SetStyle(int style) | |
148 | { | |
149 | Unshare(); | |
150 | ||
151 | M_FONTDATA->m_style = style; | |
152 | ||
153 | RealizeResource(); | |
154 | } | |
155 | ||
156 | void wxFont::SetWeight(int weight) | |
157 | { | |
158 | Unshare(); | |
159 | ||
160 | M_FONTDATA->m_weight = weight; | |
161 | ||
162 | RealizeResource(); | |
163 | } | |
164 | ||
165 | void wxFont::SetFaceName(const wxString& faceName) | |
166 | { | |
167 | Unshare(); | |
168 | ||
169 | M_FONTDATA->m_faceName = faceName; | |
170 | ||
171 | RealizeResource(); | |
172 | } | |
173 | ||
174 | void wxFont::SetUnderlined(bool underlined) | |
175 | { | |
176 | Unshare(); | |
177 | ||
178 | M_FONTDATA->m_underlined = underlined; | |
179 | ||
180 | RealizeResource(); | |
181 | } | |
182 | ||
183 | /* New font system */ | |
184 | wxString wxFont::GetFaceName() const | |
185 | { | |
186 | wxString str(""); | |
187 | if (M_FONTDATA) | |
188 | str = M_FONTDATA->m_faceName ; | |
189 | return str; | |
190 | } | |
191 | ||
192 | // vim:sts=4:sw=4:et |