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