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