]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/font.cpp
include "wx/encinfo.h" for wxNativeEncodingInfo
[wxWidgets.git] / src / cocoa / font.cpp
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 #include "wx/encinfo.h"
21
22 #if !USE_SHARED_LIBRARIES
23 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
24 #endif
25
26 void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
27 {
28 m_family = family;
29 m_style = style;
30 m_weight = weight;
31 m_underlined = underlined;
32 m_faceName = faceName;
33 m_encoding = encoding;
34 }
35
36 wxFontRefData::~wxFontRefData()
37 {
38 // TODO: delete font data
39 }
40
41 void wxFont::Init()
42 {
43 }
44
45 bool wxFont::Create(const wxNativeFontInfo&)
46 {
47 return FALSE;
48 }
49
50 void wxFont::SetEncoding(wxFontEncoding)
51 {
52 }
53
54 wxFontEncoding wxFont::GetEncoding() const
55 {
56 return wxFontEncoding();
57 }
58
59 int wxFont::GetPointSize() const
60 {
61 return 0;
62 }
63
64 bool wxFont::GetUnderlined() const
65 {
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 if (wxTheFontList)
111 wxTheFontList->DeleteObject(this);
112 }
113
114 bool wxFont::RealizeResource()
115 {
116 // TODO: create the font (if there is a native font object)
117 return FALSE;
118 }
119
120 void wxFont::Unshare()
121 {
122 // Don't change shared data
123 if (!m_refData)
124 {
125 m_refData = new wxFontRefData();
126 }
127 else
128 {
129 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
130 UnRef();
131 m_refData = ref;
132 }
133 }
134
135 void wxFont::SetPointSize(int pointSize)
136 {
137 Unshare();
138
139 M_FONTDATA->m_pointSize = pointSize;
140
141 RealizeResource();
142 }
143
144 void wxFont::SetFamily(int family)
145 {
146 Unshare();
147
148 M_FONTDATA->m_family = family;
149
150 RealizeResource();
151 }
152
153 void wxFont::SetStyle(int style)
154 {
155 Unshare();
156
157 M_FONTDATA->m_style = style;
158
159 RealizeResource();
160 }
161
162 void wxFont::SetWeight(int weight)
163 {
164 Unshare();
165
166 M_FONTDATA->m_weight = weight;
167
168 RealizeResource();
169 }
170
171 void wxFont::SetFaceName(const wxString& faceName)
172 {
173 Unshare();
174
175 M_FONTDATA->m_faceName = faceName;
176
177 RealizeResource();
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