]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/font.cpp
Check for invalid items in generic wxDataViewCtrl::GetSelections().
[wxWidgets.git] / src / dfb / font.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/font.cpp
3// Purpose: wxFont implementation
4// Author: Vaclav Slavik
5// Created: 2006-08-08
6// RCS-ID: $Id$
7// Copyright: (c) 2006 REA Elektronik GmbH
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#include "wx/font.h"
27
28#ifndef WX_PRECOMP
29 #include "wx/app.h"
30#endif
31
b3c86150 32#include "wx/dfb/private.h"
d04f9b8e 33#include "wx/private/fontmgr.h"
b3c86150 34
d04f9b8e 35typedef wxFontMgrFontRefData wxFontRefData;
68c95704 36#define M_FONTDATA ((wxFontRefData*)m_refData)
873fd4af 37
b3c86150
VS
38// ----------------------------------------------------------------------------
39// wxFont
40// ----------------------------------------------------------------------------
41
b3c86150
VS
42bool wxFont::Create(const wxNativeFontInfo& info)
43{
44 return Create(info.pointSize, info.family, info.style, info.weight,
45 info.underlined, info.faceName, info.encoding);
46}
47
48bool wxFont::Create(int pointSize,
0c14b6c3
FM
49 wxFontFamily family,
50 wxFontStyle style,
51 wxFontWeight weight,
b3c86150
VS
52 bool underlined,
53 const wxString& face,
54 wxFontEncoding encoding)
55{
56 m_refData = new wxFontRefData(pointSize, family, style, weight,
57 underlined, face, encoding);
58 return true;
59}
60
8f884a0d 61wxGDIRefData *wxFont::CreateGDIRefData() const
b3c86150
VS
62{
63 return new wxFontRefData;
64}
65
8f884a0d 66wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
67{
68 return new wxFontRefData(*(wxFontRefData *)data);
69}
70
71
72// ----------------------------------------------------------------------------
73// accessors
74// ----------------------------------------------------------------------------
75
d04f9b8e 76wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const
b3c86150 77{
a1b806b9 78 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
b3c86150 79
d04f9b8e
VS
80 // we don't support DC scaling yet, so use scale=1
81 wxFontInstance *i = M_FONTDATA->GetFontInstance(1.0, antialiased);
82 return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr();
b3c86150
VS
83}
84
85int wxFont::GetPointSize() const
86{
a1b806b9 87 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
b3c86150 88
d04f9b8e 89 return M_FONTDATA->GetPointSize();
b3c86150
VS
90}
91
92wxString wxFont::GetFaceName() const
93{
a1b806b9 94 wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
b3c86150 95
d04f9b8e 96 return M_FONTDATA->GetFaceName();
b3c86150
VS
97}
98
59b7da02 99wxFontFamily wxFont::DoGetFamily() const
b3c86150 100{
d04f9b8e 101 return M_FONTDATA->GetFamily();
b3c86150
VS
102}
103
0c14b6c3 104wxFontStyle wxFont::GetStyle() const
b3c86150 105{
a1b806b9 106 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX, wxT("invalid font") );
b3c86150 107
d04f9b8e 108 return M_FONTDATA->GetStyle();
b3c86150
VS
109}
110
0c14b6c3 111wxFontWeight wxFont::GetWeight() const
b3c86150 112{
a1b806b9 113 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
b3c86150 114
d04f9b8e 115 return M_FONTDATA->GetWeight();
b3c86150
VS
116}
117
118bool wxFont::GetUnderlined() const
119{
a1b806b9 120 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
b3c86150 121
d04f9b8e 122 return M_FONTDATA->GetUnderlined();
b3c86150
VS
123}
124
125
126wxFontEncoding wxFont::GetEncoding() const
127{
a1b806b9 128 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
b3c86150 129
d04f9b8e 130 return M_FONTDATA->GetEncoding();
b3c86150
VS
131}
132
133bool wxFont::IsFixedWidth() const
134{
a1b806b9 135 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
b3c86150 136
d04f9b8e 137 return M_FONTDATA->IsFixedWidth();
b3c86150
VS
138}
139
140const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
141{
a1b806b9 142 wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") );
b3c86150 143
d04f9b8e
VS
144 return M_FONTDATA->GetNativeFontInfo();
145}
146
b3c86150
VS
147// ----------------------------------------------------------------------------
148// change font attributes
149// ----------------------------------------------------------------------------
150
151void wxFont::SetPointSize(int pointSize)
152{
153 AllocExclusive();
d04f9b8e 154 M_FONTDATA->SetPointSize(pointSize);
b3c86150
VS
155}
156
0c14b6c3 157void wxFont::SetFamily(wxFontFamily family)
b3c86150
VS
158{
159 AllocExclusive();
d04f9b8e 160 M_FONTDATA->SetFamily(family);
b3c86150
VS
161}
162
0c14b6c3 163void wxFont::SetStyle(wxFontStyle style)
b3c86150
VS
164{
165 AllocExclusive();
d04f9b8e 166 M_FONTDATA->SetStyle(style);
b3c86150
VS
167}
168
0c14b6c3 169void wxFont::SetWeight(wxFontWeight weight)
b3c86150
VS
170{
171 AllocExclusive();
d04f9b8e 172 M_FONTDATA->SetWeight(weight);
b3c86150
VS
173}
174
175bool wxFont::SetFaceName(const wxString& faceName)
176{
177 AllocExclusive();
d04f9b8e 178 M_FONTDATA->SetFaceName(faceName);
b3c86150
VS
179 return wxFontBase::SetFaceName(faceName);
180}
181
182void wxFont::SetUnderlined(bool underlined)
183{
184 AllocExclusive();
d04f9b8e 185 M_FONTDATA->SetUnderlined(underlined);
b3c86150
VS
186}
187
188void wxFont::SetEncoding(wxFontEncoding encoding)
189{
190 AllocExclusive();
d04f9b8e
VS
191 M_FONTDATA->SetEncoding(encoding);
192}
b3c86150 193