1999-10-01 18:01:54 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fontenum.h
|
|
|
|
// Purpose: wxFontEnumerator class for getting available fonts
|
|
|
|
// Author: Julian Smart, Vadim Zeitlin
|
1999-11-04 20:40:41 +00:00
|
|
|
// Modified by: extended to enumerate more than just font facenames and works
|
|
|
|
// not only on Windows now (VZ)
|
1999-10-01 18:01:54 +00:00
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart, Vadim Zeitlin
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_FONTENUM_H_
|
|
|
|
#define _WX_FONTENUM_H_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "fontenum.h"
|
|
|
|
#endif
|
|
|
|
|
1999-11-05 19:03:19 +00:00
|
|
|
#include "wx/font.h"
|
|
|
|
|
1999-10-01 18:01:54 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFontEnumerator enumerates all available fonts on the system or only the
|
|
|
|
// fonts with given attributes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-10-25 17:22:13 +00:00
|
|
|
class WXDLLEXPORT wxFontEnumerator
|
1999-10-01 18:01:54 +00:00
|
|
|
{
|
|
|
|
public:
|
1999-11-06 15:38:23 +00:00
|
|
|
wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
|
|
|
|
|
1999-11-04 20:40:41 +00:00
|
|
|
// 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
|
1999-10-29 17:54:13 +00:00
|
|
|
(
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
|
|
|
|
bool fixedWidthOnly = FALSE
|
|
|
|
);
|
1999-10-01 18:01:54 +00:00
|
|
|
|
1999-11-04 20:40:41 +00:00
|
|
|
// 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 = wxT(""));
|
1999-10-01 18:01:54 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
|
1999-11-04 20:40:41 +00:00
|
|
|
// called by EnumerateFacenames
|
1999-11-06 15:38:23 +00:00
|
|
|
virtual bool OnFacename(const wxString& facename)
|
|
|
|
{
|
|
|
|
if (m_Facenames == NULL) m_Facenames = new wxArrayString;
|
|
|
|
m_Facenames -> Add(facename);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-10-01 18:01:54 +00:00
|
|
|
|
|
|
|
// called by EnumerateEncodings
|
1999-11-04 20:40:41 +00:00
|
|
|
virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
|
1999-11-06 15:38:23 +00:00
|
|
|
const wxString& encoding)
|
|
|
|
{
|
|
|
|
if (m_Encodings == NULL) m_Encodings = new wxArrayString;
|
|
|
|
m_Encodings -> Add(encoding);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// convenience function that returns array of facenames. Cannot be called
|
|
|
|
// before EnumerateFacenames.
|
|
|
|
wxArrayString *GetFacenames()
|
|
|
|
{ return m_Facenames; }
|
1999-10-29 17:54:13 +00:00
|
|
|
|
1999-11-06 15:38:23 +00:00
|
|
|
// convenience function that returns array of encodings.
|
|
|
|
// Cannot be called before EnumerateEncodings.
|
|
|
|
wxArrayString *GetEncodings()
|
|
|
|
{ return m_Encodings; }
|
|
|
|
|
1999-10-29 17:54:13 +00:00
|
|
|
// virtual dtor for the base class
|
1999-11-06 15:38:23 +00:00
|
|
|
virtual ~wxFontEnumerator()
|
|
|
|
{
|
|
|
|
if (m_Facenames) delete m_Facenames;
|
|
|
|
if (m_Encodings) delete m_Encodings;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxArrayString *m_Facenames, *m_Encodings;
|
1999-10-01 18:01:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_FONTENUM_H_
|