]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/cocoa/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 | #include "wx/wxprec.h" | |
13 | ||
14 | #include "wx/font.h" | |
15 | ||
16 | #ifndef WX_PRECOMP | |
17 | #include "wx/string.h" | |
18 | #include "wx/gdicmn.h" | |
19 | #endif | |
20 | ||
21 | #include "wx/encinfo.h" | |
22 | ||
23 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) | |
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 | #define M_FONTDATA ((wxFontRefData*)m_refData) | |
41 | ||
42 | bool wxFont::Create(const wxNativeFontInfo&) | |
43 | { | |
44 | return false; | |
45 | } | |
46 | ||
47 | void wxFont::SetEncoding(wxFontEncoding) | |
48 | { | |
49 | } | |
50 | ||
51 | wxFontEncoding wxFont::GetEncoding() const | |
52 | { | |
53 | return wxFontEncoding(); | |
54 | } | |
55 | ||
56 | int wxFont::GetPointSize() const | |
57 | { | |
58 | return 0; | |
59 | } | |
60 | ||
61 | bool wxFont::GetUnderlined() const | |
62 | { | |
63 | if(M_FONTDATA) | |
64 | return M_FONTDATA->m_underlined; | |
65 | else | |
66 | return false; | |
67 | } | |
68 | ||
69 | int wxFont::GetStyle() const | |
70 | { | |
71 | return 0; | |
72 | } | |
73 | ||
74 | int wxFont::GetFamily() const | |
75 | { | |
76 | return 0; | |
77 | } | |
78 | ||
79 | int wxFont::GetWeight() const | |
80 | { | |
81 | return 0; | |
82 | } | |
83 | ||
84 | const wxNativeFontInfo *wxFont::GetNativeFontInfo() const | |
85 | { | |
86 | return NULL; | |
87 | } | |
88 | ||
89 | void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*); | |
90 | ||
91 | bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) | |
92 | { | |
93 | UnRef(); | |
94 | m_refData = new wxFontRefData; | |
95 | ||
96 | M_FONTDATA->m_family = family; | |
97 | M_FONTDATA->m_style = style; | |
98 | M_FONTDATA->m_weight = weight; | |
99 | M_FONTDATA->m_pointSize = pointSize; | |
100 | M_FONTDATA->m_underlined = underlined; | |
101 | M_FONTDATA->m_faceName = faceName; | |
102 | ||
103 | RealizeResource(); | |
104 | ||
105 | return true; | |
106 | } | |
107 | ||
108 | wxFont::~wxFont() | |
109 | { | |
110 | } | |
111 | ||
112 | bool wxFont::RealizeResource() | |
113 | { | |
114 | // TODO: create the font (if there is a native font object) | |
115 | return false; | |
116 | } | |
117 | ||
118 | void wxFont::Unshare() | |
119 | { | |
120 | // Don't change shared data | |
121 | if (!m_refData) | |
122 | { | |
123 | m_refData = new wxFontRefData(); | |
124 | } | |
125 | else | |
126 | { | |
127 | wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); | |
128 | UnRef(); | |
129 | m_refData = ref; | |
130 | } | |
131 | } | |
132 | ||
133 | void wxFont::SetPointSize(int pointSize) | |
134 | { | |
135 | Unshare(); | |
136 | ||
137 | M_FONTDATA->m_pointSize = pointSize; | |
138 | ||
139 | RealizeResource(); | |
140 | } | |
141 | ||
142 | void wxFont::SetFamily(int family) | |
143 | { | |
144 | Unshare(); | |
145 | ||
146 | M_FONTDATA->m_family = family; | |
147 | ||
148 | RealizeResource(); | |
149 | } | |
150 | ||
151 | void wxFont::SetStyle(int style) | |
152 | { | |
153 | Unshare(); | |
154 | ||
155 | M_FONTDATA->m_style = style; | |
156 | ||
157 | RealizeResource(); | |
158 | } | |
159 | ||
160 | void wxFont::SetWeight(int weight) | |
161 | { | |
162 | Unshare(); | |
163 | ||
164 | M_FONTDATA->m_weight = weight; | |
165 | ||
166 | RealizeResource(); | |
167 | } | |
168 | ||
169 | bool wxFont::SetFaceName(const wxString& faceName) | |
170 | { | |
171 | Unshare(); | |
172 | ||
173 | M_FONTDATA->m_faceName = faceName; | |
174 | ||
175 | RealizeResource(); | |
176 | ||
177 | return wxFontBase::SetFaceName(faceName); | |
178 | } | |
179 | ||
180 | void wxFont::SetUnderlined(bool underlined) | |
181 | { | |
182 | Unshare(); | |
183 | ||
184 | M_FONTDATA->m_underlined = underlined; | |
185 | ||
186 | RealizeResource(); | |
187 | } | |
188 | ||
189 | /* New font system */ | |
190 | wxString wxFont::GetFaceName() const | |
191 | { | |
192 | wxString str; | |
193 | if (M_FONTDATA) | |
194 | str = M_FONTDATA->m_faceName ; | |
195 | return str; | |
196 | } | |
197 | ||
198 | // vim:sts=4:sw=4:et |