]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fontenum.h
fixed compilation breakage in 1.24 commit
[wxWidgets.git] / include / wx / fontenum.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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/fontenc.h"
17 #include "wx/arrstr.h"
18
19 // ----------------------------------------------------------------------------
20 // wxFontEnumerator enumerates all available fonts on the system or only the
21 // fonts with given attributes
22 // ----------------------------------------------------------------------------
23
24 class WXDLLEXPORT wxFontEnumerator
25 {
26 public:
27 wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
28
29 // start enumerating font facenames (either all of them or those which
30 // support the given encoding) - will result in OnFacename() being
31 // called for each available facename (until they are exhausted or
32 // OnFacename returns false)
33 virtual bool EnumerateFacenames
34 (
35 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
36 bool fixedWidthOnly = false
37 );
38
39 // enumerate the different encodings either for given font facename or for
40 // all facenames - will result in OnFontEncoding() being called for each
41 // available (facename, encoding) couple
42 virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString);
43
44 // callbacks which are called after one of EnumerateXXX() functions from
45 // above is invoked - all of them may return false to stop enumeration or
46 // true to continue with it
47
48 // called by EnumerateFacenames
49 virtual bool OnFacename(const wxString& facename)
50 {
51 if (m_Facenames == NULL) m_Facenames = new wxArrayString;
52 m_Facenames -> Add(facename);
53 return true;
54 }
55
56 // called by EnumerateEncodings
57 virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
58 const wxString& encoding)
59 {
60 if (m_Encodings == NULL) m_Encodings = new wxArrayString;
61 m_Encodings -> Add(encoding);
62 return true;
63 }
64
65 // convenience function that returns array of facenames. Cannot be called
66 // before EnumerateFacenames.
67 wxArrayString *GetFacenames()
68 { return m_Facenames; }
69
70 // convenience function that returns array of encodings.
71 // Cannot be called before EnumerateEncodings.
72 wxArrayString *GetEncodings()
73 { return m_Encodings; }
74
75 // virtual dtor for the base class
76 virtual ~wxFontEnumerator()
77 {
78 if (m_Facenames) delete m_Facenames;
79 if (m_Encodings) delete m_Encodings;
80 }
81
82 private:
83 wxArrayString *m_Facenames, *m_Encodings;
84
85 DECLARE_NO_COPY_CLASS(wxFontEnumerator)
86 };
87
88 #endif // _WX_FONTENUM_H_