2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: fontmap.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxFontMapper
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxFontMapper
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxFontMapper manages user-definable correspondence between logical font
|
|
|
|
names and the fonts present on the machine.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
In case everything else fails (i.e. there is no record in config file
|
2008-03-08 09:43:31 -05:00
|
|
|
and "interactive" is @false or user denied to choose any replacement),
|
|
|
|
the class queries wxEncodingConverter
|
2008-03-08 08:52:38 -05:00
|
|
|
for "equivalent" encodings (e.g. iso8859-2 and cp1250) and tries them.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{misc}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxEncodingConverter, @ref overview_nonenglishoverview "Writing non-English
|
2008-03-08 08:52:38 -05:00
|
|
|
applications"
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxFontMapper
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxFontMapper();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Virtual dtor for a base class.
|
|
|
|
*/
|
|
|
|
~wxFontMapper();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the encoding for the given charset (in the form of RFC 2046) or
|
|
|
|
@c wxFONTENCODING_SYSTEM if couldn't decode it.
|
2008-03-09 08:33:59 -04:00
|
|
|
Be careful when using this function with @a interactive set to @true
|
2008-03-08 08:52:38 -05:00
|
|
|
(default value) as the function then may show a dialog box to the user which
|
|
|
|
may lead to unexpected reentrancies and may also take a significantly longer
|
|
|
|
time than a simple function call. For these reasons, it is almost always a bad
|
|
|
|
idea to call this function from the event handlers for repeatedly generated
|
|
|
|
events such as @c EVT_PAINT.
|
|
|
|
*/
|
|
|
|
wxFontEncoding CharsetToEncoding(const wxString& charset,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool interactive = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Get the current font mapper object. If there is no current object, creates
|
|
|
|
one.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Set()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
static wxFontMapper* Get();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the array of all possible names for the given encoding. The array is
|
|
|
|
@NULL-terminated. IF it isn't empty, the first name in it is the canonical
|
2008-03-08 09:43:31 -05:00
|
|
|
encoding name, i.e. the same string as returned by
|
2008-03-08 08:52:38 -05:00
|
|
|
GetEncodingName().
|
|
|
|
*/
|
|
|
|
static const wxChar** GetAllEncodingNames(wxFontEncoding encoding);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Find an alternative for the given encoding (which is supposed to not be
|
|
|
|
available on this system). If successful, return @true and fill info
|
|
|
|
structure with the parameters required to create the font, otherwise
|
|
|
|
return @false.
|
|
|
|
The first form is for wxWidgets' internal use while the second one
|
|
|
|
is better suitable for general use -- it returns wxFontEncoding which
|
|
|
|
can consequently be passed to wxFont constructor.
|
|
|
|
*/
|
|
|
|
bool GetAltForEncoding(wxFontEncoding encoding,
|
|
|
|
wxNativeEncodingInfo* info,
|
|
|
|
const wxString& facename = wxEmptyString,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool interactive = true);
|
2008-03-08 09:43:31 -05:00
|
|
|
bool GetAltForEncoding(wxFontEncoding encoding,
|
|
|
|
wxFontEncoding* alt_encoding,
|
|
|
|
const wxString& facename = wxEmptyString,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool interactive = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Returns the @e n-th supported encoding. Together with
|
|
|
|
GetSupportedEncodingsCount()
|
2008-03-08 08:52:38 -05:00
|
|
|
this method may be used to get all supported encodings.
|
|
|
|
*/
|
|
|
|
static wxFontEncoding GetEncoding(size_t n);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return user-readable string describing the given encoding.
|
|
|
|
*/
|
|
|
|
static wxString GetEncodingDescription(wxFontEncoding encoding);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return the encoding corresponding to the given internal name. This function is
|
|
|
|
the inverse of GetEncodingName() and is
|
2008-03-08 09:43:31 -05:00
|
|
|
intentionally less general than
|
2008-03-08 08:52:38 -05:00
|
|
|
CharsetToEncoding(), i.e. it doesn't
|
|
|
|
try to make any guesses nor ever asks the user. It is meant just as a way of
|
2008-03-08 09:43:31 -05:00
|
|
|
restoring objects previously serialized using
|
2008-03-08 08:52:38 -05:00
|
|
|
GetEncodingName().
|
|
|
|
*/
|
|
|
|
static wxFontEncoding GetEncodingFromName(const wxString& encoding);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Return internal string identifier for the encoding (see also
|
2008-03-08 08:52:38 -05:00
|
|
|
wxFontMapper::GetEncodingDescription)
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetEncodingFromName()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxString GetEncodingName(wxFontEncoding encoding);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Returns the number of the font encodings supported by this class. Together with
|
2008-03-08 08:52:38 -05:00
|
|
|
GetEncoding() this method may be used to get
|
|
|
|
all supported encodings.
|
|
|
|
*/
|
|
|
|
static size_t GetSupportedEncodingsCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Check whether given encoding is available in given face or not.
|
|
|
|
If no facename is given, find @e any font in this encoding.
|
|
|
|
*/
|
|
|
|
bool IsEncodingAvailable(wxFontEncoding encoding,
|
|
|
|
const wxString& facename = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the current font mapper object and return previous one (may be @NULL).
|
|
|
|
This method is only useful if you want to plug-in an alternative font mapper
|
|
|
|
into wxWidgets.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Get()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
static wxFontMapper* Set(wxFontMapper* mapper);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the config object to use (may be @NULL to use default).
|
2008-03-08 09:43:31 -05:00
|
|
|
By default, the global one (from wxConfigBase::Get() will be used)
|
2008-03-08 08:52:38 -05:00
|
|
|
and the default root path for the config settings is the string returned by
|
|
|
|
GetDefaultConfigPath().
|
|
|
|
*/
|
|
|
|
void SetConfig(wxConfigBase* config);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Set the root config path to use (should be an absolute path).
|
|
|
|
*/
|
|
|
|
void SetConfigPath(const wxString& prefix);
|
|
|
|
|
|
|
|
/**
|
|
|
|
The parent window for modal dialogs.
|
|
|
|
*/
|
|
|
|
void SetDialogParent(wxWindow* parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
The title for the dialogs (note that default is quite reasonable).
|
|
|
|
*/
|
|
|
|
void SetDialogTitle(const wxString& title);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|