]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/font.cpp
Committing in .
[wxWidgets.git] / src / cocoa / font.cpp
CommitLineData
a24aff65 1/////////////////////////////////////////////////////////////////////////////
8898456d 2// Name: src/cocoa/font.cpp
a24aff65
DE
3// Purpose: wxFont class
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
8898456d 9// Licence: wxWindows licence
a24aff65
DE
10/////////////////////////////////////////////////////////////////////////////
11
8898456d
WS
12#include "wx/wxprec.h"
13
14#ifndef WX_PRECOMP
15 #include "wx/string.h"
16#endif
17
a24aff65
DE
18#include "wx/font.h"
19#include "wx/gdicmn.h"
9c6e197f 20#include "wx/encinfo.h"
a24aff65 21
a24aff65 22IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
a24aff65
DE
23
24void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding)
25{
8898456d
WS
26 m_family = family;
27 m_style = style;
28 m_weight = weight;
29 m_underlined = underlined;
30 m_faceName = faceName;
31 m_encoding = encoding;
a24aff65
DE
32}
33
34wxFontRefData::~wxFontRefData()
35{
36 // TODO: delete font data
37}
38
a24aff65
DE
39bool wxFont::Create(const wxNativeFontInfo&)
40{
8898456d 41 return false;
a24aff65
DE
42}
43
44void wxFont::SetEncoding(wxFontEncoding)
45{
46}
47
48wxFontEncoding wxFont::GetEncoding() const
49{
50 return wxFontEncoding();
51}
52
53int wxFont::GetPointSize() const
54{
55 return 0;
56}
57
58bool wxFont::GetUnderlined() const
59{
8898456d 60 return false;
a24aff65
DE
61}
62
63int wxFont::GetStyle() const
64{
65 return 0;
66}
67
68int wxFont::GetFamily() const
69{
70 return 0;
71}
72
73int wxFont::GetWeight() const
74{
75 return 0;
76}
77
3bf5a59b
VZ
78const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
79{
80 return NULL;
81}
82
a24aff65
DE
83void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*);
84
85bool 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
8898456d 99 return true;
a24aff65
DE
100}
101
102wxFont::~wxFont()
103{
a24aff65
DE
104}
105
106bool wxFont::RealizeResource()
107{
108 // TODO: create the font (if there is a native font object)
8898456d 109 return false;
a24aff65
DE
110}
111
112void wxFont::Unshare()
113{
8898456d
WS
114 // Don't change shared data
115 if (!m_refData)
a24aff65 116 {
8898456d
WS
117 m_refData = new wxFontRefData();
118 }
a24aff65
DE
119 else
120 {
8898456d
WS
121 wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
122 UnRef();
123 m_refData = ref;
124 }
a24aff65
DE
125}
126
127void wxFont::SetPointSize(int pointSize)
128{
129 Unshare();
130
131 M_FONTDATA->m_pointSize = pointSize;
132
133 RealizeResource();
134}
135
136void wxFont::SetFamily(int family)
137{
138 Unshare();
139
140 M_FONTDATA->m_family = family;
141
142 RealizeResource();
143}
144
145void wxFont::SetStyle(int style)
146{
147 Unshare();
148
149 M_FONTDATA->m_style = style;
150
151 RealizeResource();
152}
153
154void wxFont::SetWeight(int weight)
155{
156 Unshare();
157
158 M_FONTDATA->m_weight = weight;
159
160 RealizeResource();
161}
162
163void wxFont::SetFaceName(const wxString& faceName)
164{
165 Unshare();
166
167 M_FONTDATA->m_faceName = faceName;
168
169 RealizeResource();
170}
171
172void wxFont::SetUnderlined(bool underlined)
173{
174 Unshare();
175
176 M_FONTDATA->m_underlined = underlined;
177
178 RealizeResource();
179}
180
181/* New font system */
182wxString wxFont::GetFaceName() const
183{
b0c0a393 184 wxString str;
a24aff65 185 if (M_FONTDATA)
8898456d 186 str = M_FONTDATA->m_faceName ;
a24aff65
DE
187 return str;
188}
189
190// vim:sts=4:sw=4:et