]> git.saurik.com Git - wxWidgets.git/blame - include/wx/font.h
Corrections
[wxWidgets.git] / include / wx / font.h
CommitLineData
0c5d3e1c
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/font.h
3// Purpose: wxFontBase class: the interface of wxFont
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
34138703
JS
12#ifndef _WX_FONT_H_BASE_
13#define _WX_FONT_H_BASE_
c801d85f 14
1b68e0b5
RR
15#ifdef __GNUG__
16 #pragma interface "fontbase.h"
17#endif
18
0c5d3e1c
VZ
19// ----------------------------------------------------------------------------
20// headers
21// ----------------------------------------------------------------------------
22
23#include "wx/defs.h" // for wxDEFAULT &c
24#include "wx/gdiobj.h" // the base class
25
26// ----------------------------------------------------------------------------
27// forward declarations
28// ----------------------------------------------------------------------------
29
30class WXDLLEXPORT wxFontBase;
31class WXDLLEXPORT wxFont;
32
33// ----------------------------------------------------------------------------
34// font constants
35// ----------------------------------------------------------------------------
36
37// standard font families
38enum wxFontFamily
39{
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,
47 wxFONTFAMILY_MAX
48};
49
50// font styles
51enum wxFontStyle
52{
53 wxFONTSTYLE_NORMAL = wxNORMAL,
54 wxFONTSTYLE_ITALIC = wxITALIC,
55 wxFONTSTYLE_SLANT = wxSLANT,
56 wxFONTSTYLE_MAX
57};
58
59// font weights
60enum wxFontWeight
61{
62 wxFONTWEIGHT_NORMAL = wxNORMAL,
63 wxFONTWEIGHT_LIGHT = wxLIGHT,
64 wxFONTWEIGHT_BOLD = wxBOLD,
65 wxFONTWEIGHT_MAX
66};
67
68// font encodings
69enum wxFontEncoding
70{
71 wxFONTENCODING_SYSTEM = -1, // system default
72 wxFONTENCODING_DEFAULT, // current default encoding
73
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
93 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
94 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
95 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
96 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
97
98 // what would we do without Microsoft? They have their own encodings
99 // for DOS
100 wxFONTENCODING_CP437, // original MS-DOS codepage
101 wxFONTENCODING_CP850, // CP437 merged with Latin1
102 wxFONTENCODING_CP852, // CP437 merged with Latin2
103 wxFONTENCODING_CP855, // another cyrillic encoding
b9b3ccd9 104 wxFONTENCODING_CP866, // and another one
0c5d3e1c
VZ
105 // and for Windows
106 wxFONTENCODING_CP1250, // WinLatin2
107 wxFONTENCODING_CP1251, // WinCyrillic
108 wxFONTENCODING_CP1252, // WinLatin1
109
110 wxFONTENCODING_MAX
111};
112
113// ----------------------------------------------------------------------------
114// wxFontBase represents a font object
115// ----------------------------------------------------------------------------
116
117class wxFontBase : public wxGDIObject
118{
119public:
120 // creator function
121 static wxFont *New(
122 int pointSize, // size of the font in points
123 int family, // see wxFontFamily enum
124 int style, // see wxFontStyle enum
125 int weight, // see wxFontWeight enum
126 bool underlined = FALSE, // not underlined by default
127 const wxString& face = wxEmptyString, // facename
128 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
129
130 // was the font successfully created?
131 bool Ok() const { return m_refData != NULL; }
132
133 // comparison
134 bool operator == (const wxFont& font) const;
135 bool operator != (const wxFont& font) const;
136
137 // accessors: get the font characteristics
138 virtual int GetPointSize() const = 0;
139 virtual int GetFamily() const = 0;
140 virtual int GetStyle() const = 0;
141 virtual int GetWeight() const = 0;
142 virtual bool GetUnderlined() const = 0;
143 virtual wxString GetFaceName() const = 0;
144 virtual wxFontEncoding GetEncoding() const = 0;
145
146 // change the font characteristics
147 virtual void SetPointSize( int pointSize ) = 0;
148 virtual void SetFamily( int family ) = 0;
149 virtual void SetStyle( int style ) = 0;
150 virtual void SetWeight( int weight ) = 0;
151 virtual void SetFaceName( const wxString& faceName ) = 0;
152 virtual void SetUnderlined( bool underlined ) = 0;
153 virtual void SetEncoding(wxFontEncoding encoding) = 0;
154
155 // translate the fonts into human-readable string (i.e. GetStyleString()
156 // will return "wxITALIC" for an italic font, ...)
157 wxString GetFamilyString() const;
158 wxString GetStyleString() const;
159 wxString GetWeightString() const;
160
161 // the default encoding is used for creating all fonts with default
162 // encoding parameter
163 static wxFontEncoding GetDefaultEncoding()
164 { return ms_encodingDefault; }
165 static void SetDefaultEncoding(wxFontEncoding encoding)
166 { ms_encodingDefault = encoding; }
167
168protected:
169 // get the internal data
170 class WXDLLEXPORT wxFontRefData *GetFontData() const
171 { return (wxFontRefData *)m_refData; }
172
173private:
174 // the currently default encoding: by default, it's the default system
175 // encoding, but may be changed by the application using
176 // SetDefaultEncoding() to make all subsequent fonts created without
177 // specifing encoding parameter using this encoding
178 static wxFontEncoding ms_encodingDefault;
179};
180
181// include the real class declaration
2049ba38 182#if defined(__WXMSW__)
0c5d3e1c 183 #include "wx/msw/font.h"
2049ba38 184#elif defined(__WXMOTIF__)
0c5d3e1c 185 #include "wx/motif/font.h"
2049ba38 186#elif defined(__WXGTK__)
0c5d3e1c 187 #include "wx/gtk/font.h"
b4e76e0d 188#elif defined(__WXQT__)
0c5d3e1c 189 #include "wx/qt/font.h"
34138703 190#elif defined(__WXMAC__)
0c5d3e1c 191 #include "wx/mac/font.h"
1777b9bb 192#elif defined(__WXPM__)
0c5d3e1c 193 #include "wx/os2/font.h"
34138703 194#elif defined(__WXSTUBS__)
0c5d3e1c 195 #include "wx/stubs/font.h"
c801d85f
KB
196#endif
197
0c5d3e1c
VZ
198// ----------------------------------------------------------------------------
199// macros
200// ----------------------------------------------------------------------------
201
0c5d3e1c
VZ
202#define M_FONTDATA GetFontData()
203
c801d85f 204#endif
34138703 205 // _WX_FONT_H_BASE_