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