]> git.saurik.com Git - wxWidgets.git/blob - include/wx/font.h
1. wxCalendarCtrl
[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_CP874, // WinThai
109 wxFONTENCODING_CP1250, // WinLatin2
110 wxFONTENCODING_CP1251, // WinCyrillic
111 wxFONTENCODING_CP1252, // WinLatin1
112 wxFONTENCODING_CP1253, // WinGreek (8859-7)
113 wxFONTENCODING_CP1254, // WinTurkish
114 wxFONTENCODING_CP1255, // WinHebrew
115 wxFONTENCODING_CP1256, // WinArabic
116 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
117 wxFONTENCODING_CP12_MAX,
118
119 wxFONTENCODING_MAX
120 };
121
122 // ----------------------------------------------------------------------------
123 // wxFontBase represents a font object
124 // ----------------------------------------------------------------------------
125
126 class WXDLLEXPORT wxFontRefData;
127
128 class wxFontBase : public wxGDIObject
129 {
130 public:
131 // creator function
132 static wxFont *New(
133 int pointSize, // size of the font in points
134 int family, // see wxFontFamily enum
135 int style, // see wxFontStyle enum
136 int weight, // see wxFontWeight enum
137 bool underlined = FALSE, // not underlined by default
138 const wxString& face = wxEmptyString, // facename
139 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
140
141 // was the font successfully created?
142 bool Ok() const { return m_refData != NULL; }
143
144 // comparison
145 bool operator == (const wxFont& font) const;
146 bool operator != (const wxFont& font) const;
147
148 // accessors: get the font characteristics
149 virtual int GetPointSize() const = 0;
150 virtual int GetFamily() const = 0;
151 virtual int GetStyle() const = 0;
152 virtual int GetWeight() const = 0;
153 virtual bool GetUnderlined() const = 0;
154 virtual wxString GetFaceName() const = 0;
155 virtual wxFontEncoding GetEncoding() const = 0;
156
157 // change the font characteristics
158 virtual void SetPointSize( int pointSize ) = 0;
159 virtual void SetFamily( int family ) = 0;
160 virtual void SetStyle( int style ) = 0;
161 virtual void SetWeight( int weight ) = 0;
162 virtual void SetFaceName( const wxString& faceName ) = 0;
163 virtual void SetUnderlined( bool underlined ) = 0;
164 virtual void SetEncoding(wxFontEncoding encoding) = 0;
165
166 // translate the fonts into human-readable string (i.e. GetStyleString()
167 // will return "wxITALIC" for an italic font, ...)
168 wxString GetFamilyString() const;
169 wxString GetStyleString() const;
170 wxString GetWeightString() const;
171
172 // the default encoding is used for creating all fonts with default
173 // encoding parameter
174 static wxFontEncoding GetDefaultEncoding()
175 { return ms_encodingDefault; }
176 static void SetDefaultEncoding(wxFontEncoding encoding)
177 { ms_encodingDefault = encoding; }
178
179 protected:
180 // get the internal data
181 wxFontRefData *GetFontData() const
182 { return (wxFontRefData *)m_refData; }
183
184 private:
185 // the currently default encoding: by default, it's the default system
186 // encoding, but may be changed by the application using
187 // SetDefaultEncoding() to make all subsequent fonts created without
188 // specifing encoding parameter using this encoding
189 static wxFontEncoding ms_encodingDefault;
190 };
191
192 // include the real class declaration
193 #if defined(__WXMSW__)
194 #include "wx/msw/font.h"
195 #elif defined(__WXMOTIF__)
196 #include "wx/motif/font.h"
197 #elif defined(__WXGTK__)
198 #include "wx/gtk/font.h"
199 #elif defined(__WXQT__)
200 #include "wx/qt/font.h"
201 #elif defined(__WXMAC__)
202 #include "wx/mac/font.h"
203 #elif defined(__WXPM__)
204 #include "wx/os2/font.h"
205 #elif defined(__WXSTUBS__)
206 #include "wx/stubs/font.h"
207 #endif
208
209 // ----------------------------------------------------------------------------
210 // macros
211 // ----------------------------------------------------------------------------
212
213 #define M_FONTDATA GetFontData()
214
215 #endif
216 // _WX_FONT_H_BASE_