]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/font.cpp
dd538c4d8ede6e3ba40674850d63cb0a05e563d1
[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 #include "wx/defs.h"
13 #include "wx/string.h"
14 #include "wx/font.h"
15 #include "wx/gdicmn.h"
16 #include "wx/encinfo.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
19
20 void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
21 {
22 m_family = family;
23 m_style = style;
24 m_weight = weight;
25 m_underlined = underlined;
26 m_faceName = faceName;
27 m_encoding = encoding;
28 }
29
30 wxFontRefData::~wxFontRefData()
31 {
32 // TODO: delete font data
33 }
34
35 void wxFont::Init()
36 {
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 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