]> git.saurik.com Git - wxWidgets.git/blame - src/common/fontcmn.cpp
Added chapter on collection and container classes to contents
[wxWidgets.git] / src / common / fontcmn.cpp
CommitLineData
0c5d3e1c
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: common/fontcmn.cpp
3// Purpose: implementation of wxFontBase methods
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 20.09.99
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
1b68e0b5
RR
20#ifdef __GNUG__
21 #pragma implementation "fontbase.h"
22#endif
23
0c5d3e1c
VZ
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
31#ifndef WX_PRECOMP
32 #include "wx/font.h"
33#endif // WX_PRECOMP
34
35// ============================================================================
36// implementation
37// ============================================================================
38
39// ----------------------------------------------------------------------------
40// wxFontBase
41// ----------------------------------------------------------------------------
42
43wxFontEncoding wxFontBase::ms_encodingDefault = wxFONTENCODING_SYSTEM;
44
7beba2fc 45/* static */
0c5d3e1c
VZ
46wxFont *wxFontBase::New(int size,
47 int family,
48 int style,
49 int weight,
50 bool underlined,
51 const wxString& face,
52 wxFontEncoding encoding)
53{
54 return new wxFont(size, family, style, weight, underlined, face, encoding);
55}
56
57wxFont& wxFont::operator=(const wxFont& font)
58{
59 if ( this != &font )
60 Ref(font);
61
62 return (wxFont &)*this;
63}
64
65// VZ: is it correct to compare pointers and not the contents? (FIXME)
66bool wxFontBase::operator==(const wxFont& font) const
67{
5e0201ea 68 return GetFontData() == font.GetFontData();
0c5d3e1c
VZ
69}
70
71bool wxFontBase::operator!=(const wxFont& font) const
72{
5e0201ea 73 return GetFontData() != font.GetFontData();
0c5d3e1c
VZ
74}
75
76wxString wxFontBase::GetFamilyString() const
77{
223d09f6 78 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
0c5d3e1c
VZ
79
80 switch ( GetFamily() )
81 {
223d09f6
KB
82 case wxDECORATIVE: return wxT("wxDECORATIVE");
83 case wxROMAN: return wxT("wxROMAN");
84 case wxSCRIPT: return wxT("wxSCRIPT");
85 case wxSWISS: return wxT("wxSWISS");
86 case wxMODERN: return wxT("wxMODERN");
87 case wxTELETYPE: return wxT("wxTELETYPE");
88 default: return wxT("wxDEFAULT");
0c5d3e1c
VZ
89 }
90}
91
92wxString wxFontBase::GetStyleString() const
93{
223d09f6 94 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
0c5d3e1c
VZ
95
96 switch ( GetStyle() )
97 {
223d09f6
KB
98 case wxNORMAL: return wxT("wxNORMAL");
99 case wxSLANT: return wxT("wxSLANT");
100 case wxITALIC: return wxT("wxITALIC");
101 default: return wxT("wxDEFAULT");
0c5d3e1c
VZ
102 }
103}
104
105wxString wxFontBase::GetWeightString() const
106{
223d09f6 107 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
0c5d3e1c
VZ
108
109 switch ( GetWeight() )
110 {
223d09f6
KB
111 case wxNORMAL: return wxT("wxNORMAL");
112 case wxBOLD: return wxT("wxBOLD");
113 case wxLIGHT: return wxT("wxLIGHT");
114 default: return wxT("wxDEFAULT");
0c5d3e1c
VZ
115 }
116}
117