]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/font.h
store our styles in wxSpinCtrlGenericBase ctor (needed to make the changes of r59410...
[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$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
0b70c946
FM
9
10/**
11 Standard font families: these may be used only for the font creation, it
12 doesn't make sense to query an existing font for its font family as,
13 especially if the font had been created from a native font description, it
14 may be unknown.
15*/
16enum wxFontFamily
17{
18 wxFONTFAMILY_DEFAULT = wxDEFAULT, //!< Chooses a default font.
19 wxFONTFAMILY_DECORATIVE = wxDECORATIVE, //!< A decorative font.
20 wxFONTFAMILY_ROMAN = wxROMAN, //!< A formal, serif font.
21 wxFONTFAMILY_SCRIPT = wxSCRIPT, //!< A handwriting font.
22 wxFONTFAMILY_SWISS = wxSWISS, //!< A sans-serif font.
23 wxFONTFAMILY_MODERN = wxMODERN, //!< A fixed pitch font.
24 wxFONTFAMILY_TELETYPE = wxTELETYPE, //!< A teletype font.
25 wxFONTFAMILY_MAX,
26 wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
27};
28
29/**
30 Font styles.
31*/
32enum wxFontStyle
33{
34 wxFONTSTYLE_NORMAL = wxNORMAL,
35 wxFONTSTYLE_ITALIC = wxITALIC,
36 wxFONTSTYLE_SLANT = wxSLANT,
37 wxFONTSTYLE_MAX
38};
39
40/**
41 Font weights.
42*/
43enum wxFontWeight
44{
45 wxFONTWEIGHT_NORMAL = wxNORMAL, //!< Normal font.
46 wxFONTWEIGHT_LIGHT = wxLIGHT, //!< Light font.
47 wxFONTWEIGHT_BOLD = wxBOLD, //!< Bold font.
48 wxFONTWEIGHT_MAX
49};
50
51/**
52 The font flag bits for the new font ctor accepting one combined flags word.
53*/
54enum wxFontFlag
55{
56 /// no special flags: font with default weight/slant/anti-aliasing
57 wxFONTFLAG_DEFAULT = 0,
58
59 /// slant flags (default: no slant)
60 wxFONTFLAG_ITALIC = 1 << 0,
61 wxFONTFLAG_SLANT = 1 << 1,
62
63 /// weight flags (default: medium)
64 wxFONTFLAG_LIGHT = 1 << 2,
65 wxFONTFLAG_BOLD = 1 << 3,
66
67 /// anti-aliasing flag: force on or off (default: the current system default)
68 wxFONTFLAG_ANTIALIASED = 1 << 4,
69 wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
70
71 /// underlined/strikethrough flags (default: no lines)
72 wxFONTFLAG_UNDERLINED = 1 << 6,
73 wxFONTFLAG_STRIKETHROUGH = 1 << 7,
74
75 /// the mask of all currently used flags
76 wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
77 wxFONTFLAG_SLANT |
78 wxFONTFLAG_LIGHT |
79 wxFONTFLAG_BOLD |
80 wxFONTFLAG_ANTIALIASED |
81 wxFONTFLAG_NOT_ANTIALIASED |
82 wxFONTFLAG_UNDERLINED |
83 wxFONTFLAG_STRIKETHROUGH
84};
85
86
87
88/**
89 Font encodings.
90*/
91enum wxFontEncoding
92{
93 /// Default system encoding.
94 wxFONTENCODING_SYSTEM = -1, // system default
95
96 /// Default application encoding.
97 wxFONTENCODING_DEFAULT, // current default encoding
98
99 // ISO8859 standard defines a number of single-byte charsets
9a6fda22
FM
100 wxFONTENCODING_ISO8859_1, //!< West European (Latin1)
101 wxFONTENCODING_ISO8859_2, //!< Central and East European (Latin2)
102 wxFONTENCODING_ISO8859_3, //!< Esperanto (Latin3)
103 wxFONTENCODING_ISO8859_4, //!< Baltic (old) (Latin4)
104 wxFONTENCODING_ISO8859_5, //!< Cyrillic
105 wxFONTENCODING_ISO8859_6, //!< Arabic
106 wxFONTENCODING_ISO8859_7, //!< Greek
107 wxFONTENCODING_ISO8859_8, //!< Hebrew
108 wxFONTENCODING_ISO8859_9, //!< Turkish (Latin5)
109 wxFONTENCODING_ISO8859_10, //!< Variation of Latin4 (Latin6)
110 wxFONTENCODING_ISO8859_11, //!< Thai
111 wxFONTENCODING_ISO8859_12, //!< doesn't exist currently, but put it
112 //!< here anyhow to make all ISO8859
113 //!< consecutive numbers
114 wxFONTENCODING_ISO8859_13, //!< Baltic (Latin7)
115 wxFONTENCODING_ISO8859_14, //!< Latin8
116 wxFONTENCODING_ISO8859_15, //!< Latin9 (a.k.a. Latin0, includes euro)
0b70c946
FM
117 wxFONTENCODING_ISO8859_MAX,
118
119 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
9a6fda22
FM
120 wxFONTENCODING_KOI8, //!< KOI8 Russian
121 wxFONTENCODING_KOI8_U, //!< KOI8 Ukrainian
122 wxFONTENCODING_ALTERNATIVE, //!< same as MS-DOS CP866
123 wxFONTENCODING_BULGARIAN, //!< used under Linux in Bulgaria
0b70c946
FM
124
125 // what would we do without Microsoft? They have their own encodings
126 // for DOS
9a6fda22
FM
127 wxFONTENCODING_CP437, //!< original MS-DOS codepage
128 wxFONTENCODING_CP850, //!< CP437 merged with Latin1
129 wxFONTENCODING_CP852, //!< CP437 merged with Latin2
130 wxFONTENCODING_CP855, //!< another cyrillic encoding
131 wxFONTENCODING_CP866, //!< and another one
0b70c946 132 // and for Windows
9a6fda22
FM
133 wxFONTENCODING_CP874, //!< WinThai
134 wxFONTENCODING_CP932, //!< Japanese (shift-JIS)
135 wxFONTENCODING_CP936, //!< Chinese simplified (GB)
136 wxFONTENCODING_CP949, //!< Korean (Hangul charset)
137 wxFONTENCODING_CP950, //!< Chinese (traditional - Big5)
138 wxFONTENCODING_CP1250, //!< WinLatin2
139 wxFONTENCODING_CP1251, //!< WinCyrillic
140 wxFONTENCODING_CP1252, //!< WinLatin1
141 wxFONTENCODING_CP1253, //!< WinGreek (8859-7)
142 wxFONTENCODING_CP1254, //!< WinTurkish
143 wxFONTENCODING_CP1255, //!< WinHebrew
144 wxFONTENCODING_CP1256, //!< WinArabic
145 wxFONTENCODING_CP1257, //!< WinBaltic (same as Latin 7)
0b70c946
FM
146 wxFONTENCODING_CP12_MAX,
147
9a6fda22
FM
148 wxFONTENCODING_UTF7, //!< UTF-7 Unicode encoding
149 wxFONTENCODING_UTF8, //!< UTF-8 Unicode encoding
150 wxFONTENCODING_EUC_JP, //!< Extended Unix Codepage for Japanese
151 wxFONTENCODING_UTF16BE, //!< UTF-16 Big Endian Unicode encoding
152 wxFONTENCODING_UTF16LE, //!< UTF-16 Little Endian Unicode encoding
153 wxFONTENCODING_UTF32BE, //!< UTF-32 Big Endian Unicode encoding
0b70c946
FM
154 wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding
155
9a6fda22 156 wxFONTENCODING_MACROMAN, //!< the standard mac encodings
0b70c946
FM
157 wxFONTENCODING_MACJAPANESE,
158 wxFONTENCODING_MACCHINESETRAD,
159 wxFONTENCODING_MACKOREAN,
160 wxFONTENCODING_MACARABIC,
161 wxFONTENCODING_MACHEBREW,
162 wxFONTENCODING_MACGREEK,
163 wxFONTENCODING_MACCYRILLIC,
164 wxFONTENCODING_MACDEVANAGARI,
165 wxFONTENCODING_MACGURMUKHI,
166 wxFONTENCODING_MACGUJARATI,
167 wxFONTENCODING_MACORIYA,
168 wxFONTENCODING_MACBENGALI,
169 wxFONTENCODING_MACTAMIL,
170 wxFONTENCODING_MACTELUGU,
171 wxFONTENCODING_MACKANNADA,
172 wxFONTENCODING_MACMALAJALAM,
173 wxFONTENCODING_MACSINHALESE,
174 wxFONTENCODING_MACBURMESE,
175 wxFONTENCODING_MACKHMER,
176 wxFONTENCODING_MACTHAI,
177 wxFONTENCODING_MACLAOTIAN,
178 wxFONTENCODING_MACGEORGIAN,
179 wxFONTENCODING_MACARMENIAN,
180 wxFONTENCODING_MACCHINESESIMP,
181 wxFONTENCODING_MACTIBETAN,
182 wxFONTENCODING_MACMONGOLIAN,
183 wxFONTENCODING_MACETHIOPIC,
184 wxFONTENCODING_MACCENTRALEUR,
185 wxFONTENCODING_MACVIATNAMESE,
186 wxFONTENCODING_MACARABICEXT,
187 wxFONTENCODING_MACSYMBOL,
188 wxFONTENCODING_MACDINGBATS,
189 wxFONTENCODING_MACTURKISH,
190 wxFONTENCODING_MACCROATIAN,
191 wxFONTENCODING_MACICELANDIC,
192 wxFONTENCODING_MACROMANIAN,
193 wxFONTENCODING_MACCELTIC,
194 wxFONTENCODING_MACGAELIC,
195 wxFONTENCODING_MACKEYBOARD,
196
197 // more CJK encodings (for historical reasons some are already declared
198 // above)
9a6fda22 199 wxFONTENCODING_ISO2022_JP, //!< ISO-2022-JP JIS encoding
0b70c946 200
9a6fda22 201 wxFONTENCODING_MAX, //!< highest enumerated encoding value
0b70c946
FM
202
203 wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN ,
204 wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD ,
205
206 // aliases for endian-dependent UTF encodings
9a6fda22
FM
207 wxFONTENCODING_UTF16, //!< native UTF-16
208 wxFONTENCODING_UTF32, //!< native UTF-32
209
210 /// Alias for the native Unicode encoding on this platform
211 /// (this is used by wxEncodingConverter and wxUTFFile only for now)
212 wxFONTENCODING_UNICODE,
0b70c946
FM
213
214 // alternative names for Far Eastern encodings
215 // Chinese
9a6fda22
FM
216 wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, //!< Simplified Chinese
217 wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, //!< Traditional Chinese
0b70c946
FM
218
219 // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html)
9a6fda22 220 wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932 //!< Shift JIS
0b70c946
FM
221};
222
223
224
23324ae1
FM
225/**
226 @class wxFont
7c913512 227
0b70c946
FM
228 A font is an object which determines the appearance of text.
229 Fonts are used for drawing text to a device context, and setting the appearance
230 of a window's text.
7c913512 231
0b70c946 232 This class uses @ref overview_refcount "reference counting and copy-on-write"
23324ae1
FM
233 internally so that assignments between two instances of this class are very
234 cheap. You can therefore use actual objects instead of pointers without
235 efficiency problems. If an instance of this class is changed it will create
236 its own data internally so that other instances, which previously shared the
237 data using the reference counting, are not affected.
7c913512 238
23324ae1 239 You can retrieve the current system font settings with wxSystemSettings.
7c913512 240
23324ae1
FM
241 @library{wxcore}
242 @category{gdi}
7c913512 243
23324ae1 244 @stdobjects
65874118 245 ::wxNullFont, ::wxNORMAL_FONT, ::wxSMALL_FONT, ::wxITALIC_FONT, ::wxSWISS_FONT
7c913512 246
0b70c946
FM
247 @see @ref overview_font, wxDC::SetFont, wxDC::DrawText,
248 wxDC::GetTextExtent, wxFontDialog, wxSystemSettings
23324ae1
FM
249*/
250class wxFont : public wxGDIObject
251{
252public:
253 //@{
45a591fa 254 /**
0b70c946 255 Default ctor.
45a591fa
VZ
256 */
257 wxFont();
258
259 /**
0b70c946 260 Copy constructor, uses @ref overview_refcount "reference counting".
45a591fa
VZ
261 */
262 wxFont(const wxFont& font);
263
23324ae1
FM
264 /**
265 Creates a font object with the specified attributes.
3c4f71cc 266
7c913512 267 @param pointSize
4cc4bfaf 268 Size in points.
45a591fa
VZ
269 @param family
270 Font family, a generic way of referring to fonts without specifying actual
0b70c946 271 facename. One of the ::wxFontFamily enumeration values.
45a591fa
VZ
272 @param style
273 One of wxFONTSTYLE_NORMAL, wxFONTSTYLE_SLANT and wxFONTSTYLE_ITALIC.
274 @param weight
0b70c946
FM
275 Font weight, sometimes also referred to as font boldness. One of
276 the ::wxFontWeight enumeration values.
45a591fa 277 @param underline
0b70c946
FM
278 The value can be @true or @false.
279 At present this has an effect on Windows and Motif 2.x only.
45a591fa 280 @param faceName
0b70c946
FM
281 An optional string specifying the actual typeface to be used.
282 If it is an empty string, a default typeface will be chosen based on the family.
45a591fa 283 @param encoding
0b70c946
FM
284 An encoding which may be one of the enumeration values of ::wxFontEncoding.
285 Briefly these can be summed up as:
286 <TABLE>
287 <TR><TD>wxFONTENCODING_SYSTEM</TD><TD>Default system encoding.</TD></TR>
288 <TR><TD>wxFONTENCODING_DEFAULT</TD><TD>
289 Default application encoding: this
290 is the encoding set by calls to
291 SetDefaultEncoding and which may be set to,
292 say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
293 default application encoding is the same as default system encoding.</TD></TR>
294 <TR><TD>wxFONTENCODING_ISO8859_1...15</TD><TD>ISO8859 encodings.</TD></TR>
295 <TR><TD>wxFONTENCODING_KOI8</TD><TD>The standard Russian encoding for Internet.</TD></TR>
296 <TR><TD>wxFONTENCODING_CP1250...1252</TD><TD>Windows encodings similar to ISO8859 (but not identical).</TD></TR>
297 </TABLE>
45a591fa
VZ
298 If the specified encoding isn't available, no font is created
299 (see also font encoding overview).
300
301 @remarks If the desired font does not exist, the closest match will be
0b70c946 302 chosen. Under Windows, only scalable TrueType fonts are used.
45a591fa 303 */
882678eb 304 wxFont(int pointSize, wxFontFamily family, wxFontStyle style,
45a591fa 305 wxFontWeight weight,
11e3af6e 306 bool underline = false,
e9c3992c 307 const wxString& faceName = wxEmptyString,
45a591fa 308 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
0b70c946 309
45a591fa
VZ
310 /**
311 Creates a font object with the specified attributes.
312
7c913512 313 @param pixelSize
0b70c946
FM
314 Size in pixels: this is directly supported only under MSW currently
315 where this constructor can be used directly, under other platforms a
316 font with the closest size to the given one is found using binary search
317 and the static New method must be used.
7c913512 318 @param family
4cc4bfaf 319 Font family, a generic way of referring to fonts without specifying actual
0b70c946 320 facename. One of ::wxFontFamily enumeration values.
4cc4bfaf
FM
321 @param style
322 One of wxFONTSTYLE_NORMAL, wxFONTSTYLE_SLANT and wxFONTSTYLE_ITALIC.
7c913512 323 @param weight
0b70c946
FM
324 Font weight, sometimes also referred to as font boldness.
325 One of the ::wxFontWeight enumeration values.
4cc4bfaf 326 @param underline
0b70c946
FM
327 The value can be @true or @false.
328 At present this has an effect on Windows and Motif 2.x only.
4cc4bfaf 329 @param faceName
0b70c946
FM
330 An optional string specifying the actual typeface to be used.
331 If it is an empty string, a default typeface will be chosen based on the family.
7c913512 332 @param encoding
0b70c946
FM
333 An encoding which may be one of the enumeration values of ::wxFontEncoding.
334 Briefly these can be summed up as:
335 <TABLE>
336 <TR><TD>wxFONTENCODING_SYSTEM</TD><TD>Default system encoding.</TD></TR>
337 <TR><TD>wxFONTENCODING_DEFAULT</TD><TD>
338 Default application encoding: this
339 is the encoding set by calls to
340 SetDefaultEncoding and which may be set to,
341 say, KOI8 to create all fonts by default with KOI8 encoding. Initially, the
342 default application encoding is the same as default system encoding.</TD></TR>
343 <TR><TD>wxFONTENCODING_ISO8859_1...15</TD><TD>ISO8859 encodings.</TD></TR>
344 <TR><TD>wxFONTENCODING_KOI8</TD><TD>The standard Russian encoding for Internet.</TD></TR>
345 <TR><TD>wxFONTENCODING_CP1250...1252</TD><TD>Windows encodings similar to ISO8859 (but not identical).</TD></TR>
346 </TABLE>
4cc4bfaf
FM
347 If the specified encoding isn't available, no font is created
348 (see also font encoding overview).
3c4f71cc 349
23324ae1 350 @remarks If the desired font does not exist, the closest match will be
0b70c946 351 chosen. Under Windows, only scalable TrueType fonts are used.
23324ae1 352 */
7c913512 353 wxFont(const wxSize& pixelSize, wxFontFamily family,
882678eb 354 wxFontStyle style, wxFontWeight weight,
11e3af6e 355 bool underline = false,
e9c3992c 356 const wxString& faceName = wxEmptyString,
7c913512 357 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
23324ae1
FM
358 //@}
359
360 /**
361 Destructor.
0b70c946 362
674d80a7 363 See @ref overview_refcount_destruct "reference-counted object destruction"
0b70c946 364 for more info.
3c4f71cc 365
23324ae1 366 @remarks Although all remaining fonts are deleted when the application
4cc4bfaf
FM
367 exits, the application should try to clean up all fonts
368 itself. This is because wxWidgets cannot know if a
369 pointer to the font object is stored in an application
370 data structure, and there is a risk of double deletion.
23324ae1 371 */
adaaa686 372 virtual ~wxFont();
23324ae1
FM
373
374 /**
375 Returns the current application's default encoding.
3c4f71cc 376
0b70c946 377 @see @ref overview_fontencoding, SetDefaultEncoding()
23324ae1
FM
378 */
379 static wxFontEncoding GetDefaultEncoding();
380
381 /**
382 Returns the typeface name associated with the font, or the empty string if
0b70c946 383 there is no typeface information.
3c4f71cc 384
4cc4bfaf 385 @see SetFaceName()
23324ae1 386 */
adaaa686 387 virtual wxString GetFaceName() const;
23324ae1
FM
388
389 /**
390 Gets the font family. See SetFamily() for a list of valid
391 family identifiers.
3c4f71cc 392
4cc4bfaf 393 @see SetFamily()
23324ae1 394 */
26818748 395 virtual wxFontFamily GetFamily() const;
23324ae1
FM
396
397 /**
398 Returns the platform-dependent string completely describing this font.
399 Returned string is always non-empty.
0b70c946 400
23324ae1 401 Note that the returned string is not meant to be shown or edited by the user: a
0b70c946 402 typical use of this function is for serializing in string-form a wxFont object.
3c4f71cc 403
4cc4bfaf 404 @see SetNativeFontInfo(),GetNativeFontInfoUserDesc()
23324ae1 405 */
328f5751 406 wxString GetNativeFontInfoDesc() const;
23324ae1
FM
407
408 /**
0b70c946
FM
409 Returns a user-friendly string for this font object.
410 Returned string is always non-empty.
411
23324ae1
FM
412 Some examples of the formats of returned strings (which are platform-dependent)
413 are in SetNativeFontInfoUserDesc().
3c4f71cc 414
4cc4bfaf 415 @see GetNativeFontInfoDesc()
23324ae1 416 */
adaaa686 417 wxString GetNativeFontInfoUserDesc() const;
23324ae1
FM
418
419 /**
420 Gets the point size.
3c4f71cc 421
4cc4bfaf 422 @see SetPointSize()
23324ae1 423 */
adaaa686 424 virtual int GetPointSize() const;
23324ae1
FM
425
426 /**
0b70c946 427 Gets the font style. See wxFontStyle for a list of valid styles.
3c4f71cc 428
4cc4bfaf 429 @see SetStyle()
23324ae1 430 */
26818748 431 virtual wxFontStyle GetStyle() const;
23324ae1
FM
432
433 /**
434 Returns @true if the font is underlined, @false otherwise.
3c4f71cc 435
4cc4bfaf 436 @see SetUnderlined()
23324ae1 437 */
adaaa686 438 virtual bool GetUnderlined() const;
23324ae1
FM
439
440 /**
0b70c946 441 Gets the font weight. See wxFontWeight for a list of valid weight identifiers.
3c4f71cc 442
4cc4bfaf 443 @see SetWeight()
23324ae1 444 */
26818748 445 virtual wxFontWeight GetWeight() const;
23324ae1
FM
446
447 /**
448 Returns @true if the font is a fixed width (or monospaced) font,
449 @false if it is a proportional one or font is invalid.
450 */
adaaa686 451 virtual bool IsFixedWidth() const;
23324ae1
FM
452
453 /**
454 Returns @true if this object is a valid font, @false otherwise.
455 */
0004982c 456 virtual bool IsOk() const;
23324ae1
FM
457
458 //@{
459 /**
674d80a7
FM
460 These functions take the same parameters as
461 @ref wxFont::wxFont "wxFont constructors" and return a new font
462 object allocated on the heap.
0b70c946 463
23324ae1
FM
464 Using @c New() is currently the only way to directly create a font with
465 the given size in pixels on platforms other than wxMSW.
466 */
882678eb 467 static wxFont* New(int pointSize, wxFontFamily family, wxFontStyle style,
4cc4bfaf 468 wxFontWeight weight,
11e3af6e 469 bool underline = false,
e9c3992c 470 const wxString& faceName = wxEmptyString,
4cc4bfaf
FM
471 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
472 static wxFont* New(int pointSize, wxFontFamily family,
473 int flags = wxFONTFLAG_DEFAULT,
e9c3992c 474 const wxString& faceName = wxEmptyString,
4cc4bfaf
FM
475 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
476 static wxFont* New(const wxSize& pixelSize,
477 wxFontFamily family,
882678eb 478 wxFontStyle style,
4cc4bfaf 479 wxFontWeight weight,
11e3af6e 480 bool underline = false,
e9c3992c 481 const wxString& faceName = wxEmptyString,
4cc4bfaf
FM
482 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
483 static wxFont* New(const wxSize& pixelSize,
484 wxFontFamily family,
485 int flags = wxFONTFLAG_DEFAULT,
e9c3992c 486 const wxString& faceName = wxEmptyString,
4cc4bfaf 487 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
23324ae1
FM
488 //@}
489
490 /**
491 Sets the default font encoding.
3c4f71cc 492
0b70c946 493 @see @ref overview_fontencoding, GetDefaultEncoding()
23324ae1
FM
494 */
495 static void SetDefaultEncoding(wxFontEncoding encoding);
496
497 /**
498 Sets the facename for the font.
499 Returns @true if the given face name exists; @false otherwise.
3c4f71cc 500
7c913512 501 @param faceName
4cc4bfaf 502 A valid facename, which should be on the end-user's system.
3c4f71cc 503
23324ae1 504 @remarks To avoid portability problems, don't rely on a specific face,
0b70c946
FM
505 but specify the font family instead or as well.
506 A suitable font will be found on the end-user's system.
4cc4bfaf
FM
507 If both the family and the facename are specified,
508 wxWidgets will first search for the specific face, and
509 then for a font belonging to the same family.
3c4f71cc 510
4cc4bfaf 511 @see GetFaceName(), SetFamily()
23324ae1 512 */
adaaa686 513 virtual bool SetFaceName(const wxString& faceName);
23324ae1
FM
514
515 /**
516 Sets the font family.
3c4f71cc 517
7c913512 518 @param family
0b70c946 519 One of the ::wxFontFamily values.
3c4f71cc 520
4cc4bfaf 521 @see GetFamily(), SetFaceName()
23324ae1 522 */
a44f3b5a 523 virtual void SetFamily(wxFontFamily family);
23324ae1
FM
524
525 /**
0b70c946
FM
526 Creates the font corresponding to the given native font description string
527 which must have been previously returned by GetNativeFontInfoDesc().
528
529 If the string is invalid, font is unchanged.
530 This function is typically used for de-serializing a wxFont object
531 previously saved in a string-form.
532
533 @return @true if the creation was successful.
3c4f71cc 534
4cc4bfaf 535 @see SetNativeFontInfoUserDesc()
23324ae1
FM
536 */
537 bool SetNativeFontInfo(const wxString& info);
538
539 /**
540 Creates the font corresponding to the given native font description string and
0b70c946 541 returns @true if the creation was successful.
3c4f71cc 542
0b70c946
FM
543 Unlike SetNativeFontInfo(), this function accepts strings which are user-friendly.
544 Examples of accepted string formats are:
3c4f71cc 545
0b70c946
FM
546 @beginTable
547 @hdr3col{platform, generic syntax, example}
548 @row3col{wxGTK2, @c [FACE-NAME] [bold] [oblique|italic] [POINTSIZE], Monospace bold 10}
549 @row3col{wxMSW, @c [light|bold] [italic] [FACE-NAME] [POINTSIZE] [ENCODING], Tahoma 10 WINDOWS-1252}
550 @endTable
3c4f71cc 551
0b70c946 552 @todo add an example for wxMac
3c4f71cc 553
23324ae1 554 For more detailed information about the allowed syntaxes you can look at the
0b70c946
FM
555 documentation of the native API used for font-rendering
556 (e.g. @c pango_font_description_from_string on GTK).
3c4f71cc 557
4cc4bfaf 558 @see SetNativeFontInfo()
23324ae1
FM
559 */
560 bool SetNativeFontInfoUserDesc(const wxString& info);
561
562 /**
563 Sets the point size.
3c4f71cc 564
7c913512 565 @param pointSize
4cc4bfaf 566 Size in points.
3c4f71cc 567
4cc4bfaf 568 @see GetPointSize()
23324ae1 569 */
adaaa686 570 virtual void SetPointSize(int pointSize);
23324ae1
FM
571
572 /**
573 Sets the font style.
3c4f71cc 574
7c913512 575 @param style
0b70c946 576 One of the ::wxFontStyle enumeration values.
3c4f71cc 577
4cc4bfaf 578 @see GetStyle()
23324ae1 579 */
a44f3b5a 580 virtual void SetStyle(wxFontStyle style);
23324ae1
FM
581
582 /**
583 Sets underlining.
3c4f71cc 584
45a591fa 585 @param underlined
4cc4bfaf 586 @true to underline, @false otherwise.
3c4f71cc 587
4cc4bfaf 588 @see GetUnderlined()
23324ae1 589 */
26818748 590 virtual void SetUnderlined(bool underlined);
23324ae1
FM
591
592 /**
593 Sets the font weight.
3c4f71cc 594
7c913512 595 @param weight
0b70c946 596 One of the ::wxFontWeight values.
3c4f71cc 597
4cc4bfaf 598 @see GetWeight()
23324ae1 599 */
a44f3b5a 600 virtual void SetWeight(wxFontWeight weight);
23324ae1
FM
601
602 /**
603 Inequality operator.
0b70c946 604
674d80a7 605 See @ref overview_refcount_equality "reference-counted object comparison" for
23324ae1
FM
606 more info.
607 */
fadc2df6 608 bool operator!=(const wxFont& font) const;
23324ae1 609
23324ae1
FM
610 /**
611 Equality operator.
0b70c946 612
674d80a7 613 See @ref overview_refcount_equality "reference-counted object comparison" for
23324ae1
FM
614 more info.
615 */
fadc2df6 616 bool operator==(const wxFont& font) const;
0b70c946
FM
617
618 /**
619 Assignment operator, using @ref overview_refcount "reference counting".
620 */
621 wxFont& operator =(const wxFont& font);
23324ae1 622};
e54c96f1
FM
623
624
625/**
65874118 626 An empty wxFont.
e54c96f1 627*/
7fa7088e 628wxFont wxNullFont;
e54c96f1
FM
629
630/**
0b70c946 631 Equivalent to wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT).
e54c96f1 632*/
7fa7088e 633wxFont wxNORMAL_FONT;
e54c96f1
FM
634
635/**
0b70c946
FM
636 A font using the wxFONTFAMILY_SWISS family and 2 points smaller than
637 ::wxNORMAL_FONT.
e54c96f1 638*/
7fa7088e 639wxFont wxSMALL_FONT;
e54c96f1
FM
640
641/**
0b70c946
FM
642 A font using the wxFONTFAMILY_ROMAN family and wxFONTSTYLE_ITALIC style and
643 of the same size of ::wxNORMAL_FONT.
e54c96f1 644*/
7fa7088e 645wxFont wxITALIC_FONT;
e54c96f1
FM
646
647/**
0b70c946
FM
648 A font identic to ::wxNORMAL_FONT except for the family used which is
649 wxFONTFAMILY_SWISS.
e54c96f1 650*/
7fa7088e
BP
651wxFont wxSWISS_FONT;
652
653
65874118
FM
654/**
655 @class wxFontList
65874118 656
0b70c946
FM
657 A font list is a list containing all fonts which have been created.
658 There is only one instance of this class: ::wxTheFontList.
659
660 Use this object to search for a previously created font of the desired type
661 and create it if not already found.
662
65874118
FM
663 In some windowing systems, the font may be a scarce resource, so it is best to
664 reuse old resources if possible. When an application finishes, all fonts will
0b70c946 665 be deleted and their resources freed, eliminating the possibility of 'memory
65874118
FM
666 leaks'.
667
668 @library{wxcore}
669 @category{gdi}
670
671 @see wxFont
672*/
673class wxFontList : public wxList
674{
675public:
676 /**
677 Constructor. The application should not construct its own font list:
0b70c946 678 use the object pointer ::wxTheFontList.
65874118
FM
679 */
680 wxFontList();
681
682 /**
683 Finds a font of the given specification, or creates one and adds it to the
0b70c946 684 list. See the @ref wxFont "wxFont constructor" for details of the arguments.
65874118 685 */
a44f3b5a
FM
686 wxFont* FindOrCreateFont(int point_size, wxFontFamily family, wxFontStyle style,
687 wxFontWeight weight, bool underline = false,
688 const wxString& facename = wxEmptyString,
65874118
FM
689 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
690};
691
692
0b70c946
FM
693/**
694 The global wxFontList instance.
695*/
696wxFontList* wxTheFontList;
697
7fa7088e
BP
698
699// ============================================================================
700// Global functions/macros
701// ============================================================================
702
b21126db 703/** @addtogroup group_funcmacro_misc */
7fa7088e 704//@{
e54c96f1
FM
705
706/**
7fa7088e
BP
707 Converts string to a wxFont best represented by the given string. Returns
708 @true on success.
709
710 @see wxToString(const wxFont&)
711
712 @header{wx/font.h}
e54c96f1 713*/
7fa7088e 714bool wxFromString(const wxString& string, wxFont* font);
e54c96f1
FM
715
716/**
7fa7088e
BP
717 Converts the given wxFont into a string.
718
719 @see wxFromString(const wxString&, wxFont*)
720
721 @header{wx/font.h}
e54c96f1 722*/
7fa7088e 723wxString wxToString(const wxFont& font);
e54c96f1 724
7fa7088e 725//@}
e54c96f1 726