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