]> git.saurik.com Git - wxWidgets.git/blame - include/wx/fontenum.h
wxURL - doc cleanups, depreciated more methods, more source comments. wxURI - enclos...
[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
12028905 16#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
ddc8c2e3
VZ
17 #pragma interface "fontenum.h"
18#endif
19
c3d15542 20#include "wx/fontenc.h"
a6abcf2e 21#include "wx/arrstr.h"
c3d15542 22
ddc8c2e3
VZ
23// ----------------------------------------------------------------------------
24// wxFontEnumerator enumerates all available fonts on the system or only the
25// fonts with given attributes
26// ----------------------------------------------------------------------------
27
d111a89a 28class WXDLLEXPORT wxFontEnumerator
ddc8c2e3
VZ
29{
30public:
435151d7
VS
31 wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
32
3c1866e8
VZ
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
dabbc6a5 36 // OnFacename returns false)
3c1866e8 37 virtual bool EnumerateFacenames
36f210c8
VZ
38 (
39 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
dabbc6a5 40 bool fixedWidthOnly = false
36f210c8 41 );
ddc8c2e3 42
3c1866e8
VZ
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
fda7962d 46 virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString);
ddc8c2e3
VZ
47
48 // callbacks which are called after one of EnumerateXXX() functions from
dabbc6a5
DS
49 // above is invoked - all of them may return false to stop enumeration or
50 // true to continue with it
ddc8c2e3 51
3c1866e8 52 // called by EnumerateFacenames
435151d7 53 virtual bool OnFacename(const wxString& facename)
dabbc6a5 54 {
435151d7
VS
55 if (m_Facenames == NULL) m_Facenames = new wxArrayString;
56 m_Facenames -> Add(facename);
dabbc6a5 57 return true;
435151d7 58 }
ddc8c2e3
VZ
59
60 // called by EnumerateEncodings
3c1866e8 61 virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
435151d7 62 const wxString& encoding)
dabbc6a5 63 {
435151d7
VS
64 if (m_Encodings == NULL) m_Encodings = new wxArrayString;
65 m_Encodings -> Add(encoding);
dabbc6a5 66 return true;
435151d7 67 }
dabbc6a5 68
435151d7
VS
69 // convenience function that returns array of facenames. Cannot be called
70 // before EnumerateFacenames.
dabbc6a5 71 wxArrayString *GetFacenames()
435151d7 72 { return m_Facenames; }
36f210c8 73
435151d7
VS
74 // convenience function that returns array of encodings.
75 // Cannot be called before EnumerateEncodings.
dabbc6a5 76 wxArrayString *GetEncodings()
435151d7 77 { return m_Encodings; }
dabbc6a5 78
36f210c8 79 // virtual dtor for the base class
dabbc6a5
DS
80 virtual ~wxFontEnumerator()
81 {
435151d7
VS
82 if (m_Facenames) delete m_Facenames;
83 if (m_Encodings) delete m_Encodings;
84 }
dabbc6a5 85
435151d7
VS
86private:
87 wxArrayString *m_Facenames, *m_Encodings;
22f3361e
VZ
88
89 DECLARE_NO_COPY_CLASS(wxFontEnumerator)
ddc8c2e3
VZ
90};
91
92#endif // _WX_FONTENUM_H_