]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/font.cpp
don't compare invalid iterators/node pointers
[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 if (wxTheFontList)
101 wxTheFontList->DeleteObject(this);
102 }
103
104 bool wxFont::RealizeResource()
105 {
106 // TODO: create the font (if there is a native font object)
107 return FALSE;
108 }
109
110 void wxFont::Unshare()
111 {
112 // Don't change shared data
113 if (!m_refData)
114 {
115 m_refData = new wxFontRefData();
116 }
117 else
118 {
119 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
120 UnRef();
121 m_refData = ref;
122 }
123 }
124
125 void wxFont::SetPointSize(int pointSize)
126 {
127 Unshare();
128
129 M_FONTDATA->m_pointSize = pointSize;
130
131 RealizeResource();
132 }
133
134 void wxFont::SetFamily(int family)
135 {
136 Unshare();
137
138 M_FONTDATA->m_family = family;
139
140 RealizeResource();
141 }
142
143 void wxFont::SetStyle(int style)
144 {
145 Unshare();
146
147 M_FONTDATA->m_style = style;
148
149 RealizeResource();
150 }
151
152 void wxFont::SetWeight(int weight)
153 {
154 Unshare();
155
156 M_FONTDATA->m_weight = weight;
157
158 RealizeResource();
159 }
160
161 void wxFont::SetFaceName(const wxString& faceName)
162 {
163 Unshare();
164
165 M_FONTDATA->m_faceName = faceName;
166
167 RealizeResource();
168 }
169
170 void wxFont::SetUnderlined(bool underlined)
171 {
172 Unshare();
173
174 M_FONTDATA->m_underlined = underlined;
175
176 RealizeResource();
177 }
178
179 /* New font system */
180 wxString wxFont::GetFaceName() const
181 {
182 wxString str;
183 if (M_FONTDATA)
184 str = M_FONTDATA->m_faceName ;
185 return str;
186 }
187
188 // vim:sts=4:sw=4:et