]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/fontcmn.cpp
*** empty log message ***
[wxWidgets.git] / src / common / fontcmn.cpp
... / ...
CommitLineData
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
20#ifdef __GNUG__
21 #pragma implementation "fontbase.h"
22#endif
23
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
45wxFont *wxFontBase::New(int size,
46 int family,
47 int style,
48 int weight,
49 bool underlined,
50 const wxString& face,
51 wxFontEncoding encoding)
52{
53 return new wxFont(size, family, style, weight, underlined, face, encoding);
54}
55
56wxFont& wxFont::operator=(const wxFont& font)
57{
58 if ( this != &font )
59 Ref(font);
60
61 return (wxFont &)*this;
62}
63
64// VZ: is it correct to compare pointers and not the contents? (FIXME)
65bool wxFontBase::operator==(const wxFont& font) const
66{
67 return GetFontData() == font.GetFontData();
68}
69
70bool wxFontBase::operator!=(const wxFont& font) const
71{
72 return GetFontData() != font.GetFontData();
73}
74
75wxString wxFontBase::GetFamilyString() const
76{
77 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
78
79 switch ( GetFamily() )
80 {
81 case wxDECORATIVE: return wxT("wxDECORATIVE");
82 case wxROMAN: return wxT("wxROMAN");
83 case wxSCRIPT: return wxT("wxSCRIPT");
84 case wxSWISS: return wxT("wxSWISS");
85 case wxMODERN: return wxT("wxMODERN");
86 case wxTELETYPE: return wxT("wxTELETYPE");
87 default: return wxT("wxDEFAULT");
88 }
89}
90
91wxString wxFontBase::GetStyleString() const
92{
93 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
94
95 switch ( GetStyle() )
96 {
97 case wxNORMAL: return wxT("wxNORMAL");
98 case wxSLANT: return wxT("wxSLANT");
99 case wxITALIC: return wxT("wxITALIC");
100 default: return wxT("wxDEFAULT");
101 }
102}
103
104wxString wxFontBase::GetWeightString() const
105{
106 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
107
108 switch ( GetWeight() )
109 {
110 case wxNORMAL: return wxT("wxNORMAL");
111 case wxBOLD: return wxT("wxBOLD");
112 case wxLIGHT: return wxT("wxLIGHT");
113 default: return wxT("wxDEFAULT");
114 }
115}
116