]>
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 | #ifndef WX_PRECOMP | |
15 | #include "wx/string.h" | |
16 | #endif | |
17 | ||
18 | #include "wx/font.h" | |
19 | #include "wx/gdicmn.h" | |
20 | #include "wx/encinfo.h" | |
21 | ||
22 | IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) | |
23 | ||
24 | void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) | |
25 | { | |
26 | m_family = family; | |
27 | m_style = style; | |
28 | m_weight = weight; | |
29 | m_underlined = underlined; | |
30 | m_faceName = faceName; | |
31 | m_encoding = encoding; | |
32 | } | |
33 | ||
34 | wxFontRefData::~wxFontRefData() | |
35 | { | |
36 | // TODO: delete font data | |
37 | } | |
38 | ||
39 | bool wxFont::Create(const wxNativeFontInfo&) | |
40 | { | |
41 | return false; | |
42 | } | |
43 | ||
44 | void wxFont::SetEncoding(wxFontEncoding) | |
45 | { | |
46 | } | |
47 | ||
48 | wxFontEncoding wxFont::GetEncoding() const | |
49 | { | |
50 | return wxFontEncoding(); | |
51 | } | |
52 | ||
53 | int wxFont::GetPointSize() const | |
54 | { | |
55 | return 0; | |
56 | } | |
57 | ||
58 | bool wxFont::GetUnderlined() const | |
59 | { | |
60 | return false; | |
61 | } | |
62 | ||
63 | int wxFont::GetStyle() const | |
64 | { | |
65 | return 0; | |
66 | } | |
67 | ||
68 | int wxFont::GetFamily() const | |
69 | { | |
70 | return 0; | |
71 | } | |
72 | ||
73 | int wxFont::GetWeight() const | |
74 | { | |
75 | return 0; | |
76 | } | |
77 | ||
78 | const wxNativeFontInfo *wxFont::GetNativeFontInfo() const | |
79 | { | |
80 | return NULL; | |
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 | } | |
105 | ||
106 | bool wxFont::RealizeResource() | |
107 | { | |
108 | // TODO: create the font (if there is a native font object) | |
109 | return false; | |
110 | } | |
111 | ||
112 | void wxFont::Unshare() | |
113 | { | |
114 | // Don't change shared data | |
115 | if (!m_refData) | |
116 | { | |
117 | m_refData = new wxFontRefData(); | |
118 | } | |
119 | else | |
120 | { | |
121 | wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); | |
122 | UnRef(); | |
123 | m_refData = ref; | |
124 | } | |
125 | } | |
126 | ||
127 | void wxFont::SetPointSize(int pointSize) | |
128 | { | |
129 | Unshare(); | |
130 | ||
131 | M_FONTDATA->m_pointSize = pointSize; | |
132 | ||
133 | RealizeResource(); | |
134 | } | |
135 | ||
136 | void wxFont::SetFamily(int family) | |
137 | { | |
138 | Unshare(); | |
139 | ||
140 | M_FONTDATA->m_family = family; | |
141 | ||
142 | RealizeResource(); | |
143 | } | |
144 | ||
145 | void wxFont::SetStyle(int style) | |
146 | { | |
147 | Unshare(); | |
148 | ||
149 | M_FONTDATA->m_style = style; | |
150 | ||
151 | RealizeResource(); | |
152 | } | |
153 | ||
154 | void wxFont::SetWeight(int weight) | |
155 | { | |
156 | Unshare(); | |
157 | ||
158 | M_FONTDATA->m_weight = weight; | |
159 | ||
160 | RealizeResource(); | |
161 | } | |
162 | ||
163 | void wxFont::SetFaceName(const wxString& faceName) | |
164 | { | |
165 | Unshare(); | |
166 | ||
167 | M_FONTDATA->m_faceName = faceName; | |
168 | ||
169 | RealizeResource(); | |
170 | } | |
171 | ||
172 | void wxFont::SetUnderlined(bool underlined) | |
173 | { | |
174 | Unshare(); | |
175 | ||
176 | M_FONTDATA->m_underlined = underlined; | |
177 | ||
178 | RealizeResource(); | |
179 | } | |
180 | ||
181 | /* New font system */ | |
182 | wxString wxFont::GetFaceName() const | |
183 | { | |
184 | wxString str; | |
185 | if (M_FONTDATA) | |
186 | str = M_FONTDATA->m_faceName ; | |
187 | return str; | |
188 | } | |
189 | ||
190 | // vim:sts=4:sw=4:et |