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