]>
Commit | Line | Data |
---|---|---|
ddc8c2e3 | 1 | ///////////////////////////////////////////////////////////////////////////// |
dd74a8f6 | 2 | // Name: wx/fontenum.h |
ddc8c2e3 VZ |
3 | // Purpose: wxFontEnumerator class for getting available fonts |
4 | // Author: Julian Smart, Vadim Zeitlin | |
3c1866e8 VZ |
5 | // Modified by: extended to enumerate more than just font facenames and works |
6 | // not only on Windows now (VZ) | |
ddc8c2e3 VZ |
7 | // Created: 04/01/98 |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) Julian Smart, Vadim Zeitlin | |
65571936 | 10 | // Licence: wxWindows licence |
ddc8c2e3 VZ |
11 | ///////////////////////////////////////////////////////////////////////////// |
12 | ||
13 | #ifndef _WX_FONTENUM_H_ | |
14 | #define _WX_FONTENUM_H_ | |
15 | ||
c3d15542 | 16 | #include "wx/fontenc.h" |
a6abcf2e | 17 | #include "wx/arrstr.h" |
c3d15542 | 18 | |
4e1d79d3 VS |
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 | ||
ddc8c2e3 VZ |
24 | // ---------------------------------------------------------------------------- |
25 | // wxFontEnumerator enumerates all available fonts on the system or only the | |
26 | // fonts with given attributes | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
d111a89a | 29 | class WXDLLEXPORT wxFontEnumerator |
ddc8c2e3 VZ |
30 | { |
31 | public: | |
6540132f VZ |
32 | wxFontEnumerator() {} |
33 | ||
34 | // virtual dtor for the base class | |
35 | virtual ~wxFontEnumerator() {} | |
435151d7 | 36 | |
3c1866e8 VZ |
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 | |
dabbc6a5 | 40 | // OnFacename returns false) |
3c1866e8 | 41 | virtual bool EnumerateFacenames |
36f210c8 VZ |
42 | ( |
43 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
dabbc6a5 | 44 | bool fixedWidthOnly = false |
36f210c8 | 45 | ); |
ddc8c2e3 | 46 | |
3c1866e8 VZ |
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 | |
fda7962d | 50 | virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString); |
ddc8c2e3 VZ |
51 | |
52 | // callbacks which are called after one of EnumerateXXX() functions from | |
dabbc6a5 DS |
53 | // above is invoked - all of them may return false to stop enumeration or |
54 | // true to continue with it | |
ddc8c2e3 | 55 | |
3c1866e8 | 56 | // called by EnumerateFacenames |
6540132f VZ |
57 | virtual bool OnFacename(const wxString& WXUNUSED(facename)) |
58 | { return true; } | |
ddc8c2e3 VZ |
59 | |
60 | // called by EnumerateEncodings | |
3c1866e8 | 61 | virtual bool OnFontEncoding(const wxString& WXUNUSED(facename), |
6540132f VZ |
62 | const wxString& WXUNUSED(encoding)) |
63 | { return true; } | |
dabbc6a5 | 64 | |
dabbc6a5 | 65 | |
22f3361e | 66 | |
6540132f VZ |
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 | ||
85ab460e VZ |
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 | ||
6540132f | 79 | private: |
4e1d79d3 VS |
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 | ||
22f3361e | 85 | DECLARE_NO_COPY_CLASS(wxFontEnumerator) |
ddc8c2e3 VZ |
86 | }; |
87 | ||
88 | #endif // _WX_FONTENUM_H_ |