]> git.saurik.com Git - wxWidgets.git/blob - include/wx/font.h
Further stream tests, doc updates and minor clean-ups.
[wxWidgets.git] / include / wx / font.h
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
12 #ifndef _WX_FONT_H_BASE_
13 #define _WX_FONT_H_BASE_
14
15 #ifdef __GNUG__
16 #pragma interface "fontbase.h"
17 #endif
18
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
30 class WXDLLEXPORT wxFontData;
31 class WXDLLEXPORT wxFontBase;
32 class WXDLLEXPORT wxFont;
33
34 // ----------------------------------------------------------------------------
35 // font constants
36 // ----------------------------------------------------------------------------
37
38 // standard font families
39 enum wxFontFamily
40 {
41 wxFONTFAMILY_DEFAULT = wxDEFAULT,
42 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
43 wxFONTFAMILY_ROMAN = wxROMAN,
44 wxFONTFAMILY_SCRIPT = wxSCRIPT,
45 wxFONTFAMILY_SWISS = wxSWISS,
46 wxFONTFAMILY_MODERN = wxMODERN,
47 wxFONTFAMILY_TELETYPE = wxTELETYPE,
48 wxFONTFAMILY_MAX
49 };
50
51 // font styles
52 enum wxFontStyle
53 {
54 wxFONTSTYLE_NORMAL = wxNORMAL,
55 wxFONTSTYLE_ITALIC = wxITALIC,
56 wxFONTSTYLE_SLANT = wxSLANT,
57 wxFONTSTYLE_MAX
58 };
59
60 // font weights
61 enum wxFontWeight
62 {
63 wxFONTWEIGHT_NORMAL = wxNORMAL,
64 wxFONTWEIGHT_LIGHT = wxLIGHT,
65 wxFONTWEIGHT_BOLD = wxBOLD,
66 wxFONTWEIGHT_MAX
67 };
68
69 // font encodings
70 enum wxFontEncoding
71 {
72 wxFONTENCODING_SYSTEM = -1, // system default
73 wxFONTENCODING_DEFAULT, // current default encoding
74
75 // ISO8859 standard defines a number of single-byte charsets
76 wxFONTENCODING_ISO8859_1, // West European (Latin1)
77 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
78 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
79 wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
80 wxFONTENCODING_ISO8859_5, // Cyrillic
81 wxFONTENCODING_ISO8859_6, // Arabic
82 wxFONTENCODING_ISO8859_7, // Greek
83 wxFONTENCODING_ISO8859_8, // Hebrew
84 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
85 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
86 wxFONTENCODING_ISO8859_11, // Thai
87 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
88 // here anyhow to make all ISO8859
89 // consecutive numbers
90 wxFONTENCODING_ISO8859_13, // Latin7
91 wxFONTENCODING_ISO8859_14, // Latin8
92 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
93 wxFONTENCODING_ISO8859_MAX,
94
95 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
96 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
97 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
98 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
99
100 // what would we do without Microsoft? They have their own encodings
101 // for DOS
102 wxFONTENCODING_CP437, // original MS-DOS codepage
103 wxFONTENCODING_CP850, // CP437 merged with Latin1
104 wxFONTENCODING_CP852, // CP437 merged with Latin2
105 wxFONTENCODING_CP855, // another cyrillic encoding
106 wxFONTENCODING_CP866, // and another one
107 // and for Windows
108 wxFONTENCODING_CP1250, // WinLatin2
109 wxFONTENCODING_CP1251, // WinCyrillic
110 wxFONTENCODING_CP1252, // WinLatin1
111 wxFONTENCODING_CP1253, // WinGreek (8859-7)
112 wxFONTENCODING_CP1254, // WinTurkish
113 wxFONTENCODING_CP1255, // WinHebrew
114 wxFONTENCODING_CP1256, // WinArabic
115 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
116 wxFONTENCODING_CP12_MAX,
117
118 wxFONTENCODING_MAX
119 };
120
121 // ----------------------------------------------------------------------------
122 // wxFontBase represents a font object
123 // ----------------------------------------------------------------------------
124
125 class WXDLLEXPORT wxFontRefData;
126
127 class wxFontBase : public wxGDIObject
128 {
129 public:
130 // creator function
131 static wxFont *New(
132 int pointSize, // size of the font in points
133 int family, // see wxFontFamily enum
134 int style, // see wxFontStyle enum
135 int weight, // see wxFontWeight enum
136 bool underlined = FALSE, // not underlined by default
137 const wxString& face = wxEmptyString, // facename
138 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
139
140 // was the font successfully created?
141 bool Ok() const { return m_refData != NULL; }
142
143 // comparison
144 bool operator == (const wxFont& font) const;
145 bool operator != (const wxFont& font) const;
146
147 // accessors: get the font characteristics
148 virtual int GetPointSize() const = 0;
149 virtual int GetFamily() const = 0;
150 virtual int GetStyle() const = 0;
151 virtual int GetWeight() const = 0;
152 virtual bool GetUnderlined() const = 0;
153 virtual wxString GetFaceName() const = 0;
154 virtual wxFontEncoding GetEncoding() const = 0;
155
156 // change the font characteristics
157 virtual void SetPointSize( int pointSize ) = 0;
158 virtual void SetFamily( int family ) = 0;
159 virtual void SetStyle( int style ) = 0;
160 virtual void SetWeight( int weight ) = 0;
161 virtual void SetFaceName( const wxString& faceName ) = 0;
162 virtual void SetUnderlined( bool underlined ) = 0;
163 virtual void SetEncoding(wxFontEncoding encoding) = 0;
164
165 // translate the fonts into human-readable string (i.e. GetStyleString()
166 // will return "wxITALIC" for an italic font, ...)
167 wxString GetFamilyString() const;
168 wxString GetStyleString() const;
169 wxString GetWeightString() const;
170
171 // the default encoding is used for creating all fonts with default
172 // encoding parameter
173 static wxFontEncoding GetDefaultEncoding()
174 { return ms_encodingDefault; }
175 static void SetDefaultEncoding(wxFontEncoding encoding)
176 { ms_encodingDefault = encoding; }
177
178 protected:
179 // get the internal data
180 wxFontRefData *GetFontData() const
181 { return (wxFontRefData *)m_refData; }
182
183 private:
184 // the currently default encoding: by default, it's the default system
185 // encoding, but may be changed by the application using
186 // SetDefaultEncoding() to make all subsequent fonts created without
187 // specifing encoding parameter using this encoding
188 static wxFontEncoding ms_encodingDefault;
189 };
190
191 // include the real class declaration
192 #if defined(__WXMSW__)
193 #include "wx/msw/font.h"
194 #elif defined(__WXMOTIF__)
195 #include "wx/motif/font.h"
196 #elif defined(__WXGTK__)
197 #include "wx/gtk/font.h"
198 #elif defined(__WXQT__)
199 #include "wx/qt/font.h"
200 #elif defined(__WXMAC__)
201 #include "wx/mac/font.h"
202 #elif defined(__WXPM__)
203 #include "wx/os2/font.h"
204 #elif defined(__WXSTUBS__)
205 #include "wx/stubs/font.h"
206 #endif
207
208 // ----------------------------------------------------------------------------
209 // macros
210 // ----------------------------------------------------------------------------
211
212 #define M_FONTDATA GetFontData()
213
214 #endif
215 // _WX_FONT_H_BASE_