]> git.saurik.com Git - wxWidgets.git/blob - src/common/fontcmn.cpp
Finally deprecated callbacks.
[wxWidgets.git] / src / common / fontcmn.cpp
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
43 wxFontEncoding wxFontBase::ms_encodingDefault = wxFONTENCODING_SYSTEM;
44
45 /* static */
46 wxFont *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
57 wxFont& 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)
66 bool wxFontBase::operator==(const wxFont& font) const
67 {
68 return GetFontData() == font.GetFontData();
69 }
70
71 bool wxFontBase::operator!=(const wxFont& font) const
72 {
73 return GetFontData() != font.GetFontData();
74 }
75
76 wxString wxFontBase::GetFamilyString() const
77 {
78 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
79
80 switch ( GetFamily() )
81 {
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");
89 }
90 }
91
92 wxString wxFontBase::GetStyleString() const
93 {
94 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
95
96 switch ( GetStyle() )
97 {
98 case wxNORMAL: return wxT("wxNORMAL");
99 case wxSLANT: return wxT("wxSLANT");
100 case wxITALIC: return wxT("wxITALIC");
101 default: return wxT("wxDEFAULT");
102 }
103 }
104
105 wxString wxFontBase::GetWeightString() const
106 {
107 wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") );
108
109 switch ( GetWeight() )
110 {
111 case wxNORMAL: return wxT("wxNORMAL");
112 case wxBOLD: return wxT("wxBOLD");
113 case wxLIGHT: return wxT("wxLIGHT");
114 default: return wxT("wxDEFAULT");
115 }
116 }
117