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