1999-10-01 14:01:54 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fontenum.h
|
|
|
|
// Purpose: wxFontEnumerator class for getting available fonts
|
|
|
|
// Author: Julian Smart, Vadim Zeitlin
|
1999-11-04 15:40:41 -05:00
|
|
|
// Modified by: extended to enumerate more than just font facenames and works
|
|
|
|
// not only on Windows now (VZ)
|
1999-10-01 14:01:54 -04:00
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart, Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-10-01 14:01:54 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_FONTENUM_H_
|
|
|
|
#define _WX_FONTENUM_H_
|
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-10-01 14:01:54 -04:00
|
|
|
#pragma interface "fontenum.h"
|
|
|
|
#endif
|
|
|
|
|
2003-02-12 15:35:27 -05:00
|
|
|
#include "wx/fontenc.h"
|
2003-07-08 16:41:48 -04:00
|
|
|
#include "wx/arrstr.h"
|
2003-02-12 15:35:27 -05:00
|
|
|
|
1999-10-01 14:01:54 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxFontEnumerator enumerates all available fonts on the system or only the
|
|
|
|
// fonts with given attributes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-10-25 13:22:13 -04:00
|
|
|
class WXDLLEXPORT wxFontEnumerator
|
1999-10-01 14:01:54 -04:00
|
|
|
{
|
|
|
|
public:
|
1999-11-06 10:38:23 -05:00
|
|
|
wxFontEnumerator() : m_Facenames(NULL), m_Encodings(NULL) { }
|
|
|
|
|
1999-11-04 15:40:41 -05: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
|
2004-06-12 19:44:08 -04:00
|
|
|
// OnFacename returns false)
|
1999-11-04 15:40:41 -05:00
|
|
|
virtual bool EnumerateFacenames
|
1999-10-29 13:54:13 -04:00
|
|
|
(
|
|
|
|
wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
|
2004-06-12 19:44:08 -04:00
|
|
|
bool fixedWidthOnly = false
|
1999-10-29 13:54:13 -04:00
|
|
|
);
|
1999-10-01 14:01:54 -04:00
|
|
|
|
1999-11-04 15:40:41 -05: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
|
2003-07-10 04:36:14 -04:00
|
|
|
virtual bool EnumerateEncodings(const wxString& facename = wxEmptyString);
|
1999-10-01 14:01:54 -04:00
|
|
|
|
|
|
|
// callbacks which are called after one of EnumerateXXX() functions from
|
2004-06-12 19:44:08 -04:00
|
|
|
// above is invoked - all of them may return false to stop enumeration or
|
|
|
|
// true to continue with it
|
1999-10-01 14:01:54 -04:00
|
|
|
|
1999-11-04 15:40:41 -05:00
|
|
|
// called by EnumerateFacenames
|
1999-11-06 10:38:23 -05:00
|
|
|
virtual bool OnFacename(const wxString& facename)
|
2004-06-12 19:44:08 -04:00
|
|
|
{
|
1999-11-06 10:38:23 -05:00
|
|
|
if (m_Facenames == NULL) m_Facenames = new wxArrayString;
|
|
|
|
m_Facenames -> Add(facename);
|
2004-06-12 19:44:08 -04:00
|
|
|
return true;
|
1999-11-06 10:38:23 -05:00
|
|
|
}
|
1999-10-01 14:01:54 -04:00
|
|
|
|
|
|
|
// called by EnumerateEncodings
|
1999-11-04 15:40:41 -05:00
|
|
|
virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
|
1999-11-06 10:38:23 -05:00
|
|
|
const wxString& encoding)
|
2004-06-12 19:44:08 -04:00
|
|
|
{
|
1999-11-06 10:38:23 -05:00
|
|
|
if (m_Encodings == NULL) m_Encodings = new wxArrayString;
|
|
|
|
m_Encodings -> Add(encoding);
|
2004-06-12 19:44:08 -04:00
|
|
|
return true;
|
1999-11-06 10:38:23 -05:00
|
|
|
}
|
2004-06-12 19:44:08 -04:00
|
|
|
|
1999-11-06 10:38:23 -05:00
|
|
|
// convenience function that returns array of facenames. Cannot be called
|
|
|
|
// before EnumerateFacenames.
|
2004-06-12 19:44:08 -04:00
|
|
|
wxArrayString *GetFacenames()
|
1999-11-06 10:38:23 -05:00
|
|
|
{ return m_Facenames; }
|
1999-10-29 13:54:13 -04:00
|
|
|
|
1999-11-06 10:38:23 -05:00
|
|
|
// convenience function that returns array of encodings.
|
|
|
|
// Cannot be called before EnumerateEncodings.
|
2004-06-12 19:44:08 -04:00
|
|
|
wxArrayString *GetEncodings()
|
1999-11-06 10:38:23 -05:00
|
|
|
{ return m_Encodings; }
|
2004-06-12 19:44:08 -04:00
|
|
|
|
1999-10-29 13:54:13 -04:00
|
|
|
// virtual dtor for the base class
|
2004-06-12 19:44:08 -04:00
|
|
|
virtual ~wxFontEnumerator()
|
|
|
|
{
|
1999-11-06 10:38:23 -05:00
|
|
|
if (m_Facenames) delete m_Facenames;
|
|
|
|
if (m_Encodings) delete m_Encodings;
|
|
|
|
}
|
2004-06-12 19:44:08 -04:00
|
|
|
|
1999-11-06 10:38:23 -05:00
|
|
|
private:
|
|
|
|
wxArrayString *m_Facenames, *m_Encodings;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxFontEnumerator)
|
1999-10-01 14:01:54 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WX_FONTENUM_H_
|