]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/font.h
Add wxDataViewCtrl::GetCurrentColumn().
[wxWidgets.git] / interface / wx / font.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: font.h
e54c96f1 3// Purpose: interface of wxFont
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
0b70c946
FM
9
10/**
6aea1e4a
FM
11 Standard font families: these are used mainly during wxFont creation to specify
12 the generic properties of the font without hardcoding in the sources a specific
13 face name.
14
15 wxFontFamily thus allows to group the font face names of fonts with similar
16 properties. Most wxWidgets ports use lists of fonts for each font family
17 inspired by the data taken from http://www.codestyle.org/css/font-family.
0b70c946
FM
18*/
19enum wxFontFamily
20{
21 wxFONTFAMILY_DEFAULT = wxDEFAULT, //!< Chooses a default font.
f76c0758 22
0b70c946
FM
23 wxFONTFAMILY_DECORATIVE = wxDECORATIVE, //!< A decorative font.
24 wxFONTFAMILY_ROMAN = wxROMAN, //!< A formal, serif font.
25 wxFONTFAMILY_SCRIPT = wxSCRIPT, //!< A handwriting font.
26 wxFONTFAMILY_SWISS = wxSWISS, //!< A sans-serif font.
f76c0758 27
6aea1e4a
FM
28 /// A fixed pitch font. Note that wxFont currently does not make distinctions
29 /// between @c wxFONTFAMILY_MODERN and @c wxFONTFAMILY_TELETYPE.
30 wxFONTFAMILY_MODERN = wxMODERN,
f76c0758 31
6aea1e4a 32 /// A teletype (i.e. monospaced) font.
f76c0758
VZ
33 /// Monospace fonts have a fixed width like typewriters and often have strong angular
34 /// or block serifs. Monospace font faces are often used code samples and have a simple,
6aea1e4a
FM
35 /// functional font style.
36 /// See also wxFont::IsFixedWidth() for an easy way to test for monospace property.
37 wxFONTFAMILY_TELETYPE = wxTELETYPE,
f76c0758 38
e9321277 39 wxFONTFAMILY_MAX,
59b7da02
VZ
40 /// Invalid font family value, returned by wxFont::GetFamily() when the
41 /// font is invalid for example.
e9321277 42 wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
0b70c946
FM
43};
44
45/**
46 Font styles.
47*/
48enum wxFontStyle
49{
071de7a0 50 /// The font is drawn without slant.
0b70c946 51 wxFONTSTYLE_NORMAL = wxNORMAL,
071de7a0
FM
52
53 /// The font is slanted in an italic style.
0b70c946 54 wxFONTSTYLE_ITALIC = wxITALIC,
f76c0758
VZ
55
56 /// The font is slanted, but in a roman style.
071de7a0 57 /// Note that under wxMSW this style is the same as @c wxFONTSTYLE_ITALIC.
0b70c946 58 wxFONTSTYLE_SLANT = wxSLANT,
071de7a0 59
0b70c946
FM
60 wxFONTSTYLE_MAX
61};
62
63/**
64 Font weights.
65*/
66enum wxFontWeight
67{
68 wxFONTWEIGHT_NORMAL = wxNORMAL, //!< Normal font.
69 wxFONTWEIGHT_LIGHT = wxLIGHT, //!< Light font.
70 wxFONTWEIGHT_BOLD = wxBOLD, //!< Bold font.
71 wxFONTWEIGHT_MAX
72};
73
19da7aaa
VZ
74/**
75 Symbolic font sizes.
76
77 The elements of this enum correspond to CSS absolute size specifications,
78 see http://www.w3.org/TR/CSS21/fonts.html#font-size-props
79
80 @see wxFont::SetSymbolicSize()
81
82 @since 2.9.2
83 */
84enum wxFontSymbolicSize
85{
86 wxFONTSIZE_XX_SMALL = -3, //!< Extra small.
87 wxFONTSIZE_X_SMALL, //!< Very small.
88 wxFONTSIZE_SMALL, //!< Small.
89 wxFONTSIZE_MEDIUM, //!< Normal.
90 wxFONTSIZE_LARGE, //!< Large.
91 wxFONTSIZE_X_LARGE, //!< Very large.
92 wxFONTSIZE_XX_LARGE //!< Extra large.
93};
94
0b70c946
FM
95/**
96 The font flag bits for the new font ctor accepting one combined flags word.
97*/
98enum wxFontFlag
99{
100 /// no special flags: font with default weight/slant/anti-aliasing
101 wxFONTFLAG_DEFAULT = 0,
102
103 /// slant flags (default: no slant)
104 wxFONTFLAG_ITALIC = 1 << 0,
105 wxFONTFLAG_SLANT = 1 << 1,
106
107 /// weight flags (default: medium)
108 wxFONTFLAG_LIGHT = 1 << 2,
109 wxFONTFLAG_BOLD = 1 << 3,
110
111 /// anti-aliasing flag: force on or off (default: the current system default)
112 wxFONTFLAG_ANTIALIASED = 1 << 4,
113 wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
114
115 /// underlined/strikethrough flags (default: no lines)
116 wxFONTFLAG_UNDERLINED = 1 << 6,
117 wxFONTFLAG_STRIKETHROUGH = 1 << 7,
118
119 /// the mask of all currently used flags
120 wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
121 wxFONTFLAG_SLANT |
122 wxFONTFLAG_LIGHT |
123 wxFONTFLAG_BOLD |
124 wxFONTFLAG_ANTIALIASED |
125 wxFONTFLAG_NOT_ANTIALIASED |
126 wxFONTFLAG_UNDERLINED |
127 wxFONTFLAG_STRIKETHROUGH
128};
129
130
131
132/**
133 Font encodings.
f76c0758 134
7ce58684 135 See wxFont::SetEncoding().
0b70c946
FM
136*/
137enum wxFontEncoding
138{
139 /// Default system encoding.
140 wxFONTENCODING_SYSTEM = -1, // system default
141
142 /// Default application encoding.
143 wxFONTENCODING_DEFAULT, // current default encoding
144
145 // ISO8859 standard defines a number of single-byte charsets
9a6fda22
FM
146 wxFONTENCODING_ISO8859_1, //!< West European (Latin1)
147 wxFONTENCODING_ISO8859_2, //!< Central and East European (Latin2)
148 wxFONTENCODING_ISO8859_3, //!< Esperanto (Latin3)
149 wxFONTENCODING_ISO8859_4, //!< Baltic (old) (Latin4)
150 wxFONTENCODING_ISO8859_5, //!< Cyrillic
151 wxFONTENCODING_ISO8859_6, //!< Arabic
152 wxFONTENCODING_ISO8859_7, //!< Greek
153 wxFONTENCODING_ISO8859_8, //!< Hebrew
154 wxFONTENCODING_ISO8859_9, //!< Turkish (Latin5)
155 wxFONTENCODING_ISO8859_10, //!< Variation of Latin4 (Latin6)
156 wxFONTENCODING_ISO8859_11, //!< Thai
157 wxFONTENCODING_ISO8859_12, //!< doesn't exist currently, but put it
158 //!< here anyhow to make all ISO8859
159 //!< consecutive numbers
160 wxFONTENCODING_ISO8859_13, //!< Baltic (Latin7)
161 wxFONTENCODING_ISO8859_14, //!< Latin8
162 wxFONTENCODING_ISO8859_15, //!< Latin9 (a.k.a. Latin0, includes euro)
0b70c946
FM
163 wxFONTENCODING_ISO8859_MAX,
164
165 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
9a6fda22
FM
166 wxFONTENCODING_KOI8, //!< KOI8 Russian
167 wxFONTENCODING_KOI8_U, //!< KOI8 Ukrainian
168 wxFONTENCODING_ALTERNATIVE, //!< same as MS-DOS CP866
169 wxFONTENCODING_BULGARIAN, //!< used under Linux in Bulgaria
0b70c946
FM
170
171 // what would we do without Microsoft? They have their own encodings
172 // for DOS
9a6fda22
FM
173 wxFONTENCODING_CP437, //!< original MS-DOS codepage
174 wxFONTENCODING_CP850, //!< CP437 merged with Latin1
175 wxFONTENCODING_CP852, //!< CP437 merged with Latin2
176 wxFONTENCODING_CP855, //!< another cyrillic encoding
177 wxFONTENCODING_CP866, //!< and another one
0b70c946 178 // and for Windows
9a6fda22
FM
179 wxFONTENCODING_CP874, //!< WinThai
180 wxFONTENCODING_CP932, //!< Japanese (shift-JIS)
181 wxFONTENCODING_CP936, //!< Chinese simplified (GB)
182 wxFONTENCODING_CP949, //!< Korean (Hangul charset)
183 wxFONTENCODING_CP950, //!< Chinese (traditional - Big5)
184 wxFONTENCODING_CP1250, //!< WinLatin2
185 wxFONTENCODING_CP1251, //!< WinCyrillic
186 wxFONTENCODING_CP1252, //!< WinLatin1
187 wxFONTENCODING_CP1253, //!< WinGreek (8859-7)
188 wxFONTENCODING_CP1254, //!< WinTurkish
189 wxFONTENCODING_CP1255, //!< WinHebrew
190 wxFONTENCODING_CP1256, //!< WinArabic
191 wxFONTENCODING_CP1257, //!< WinBaltic (same as Latin 7)
0b70c946
FM
192 wxFONTENCODING_CP12_MAX,
193
9a6fda22
FM
194 wxFONTENCODING_UTF7, //!< UTF-7 Unicode encoding
195 wxFONTENCODING_UTF8, //!< UTF-8 Unicode encoding
196 wxFONTENCODING_EUC_JP, //!< Extended Unix Codepage for Japanese
197 wxFONTENCODING_UTF16BE, //!< UTF-16 Big Endian Unicode encoding
198 wxFONTENCODING_UTF16LE, //!< UTF-16 Little Endian Unicode encoding
199 wxFONTENCODING_UTF32BE, //!< UTF-32 Big Endian Unicode encoding
0b70c946
FM
200 wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding
201
9a6fda22 202 wxFONTENCODING_MACROMAN, //!< the standard mac encodings
0b70c946
FM
203 wxFONTENCODING_MACJAPANESE,
204 wxFONTENCODING_MACCHINESETRAD,
205 wxFONTENCODING_MACKOREAN,
206 wxFONTENCODING_MACARABIC,
207 wxFONTENCODING_MACHEBREW,
208 wxFONTENCODING_MACGREEK,
209 wxFONTENCODING_MACCYRILLIC,
210 wxFONTENCODING_MACDEVANAGARI,
211 wxFONTENCODING_MACGURMUKHI,
212 wxFONTENCODING_MACGUJARATI,
213 wxFONTENCODING_MACORIYA,
214 wxFONTENCODING_MACBENGALI,
215 wxFONTENCODING_MACTAMIL,
216 wxFONTENCODING_MACTELUGU,
217 wxFONTENCODING_MACKANNADA,
218 wxFONTENCODING_MACMALAJALAM,
219 wxFONTENCODING_MACSINHALESE,
220 wxFONTENCODING_MACBURMESE,
221 wxFONTENCODING_MACKHMER,
222 wxFONTENCODING_MACTHAI,
223 wxFONTENCODING_MACLAOTIAN,
224 wxFONTENCODING_MACGEORGIAN,
225 wxFONTENCODING_MACARMENIAN,
226 wxFONTENCODING_MACCHINESESIMP,
227 wxFONTENCODING_MACTIBETAN,
228 wxFONTENCODING_MACMONGOLIAN,
229 wxFONTENCODING_MACETHIOPIC,
230 wxFONTENCODING_MACCENTRALEUR,
231 wxFONTENCODING_MACVIATNAMESE,
232 wxFONTENCODING_MACARABICEXT,
233 wxFONTENCODING_MACSYMBOL,
234 wxFONTENCODING_MACDINGBATS,
235 wxFONTENCODING_MACTURKISH,
236 wxFONTENCODING_MACCROATIAN,
237 wxFONTENCODING_MACICELANDIC,
238 wxFONTENCODING_MACROMANIAN,
239 wxFONTENCODING_MACCELTIC,
240 wxFONTENCODING_MACGAELIC,
241 wxFONTENCODING_MACKEYBOARD,
242
243 // more CJK encodings (for historical reasons some are already declared
244 // above)
9a6fda22 245 wxFONTENCODING_ISO2022_JP, //!< ISO-2022-JP JIS encoding
0b70c946 246
9a6fda22 247 wxFONTENCODING_MAX, //!< highest enumerated encoding value
0b70c946
FM
248
249 wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN ,
250 wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD ,
251
252 // aliases for endian-dependent UTF encodings
9a6fda22
FM
253 wxFONTENCODING_UTF16, //!< native UTF-16
254 wxFONTENCODING_UTF32, //!< native UTF-32
255
256 /// Alias for the native Unicode encoding on this platform
257 /// (this is used by wxEncodingConverter and wxUTFFile only for now)
258 wxFONTENCODING_UNICODE,
0b70c946 259
9a6fda22
FM
260 wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, //!< Simplified Chinese
261 wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, //!< Traditional Chinese
3d4e20dd
VZ
262 wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932, //!< Shift JIS
263 wxFONTENCODING_EUC_KR = wxFONTENCODING_CP949 //!< Korean
0b70c946
FM
264};
265
266
23324ae1
FM
267/**
268 @class wxFont
7c913512 269
0b70c946
FM
270 A font is an object which determines the appearance of text.
271 Fonts are used for drawing text to a device context, and setting the appearance
272 of a window's text.
7c913512 273
0b70c946 274 This class uses @ref overview_refcount "reference counting and copy-on-write"
23324ae1
FM
275 internally so that assignments between two instances of this class are very
276 cheap. You can therefore use actual objects instead of pointers without
277 efficiency problems. If an instance of this class is changed it will create
278 its own data internally so that other instances, which previously shared the
279 data using the reference counting, are not affected.
7c913512 280
23324ae1 281 You can retrieve the current system font settings with wxSystemSettings.
7c913512 282
23324ae1
FM
283 @library{wxcore}
284 @category{gdi}
7c913512 285
23324ae1 286 @stdobjects
65874118 287 ::wxNullFont, ::wxNORMAL_FONT, ::wxSMALL_FONT, ::wxITALIC_FONT, ::wxSWISS_FONT
7c913512 288
0b70c946
FM
289 @see @ref overview_font, wxDC::SetFont, wxDC::DrawText,
290 wxDC::GetTextExtent, wxFontDialog, wxSystemSettings
23324ae1
FM
291*/
292class wxFont : public wxGDIObject
293{
294public:
45a591fa 295 /**
0b70c946 296 Default ctor.
45a591fa
VZ
297 */
298 wxFont();
299
300 /**
0b70c946 301 Copy constructor, uses @ref overview_refcount "reference counting".
45a591fa
VZ
302 */
303 wxFont(const wxFont& font);
304
23324ae1
FM
305 /**
306 Creates a font object with the specified attributes.
3c4f71cc 307
7c913512 308 @param pointSize
b5791cc7 309 Size in points. See SetPointSize() for more info.
45a591fa 310 @param family
6aea1e4a
FM
311 The font family: a generic portable way of referring to fonts without specifying a
312 facename. This parameter must be one of the ::wxFontFamily enumeration values.
313 If the @a faceName argument is provided, then it overrides the font family.
45a591fa 314 @param style
b5791cc7 315 One of @c wxFONTSTYLE_NORMAL, @c wxFONTSTYLE_SLANT and @c wxFONTSTYLE_ITALIC.
45a591fa 316 @param weight
f76c0758 317 Font weight, sometimes also referred to as font boldness.
b5791cc7 318 One of the ::wxFontWeight enumeration values.
45a591fa 319 @param underline
0b70c946
FM
320 The value can be @true or @false.
321 At present this has an effect on Windows and Motif 2.x only.
45a591fa 322 @param faceName
6aea1e4a
FM
323 An optional string specifying the face name to be used.
324 If it is an empty string, a default face name will be chosen based on the family.
45a591fa 325 @param encoding
0b70c946
FM
326 An encoding which may be one of the enumeration values of ::wxFontEncoding.
327 Briefly these can be summed up as:
328 <TABLE>
b5791cc7
FM
329 <TR><TD>@c wxFONTENCODING_SYSTEM</TD><TD>Default system encoding.</TD></TR>
330 <TR><TD>@c wxFONTENCODING_DEFAULT</TD><TD>
8f1337ed 331 Default application encoding: this is the encoding set by calls to
f76c0758
VZ
332 SetDefaultEncoding() and which may be set to, say, KOI8 to create all
333 fonts by default with KOI8 encoding. Initially, the default application
8f1337ed 334 encoding is the same as default system encoding.</TD></TR>
b5791cc7
FM
335 <TR><TD>@c wxFONTENCODING_ISO8859_1...15</TD><TD>ISO8859 encodings.</TD></TR>
336 <TR><TD>@c wxFONTENCODING_KOI8</TD><TD>The standard Russian encoding for Internet.</TD></TR>
337 <TR><TD>@c wxFONTENCODING_CP1250...1252</TD><TD>Windows encodings similar to ISO8859 (but not identical).</TD></TR>
0b70c946 338 </TABLE>
45a591fa 339 If the specified encoding isn't available, no font is created
8f1337ed 340 (see also @ref overview_fontencoding).
45a591fa
VZ
341
342 @remarks If the desired font does not exist, the closest match will be
0b70c946 343 chosen. Under Windows, only scalable TrueType fonts are used.
45a591fa 344 */
882678eb 345 wxFont(int pointSize, wxFontFamily family, wxFontStyle style,
45a591fa 346 wxFontWeight weight,
11e3af6e 347 bool underline = false,
e9c3992c 348 const wxString& faceName = wxEmptyString,
45a591fa 349 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
0b70c946 350
45a591fa
VZ
351 /**
352 Creates a font object with the specified attributes.
353
7c913512 354 @param pixelSize
b5791cc7 355 Size in pixels. See SetPixelSize() for more info.
7c913512 356 @param family
6aea1e4a
FM
357 The font family: a generic portable way of referring to fonts without specifying a
358 facename. This parameter must be one of the ::wxFontFamily enumeration values.
359 If the @a faceName argument is provided, then it overrides the font family.
4cc4bfaf 360 @param style
b5791cc7 361 One of @c wxFONTSTYLE_NORMAL, @c wxFONTSTYLE_SLANT and @c wxFONTSTYLE_ITALIC.
7c913512 362 @param weight
0b70c946
FM
363 Font weight, sometimes also referred to as font boldness.
364 One of the ::wxFontWeight enumeration values.
4cc4bfaf 365 @param underline
0b70c946
FM
366 The value can be @true or @false.
367 At present this has an effect on Windows and Motif 2.x only.
4cc4bfaf 368 @param faceName
6aea1e4a
FM
369 An optional string specifying the face name to be used.
370 If it is an empty string, a default face name will be chosen based on the family.
7c913512 371 @param encoding
0b70c946
FM
372 An encoding which may be one of the enumeration values of ::wxFontEncoding.
373 Briefly these can be summed up as:
374 <TABLE>
b5791cc7
FM
375 <TR><TD>@c wxFONTENCODING_SYSTEM</TD><TD>Default system encoding.</TD></TR>
376 <TR><TD>@c wxFONTENCODING_DEFAULT</TD><TD>
8f1337ed 377 Default application encoding: this is the encoding set by calls to
f76c0758
VZ
378 SetDefaultEncoding() and which may be set to, say, KOI8 to create all
379 fonts by default with KOI8 encoding. Initially, the default application
8f1337ed 380 encoding is the same as default system encoding.</TD></TR>
b5791cc7
FM
381 <TR><TD>@c wxFONTENCODING_ISO8859_1...15</TD><TD>ISO8859 encodings.</TD></TR>
382 <TR><TD>@c wxFONTENCODING_KOI8</TD><TD>The standard Russian encoding for Internet.</TD></TR>
383 <TR><TD>@c wxFONTENCODING_CP1250...1252</TD><TD>Windows encodings similar to ISO8859 (but not identical).</TD></TR>
0b70c946 384 </TABLE>
4cc4bfaf 385 If the specified encoding isn't available, no font is created
8f1337ed 386 (see also @ref overview_fontencoding).
3c4f71cc 387
23324ae1 388 @remarks If the desired font does not exist, the closest match will be
0b70c946 389 chosen. Under Windows, only scalable TrueType fonts are used.
23324ae1 390 */
7c913512 391 wxFont(const wxSize& pixelSize, wxFontFamily family,
882678eb 392 wxFontStyle style, wxFontWeight weight,
11e3af6e 393 bool underline = false,
e9c3992c 394 const wxString& faceName = wxEmptyString,
7c913512 395 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
23324ae1 396
20cc4e19
VZ
397 /**
398 Constructor from font description string.
399
6aea1e4a
FM
400 This constructor uses SetNativeFontInfo() to initialize the font.
401 If @a fontdesc is invalid the font remains uninitialized, i.e. its IsOk() method
20cc4e19
VZ
402 will return @false.
403 */
d775ec48
RD
404 wxFont(const wxString& nativeInfoString);
405
406 /**
407 Construct font from a native font info structure.
408 */
409 wxFont(const wxNativeFontInfo& nativeInfo);
20cc4e19 410
23324ae1
FM
411 /**
412 Destructor.
0b70c946 413
674d80a7 414 See @ref overview_refcount_destruct "reference-counted object destruction"
0b70c946 415 for more info.
3c4f71cc 416
23324ae1 417 @remarks Although all remaining fonts are deleted when the application
4cc4bfaf
FM
418 exits, the application should try to clean up all fonts
419 itself. This is because wxWidgets cannot know if a
420 pointer to the font object is stored in an application
421 data structure, and there is a risk of double deletion.
23324ae1 422 */
adaaa686 423 virtual ~wxFont();
23324ae1 424
f76c0758 425
23324ae1 426 /**
060c4f90 427 @name Getters
23324ae1 428 */
060c4f90 429 //@{
f76c0758 430
7ce58684
FM
431 /**
432 Returns the encoding of this font.
f76c0758 433
7ce58684 434 Note that under wxGTK the returned value is always @c wxFONTENCODING_UTF8.
f76c0758 435
7ce58684
FM
436 @see SetEncoding()
437 */
438 virtual wxFontEncoding GetEncoding() const;
f76c0758 439
23324ae1 440 /**
6aea1e4a
FM
441 Returns the face name associated with the font, or the empty string if
442 there is no face information.
3c4f71cc 443
4cc4bfaf 444 @see SetFaceName()
23324ae1 445 */
adaaa686 446 virtual wxString GetFaceName() const;
23324ae1
FM
447
448 /**
59b7da02
VZ
449 Gets the font family if possible.
450
6aea1e4a
FM
451 As described in ::wxFontFamily docs the returned value acts as a rough,
452 basic classification of the main font properties (look, spacing).
f76c0758 453
6aea1e4a 454 If the current font face name is not recognized by wxFont or by the
59b7da02 455 underlying system, @c wxFONTFAMILY_DEFAULT is returned.
f76c0758 456
59b7da02
VZ
457 Note that currently this function is not very precise and so not
458 particularly useful. Font families mostly make sense only for font
459 creation, see SetFamily().
3c4f71cc 460
4cc4bfaf 461 @see SetFamily()
23324ae1 462 */
26818748 463 virtual wxFontFamily GetFamily() const;
23324ae1
FM
464
465 /**
466 Returns the platform-dependent string completely describing this font.
64932e41
VZ
467
468 Returned string is always non-empty unless the font is invalid (in
469 which case an assert is triggered).
0b70c946 470
23324ae1 471 Note that the returned string is not meant to be shown or edited by the user: a
0b70c946 472 typical use of this function is for serializing in string-form a wxFont object.
3c4f71cc 473
a912ea26 474 @see SetNativeFontInfo(), GetNativeFontInfoUserDesc()
23324ae1 475 */
328f5751 476 wxString GetNativeFontInfoDesc() const;
23324ae1
FM
477
478 /**
0b70c946 479 Returns a user-friendly string for this font object.
64932e41
VZ
480
481 Returned string is always non-empty unless the font is invalid (in
482 which case an assert is triggered).
f76c0758 483
a912ea26
FM
484 The string does not encode all wxFont infos under all platforms;
485 e.g. under wxMSW the font family is not present in the returned string.
0b70c946 486
23324ae1
FM
487 Some examples of the formats of returned strings (which are platform-dependent)
488 are in SetNativeFontInfoUserDesc().
3c4f71cc 489
a912ea26 490 @see SetNativeFontInfoUserDesc(), GetNativeFontInfoDesc()
23324ae1 491 */
adaaa686 492 wxString GetNativeFontInfoUserDesc() const;
23324ae1 493
d775ec48
RD
494 const wxNativeFontInfo *GetNativeFontInfo() const;
495
23324ae1
FM
496 /**
497 Gets the point size.
3c4f71cc 498
4cc4bfaf 499 @see SetPointSize()
23324ae1 500 */
adaaa686 501 virtual int GetPointSize() const;
23324ae1
FM
502
503 /**
b5791cc7 504 Gets the pixel size.
f76c0758 505
b5791cc7
FM
506 Note that under wxMSW if you passed to SetPixelSize() (or to the ctor)
507 a wxSize object with a null width value, you'll get a null width in
508 the returned object.
509
510 @see SetPixelSize()
511 */
512 virtual wxSize GetPixelSize() const;
f76c0758 513
b5791cc7
FM
514 /**
515 Gets the font style. See ::wxFontStyle for a list of valid styles.
3c4f71cc 516
4cc4bfaf 517 @see SetStyle()
23324ae1 518 */
26818748 519 virtual wxFontStyle GetStyle() const;
23324ae1
FM
520
521 /**
522 Returns @true if the font is underlined, @false otherwise.
3c4f71cc 523
4cc4bfaf 524 @see SetUnderlined()
23324ae1 525 */
adaaa686 526 virtual bool GetUnderlined() const;
23324ae1
FM
527
528 /**
b5791cc7 529 Gets the font weight. See ::wxFontWeight for a list of valid weight identifiers.
3c4f71cc 530
4cc4bfaf 531 @see SetWeight()
23324ae1 532 */
26818748 533 virtual wxFontWeight GetWeight() const;
23324ae1
FM
534
535 /**
536 Returns @true if the font is a fixed width (or monospaced) font,
537 @false if it is a proportional one or font is invalid.
f76c0758 538
6aea1e4a
FM
539 Note that this function under some platforms is different than just testing
540 for the font family being equal to @c wxFONTFAMILY_TELETYPE because native
541 platform-specific functions are used for the check (resulting in a more
542 accurate return value).
23324ae1 543 */
adaaa686 544 virtual bool IsFixedWidth() const;
23324ae1
FM
545
546 /**
547 Returns @true if this object is a valid font, @false otherwise.
548 */
0004982c 549 virtual bool IsOk() const;
f76c0758
VZ
550
551 //@}
552
553
554 /**
555 @name Similar fonts creation
556
6e7d2550
VZ
557 The functions in this section either modify the font in place or create
558 a new font similar to the given one but with its weight, style or size
559 changed.
f76c0758
VZ
560 */
561 //@{
562
563 /**
efb09182 564 Returns a bold version of this font.
6e7d2550
VZ
565
566 @see MakeBold()
567
568 @since 2.9.1
f76c0758 569 */
6e7d2550 570 wxFont Bold() const;
f76c0758
VZ
571
572 /**
efb09182 573 Returns an italic version of this font.
6e7d2550
VZ
574
575 @see MakeItalic()
576
577 @since 2.9.1
f76c0758 578 */
6e7d2550 579 wxFont Italic() const;
f76c0758
VZ
580
581 /**
efb09182 582 Returns a larger version of this font.
f76c0758 583
efb09182
VZ
584 The font size is multiplied by @c 1.2, the factor of @c 1.2 being
585 inspired by the W3C CSS specification.
f76c0758 586
efb09182 587 @see MakeLarger(), Smaller(), Scaled()
6e7d2550
VZ
588
589 @since 2.9.1
590 */
591 wxFont Larger() const;
592
efb09182
VZ
593 /**
594 Returns a smaller version of this font.
595
596 The font size is divided by @c 1.2, the factor of @c 1.2 being
597 inspired by the W3C CSS specification.
598
599 @see MakeSmaller(), Larger(), Scaled()
600
601 @since 2.9.1
602 */
603 wxFont Smaller() const;
604
801423ee
VZ
605 /**
606 Returns underlined version of this font.
607
608 @see MakeUnderlined()
609
610 @since 2.9.2
611 */
612 wxFont Underlined() const;
613
6e7d2550
VZ
614 /**
615 Changes this font to be bold.
616
617 @see Bold()
618
619 @since 2.9.1
620 */
621 wxFont& MakeBold();
622
623 /**
624 Changes this font to be italic.
625
626 @see Italic()
627
628 @since 2.9.1
f76c0758 629 */
6e7d2550
VZ
630 wxFont& MakeItalic();
631
632 /**
633 Changes this font to be larger.
634
efb09182
VZ
635 The font size is multiplied by @c 1.2, the factor of @c 1.2 being
636 inspired by the W3C CSS specification.
6e7d2550
VZ
637
638 @see Larger(), MakeSmaller(), Scale()
639
640 @since 2.9.1
641 */
642 wxFont& MakeLarger();
f76c0758
VZ
643
644 /**
efb09182 645 Changes this font to be smaller.
f76c0758 646
efb09182
VZ
647 The font size is divided by @c 1.2, the factor of @c 1.2 being
648 inspired by the W3C CSS specification.
f76c0758 649
efb09182 650 @see Smaller(), MakeLarger(), Scale()
6e7d2550
VZ
651
652 @since 2.9.1
f76c0758 653 */
6e7d2550
VZ
654 wxFont& MakeSmaller();
655
801423ee
VZ
656 /**
657 Changes this font to be underlined.
658
659 @see Underlined()
660
661 @since 2.9.2
662 */
663 wxFont& MakeUnderlined();
664
6e7d2550
VZ
665 /**
666 Changes the size of this font.
667
668 The font size is multiplied by the given factor (which may be less than
669 1 to create a smaller version of the font).
670
671 @see Scaled(), MakeLarger(), MakeSmaller()
672
673 @since 2.9.1
674 */
675 wxFont& Scale(float x);
f76c0758
VZ
676
677 /**
efb09182 678 Returns a scaled version of this font.
f76c0758
VZ
679
680 The font size is multiplied by the given factor (which may be less than
681 1 to create a smaller version of the font).
6e7d2550
VZ
682
683 @see Scale(), Larger(), Smaller()
684
685 @since 2.9.1
686 */
687 wxFont Scaled(float x) const;
688
23324ae1 689 //@}
f76c0758 690
23324ae1 691 /**
060c4f90 692 @name Setters
f76c0758 693
060c4f90
FM
694 These functions internally recreate the native font object with the new
695 specified property.
23324ae1 696 */
060c4f90
FM
697 //@{
698
7ce58684
FM
699 /**
700 Sets the encoding for this font.
f76c0758 701
7ce58684
FM
702 Note that under wxGTK this function has no effect (because the underlying
703 Pango library always uses @c wxFONTENCODING_UTF8).
f76c0758 704
7ce58684
FM
705 @see GetEncoding()
706 */
707 virtual void SetEncoding(wxFontEncoding encoding);
23324ae1
FM
708
709 /**
710 Sets the facename for the font.
3c4f71cc 711
7c913512 712 @param faceName
4cc4bfaf 713 A valid facename, which should be on the end-user's system.
3c4f71cc 714
23324ae1 715 @remarks To avoid portability problems, don't rely on a specific face,
f7008bad
FM
716 but specify the font family instead (see ::wxFontFamily and SetFamily()).
717
718 @return @true if the given face name exists; if the face name doesn't exist
f76c0758 719 in the user's system then the font is invalidated (so that IsOk() will
f7008bad 720 return @false) and @false is returned.
3c4f71cc 721
4cc4bfaf 722 @see GetFaceName(), SetFamily()
23324ae1 723 */
adaaa686 724 virtual bool SetFaceName(const wxString& faceName);
23324ae1
FM
725
726 /**
727 Sets the font family.
f76c0758 728
060c4f90
FM
729 As described in ::wxFontFamily docs the given @a family value acts as a rough,
730 basic indication of the main font properties (look, spacing).
731
732 Note that changing the font family results in changing the font face name.
3c4f71cc 733
7c913512 734 @param family
0b70c946 735 One of the ::wxFontFamily values.
3c4f71cc 736
4cc4bfaf 737 @see GetFamily(), SetFaceName()
23324ae1 738 */
a44f3b5a 739 virtual void SetFamily(wxFontFamily family);
23324ae1
FM
740
741 /**
0b70c946
FM
742 Creates the font corresponding to the given native font description string
743 which must have been previously returned by GetNativeFontInfoDesc().
744
745 If the string is invalid, font is unchanged.
746 This function is typically used for de-serializing a wxFont object
747 previously saved in a string-form.
748
749 @return @true if the creation was successful.
3c4f71cc 750
4cc4bfaf 751 @see SetNativeFontInfoUserDesc()
23324ae1
FM
752 */
753 bool SetNativeFontInfo(const wxString& info);
754
755 /**
756 Creates the font corresponding to the given native font description string and
0b70c946 757 returns @true if the creation was successful.
3c4f71cc 758
0b70c946
FM
759 Unlike SetNativeFontInfo(), this function accepts strings which are user-friendly.
760 Examples of accepted string formats are:
3c4f71cc 761
0b70c946
FM
762 @beginTable
763 @hdr3col{platform, generic syntax, example}
b5791cc7
FM
764 @row3col{wxGTK2, <tt>[FACE-NAME] [bold] [oblique|italic] [POINTSIZE]</tt>, Monospace bold 10}
765 @row3col{wxMSW, <tt>[light|bold] [italic] [FACE-NAME] [POINTSIZE] [ENCODING]</tt>, Tahoma 10 WINDOWS-1252}
0b70c946 766 @endTable
3c4f71cc 767
0b70c946 768 @todo add an example for wxMac
3c4f71cc 769
23324ae1 770 For more detailed information about the allowed syntaxes you can look at the
0b70c946
FM
771 documentation of the native API used for font-rendering
772 (e.g. @c pango_font_description_from_string on GTK).
f76c0758 773
a912ea26
FM
774 Note that unlike SetNativeFontInfo(), this function doesn't always restore all
775 attributes of the wxFont object under all platforms; e.g. on wxMSW the font family
776 is not restored (because GetNativeFontInfoUserDesc doesn't return it on wxMSW).
777 If you want to serialize/deserialize a font in string form, you should use
778 GetNativeFontInfoDesc() and SetNativeFontInfo() instead.
3c4f71cc 779
4cc4bfaf 780 @see SetNativeFontInfo()
23324ae1
FM
781 */
782 bool SetNativeFontInfoUserDesc(const wxString& info);
783
d775ec48
RD
784 void SetNativeFontInfo(const wxNativeFontInfo& info);
785
23324ae1
FM
786 /**
787 Sets the point size.
f76c0758
VZ
788
789 The <em>point size</em> is defined as 1/72 of the anglo-Saxon inch
790 (25.4 mm): it is approximately 0.0139 inch or 352.8 um.
3c4f71cc 791
7c913512 792 @param pointSize
4cc4bfaf 793 Size in points.
3c4f71cc 794
4cc4bfaf 795 @see GetPointSize()
23324ae1 796 */
adaaa686 797 virtual void SetPointSize(int pointSize);
23324ae1 798
b5791cc7
FM
799 /**
800 Sets the pixel size.
f76c0758 801
b5791cc7
FM
802 The height parameter of @a pixelSize must be positive while the width
803 parameter may also be zero (to indicate that you're not interested in the
804 width of the characters: a suitable width will be chosen for best rendering).
f76c0758
VZ
805
806 This feature (specifying the font pixel size) is directly supported only
807 under wxMSW and wxGTK currently; under other platforms a font with the
b5791cc7
FM
808 closest size to the given one is found using binary search (this maybe slower).
809
810 @see GetPixelSize()
811 */
812 virtual void SetPixelSize(const wxSize& pixelSize);
f76c0758 813
23324ae1
FM
814 /**
815 Sets the font style.
3c4f71cc 816
7c913512 817 @param style
0b70c946 818 One of the ::wxFontStyle enumeration values.
3c4f71cc 819
4cc4bfaf 820 @see GetStyle()
23324ae1 821 */
a44f3b5a 822 virtual void SetStyle(wxFontStyle style);
23324ae1 823
19da7aaa
VZ
824 /**
825 Sets the font size using a predefined symbolic size name.
826
827 This function allows to change font size to be (very) large or small
828 compared to the standard font size.
829
830 @see SetSymbolicSizeRelativeTo().
831
832 @since 2.9.2
833 */
834 void SetSymbolicSize(wxFontSymbolicSize size);
835
836 /**
837 Sets the font size compared to the base font size.
838
839 This is the same as SetSymbolicSize() except that it uses the given
840 font size as the normal font size instead of the standard font size.
841
842 @since 2.9.2
843 */
844 void SetSymbolicSizeRelativeTo(wxFontSymbolicSize size, int base);
845
23324ae1
FM
846 /**
847 Sets underlining.
3c4f71cc 848
45a591fa 849 @param underlined
4cc4bfaf 850 @true to underline, @false otherwise.
3c4f71cc 851
4cc4bfaf 852 @see GetUnderlined()
23324ae1 853 */
26818748 854 virtual void SetUnderlined(bool underlined);
23324ae1
FM
855
856 /**
857 Sets the font weight.
3c4f71cc 858
7c913512 859 @param weight
0b70c946 860 One of the ::wxFontWeight values.
3c4f71cc 861
4cc4bfaf 862 @see GetWeight()
23324ae1 863 */
a44f3b5a 864 virtual void SetWeight(wxFontWeight weight);
f76c0758 865
060c4f90
FM
866 //@}
867
23324ae1
FM
868
869 /**
870 Inequality operator.
0b70c946 871
674d80a7 872 See @ref overview_refcount_equality "reference-counted object comparison" for
23324ae1
FM
873 more info.
874 */
fadc2df6 875 bool operator!=(const wxFont& font) const;
23324ae1 876
23324ae1
FM
877 /**
878 Equality operator.
0b70c946 879
674d80a7 880 See @ref overview_refcount_equality "reference-counted object comparison" for
23324ae1
FM
881 more info.
882 */
fadc2df6 883 bool operator==(const wxFont& font) const;
0b70c946
FM
884
885 /**
886 Assignment operator, using @ref overview_refcount "reference counting".
887 */
888 wxFont& operator =(const wxFont& font);
f76c0758
VZ
889
890
060c4f90
FM
891 // statics
892
893 /**
894 Returns the current application's default encoding.
895
896 @see @ref overview_fontencoding, SetDefaultEncoding()
897 */
898 static wxFontEncoding GetDefaultEncoding();
899
900 /**
901 Sets the default font encoding.
902
903 @see @ref overview_fontencoding, GetDefaultEncoding()
904 */
905 static void SetDefaultEncoding(wxFontEncoding encoding);
f76c0758 906
060c4f90
FM
907 //@{
908 /**
909 This function takes the same parameters as the relative
910 @ref wxFont::wxFont "wxFont constructor" and returns a new font
911 object allocated on the heap.
912 */
913 static wxFont* New(int pointSize, wxFontFamily family, wxFontStyle style,
914 wxFontWeight weight,
915 bool underline = false,
916 const wxString& faceName = wxEmptyString,
917 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
918 static wxFont* New(int pointSize, wxFontFamily family,
919 int flags = wxFONTFLAG_DEFAULT,
920 const wxString& faceName = wxEmptyString,
921 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
922 static wxFont* New(const wxSize& pixelSize,
923 wxFontFamily family,
924 wxFontStyle style,
925 wxFontWeight weight,
926 bool underline = false,
927 const wxString& faceName = wxEmptyString,
928 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
929 static wxFont* New(const wxSize& pixelSize,
930 wxFontFamily family,
931 int flags = wxFONTFLAG_DEFAULT,
932 const wxString& faceName = wxEmptyString,
933 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
d775ec48
RD
934
935
936 static wxFont *New(const wxNativeFontInfo& nativeInfo);
937 static wxFont *New(const wxString& nativeInfoString);
938
060c4f90 939 //@}
23324ae1 940};
e54c96f1
FM
941
942
943/**
65874118 944 An empty wxFont.
e54c96f1 945*/
7fa7088e 946wxFont wxNullFont;
e54c96f1
FM
947
948/**
0b70c946 949 Equivalent to wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).
f76c0758 950
b5791cc7 951 @see wxSystemSettings
e54c96f1 952*/
7fa7088e 953wxFont wxNORMAL_FONT;
e54c96f1
FM
954
955/**
b5791cc7 956 A font using the @c wxFONTFAMILY_SWISS family and 2 points smaller than
0b70c946 957 ::wxNORMAL_FONT.
e54c96f1 958*/
7fa7088e 959wxFont wxSMALL_FONT;
e54c96f1
FM
960
961/**
b5791cc7 962 A font using the @c wxFONTFAMILY_ROMAN family and @c wxFONTSTYLE_ITALIC style and
0b70c946 963 of the same size of ::wxNORMAL_FONT.
e54c96f1 964*/
7fa7088e 965wxFont wxITALIC_FONT;
e54c96f1
FM
966
967/**
0b70c946 968 A font identic to ::wxNORMAL_FONT except for the family used which is
b5791cc7 969 @c wxFONTFAMILY_SWISS.
e54c96f1 970*/
7fa7088e
BP
971wxFont wxSWISS_FONT;
972
973
65874118
FM
974/**
975 @class wxFontList
65874118 976
0b70c946
FM
977 A font list is a list containing all fonts which have been created.
978 There is only one instance of this class: ::wxTheFontList.
979
980 Use this object to search for a previously created font of the desired type
981 and create it if not already found.
982
65874118
FM
983 In some windowing systems, the font may be a scarce resource, so it is best to
984 reuse old resources if possible. When an application finishes, all fonts will
0b70c946 985 be deleted and their resources freed, eliminating the possibility of 'memory
65874118
FM
986 leaks'.
987
988 @library{wxcore}
989 @category{gdi}
990
991 @see wxFont
992*/
993class wxFontList : public wxList
994{
995public:
996 /**
997 Constructor. The application should not construct its own font list:
0b70c946 998 use the object pointer ::wxTheFontList.
65874118
FM
999 */
1000 wxFontList();
1001
1002 /**
1003 Finds a font of the given specification, or creates one and adds it to the
0b70c946 1004 list. See the @ref wxFont "wxFont constructor" for details of the arguments.
65874118 1005 */
a44f3b5a
FM
1006 wxFont* FindOrCreateFont(int point_size, wxFontFamily family, wxFontStyle style,
1007 wxFontWeight weight, bool underline = false,
1008 const wxString& facename = wxEmptyString,
65874118
FM
1009 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
1010};
1011
1012
0b70c946
FM
1013/**
1014 The global wxFontList instance.
1015*/
1016wxFontList* wxTheFontList;
1017
7fa7088e
BP
1018
1019// ============================================================================
1020// Global functions/macros
1021// ============================================================================
1022
b21126db 1023/** @addtogroup group_funcmacro_misc */
7fa7088e 1024//@{
e54c96f1
FM
1025
1026/**
7fa7088e
BP
1027 Converts string to a wxFont best represented by the given string. Returns
1028 @true on success.
1029
1030 @see wxToString(const wxFont&)
1031
1032 @header{wx/font.h}
e54c96f1 1033*/
7fa7088e 1034bool wxFromString(const wxString& string, wxFont* font);
e54c96f1
FM
1035
1036/**
7fa7088e
BP
1037 Converts the given wxFont into a string.
1038
1039 @see wxFromString(const wxString&, wxFont*)
1040
1041 @header{wx/font.h}
e54c96f1 1042*/
7fa7088e 1043wxString wxToString(const wxFont& font);
e54c96f1 1044
7fa7088e 1045//@}
e54c96f1 1046