]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/font.h | |
3 | // Purpose: wxFontBase class: the interface of wxFont | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 20.09.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWidgets team | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_FONT_H_BASE_ | |
13 | #define _WX_FONT_H_BASE_ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/defs.h" // for wxDEFAULT &c | |
20 | #include "wx/fontenc.h" // the font encoding constants | |
21 | #include "wx/gdiobj.h" // the base class | |
22 | #include "wx/gdicmn.h" // for wxGDIObjListBase | |
23 | ||
24 | // ---------------------------------------------------------------------------- | |
25 | // forward declarations | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
28 | class WXDLLIMPEXP_FWD_CORE wxFont; | |
29 | ||
30 | // ---------------------------------------------------------------------------- | |
31 | // font constants | |
32 | // ---------------------------------------------------------------------------- | |
33 | ||
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 | |
38 | enum 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, | |
47 | wxFONTFAMILY_MAX, | |
48 | wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX | |
49 | }; | |
50 | ||
51 | // font styles | |
52 | enum wxFontStyle | |
53 | { | |
54 | wxFONTSTYLE_NORMAL = wxNORMAL, | |
55 | wxFONTSTYLE_ITALIC = wxITALIC, | |
56 | wxFONTSTYLE_SLANT = wxSLANT, | |
57 | wxFONTSTYLE_MAX | |
58 | }; | |
59 | ||
60 | // font weights | |
61 | enum wxFontWeight | |
62 | { | |
63 | wxFONTWEIGHT_NORMAL = wxNORMAL, | |
64 | wxFONTWEIGHT_LIGHT = wxLIGHT, | |
65 | wxFONTWEIGHT_BOLD = wxBOLD, | |
66 | wxFONTWEIGHT_MAX | |
67 | }; | |
68 | ||
69 | // Symbolic font sizes as defined in CSS specification. | |
70 | enum 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 | ||
81 | // the font flag bits for the new font ctor accepting one combined flags word | |
82 | enum wxFontFlag | |
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 | ||
114 | // ---------------------------------------------------------------------------- | |
115 | // wxFontInfo describes a wxFont | |
116 | // ---------------------------------------------------------------------------- | |
117 | ||
118 | class wxFontInfo | |
119 | { | |
120 | public: | |
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 | ||
212 | private: | |
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 | ||
253 | // ---------------------------------------------------------------------------- | |
254 | // wxFontBase represents a font object | |
255 | // ---------------------------------------------------------------------------- | |
256 | ||
257 | class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo; | |
258 | ||
259 | class WXDLLIMPEXP_CORE wxFontBase : public wxGDIObject | |
260 | { | |
261 | public: | |
262 | /* | |
263 | derived classes should provide the following ctors: | |
264 | ||
265 | wxFont(); | |
266 | wxFont(const wxFontInfo& info); | |
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 | */ | |
284 | ||
285 | // creator function | |
286 | virtual ~wxFontBase(); | |
287 | ||
288 | ||
289 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
290 | // from the font components | |
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 | |
296 | bool underlined = false, // not underlined by default | |
297 | const wxString& face = wxEmptyString, // facename | |
298 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) // ISO8859-X, ... | |
299 | { return New(pointSize, (wxFontFamily)family, (wxFontStyle)style, | |
300 | (wxFontWeight)weight, underlined, face, encoding); } | |
301 | ||
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 | |
308 | bool underlined = false, // not underlined by default | |
309 | const wxString& face = wxEmptyString, // facename | |
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 | |
323 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... | |
324 | ||
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 | ||
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 | ||
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); | |
357 | ||
358 | // comparison | |
359 | bool operator==(const wxFont& font) const; | |
360 | bool operator!=(const wxFont& font) const { return !(*this == font); } | |
361 | ||
362 | // accessors: get the font characteristics | |
363 | virtual int GetPointSize() const = 0; | |
364 | virtual wxSize GetPixelSize() const; | |
365 | virtual bool IsUsingSizeInPixels() const; | |
366 | wxFontFamily GetFamily() const; | |
367 | virtual wxFontStyle GetStyle() const = 0; | |
368 | virtual wxFontWeight GetWeight() const = 0; | |
369 | virtual bool GetUnderlined() const = 0; | |
370 | virtual bool GetStrikethrough() const { return false; } | |
371 | virtual wxString GetFaceName() const = 0; | |
372 | virtual wxFontEncoding GetEncoding() const = 0; | |
373 | virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0; | |
374 | ||
375 | virtual bool IsFixedWidth() const; | |
376 | ||
377 | wxString GetNativeFontInfoDesc() const; | |
378 | wxString GetNativeFontInfoUserDesc() const; | |
379 | ||
380 | // change the font characteristics | |
381 | virtual void SetPointSize( int pointSize ) = 0; | |
382 | virtual void SetPixelSize( const wxSize& pixelSize ); | |
383 | virtual void SetFamily( wxFontFamily family ) = 0; | |
384 | virtual void SetStyle( wxFontStyle style ) = 0; | |
385 | virtual void SetWeight( wxFontWeight weight ) = 0; | |
386 | ||
387 | virtual void SetUnderlined( bool underlined ) = 0; | |
388 | virtual void SetStrikethrough( bool WXUNUSED(strikethrough) ) {} | |
389 | virtual void SetEncoding(wxFontEncoding encoding) = 0; | |
390 | virtual bool SetFaceName( const wxString& faceName ); | |
391 | void SetNativeFontInfo(const wxNativeFontInfo& info) | |
392 | { DoSetNativeFontInfo(info); } | |
393 | ||
394 | bool SetNativeFontInfo(const wxString& info); | |
395 | bool SetNativeFontInfoUserDesc(const wxString& info); | |
396 | ||
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 | ||
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 | |
418 | static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } | |
419 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
420 | ||
421 | // this doesn't do anything and is kept for compatibility only | |
422 | #if WXWIN_COMPATIBILITY_2_8 | |
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 | ||
427 | protected: | |
428 | // the function called by both overloads of SetNativeFontInfo() | |
429 | virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); | |
430 | ||
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 | ||
435 | ||
436 | // Helper functions to recover wxFONTSTYLE/wxFONTWEIGHT and underlined flag | |
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 | ||
461 | static bool GetStrikethroughFromFlags(int flags) | |
462 | { | |
463 | return (flags & wxFONTFLAG_STRIKETHROUGH) != 0; | |
464 | } | |
465 | ||
466 | private: | |
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 | |
470 | // specifying encoding parameter using this encoding | |
471 | static wxFontEncoding ms_encodingDefault; | |
472 | }; | |
473 | ||
474 | // wxFontBase <-> wxString utilities, used by wxConfig | |
475 | WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font); | |
476 | WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font); | |
477 | ||
478 | ||
479 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
480 | #define wxDECLARE_FONT_COMPAT_SETTER \ | |
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 | |
494 | #define wxDECLARE_FONT_COMPAT_SETTER /*empty*/ | |
495 | #endif | |
496 | ||
497 | // this macro must be used in all derived wxFont classes declarations | |
498 | #define wxDECLARE_COMMON_FONT_METHODS() \ | |
499 | wxDECLARE_FONT_COMPAT_SETTER \ | |
500 | \ | |
501 | /* functions for modifying font in place */ \ | |
502 | wxFont& MakeBold(); \ | |
503 | wxFont& MakeItalic(); \ | |
504 | wxFont& MakeUnderlined(); \ | |
505 | wxFont& MakeStrikethrough(); \ | |
506 | wxFont& MakeLarger() { return Scale(1.2f); } \ | |
507 | wxFont& MakeSmaller() { return Scale(1/1.2f); } \ | |
508 | wxFont& Scale(float x); \ | |
509 | /* functions for creating fonts based on this one */ \ | |
510 | wxFont Bold() const; \ | |
511 | wxFont Italic() const; \ | |
512 | wxFont Underlined() const; \ | |
513 | wxFont Strikethrough() const; \ | |
514 | wxFont Larger() const { return Scaled(1.2f); } \ | |
515 | wxFont Smaller() const { return Scaled(1/1.2f); } \ | |
516 | wxFont Scaled(float x) const | |
517 | ||
518 | // include the real class declaration | |
519 | #if defined(__WXMSW__) | |
520 | #include "wx/msw/font.h" | |
521 | #elif defined(__WXMOTIF__) | |
522 | #include "wx/motif/font.h" | |
523 | #elif defined(__WXGTK20__) | |
524 | #include "wx/gtk/font.h" | |
525 | #elif defined(__WXGTK__) | |
526 | #include "wx/gtk1/font.h" | |
527 | #elif defined(__WXX11__) | |
528 | #include "wx/x11/font.h" | |
529 | #elif defined(__WXDFB__) | |
530 | #include "wx/dfb/font.h" | |
531 | #elif defined(__WXMAC__) | |
532 | #include "wx/osx/font.h" | |
533 | #elif defined(__WXCOCOA__) | |
534 | #include "wx/cocoa/font.h" | |
535 | #elif defined(__WXPM__) | |
536 | #include "wx/os2/font.h" | |
537 | #endif | |
538 | ||
539 | class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase | |
540 | { | |
541 | public: | |
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); | |
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 | ||
559 | #if WXWIN_COMPATIBILITY_2_6 | |
560 | wxDEPRECATED( void AddFont(wxFont*) ); | |
561 | wxDEPRECATED( void RemoveFont(wxFont*) ); | |
562 | #endif | |
563 | }; | |
564 | ||
565 | extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList; | |
566 | ||
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 | ||
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 | ||
581 | inline bool operator==(wxFontFamily s, wxDeprecatedGUIConstants t) | |
582 | { return static_cast<int>(s) == static_cast<int>(t); } | |
583 | inline bool operator!=(wxFontFamily s, wxDeprecatedGUIConstants t) | |
584 | { return !(s == t); } | |
585 | inline bool operator==(wxFontStyle s, wxDeprecatedGUIConstants t) | |
586 | { return static_cast<int>(s) == static_cast<int>(t); } | |
587 | inline bool operator!=(wxFontStyle s, wxDeprecatedGUIConstants t) | |
588 | { return !(s == t); } | |
589 | inline bool operator==(wxFontWeight s, wxDeprecatedGUIConstants t) | |
590 | { return static_cast<int>(s) == static_cast<int>(t); } | |
591 | inline bool operator!=(wxFontWeight s, wxDeprecatedGUIConstants t) | |
592 | { return !(s == t); } | |
593 | ||
594 | #endif // // wxCOMPILER_NO_OVERLOAD_ON_ENUM | |
595 | ||
596 | #endif // FUTURE_WXWIN_COMPATIBILITY_3_0 | |
597 | ||
598 | #endif | |
599 | // _WX_FONT_H_BASE_ |