]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/font.cpp
fixed LastRead() after Read(wxOutputStream&) (patch 1658301)
[wxWidgets.git] / src / cocoa / font.cpp
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 return false;
64 }
65
66 int wxFont::GetStyle() const
67 {
68 return 0;
69 }
70
71 int wxFont::GetFamily() const
72 {
73 return 0;
74 }
75
76 int wxFont::GetWeight() const
77 {
78 return 0;
79 }
80
81 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
82 {
83 return NULL;
84 }
85
86 void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*);
87
88 bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
89 {
90 UnRef();
91 m_refData = new wxFontRefData;
92
93 M_FONTDATA->m_family = family;
94 M_FONTDATA->m_style = style;
95 M_FONTDATA->m_weight = weight;
96 M_FONTDATA->m_pointSize = pointSize;
97 M_FONTDATA->m_underlined = underlined;
98 M_FONTDATA->m_faceName = faceName;
99
100 RealizeResource();
101
102 return true;
103 }
104
105 wxFont::~wxFont()
106 {
107 }
108
109 bool wxFont::RealizeResource()
110 {
111 // TODO: create the font (if there is a native font object)
112 return false;
113 }
114
115 void wxFont::Unshare()
116 {
117 // Don't change shared data
118 if (!m_refData)
119 {
120 m_refData = new wxFontRefData();
121 }
122 else
123 {
124 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
125 UnRef();
126 m_refData = ref;
127 }
128 }
129
130 void wxFont::SetPointSize(int pointSize)
131 {
132 Unshare();
133
134 M_FONTDATA->m_pointSize = pointSize;
135
136 RealizeResource();
137 }
138
139 void wxFont::SetFamily(int family)
140 {
141 Unshare();
142
143 M_FONTDATA->m_family = family;
144
145 RealizeResource();
146 }
147
148 void wxFont::SetStyle(int style)
149 {
150 Unshare();
151
152 M_FONTDATA->m_style = style;
153
154 RealizeResource();
155 }
156
157 void wxFont::SetWeight(int weight)
158 {
159 Unshare();
160
161 M_FONTDATA->m_weight = weight;
162
163 RealizeResource();
164 }
165
166 bool wxFont::SetFaceName(const wxString& faceName)
167 {
168 Unshare();
169
170 M_FONTDATA->m_faceName = faceName;
171
172 RealizeResource();
173
174 return wxFontBase::SetFaceName(faceName);
175 }
176
177 void wxFont::SetUnderlined(bool underlined)
178 {
179 Unshare();
180
181 M_FONTDATA->m_underlined = underlined;
182
183 RealizeResource();
184 }
185
186 /* New font system */
187 wxString wxFont::GetFaceName() const
188 {
189 wxString str;
190 if (M_FONTDATA)
191 str = M_FONTDATA->m_faceName ;
192 return str;
193 }
194
195 // vim:sts=4:sw=4:et