]> git.saurik.com Git - wxWidgets.git/blame - include/wx/font.h
Fix warnings about implicit float or double to int conversions in wxMSW.
[wxWidgets.git] / include / wx / font.h
CommitLineData
0c5d3e1c
VZ
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$
77ffb593 8// Copyright: (c) wxWidgets team
65571936 9// Licence: wxWindows licence
0c5d3e1c
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_FONT_H_BASE_
13#define _WX_FONT_H_BASE_
c801d85f 14
0c5d3e1c
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#include "wx/defs.h" // for wxDEFAULT &c
f6bcfd97 20#include "wx/fontenc.h" // the font encoding constants
0c5d3e1c 21#include "wx/gdiobj.h" // the base class
9d7a8e4a 22#include "wx/gdicmn.h" // for wxGDIObjListBase
0c5d3e1c
VZ
23
24// ----------------------------------------------------------------------------
25// forward declarations
26// ----------------------------------------------------------------------------
27
b5dbe15d 28class WXDLLIMPEXP_FWD_CORE wxFont;
0c5d3e1c
VZ
29
30// ----------------------------------------------------------------------------
31// font constants
32// ----------------------------------------------------------------------------
33
409d5a58
VZ
34// standard font families: these may be used only for the font creation, it
35// doesn't make sense to query an existing font for its font family as,
36// especially if the font had been created from a native font description, it
37// may be unknown
0c5d3e1c
VZ
38enum wxFontFamily
39{
40 wxFONTFAMILY_DEFAULT = wxDEFAULT,
41 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
42 wxFONTFAMILY_ROMAN = wxROMAN,
43 wxFONTFAMILY_SCRIPT = wxSCRIPT,
44 wxFONTFAMILY_SWISS = wxSWISS,
45 wxFONTFAMILY_MODERN = wxMODERN,
46 wxFONTFAMILY_TELETYPE = wxTELETYPE,
409d5a58
VZ
47 wxFONTFAMILY_MAX,
48 wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
0c5d3e1c
VZ
49};
50
51// font styles
52enum wxFontStyle
53{
54 wxFONTSTYLE_NORMAL = wxNORMAL,
55 wxFONTSTYLE_ITALIC = wxITALIC,
56 wxFONTSTYLE_SLANT = wxSLANT,
57 wxFONTSTYLE_MAX
58};
59
60// font weights
61enum wxFontWeight
62{
63 wxFONTWEIGHT_NORMAL = wxNORMAL,
64 wxFONTWEIGHT_LIGHT = wxLIGHT,
65 wxFONTWEIGHT_BOLD = wxBOLD,
66 wxFONTWEIGHT_MAX
67};
68
19da7aaa
VZ
69// Symbolic font sizes as defined in CSS specification.
70enum wxFontSymbolicSize
71{
72 wxFONTSIZE_XX_SMALL = -3,
73 wxFONTSIZE_X_SMALL,
74 wxFONTSIZE_SMALL,
75 wxFONTSIZE_MEDIUM,
76 wxFONTSIZE_LARGE,
77 wxFONTSIZE_X_LARGE,
78 wxFONTSIZE_XX_LARGE
79};
80
01cb1c26 81// the font flag bits for the new font ctor accepting one combined flags word
0b70c946 82enum wxFontFlag
01cb1c26
VZ
83{
84 // no special flags: font with default weight/slant/anti-aliasing
85 wxFONTFLAG_DEFAULT = 0,
86
87 // slant flags (default: no slant)
88 wxFONTFLAG_ITALIC = 1 << 0,
89 wxFONTFLAG_SLANT = 1 << 1,
90
91 // weight flags (default: medium)
92 wxFONTFLAG_LIGHT = 1 << 2,
93 wxFONTFLAG_BOLD = 1 << 3,
94
95 // anti-aliasing flag: force on or off (default: the current system default)
96 wxFONTFLAG_ANTIALIASED = 1 << 4,
97 wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
98
99 // underlined/strikethrough flags (default: no lines)
100 wxFONTFLAG_UNDERLINED = 1 << 6,
101 wxFONTFLAG_STRIKETHROUGH = 1 << 7,
102
103 // the mask of all currently used flags
104 wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
105 wxFONTFLAG_SLANT |
106 wxFONTFLAG_LIGHT |
107 wxFONTFLAG_BOLD |
108 wxFONTFLAG_ANTIALIASED |
109 wxFONTFLAG_NOT_ANTIALIASED |
110 wxFONTFLAG_UNDERLINED |
111 wxFONTFLAG_STRIKETHROUGH
112};
113
b960795e
VZ
114// ----------------------------------------------------------------------------
115// wxFontInfo describes a wxFont
116// ----------------------------------------------------------------------------
117
118class wxFontInfo
119{
120public:
121 // Default ctor uses the default font size appropriate for the current
122 // platform.
123 wxFontInfo()
124 { InitPointSize(-1); }
125
126 // These ctors specify the font size, either in points or in pixels.
127 wxEXPLICIT wxFontInfo(int pointSize)
128 { InitPointSize(pointSize); }
129 wxEXPLICIT wxFontInfo(const wxSize& pixelSize) : m_pixelSize(pixelSize)
130 { Init(); }
131
132 // Setters for the various attributes. All of them return the object itself
133 // so that the calls to them could be chained.
134 wxFontInfo& Family(wxFontFamily family)
135 { m_family = family; return *this; }
136 wxFontInfo& FaceName(const wxString& faceName)
137 { m_faceName = faceName; return *this; }
138
139 wxFontInfo& Bold(bool bold = true)
140 { SetFlag(wxFONTFLAG_BOLD, bold); return *this; }
141 wxFontInfo& Light(bool light = true)
142 { SetFlag(wxFONTFLAG_LIGHT, light); return *this; }
143
144 wxFontInfo& Italic(bool italic = true)
145 { SetFlag(wxFONTFLAG_ITALIC, italic); return *this; }
146 wxFontInfo& Slant(bool slant = true)
147 { SetFlag(wxFONTFLAG_SLANT, slant); return *this; }
148
149 wxFontInfo& AntiAliased(bool antiAliased = true)
150 { SetFlag(wxFONTFLAG_ANTIALIASED, antiAliased); return *this; }
151 wxFontInfo& Underlined(bool underlined = true)
152 { SetFlag(wxFONTFLAG_UNDERLINED, underlined); return *this; }
153 wxFontInfo& Strikethrough(bool strikethrough = true)
154 { SetFlag(wxFONTFLAG_STRIKETHROUGH, strikethrough); return *this; }
155
156 wxFontInfo& Encoding(wxFontEncoding encoding)
157 { m_encoding = encoding; return *this; }
158
159
160 // Set all flags at once.
161 wxFontInfo& AllFlags(int flags)
162 { m_flags = flags; return *this; }
163
164
165 // Accessors are mostly meant to be used by wxFont itself to extract the
166 // various pieces of the font description.
167
168 bool IsUsingSizeInPixels() const { return m_pixelSize != wxDefaultSize; }
169 int GetPointSize() const { return m_pointSize; }
170 wxSize GetPixelSize() const { return m_pixelSize; }
171 wxFontFamily GetFamily() const { return m_family; }
172 const wxString& GetFaceName() const { return m_faceName; }
173
174 wxFontStyle GetStyle() const
175 {
176 return m_flags & wxFONTFLAG_ITALIC
177 ? wxFONTSTYLE_ITALIC
178 : m_flags & wxFONTFLAG_SLANT
179 ? wxFONTSTYLE_SLANT
180 : wxFONTSTYLE_NORMAL;
181 }
182
183 wxFontWeight GetWeight() const
184 {
185 return m_flags & wxFONTFLAG_LIGHT
186 ? wxFONTWEIGHT_LIGHT
187 : m_flags & wxFONTFLAG_BOLD
188 ? wxFONTWEIGHT_BOLD
189 : wxFONTWEIGHT_NORMAL;
190 }
191
192 bool IsAntiAliased() const
193 {
194 return (m_flags & wxFONTFLAG_ANTIALIASED) != 0;
195 }
196
197 bool IsUnderlined() const
198 {
199 return (m_flags & wxFONTFLAG_UNDERLINED) != 0;
200 }
201
202 bool IsStrikethrough() const
203 {
204 return (m_flags & wxFONTFLAG_STRIKETHROUGH) != 0;
205 }
206
207 wxFontEncoding GetEncoding() const { return m_encoding; }
208
209
210 // Default copy ctor, assignment operator and dtor are OK.
211
212private:
213 // Common part of all ctor, initializing everything except the size (which
214 // is initialized by the ctors themselves).
215 void Init()
216 {
217 m_family = wxFONTFAMILY_DEFAULT;
218 m_flags = wxFONTFLAG_DEFAULT;
219 m_encoding = wxFONTENCODING_DEFAULT;
220 }
221
222 void InitPointSize(int pointSize)
223 {
224 Init();
225
226 m_pointSize = pointSize;
227 m_pixelSize = wxDefaultSize;
228 }
229
230 // Turn on or off the given bit in m_flags depending on the value of the
231 // boolean argument.
232 void SetFlag(int flag, bool on)
233 {
234 if ( on )
235 m_flags |= flag;
236 else
237 m_flags &= ~flag;
238 }
239
240 // The size information: if m_pixelSize is valid (!= wxDefaultSize), then
241 // it is used. Otherwise m_pointSize is used, taking into account that if
242 // it is == -1, it means that the platform dependent font size should be
243 // used.
244 int m_pointSize;
245 wxSize m_pixelSize;
246
247 wxFontFamily m_family;
248 wxString m_faceName;
249 int m_flags;
250 wxFontEncoding m_encoding;
251};
252
0c5d3e1c
VZ
253// ----------------------------------------------------------------------------
254// wxFontBase represents a font object
255// ----------------------------------------------------------------------------
256
b5dbe15d 257class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo;
4d85bcd1 258
53a2db12 259class WXDLLIMPEXP_CORE wxFontBase : public wxGDIObject
0c5d3e1c
VZ
260{
261public:
b5791cc7
FM
262 /*
263 derived classes should provide the following ctors:
03647350 264
b5791cc7 265 wxFont();
b960795e 266 wxFont(const wxFontInfo& info);
b5791cc7
FM
267 wxFont(const wxString& nativeFontInfoString);
268 wxFont(const wxNativeFontInfo& info);
269 wxFont(int size,
270 wxFontFamily family,
271 wxFontStyle style,
272 wxFontWeight weight,
273 bool underlined = false,
274 const wxString& face = wxEmptyString,
275 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
276 wxFont(const wxSize& pixelSize,
277 wxFontFamily family,
278 wxFontStyle style,
279 wxFontWeight weight,
280 bool underlined = false,
281 const wxString& face = wxEmptyString,
282 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
283 */
03647350 284
0c5d3e1c 285 // creator function
799ea011 286 virtual ~wxFontBase();
7826e2dd 287
0c14b6c3
FM
288
289#if FUTURE_WXWIN_COMPATIBILITY_3_0
7826e2dd 290 // from the font components
0c5d3e1c
VZ
291 static wxFont *New(
292 int pointSize, // size of the font in points
293 int family, // see wxFontFamily enum
294 int style, // see wxFontStyle enum
295 int weight, // see wxFontWeight enum
a62848fd 296 bool underlined = false, // not underlined by default
0c5d3e1c 297 const wxString& face = wxEmptyString, // facename
0c14b6c3
FM
298 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ...
299 { return New(pointSize, (wxFontFamily)family, (wxFontStyle)style,
300 (wxFontWeight)weight, underlined, face, encoding); }
01cb1c26 301
544229d1
VZ
302 // from the font components
303 static wxFont *New(
304 const wxSize& pixelSize, // size of the font in pixels
305 int family, // see wxFontFamily enum
306 int style, // see wxFontStyle enum
307 int weight, // see wxFontWeight enum
4055ed82 308 bool underlined = false, // not underlined by default
544229d1 309 const wxString& face = wxEmptyString, // facename
0c14b6c3
FM
310 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ...
311 { return New(pixelSize, (wxFontFamily)family, (wxFontStyle)style,
312 (wxFontWeight)weight, underlined, face, encoding); }
313#endif
314
315 // from the font components
316 static wxFont *New(
317 int pointSize, // size of the font in points
318 wxFontFamily family, // see wxFontFamily enum
319 wxFontStyle style, // see wxFontStyle enum
320 wxFontWeight weight, // see wxFontWeight enum
321 bool underlined = false, // not underlined by default
322 const wxString& face = wxEmptyString, // facename
544229d1
VZ
323 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
324
0c14b6c3
FM
325 // from the font components
326 static wxFont *New(
327 const wxSize& pixelSize, // size of the font in pixels
328 wxFontFamily family, // see wxFontFamily enum
329 wxFontStyle style, // see wxFontStyle enum
330 wxFontWeight weight, // see wxFontWeight enum
331 bool underlined = false, // not underlined by default
332 const wxString& face = wxEmptyString, // facename
333 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
334
335 // from the font components but using the font flags instead of separate
336 // parameters for each flag
337 static wxFont *New(int pointSize,
338 wxFontFamily family,
339 int flags = wxFONTFLAG_DEFAULT,
340 const wxString& face = wxEmptyString,
341 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
342
343
544229d1
VZ
344 // from the font components but using the font flags instead of separate
345 // parameters for each flag
346 static wxFont *New(const wxSize& pixelSize,
347 wxFontFamily family,
348 int flags = wxFONTFLAG_DEFAULT,
349 const wxString& face = wxEmptyString,
350 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
351
7826e2dd
VZ
352 // from the (opaque) native font description object
353 static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
354
355 // from the string representation of wxNativeFontInfo
356 static wxFont *New(const wxString& strNativeFontDesc);
0c5d3e1c 357
0c5d3e1c 358 // comparison
8f884a0d
VZ
359 bool operator==(const wxFont& font) const;
360 bool operator!=(const wxFont& font) const { return !(*this == font); }
0c5d3e1c
VZ
361
362 // accessors: get the font characteristics
363 virtual int GetPointSize() const = 0;
544229d1
VZ
364 virtual wxSize GetPixelSize() const;
365 virtual bool IsUsingSizeInPixels() const;
59b7da02 366 wxFontFamily GetFamily() const;
0c14b6c3
FM
367 virtual wxFontStyle GetStyle() const = 0;
368 virtual wxFontWeight GetWeight() const = 0;
0c5d3e1c 369 virtual bool GetUnderlined() const = 0;
c7a49742 370 virtual bool GetStrikethrough() const { return false; }
0c5d3e1c
VZ
371 virtual wxString GetFaceName() const = 0;
372 virtual wxFontEncoding GetEncoding() const = 0;
3bf5a59b 373 virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
ab5fe833 374
53f6aab7
VZ
375 virtual bool IsFixedWidth() const;
376
7826e2dd 377 wxString GetNativeFontInfoDesc() const;
ab5fe833 378 wxString GetNativeFontInfoUserDesc() const;
0c5d3e1c
VZ
379
380 // change the font characteristics
381 virtual void SetPointSize( int pointSize ) = 0;
544229d1 382 virtual void SetPixelSize( const wxSize& pixelSize );
0c14b6c3
FM
383 virtual void SetFamily( wxFontFamily family ) = 0;
384 virtual void SetStyle( wxFontStyle style ) = 0;
385 virtual void SetWeight( wxFontWeight weight ) = 0;
386
0c5d3e1c 387 virtual void SetUnderlined( bool underlined ) = 0;
c7a49742 388 virtual void SetStrikethrough( bool WXUNUSED(strikethrough) ) {}
0c5d3e1c 389 virtual void SetEncoding(wxFontEncoding encoding) = 0;
85ab460e 390 virtual bool SetFaceName( const wxString& faceName );
9045ad9d
VZ
391 void SetNativeFontInfo(const wxNativeFontInfo& info)
392 { DoSetNativeFontInfo(info); }
ab5fe833 393
85ab460e
VZ
394 bool SetNativeFontInfo(const wxString& info);
395 bool SetNativeFontInfoUserDesc(const wxString& info);
7826e2dd 396
19da7aaa
VZ
397 // Symbolic font sizes support: set the font size to "large" or "very
398 // small" either absolutely (i.e. compared to the default font size) or
399 // relatively to the given font size.
400 void SetSymbolicSize(wxFontSymbolicSize size);
401 void SetSymbolicSizeRelativeTo(wxFontSymbolicSize size, int base)
402 {
403 SetPointSize(AdjustToSymbolicSize(size, base));
404 }
405
406 // Adjust the base size in points according to symbolic size.
407 static int AdjustToSymbolicSize(wxFontSymbolicSize size, int base);
408
409
0c5d3e1c
VZ
410 // translate the fonts into human-readable string (i.e. GetStyleString()
411 // will return "wxITALIC" for an italic font, ...)
412 wxString GetFamilyString() const;
413 wxString GetStyleString() const;
414 wxString GetWeightString() const;
415
416 // the default encoding is used for creating all fonts with default
417 // encoding parameter
cafbf6fb
VZ
418 static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
419 static void SetDefaultEncoding(wxFontEncoding encoding);
0c5d3e1c 420
8462a84b 421 // this doesn't do anything and is kept for compatibility only
7bc57fd9 422#if WXWIN_COMPATIBILITY_2_8
8462a84b
VZ
423 wxDEPRECATED_INLINE(void SetNoAntiAliasing(bool no = true), wxUnusedVar(no););
424 wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;)
425#endif // WXWIN_COMPATIBILITY_2_8
426
0c5d3e1c 427protected:
9045ad9d
VZ
428 // the function called by both overloads of SetNativeFontInfo()
429 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
430
59b7da02
VZ
431 // The function called by public GetFamily(): it can return
432 // wxFONTFAMILY_UNKNOWN unlike the public method (see comment there).
433 virtual wxFontFamily DoGetFamily() const = 0;
434
0634700a 435
b960795e 436 // Helper functions to recover wxFONTSTYLE/wxFONTWEIGHT and underlined flag
0634700a
VZ
437 // values from flags containing a combination of wxFONTFLAG_XXX.
438 static wxFontStyle GetStyleFromFlags(int flags)
439 {
440 return flags & wxFONTFLAG_ITALIC
441 ? wxFONTSTYLE_ITALIC
442 : flags & wxFONTFLAG_SLANT
443 ? wxFONTSTYLE_SLANT
444 : wxFONTSTYLE_NORMAL;
445 }
446
447 static wxFontWeight GetWeightFromFlags(int flags)
448 {
449 return flags & wxFONTFLAG_LIGHT
450 ? wxFONTWEIGHT_LIGHT
451 : flags & wxFONTFLAG_BOLD
452 ? wxFONTWEIGHT_BOLD
453 : wxFONTWEIGHT_NORMAL;
454 }
455
456 static bool GetUnderlinedFromFlags(int flags)
457 {
458 return (flags & wxFONTFLAG_UNDERLINED) != 0;
459 }
460
cba4e486
VZ
461 static bool GetStrikethroughFromFlags(int flags)
462 {
463 return (flags & wxFONTFLAG_STRIKETHROUGH) != 0;
464 }
0634700a 465
0c5d3e1c
VZ
466private:
467 // the currently default encoding: by default, it's the default system
468 // encoding, but may be changed by the application using
469 // SetDefaultEncoding() to make all subsequent fonts created without
3103e8a9 470 // specifying encoding parameter using this encoding
0c5d3e1c
VZ
471 static wxFontEncoding ms_encodingDefault;
472};
473
fc9361e3
VZ
474// wxFontBase <-> wxString utilities, used by wxConfig
475WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font);
476WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
477
478
0c14b6c3 479#if FUTURE_WXWIN_COMPATIBILITY_3_0
f76c0758 480#define wxDECLARE_FONT_COMPAT_SETTER \
0c14b6c3
FM
481 wxDEPRECATED_FUTURE( void SetFamily(int family) ) \
482 { SetFamily((wxFontFamily)family); } \
483 wxDEPRECATED_FUTURE( void SetStyle(int style) ) \
484 { SetStyle((wxFontStyle)style); } \
485 wxDEPRECATED_FUTURE( void SetWeight(int weight) ) \
486 { SetWeight((wxFontWeight)weight); } \
487 wxDEPRECATED_FUTURE( void SetFamily(wxDeprecatedGUIConstants family) ) \
488 { SetFamily((wxFontFamily)family); } \
489 wxDEPRECATED_FUTURE( void SetStyle(wxDeprecatedGUIConstants style) ) \
490 { SetStyle((wxFontStyle)style); } \
491 wxDEPRECATED_FUTURE( void SetWeight(wxDeprecatedGUIConstants weight) ) \
492 { SetWeight((wxFontWeight)weight); }
493#else
f76c0758 494#define wxDECLARE_FONT_COMPAT_SETTER /*empty*/
0c14b6c3 495#endif
fc9361e3 496
f76c0758
VZ
497// this macro must be used in all derived wxFont classes declarations
498#define wxDECLARE_COMMON_FONT_METHODS() \
499 wxDECLARE_FONT_COMPAT_SETTER \
500 \
6e7d2550
VZ
501 /* functions for modifying font in place */ \
502 wxFont& MakeBold(); \
503 wxFont& MakeItalic(); \
801423ee 504 wxFont& MakeUnderlined(); \
c7a49742 505 wxFont& MakeStrikethrough(); \
6e7d2550
VZ
506 wxFont& MakeLarger() { return Scale(1.2f); } \
507 wxFont& MakeSmaller() { return Scale(1/1.2f); } \
508 wxFont& Scale(float x); \
f76c0758 509 /* functions for creating fonts based on this one */ \
6e7d2550
VZ
510 wxFont Bold() const; \
511 wxFont Italic() const; \
801423ee 512 wxFont Underlined() const; \
c7a49742 513 wxFont Strikethrough() const; \
6e7d2550
VZ
514 wxFont Larger() const { return Scaled(1.2f); } \
515 wxFont Smaller() const { return Scaled(1/1.2f); } \
516 wxFont Scaled(float x) const
f76c0758 517
0c5d3e1c 518// include the real class declaration
bd362275 519#if defined(__WXMSW__)
0c5d3e1c 520 #include "wx/msw/font.h"
2049ba38 521#elif defined(__WXMOTIF__)
0c5d3e1c 522 #include "wx/motif/font.h"
1be7a35c 523#elif defined(__WXGTK20__)
0c5d3e1c 524 #include "wx/gtk/font.h"
1be7a35c
MR
525#elif defined(__WXGTK__)
526 #include "wx/gtk1/font.h"
83df96d6
JS
527#elif defined(__WXX11__)
528 #include "wx/x11/font.h"
b3c86150
VS
529#elif defined(__WXDFB__)
530 #include "wx/dfb/font.h"
34138703 531#elif defined(__WXMAC__)
ef0e9220 532 #include "wx/osx/font.h"
e64df9bc
DE
533#elif defined(__WXCOCOA__)
534 #include "wx/cocoa/font.h"
1777b9bb 535#elif defined(__WXPM__)
0c5d3e1c 536 #include "wx/os2/font.h"
c801d85f
KB
537#endif
538
82cddbd9
FM
539class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase
540{
541public:
542 wxFont *FindOrCreateFont(int pointSize,
543 wxFontFamily family,
544 wxFontStyle style,
545 wxFontWeight weight,
546 bool underline = false,
547 const wxString& face = wxEmptyString,
548 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
020eeaa8
FM
549
550#if FUTURE_WXWIN_COMPATIBILITY_3_0
551 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
552 bool underline = false,
553 const wxString& face = wxEmptyString,
554 wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
555 { return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
556 (wxFontWeight)weight, underline, face, encoding); }
557#endif
558
82cddbd9
FM
559#if WXWIN_COMPATIBILITY_2_6
560 wxDEPRECATED( void AddFont(wxFont*) );
561 wxDEPRECATED( void RemoveFont(wxFont*) );
562#endif
563};
564
53a2db12 565extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList;
82cddbd9 566
0c14b6c3
FM
567
568// provide comparison operators to allow code such as
569//
570// if ( font.GetStyle() == wxFONTSTYLE_SLANT )
571//
572// to compile without warnings which it would otherwise provoke from some
573// compilers as it compares elements of different enums
574#if FUTURE_WXWIN_COMPATIBILITY_3_0
575
25859335
VZ
576// Unfortunately some compilers have ambiguity issues when enum comparisons are
577// overloaded so we have to disable the overloads in this case, see
578// wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
579#ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
580
0c14b6c3
FM
581inline bool operator==(wxFontFamily s, wxDeprecatedGUIConstants t)
582{ return static_cast<int>(s) == static_cast<int>(t); }
583inline bool operator!=(wxFontFamily s, wxDeprecatedGUIConstants t)
584{ return !(s == t); }
585inline bool operator==(wxFontStyle s, wxDeprecatedGUIConstants t)
586{ return static_cast<int>(s) == static_cast<int>(t); }
587inline bool operator!=(wxFontStyle s, wxDeprecatedGUIConstants t)
588{ return !(s == t); }
589inline bool operator==(wxFontWeight s, wxDeprecatedGUIConstants t)
590{ return static_cast<int>(s) == static_cast<int>(t); }
591inline bool operator!=(wxFontWeight s, wxDeprecatedGUIConstants t)
592{ return !(s == t); }
593
25859335
VZ
594#endif // // wxCOMPILER_NO_OVERLOAD_ON_ENUM
595
0c14b6c3
FM
596#endif // FUTURE_WXWIN_COMPATIBILITY_3_0
597
c801d85f 598#endif
34138703 599 // _WX_FONT_H_BASE_