]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fontenum.h
Implemented wxToggleButton under Motif.
[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 #if defined(__GNUG__) && !defined(__APPLE__)
17 #pragma interface "fontenum.h"
18 #endif
19
20 // ----------------------------------------------------------------------------
21 // wxFontEnumerator enumerates all available fonts on the system or only the
22 // fonts with given attributes
23 // ----------------------------------------------------------------------------
24
25 class WXDLLEXPORT wxFontEnumerator
26 {
27 public:
28 wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
29
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
35 (
36 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
37 bool fixedWidthOnly = FALSE
38 );
39
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(""));
44
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
48
49 // called by EnumerateFacenames
50 virtual bool OnFacename(const wxString& facename)
51 {
52 if (m_Facenames == NULL) m_Facenames = new wxArrayString;
53 m_Facenames -> Add(facename);
54 return TRUE;
55 }
56
57 // called by EnumerateEncodings
58 virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
59 const wxString& encoding)
60 {
61 if (m_Encodings == NULL) m_Encodings = new wxArrayString;
62 m_Encodings -> Add(encoding);
63 return TRUE;
64 }
65
66 // convenience function that returns array of facenames. Cannot be called
67 // before EnumerateFacenames.
68 wxArrayString *GetFacenames()
69 { return m_Facenames; }
70
71 // convenience function that returns array of encodings.
72 // Cannot be called before EnumerateEncodings.
73 wxArrayString *GetEncodings()
74 { return m_Encodings; }
75
76 // virtual dtor for the base class
77 virtual ~wxFontEnumerator()
78 {
79 if (m_Facenames) delete m_Facenames;
80 if (m_Encodings) delete m_Encodings;
81 }
82
83 private:
84 wxArrayString *m_Facenames, *m_Encodings;
85
86 DECLARE_NO_COPY_CLASS(wxFontEnumerator)
87 };
88
89 #endif // _WX_FONTENUM_H_