fmappriv.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/fmappriv.h
  3. // Purpose: private wxFontMapper stuff, not to be used by the library users
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 21.06.2003 (extracted from common/fontmap.cpp)
  7. // Copyright: (c) 1999-2003 Vadim Zeitlin <vadim@wxwidgets.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FMAPPRIV_H_
  11. #define _WX_FMAPPRIV_H_
  12. // ----------------------------------------------------------------------------
  13. // constants
  14. // ----------------------------------------------------------------------------
  15. // a special pseudo encoding which means "don't ask me about this charset
  16. // any more" -- we need it to avoid driving the user crazy with asking him
  17. // time after time about the same charset which he [presumably] doesn't
  18. // have the fonts for
  19. enum { wxFONTENCODING_UNKNOWN = -2 };
  20. // the config paths we use
  21. #if wxUSE_CONFIG
  22. #define FONTMAPPER_ROOT_PATH wxT("/wxWindows/FontMapper")
  23. #define FONTMAPPER_CHARSET_PATH wxT("Charsets")
  24. #define FONTMAPPER_CHARSET_ALIAS_PATH wxT("Aliases")
  25. #endif // wxUSE_CONFIG
  26. // ----------------------------------------------------------------------------
  27. // wxFontMapperPathChanger: change the config path during our lifetime
  28. // ----------------------------------------------------------------------------
  29. #if wxUSE_CONFIG && wxUSE_FILECONFIG
  30. class wxFontMapperPathChanger
  31. {
  32. public:
  33. wxFontMapperPathChanger(wxFontMapperBase *fontMapper, const wxString& path)
  34. {
  35. m_fontMapper = fontMapper;
  36. m_ok = m_fontMapper->ChangePath(path, &m_pathOld);
  37. }
  38. bool IsOk() const { return m_ok; }
  39. ~wxFontMapperPathChanger()
  40. {
  41. if ( IsOk() )
  42. m_fontMapper->RestorePath(m_pathOld);
  43. }
  44. private:
  45. // the fontmapper object we're working with
  46. wxFontMapperBase *m_fontMapper;
  47. // the old path to be restored if m_ok
  48. wxString m_pathOld;
  49. // have we changed the path successfully?
  50. bool m_ok;
  51. wxDECLARE_NO_COPY_CLASS(wxFontMapperPathChanger);
  52. };
  53. #endif // wxUSE_CONFIG
  54. #endif // _WX_FMAPPRIV_H_