]> git.saurik.com Git - wxWidgets.git/blame - include/wx/fontenum.h
Warning fix for wxOS2 night build.
[wxWidgets.git] / include / wx / fontenum.h
CommitLineData
ddc8c2e3
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: fontenum.h
3// Purpose: wxFontEnumerator class for getting available fonts
4// Author: Julian Smart, Vadim Zeitlin
3c1866e8
VZ
5// Modified by: extended to enumerate more than just font facenames and works
6// not only on Windows now (VZ)
ddc8c2e3
VZ
7// Created: 04/01/98
8// RCS-ID: $Id$
9// Copyright: (c) Julian Smart, Vadim Zeitlin
65571936 10// Licence: wxWindows licence
ddc8c2e3
VZ
11/////////////////////////////////////////////////////////////////////////////
12
13#ifndef _WX_FONTENUM_H_
14#define _WX_FONTENUM_H_
15
c3d15542 16#include "wx/fontenc.h"
a6abcf2e 17#include "wx/arrstr.h"
c3d15542 18
ddc8c2e3
VZ
19// ----------------------------------------------------------------------------
20// wxFontEnumerator enumerates all available fonts on the system or only the
21// fonts with given attributes
22// ----------------------------------------------------------------------------
23
d111a89a 24class WXDLLEXPORT wxFontEnumerator
ddc8c2e3
VZ
25{
26public:
435151d7
VS
27 wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
28
3c1866e8
VZ
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
dabbc6a5 32 // OnFacename returns false)
3c1866e8 33 virtual bool EnumerateFacenames
36f210c8
VZ
34 (
35 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
dabbc6a5 36 bool fixedWidthOnly = false
36f210c8 37 );
ddc8c2e3 38
3c1866e8
VZ
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
fda7962d 42 virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString);
ddc8c2e3
VZ
43
44 // callbacks which are called after one of EnumerateXXX() functions from
dabbc6a5
DS
45 // above is invoked - all of them may return false to stop enumeration or
46 // true to continue with it
ddc8c2e3 47
3c1866e8 48 // called by EnumerateFacenames
435151d7 49 virtual bool OnFacename(const wxString& facename)
dabbc6a5 50 {
435151d7
VS
51 if (m_Facenames == NULL) m_Facenames = new wxArrayString;
52 m_Facenames -> Add(facename);
dabbc6a5 53 return true;
435151d7 54 }
ddc8c2e3
VZ
55
56 // called by EnumerateEncodings
3c1866e8 57 virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
435151d7 58 const wxString& encoding)
dabbc6a5 59 {
435151d7
VS
60 if (m_Encodings == NULL) m_Encodings = new wxArrayString;
61 m_Encodings -> Add(encoding);
dabbc6a5 62 return true;
435151d7 63 }
dabbc6a5 64
435151d7
VS
65 // convenience function that returns array of facenames. Cannot be called
66 // before EnumerateFacenames.
dabbc6a5 67 wxArrayString *GetFacenames()
435151d7 68 { return m_Facenames; }
36f210c8 69
435151d7
VS
70 // convenience function that returns array of encodings.
71 // Cannot be called before EnumerateEncodings.
dabbc6a5 72 wxArrayString *GetEncodings()
435151d7 73 { return m_Encodings; }
dabbc6a5 74
36f210c8 75 // virtual dtor for the base class
dabbc6a5
DS
76 virtual ~wxFontEnumerator()
77 {
435151d7
VS
78 if (m_Facenames) delete m_Facenames;
79 if (m_Encodings) delete m_Encodings;
80 }
dabbc6a5 81
435151d7
VS
82private:
83 wxArrayString *m_Facenames, *m_Encodings;
22f3361e
VZ
84
85 DECLARE_NO_COPY_CLASS(wxFontEnumerator)
ddc8c2e3
VZ
86};
87
88#endif // _WX_FONTENUM_H_