1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFontBase class: the interface of wxFont
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FONT_H_BASE_
13 #define _WX_FONT_H_BASE_
16 #pragma interface "fontbase.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 #include "wx/defs.h" // for wxDEFAULT &c
24 #include "wx/gdiobj.h" // the base class
26 // ----------------------------------------------------------------------------
27 // forward declarations
28 // ----------------------------------------------------------------------------
30 class WXDLLEXPORT wxFontBase
;
31 class WXDLLEXPORT wxFont
;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 // standard font families
40 wxFONTFAMILY_DEFAULT
= wxDEFAULT
,
41 wxFONTFAMILY_DECORATIVE
= wxDECORATIVE
,
42 wxFONTFAMILY_ROMAN
= wxROMAN
,
43 wxFONTFAMILY_SCRIPT
= wxSCRIPT
,
44 wxFONTFAMILY_SWISS
= wxSWISS
,
45 wxFONTFAMILY_MODERN
= wxMODERN
,
46 wxFONTFAMILY_TELETYPE
= wxTELETYPE
,
53 wxFONTSTYLE_NORMAL
= wxNORMAL
,
54 wxFONTSTYLE_ITALIC
= wxITALIC
,
55 wxFONTSTYLE_SLANT
= wxSLANT
,
62 wxFONTWEIGHT_NORMAL
= wxNORMAL
,
63 wxFONTWEIGHT_LIGHT
= wxLIGHT
,
64 wxFONTWEIGHT_BOLD
= wxBOLD
,
71 wxFONTENCODING_SYSTEM
= -1, // system default
72 wxFONTENCODING_DEFAULT
, // current default encoding
74 // ISO8859 standard defines a number of single-byte charsets
75 wxFONTENCODING_ISO8859_1
, // West European (Latin1)
76 wxFONTENCODING_ISO8859_2
, // Central and East European (Latin2)
77 wxFONTENCODING_ISO8859_3
, // Esperanto (Latin3)
78 wxFONTENCODING_ISO8859_4
, // Baltic languages (Estonian) (Latin4)
79 wxFONTENCODING_ISO8859_5
, // Cyrillic
80 wxFONTENCODING_ISO8859_6
, // Arabic
81 wxFONTENCODING_ISO8859_7
, // Greek
82 wxFONTENCODING_ISO8859_8
, // Hebrew
83 wxFONTENCODING_ISO8859_9
, // Turkish (Latin5)
84 wxFONTENCODING_ISO8859_10
, // Variation of Latin4 (Latin6)
85 wxFONTENCODING_ISO8859_11
, // Thai
86 wxFONTENCODING_ISO8859_12
, // doesn't exist currently, but put it
87 // here anyhow to make all ISO8859
88 // consecutive numbers
89 wxFONTENCODING_ISO8859_13
, // Latin7
90 wxFONTENCODING_ISO8859_14
, // Latin8
91 wxFONTENCODING_ISO8859_15
, // Latin9 (a.k.a. Latin0, includes euro)
92 wxFONTENCODING_ISO8859_MAX
,
94 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
95 wxFONTENCODING_KOI8
, // we don't support any of KOI8 variants
96 wxFONTENCODING_ALTERNATIVE
, // same as MS-DOS CP866
97 wxFONTENCODING_BULGARIAN
, // used under Linux in Bulgaria
99 // what would we do without Microsoft? They have their own encodings
101 wxFONTENCODING_CP437
, // original MS-DOS codepage
102 wxFONTENCODING_CP850
, // CP437 merged with Latin1
103 wxFONTENCODING_CP852
, // CP437 merged with Latin2
104 wxFONTENCODING_CP855
, // another cyrillic encoding
105 wxFONTENCODING_CP866
, // and another one
107 wxFONTENCODING_CP1250
, // WinLatin2
108 wxFONTENCODING_CP1251
, // WinCyrillic
109 wxFONTENCODING_CP1252
, // WinLatin1
110 wxFONTENCODING_CP1253
, // WinGreek (8859-7)
111 wxFONTENCODING_CP1254
, // WinTurkish
112 wxFONTENCODING_CP1255
, // WinHebrew
113 wxFONTENCODING_CP1256
, // WinArabic
114 wxFONTENCODING_CP1257
, // WinBaltic (same as Latin 7)
115 wxFONTENCODING_CP12_MAX
,
120 // ----------------------------------------------------------------------------
121 // wxFontBase represents a font object
122 // ----------------------------------------------------------------------------
124 class WXDLLEXPORT wxFontRefData
;
126 class wxFontBase
: public wxGDIObject
131 int pointSize
, // size of the font in points
132 int family
, // see wxFontFamily enum
133 int style
, // see wxFontStyle enum
134 int weight
, // see wxFontWeight enum
135 bool underlined
= FALSE
, // not underlined by default
136 const wxString
& face
= wxEmptyString
, // facename
137 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
); // ISO8859-X, ...
139 // was the font successfully created?
140 bool Ok() const { return m_refData
!= NULL
; }
143 bool operator == (const wxFont
& font
) const;
144 bool operator != (const wxFont
& font
) const;
146 // accessors: get the font characteristics
147 virtual int GetPointSize() const = 0;
148 virtual int GetFamily() const = 0;
149 virtual int GetStyle() const = 0;
150 virtual int GetWeight() const = 0;
151 virtual bool GetUnderlined() const = 0;
152 virtual wxString
GetFaceName() const = 0;
153 virtual wxFontEncoding
GetEncoding() const = 0;
155 // change the font characteristics
156 virtual void SetPointSize( int pointSize
) = 0;
157 virtual void SetFamily( int family
) = 0;
158 virtual void SetStyle( int style
) = 0;
159 virtual void SetWeight( int weight
) = 0;
160 virtual void SetFaceName( const wxString
& faceName
) = 0;
161 virtual void SetUnderlined( bool underlined
) = 0;
162 virtual void SetEncoding(wxFontEncoding encoding
) = 0;
164 // translate the fonts into human-readable string (i.e. GetStyleString()
165 // will return "wxITALIC" for an italic font, ...)
166 wxString
GetFamilyString() const;
167 wxString
GetStyleString() const;
168 wxString
GetWeightString() const;
170 // the default encoding is used for creating all fonts with default
171 // encoding parameter
172 static wxFontEncoding
GetDefaultEncoding()
173 { return ms_encodingDefault
; }
174 static void SetDefaultEncoding(wxFontEncoding encoding
)
175 { ms_encodingDefault
= encoding
; }
178 // get the internal data
179 wxFontRefData
*GetFontData() const
180 { return (wxFontRefData
*)m_refData
; }
183 // the currently default encoding: by default, it's the default system
184 // encoding, but may be changed by the application using
185 // SetDefaultEncoding() to make all subsequent fonts created without
186 // specifing encoding parameter using this encoding
187 static wxFontEncoding ms_encodingDefault
;
190 // include the real class declaration
191 #if defined(__WXMSW__)
192 #include "wx/msw/font.h"
193 #elif defined(__WXMOTIF__)
194 #include "wx/motif/font.h"
195 #elif defined(__WXGTK__)
196 #include "wx/gtk/font.h"
197 #elif defined(__WXQT__)
198 #include "wx/qt/font.h"
199 #elif defined(__WXMAC__)
200 #include "wx/mac/font.h"
201 #elif defined(__WXPM__)
202 #include "wx/os2/font.h"
203 #elif defined(__WXSTUBS__)
204 #include "wx/stubs/font.h"
207 // ----------------------------------------------------------------------------
209 // ----------------------------------------------------------------------------
211 #define M_FONTDATA GetFontData()