X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3c1866e88fb77fc7e0b349cc15f6cebf0f727a9d..73bab6b44da953b35b902c9f3199582e4e76d89b:/include/wx/fontmap.h diff --git a/include/wx/fontmap.h b/include/wx/fontmap.h index 7c2ee4ba85..af3e7b5603 100644 --- a/include/wx/fontmap.h +++ b/include/wx/fontmap.h @@ -6,13 +6,13 @@ // Created: 04.11.99 // RCS-ID: $Id$ // Copyright: (c) Vadim Zeitlin -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_FONTMAPPER_H_ #define _WX_FONTMAPPER_H_ -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "fontmap.h" #endif @@ -20,11 +20,21 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/defs.h" // for wxDEFAULT &c +#if wxUSE_FONTMAP -#include "wx/font.h" // for wxFontEncoding +#include "wx/fontenc.h" // for wxFontEncoding -class WXDLLEXPORT wxConfigBase; +#if wxUSE_GUI + #include "wx/fontutil.h" // for wxNativeEncodingInfo +#endif // wxUSE_GUI + +#if wxUSE_CONFIG + class WXDLLEXPORT wxConfigBase; +#endif // wxUSE_CONFIG + +#if wxUSE_GUI + class WXDLLEXPORT wxWindow; +#endif // wxUSE_GUI // ---------------------------------------------------------------------------- // wxFontMapper manages user-definable correspondence between logical font @@ -49,15 +59,61 @@ public: // virtual dtor for a base class virtual ~wxFontMapper(); + // return instance of the wxFontMapper singleton + static wxFontMapper *Get(); + // set the sigleton to 'mapper' instance and return previous one + static wxFontMapper *Set(wxFontMapper *mapper); + +#if wxUSE_GUI + // 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 + virtual bool GetAltForEncoding(wxFontEncoding encoding, + wxNativeEncodingInfo *info, + const wxString& facename = wxEmptyString, + bool interactive = TRUE); + + // version better suitable for 'public' use. Returns wxFontEcoding + // that can be used it wxFont ctor + bool GetAltForEncoding(wxFontEncoding encoding, + wxFontEncoding *alt_encoding, + const wxString& facename = wxEmptyString, + bool interactive = TRUE); + + // checks whether given encoding is available in given face or not. + // If no facename is given, + virtual bool IsEncodingAvailable(wxFontEncoding encoding, + const wxString& facename = wxEmptyString); +#endif // wxUSE_GUI + // 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); + // encoding names + // -------------- + + // return internal string identifier for the encoding (see also + // GetEncodingDescription()) + static wxString GetEncodingName(wxFontEncoding encoding); + + // return user-readable string describing the given encoding + // + // NB: hard-coded now, but might change later (read it from config?) + static wxString GetEncodingDescription(wxFontEncoding encoding); + // configure the appearance of the dialogs we may popup // ---------------------------------------------------- +#if wxUSE_GUI + // the parent window for modal dialogs + void SetDialogParent(wxWindow *parent) { m_windowParent = parent; } + + // the title for the dialogs (note that default is quite reasonable) void SetDialogTitle(const wxString& title) { m_titleDialog = title; } +#endif // wxUSE_GUI // functions which allow to configure the config object used: by default, // the global one (from wxConfigBase::Get() will be used) and the default @@ -65,6 +121,7 @@ public: // GetDefaultConfigPath() // ---------------------------------------------------------------------- +#if wxUSE_CONFIG // set the config object to use (may be NULL to use default) void SetConfig(wxConfigBase *config) { m_config = config; } @@ -73,8 +130,11 @@ public: // return default config path static const wxChar *GetDefaultConfigPath(); +#endif protected: + +#if wxUSE_CONFIG // 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(); @@ -82,6 +142,7 @@ protected: // gets the root path for our settings - if itwasn't set explicitly, use // GetDefaultConfigPath() const wxString& GetConfigPath(); +#endif // change to the given (relative) path in the config, return TRUE if ok // (then GetConfig() will return something !NULL), FALSE if no config @@ -94,15 +155,58 @@ protected: // restore the config path after use void RestorePath(const wxString& pathOld); +#if wxUSE_GUI + // GetAltForEncoding() helper: tests for the existence of the given + // encoding and saves the result in config if ok - this results in the + // following (desired) behaviour: when an unknown/unavailable encoding is + // requested for the first time, the user is asked about a replacement, + // but if he doesn't choose any and the default logic finds one, it will + // be saved in the config so that the user won't be asked about it any + // more + bool TestAltEncoding(const wxString& configEntry, + wxFontEncoding encReplacement, + wxNativeEncodingInfo *info); +#endif // wxUSE_GUI + +#if wxUSE_CONFIG // config object and path (in it) to use wxConfigBase *m_config; + bool m_configIsDummy; +#endif + wxString m_configRootPath; +#if wxUSE_GUI // the title for our dialogs wxString m_titleDialog; // the parent window for our dialogs wxWindow *m_windowParent; +#endif // wxUSE_GUI + + friend class wxFontMapperPathChanger; + +private: + static wxFontMapper *sm_instance; + + DECLARE_NO_COPY_CLASS(wxFontMapper) }; +// ---------------------------------------------------------------------------- +// global variables +// ---------------------------------------------------------------------------- + +// the default font mapper for wxWindows programs +// do NOT use! This is for backward compatibility, use wxFontMapper::Get() instead +#define wxTheFontMapper (wxFontMapper::Get()) + +#else // !wxUSE_FONTMAP + +#if wxUSE_GUI + // wxEncodingToCodepage (utils.cpp) needs wxGetNativeFontEncoding + #include "wx/fontutil.h" +#endif + +#endif // wxUSE_FONTMAP/!wxUSE_FONTMAP + #endif // _WX_FONTMAPPER_H_