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