]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fontenum.h
use correct test
[wxWidgets.git] / include / wx / fontenum.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/fontenum.h
3 // Purpose: wxFontEnumerator class for getting available fonts
4 // Author: Julian Smart, Vadim Zeitlin
5 // Modified by: extended to enumerate more than just font facenames and works
6 // not only on Windows now (VZ)
7 // Created: 04/01/98
8 // RCS-ID: $Id$
9 // Copyright: (c) Julian Smart, Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_FONTENUM_H_
14 #define _WX_FONTENUM_H_
15
16 #include "wx/fontenc.h"
17 #include "wx/arrstr.h"
18
19 #if wxUSE_PANGO || defined(__WXDFB__)
20 // defined if the port uses only UTF-8 font encodings internally
21 #define wxHAS_UTF8_FONTS
22 #endif
23
24 // ----------------------------------------------------------------------------
25 // wxFontEnumerator enumerates all available fonts on the system or only the
26 // fonts with given attributes
27 // ----------------------------------------------------------------------------
28
29 class WXDLLEXPORT wxFontEnumerator
30 {
31 public:
32 wxFontEnumerator() {}
33
34 // virtual dtor for the base class
35 virtual ~wxFontEnumerator() {}
36
37 // start enumerating font facenames (either all of them or those which
38 // support the given encoding) - will result in OnFacename() being
39 // called for each available facename (until they are exhausted or
40 // OnFacename returns false)
41 virtual bool EnumerateFacenames
42 (
43 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
44 bool fixedWidthOnly = false
45 );
46
47 // enumerate the different encodings either for given font facename or for
48 // all facenames - will result in OnFontEncoding() being called for each
49 // available (facename, encoding) couple
50 virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString);
51
52 // callbacks which are called after one of EnumerateXXX() functions from
53 // above is invoked - all of them may return false to stop enumeration or
54 // true to continue with it
55
56 // called by EnumerateFacenames
57 virtual bool OnFacename(const wxString& WXUNUSED(facename))
58 { return true; }
59
60 // called by EnumerateEncodings
61 virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
62 const wxString& WXUNUSED(encoding))
63 { return true; }
64
65
66
67 // convenience function that returns array of facenames.
68 static wxArrayString
69 GetFacenames(wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
70 bool fixedWidthOnly = false);
71
72 // convenience function that returns array of all available encodings.
73 static wxArrayString GetEncodings(const wxString& facename = wxEmptyString);
74
75 // convenience function that returns true if the given face name exist
76 // in the user's system
77 static bool IsValidFacename(const wxString &str);
78
79 private:
80 #ifdef wxHAS_UTF8_FONTS
81 // helper for ports that only use UTF-8 encoding natively
82 bool EnumerateEncodingsUTF8(const wxString& facename);
83 #endif
84
85 DECLARE_NO_COPY_CLASS(wxFontEnumerator)
86 };
87
88 #endif // _WX_FONTENUM_H_