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"
20 // ----------------------------------------------------------------------------
21 // wxFontEnumerator enumerates all available fonts on the system or only the
22 // fonts with given attributes
23 // ----------------------------------------------------------------------------
25 class WXDLLEXPORT wxFontEnumerator
28 wxFontEnumerator() : m_Facenames(NULL
), m_Encodings(NULL
) { }
30 // start enumerating font facenames (either all of them or those which
31 // support the given encoding) - will result in OnFacename() being
32 // called for each available facename (until they are exhausted or
33 // OnFacename returns FALSE)
34 virtual bool EnumerateFacenames
36 wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
, // all
37 bool fixedWidthOnly
= FALSE
40 // enumerate the different encodings either for given font facename or for
41 // all facenames - will result in OnFontEncoding() being called for each
42 // available (facename, encoding) couple
43 virtual bool EnumerateEncodings(const wxString
& facename
= wxT(""));
45 // callbacks which are called after one of EnumerateXXX() functions from
46 // above is invoked - all of them may return FALSE to stop enumeration or
47 // TRUE to continue with it
49 // called by EnumerateFacenames
50 virtual bool OnFacename(const wxString
& facename
)
52 if (m_Facenames
== NULL
) m_Facenames
= new wxArrayString
;
53 m_Facenames
-> Add(facename
);
57 // called by EnumerateEncodings
58 virtual bool OnFontEncoding(const wxString
& WXUNUSED(facename
),
59 const wxString
& encoding
)
61 if (m_Encodings
== NULL
) m_Encodings
= new wxArrayString
;
62 m_Encodings
-> Add(encoding
);
66 // convenience function that returns array of facenames. Cannot be called
67 // before EnumerateFacenames.
68 wxArrayString
*GetFacenames()
69 { return m_Facenames
; }
71 // convenience function that returns array of encodings.
72 // Cannot be called before EnumerateEncodings.
73 wxArrayString
*GetEncodings()
74 { return m_Encodings
; }
76 // virtual dtor for the base class
77 virtual ~wxFontEnumerator()
79 if (m_Facenames
) delete m_Facenames
;
80 if (m_Encodings
) delete m_Encodings
;
84 wxArrayString
*m_Facenames
, *m_Encodings
;
86 DECLARE_NO_COPY_CLASS(wxFontEnumerator
)
89 #endif // _WX_FONTENUM_H_