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