fontenum.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: fontenum.h
  3. // Purpose: interface of wxFontEnumerator
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxFontEnumerator
  9. wxFontEnumerator enumerates either all available fonts on the system or only
  10. the ones with given attributes - either only fixed-width (suited for use in
  11. programs such as terminal emulators and the like) or the fonts available in
  12. the given encoding).
  13. To do this, you just have to call one of EnumerateXXX() functions - either
  14. wxFontEnumerator::EnumerateFacenames() or wxFontEnumerator::EnumerateEncodings()
  15. and the corresponding callback (wxFontEnumerator::OnFacename() or
  16. wxFontEnumerator::OnFontEncoding()) will be called repeatedly until either
  17. all fonts satisfying the specified criteria are exhausted or the callback
  18. returns @false.
  19. @section fontenum_virtual Virtual functions to override
  20. Either OnFacename or OnFontEncoding should be overridden depending on
  21. whether you plan to call EnumerateFacenames or EnumerateEncodings.
  22. Of course, if you call both of them, you should override both functions.
  23. @library{wxcore}
  24. @category{gdi}
  25. @see @ref overview_fontencoding, @ref page_samples_font, wxFont, wxFontMapper
  26. */
  27. class wxFontEnumerator
  28. {
  29. public:
  30. wxFontEnumerator();
  31. virtual ~wxFontEnumerator();
  32. /**
  33. Call OnFontEncoding() for each encoding supported by the given font -
  34. or for each encoding supported by at least some font if @a font is not specified.
  35. */
  36. virtual bool EnumerateEncodings(const wxString& font = wxEmptyString);
  37. /**
  38. Call OnFacename() for each font which supports given encoding (only if
  39. it is not @c wxFONTENCODING_SYSTEM) and is of fixed width
  40. (if @a fixedWidthOnly is @true).
  41. Calling this function with default arguments will result in enumerating all
  42. fonts available on the system.
  43. */
  44. virtual bool EnumerateFacenames(wxFontEncoding encoding = wxFONTENCODING_SYSTEM,
  45. bool fixedWidthOnly = false);
  46. /**
  47. Return array of strings containing all encodings found by
  48. EnumerateEncodings().
  49. */
  50. static wxArrayString GetEncodings(const wxString& facename = wxEmptyString);
  51. /**
  52. Return array of strings containing all facenames found by
  53. EnumerateFacenames().
  54. */
  55. static wxArrayString GetFacenames(wxFontEncoding encoding = wxFONTENCODING_SYSTEM,
  56. bool fixedWidthOnly = false);
  57. /**
  58. Returns @true if the given string is valid face name, i.e. it's the face name
  59. of an installed font and it can safely be used with wxFont::SetFaceName.
  60. */
  61. static bool IsValidFacename(const wxString& facename);
  62. /**
  63. Called by EnumerateFacenames() for each match.
  64. Return @true to continue enumeration or @false to stop it.
  65. */
  66. virtual bool OnFacename(const wxString& font);
  67. /**
  68. Called by EnumerateEncodings() for each match.
  69. Return @true to continue enumeration or @false to stop it.
  70. */
  71. virtual bool OnFontEncoding(const wxString& font,
  72. const wxString& encoding);
  73. };