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