1. wxFontMapper starts to materialise

2. wxFontEnumerator corrections: EnumerateFamilies => EnumerateFacenames


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4363 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-11-04 20:40:41 +00:00
parent 7f24fdbfea
commit 3c1866e88f
10 changed files with 594 additions and 41 deletions

View File

@@ -89,6 +89,7 @@ enum wxFontEncoding
wxFONTENCODING_ISO8859_13, // Latin7
wxFONTENCODING_ISO8859_14, // Latin8
wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
wxFONTENCODING_ISO8859_MAX,
// Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
@@ -106,6 +107,12 @@ enum wxFontEncoding
wxFONTENCODING_CP1250, // WinLatin2
wxFONTENCODING_CP1251, // WinCyrillic
wxFONTENCODING_CP1252, // WinLatin1
wxFONTENCODING_CP1253, // WinGreek (8859-7)
wxFONTENCODING_CP1254, // WinTurkish
wxFONTENCODING_CP1255, // WinHebrew
wxFONTENCODING_CP1256, // WinArabic
wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
wxFONTENCODING_CP12_MAX,
wxFONTENCODING_MAX
};

View File

@@ -2,8 +2,8 @@
// Name: fontenum.h
// Purpose: wxFontEnumerator class for getting available fonts
// Author: Julian Smart, Vadim Zeitlin
// Modified by: extended to enumerate more than just font families and work ot
// only on Windows (VZ)
// Modified by: extended to enumerate more than just font facenames and works
// not only on Windows now (VZ)
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Vadim Zeitlin
@@ -25,31 +25,31 @@
class WXDLLEXPORT wxFontEnumerator
{
public:
// start enumerating font families (either all of them or those which
// support the given encoding) - will result in OnFontFamily() being
// called for each available font family (until they are exhausted or
// OnFontFamily returns FALSE)
virtual bool EnumerateFamilies
// 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 family or for
// all font families - will result in OnFontEncoding() being called for
// each available (family, encoding) couple
virtual bool EnumerateEncodings(const wxString& family = wxT(""));
// 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(""));
// 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 EnumerateFamilies
virtual bool OnFontFamily(const wxString& WXUNUSED(family))
// called by EnumerateFacenames
virtual bool OnFacename(const wxString& WXUNUSED(facename))
{ return FALSE; }
// called by EnumerateEncodings
virtual bool OnFontEncoding(const wxString& WXUNUSED(family),
virtual bool OnFontEncoding(const wxString& WXUNUSED(facename),
const wxString& WXUNUSED(encoding))
{ return FALSE; }

108
include/wx/fontmap.h Normal file
View File

@@ -0,0 +1,108 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/fontmap.h
// Purpose: wxFontMapper class
// Author: Vadim Zeitlin
// Modified by:
// Created: 04.11.99
// RCS-ID: $Id$
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONTMAPPER_H_
#define _WX_FONTMAPPER_H_
#ifdef __GNUG__
#pragma interface "fontmap.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h" // for wxDEFAULT &c
#include "wx/font.h" // for wxFontEncoding
class WXDLLEXPORT wxConfigBase;
// ----------------------------------------------------------------------------
// wxFontMapper manages user-definable correspondence between logical font
// names and the fonts present on the machine.
//
// The default implementations of all functions will ask the user if they are
// not capable of finding the answer themselves and store the answer in a
// config file (configurable via SetConfigXXX functions). This behaviour may
// be disabled by giving the value of FALSE to "interactive" parameter.
// However, the functions will always consult the config file to allow the
// user-defined values override the default logic and there is no way to
// disable this - which shouldn't be ever needed because if "interactive" was
// never TRUE, the config file is never created anyhow.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontMapper
{
public:
// default ctor
wxFontMapper();
// virtual dtor for a base class
virtual ~wxFontMapper();
// returns the encoding for the given charset (in the form of RFC 2046) or
// wxFONTENCODING_SYSTEM if couldn't decode it
virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
bool interactive = TRUE);
// configure the appearance of the dialogs we may popup
// ----------------------------------------------------
void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
// functions which allow to configure the config object used: by default,
// the global one (from wxConfigBase::Get() will be used) and the default
// root path for the config settings is the string returned by
// GetDefaultConfigPath()
// ----------------------------------------------------------------------
// set the config object to use (may be NULL to use default)
void SetConfig(wxConfigBase *config) { m_config = config; }
// set the root config path to use (should be an absolute path)
void SetConfigPath(const wxString& prefix);
// return default config path
static const wxChar *GetDefaultConfigPath();
protected:
// get the config object we're using - if it wasn't set explicitly, this
// function will use wxConfig::Get() to get the global one
wxConfigBase *GetConfig();
// gets the root path for our settings - if itwasn't set explicitly, use
// GetDefaultConfigPath()
const wxString& GetConfigPath();
// change to the given (relative) path in the config, return TRUE if ok
// (then GetConfig() will return something !NULL), FALSE if no config
// object
//
// caller should provide a pointer to the string variable which should be
// later passed to RestorePath()
bool ChangePath(const wxString& pathNew, wxString *pathOld);
// restore the config path after use
void RestorePath(const wxString& pathOld);
// config object and path (in it) to use
wxConfigBase *m_config;
wxString m_configRootPath;
// the title for our dialogs
wxString m_titleDialog;
// the parent window for our dialogs
wxWindow *m_windowParent;
};
#endif // _WX_FONTMAPPER_H_

View File

@@ -35,6 +35,10 @@
#define _(str) wxGetTranslation(wxT(str))
#endif
// another one which just marks the strings for extraction, but doesn't
// perform the translation (use -kwxTRANSLATE with xgettext!)
#define wxTRANSLATE(str) (str)
// ----------------------------------------------------------------------------
// forward decls
// ----------------------------------------------------------------------------