1 /////////////////////////////////////////////////////////////////////////////
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)
9 // Copyright: (c) Julian Smart, Vadim Zeitlin
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 #ifndef _WX_FONTENUM_H_
14 #define _WX_FONTENUM_H_
16 #if defined(__GNUG__) && !defined(__APPLE__)
17 #pragma interface "fontenum.h"
22 // ----------------------------------------------------------------------------
23 // wxFontEnumerator enumerates all available fonts on the system or only the
24 // fonts with given attributes
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxFontEnumerator
30 wxFontEnumerator() : m_Facenames(NULL
), m_Encodings(NULL
) { }
32 // start enumerating font facenames (either all of them or those which
33 // support the given encoding) - will result in OnFacename() being
34 // called for each available facename (until they are exhausted or
35 // OnFacename returns FALSE)
36 virtual bool EnumerateFacenames
38 wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
39 bool fixedWidthOnly
= FALSE
42 // enumerate the different encodings either for given font facename or for
43 // all facenames - will result in OnFontEncoding() being called for each
44 // available (facename, encoding) couple
45 virtual bool EnumerateEncodings(const wxString
& facename
= wxT(""));
47 // callbacks which are called after one of EnumerateXXX() functions from
48 // above is invoked - all of them may return FALSE to stop enumeration or
49 // TRUE to continue with it
51 // called by EnumerateFacenames
52 virtual bool OnFacename(const wxString
& facename
)
54 if (m_Facenames
== NULL
) m_Facenames
= new wxArrayString
;
55 m_Facenames
-> Add(facename
);
59 // called by EnumerateEncodings
60 virtual bool OnFontEncoding(const wxString
& WXUNUSED(facename
),
61 const wxString
& encoding
)
63 if (m_Encodings
== NULL
) m_Encodings
= new wxArrayString
;
64 m_Encodings
-> Add(encoding
);
68 // convenience function that returns array of facenames. Cannot be called
69 // before EnumerateFacenames.
70 wxArrayString
*GetFacenames()
71 { return m_Facenames
; }
73 // convenience function that returns array of encodings.
74 // Cannot be called before EnumerateEncodings.
75 wxArrayString
*GetEncodings()
76 { return m_Encodings
; }
78 // virtual dtor for the base class
79 virtual ~wxFontEnumerator()
81 if (m_Facenames
) delete m_Facenames
;
82 if (m_Encodings
) delete m_Encodings
;
86 wxArrayString
*m_Facenames
, *m_Encodings
;
88 DECLARE_NO_COPY_CLASS(wxFontEnumerator
)
91 #endif // _WX_FONTENUM_H_