]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/font.cpp
simplify/cleanup wxTheXXXList and wxGDIObject code (patch 1452023 from Paul Cornett)
[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 bool wxFont::Create(const wxNativeFontInfo&)
36 {
37 return FALSE;
38 }
39
40 void wxFont::SetEncoding(wxFontEncoding)
41 {
42 }
43
44 wxFontEncoding wxFont::GetEncoding() const
45 {
46 return wxFontEncoding();
47 }
48
49 int wxFont::GetPointSize() const
50 {
51 return 0;
52 }
53
54 bool wxFont::GetUnderlined() const
55 {
56 return FALSE;
57 }
58
59 int wxFont::GetStyle() const
60 {
61 return 0;
62 }
63
64 int wxFont::GetFamily() const
65 {
66 return 0;
67 }
68
69 int wxFont::GetWeight() const
70 {
71 return 0;
72 }
73
74 const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
75 {
76 return NULL;
77 }
78
79 void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*);
80
81 bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
82 {
83 UnRef();
84 m_refData = new wxFontRefData;
85
86 M_FONTDATA->m_family = family;
87 M_FONTDATA->m_style = style;
88 M_FONTDATA->m_weight = weight;
89 M_FONTDATA->m_pointSize = pointSize;
90 M_FONTDATA->m_underlined = underlined;
91 M_FONTDATA->m_faceName = faceName;
92
93 RealizeResource();
94
95 return TRUE;
96 }
97
98 wxFont::~wxFont()
99 {
100 }
101
102 bool wxFont::RealizeResource()
103 {
104 // TODO: create the font (if there is a native font object)
105 return FALSE;
106 }
107
108 void wxFont::Unshare()
109 {
110 // Don't change shared data
111 if (!m_refData)
112 {
113 m_refData = new wxFontRefData();
114 }
115 else
116 {
117 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
118 UnRef();
119 m_refData = ref;
120 }
121 }
122
123 void wxFont::SetPointSize(int pointSize)
124 {
125 Unshare();
126
127 M_FONTDATA->m_pointSize = pointSize;
128
129 RealizeResource();
130 }
131
132 void wxFont::SetFamily(int family)
133 {
134 Unshare();
135
136 M_FONTDATA->m_family = family;
137
138 RealizeResource();
139 }
140
141 void wxFont::SetStyle(int style)
142 {
143 Unshare();
144
145 M_FONTDATA->m_style = style;
146
147 RealizeResource();
148 }
149
150 void wxFont::SetWeight(int weight)
151 {
152 Unshare();
153
154 M_FONTDATA->m_weight = weight;
155
156 RealizeResource();
157 }
158
159 void wxFont::SetFaceName(const wxString& faceName)
160 {
161 Unshare();
162
163 M_FONTDATA->m_faceName = faceName;
164
165 RealizeResource();
166 }
167
168 void wxFont::SetUnderlined(bool underlined)
169 {
170 Unshare();
171
172 M_FONTDATA->m_underlined = underlined;
173
174 RealizeResource();
175 }
176
177 /* New font system */
178 wxString wxFont::GetFaceName() const
179 {
180 wxString str;
181 if (M_FONTDATA)
182 str = M_FONTDATA->m_faceName ;
183 return str;
184 }
185
186 // vim:sts=4:sw=4:et