File: fontenum.h

package info (click to toggle)
wxwidgets3.0 3.0.5.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 120,464 kB
  • sloc: cpp: 896,633; makefile: 52,303; ansic: 21,971; sh: 5,713; python: 2,940; xml: 1,534; perl: 264; javascript: 33
file content (88 lines) | stat: -rw-r--r-- 3,120 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/////////////////////////////////////////////////////////////////////////////
// Name:        wx/fontenum.h
// Purpose:     wxFontEnumerator class for getting available fonts
// Author:      Julian Smart, Vadim Zeitlin
// Modified by: extended to enumerate more than just font facenames and works
//              not only on Windows now (VZ)
// Created:     04/01/98
// Copyright:   (c) Julian Smart, Vadim Zeitlin
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

#ifndef _WX_FONTENUM_H_
#define _WX_FONTENUM_H_

#include "wx/defs.h"

#if wxUSE_FONTENUM

#include "wx/fontenc.h"
#include "wx/arrstr.h"

// ----------------------------------------------------------------------------
// wxFontEnumerator enumerates all available fonts on the system or only the
// fonts with given attributes
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxFontEnumerator
{
public:
    wxFontEnumerator() {}

    // virtual dtor for the base class
    virtual ~wxFontEnumerator() {}

    // start enumerating font facenames (either all of them or those which
    // support the given encoding) - will result in OnFacename() being
    // called for each available facename (until they are exhausted or
    // OnFacename returns false)
    virtual bool EnumerateFacenames
                 (
                    wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
                    bool fixedWidthOnly = false
                 );

    // enumerate the different encodings either for given font facename or for
    // all facenames - will result in OnFontEncoding() being called for each
    // available (facename, encoding) couple
    virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString);

    // callbacks which are called after one of EnumerateXXX() functions from
    // above is invoked - all of them may return false to stop enumeration or
    // true to continue with it

    // called by EnumerateFacenames
    virtual bool OnFacename(const wxString& WXUNUSED(facename))
        { return true; }

    // called by EnumerateEncodings
    virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
                                const wxString& WXUNUSED(encoding))
        { return true; }



    // convenience function that returns array of facenames.
    static wxArrayString
    GetFacenames(wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
                 bool fixedWidthOnly = false);

    // convenience function that returns array of all available encodings.
    static wxArrayString GetEncodings(const wxString& facename = wxEmptyString);

    // convenience function that returns true if the given face name exist
    // in the user's system
    static bool IsValidFacename(const wxString &str);

private:
#ifdef wxHAS_UTF8_FONTS
    // helper for ports that only use UTF-8 encoding natively
    bool EnumerateEncodingsUTF8(const wxString& facename);
#endif

    wxDECLARE_NO_COPY_CLASS(wxFontEnumerator);
};

#endif // wxUSE_FONTENUM

#endif // _WX_FONTENUM_H_