font.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/font.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_GTK_FONT_H_
  9. #define _WX_GTK_FONT_H_
  10. // ----------------------------------------------------------------------------
  11. // wxFont
  12. // ----------------------------------------------------------------------------
  13. class WXDLLIMPEXP_CORE wxFont : public wxFontBase
  14. {
  15. public:
  16. wxFont() { }
  17. wxFont(const wxFontInfo& info);
  18. wxFont(const wxString& nativeFontInfoString)
  19. {
  20. Create(nativeFontInfoString);
  21. }
  22. wxFont(const wxNativeFontInfo& info);
  23. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  24. wxFont(int size,
  25. int family,
  26. int style,
  27. int weight,
  28. bool underlined = false,
  29. const wxString& face = wxEmptyString,
  30. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  31. {
  32. (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
  33. }
  34. #endif
  35. wxFont(int size,
  36. wxFontFamily family,
  37. wxFontStyle style,
  38. wxFontWeight weight,
  39. bool underlined = false,
  40. const wxString& face = wxEmptyString,
  41. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  42. {
  43. Create(size, family, style, weight, underlined, face, encoding);
  44. }
  45. wxFont(const wxSize& pixelSize,
  46. wxFontFamily family,
  47. wxFontStyle style,
  48. wxFontWeight weight,
  49. bool underlined = false,
  50. const wxString& face = wxEmptyString,
  51. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  52. {
  53. Create(10, family, style, weight, underlined, face, encoding);
  54. SetPixelSize(pixelSize);
  55. }
  56. bool Create(int size,
  57. wxFontFamily family,
  58. wxFontStyle style,
  59. wxFontWeight weight,
  60. bool underlined = false,
  61. const wxString& face = wxEmptyString,
  62. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  63. // wxGTK-specific
  64. bool Create(const wxString& fontname);
  65. virtual ~wxFont();
  66. // implement base class pure virtuals
  67. virtual int GetPointSize() const;
  68. virtual wxFontStyle GetStyle() const;
  69. virtual wxFontWeight GetWeight() const;
  70. virtual wxString GetFaceName() const;
  71. virtual bool GetUnderlined() const;
  72. virtual bool GetStrikethrough() const;
  73. virtual wxFontEncoding GetEncoding() const;
  74. virtual const wxNativeFontInfo *GetNativeFontInfo() const;
  75. virtual bool IsFixedWidth() const;
  76. virtual void SetPointSize( int pointSize );
  77. virtual void SetFamily(wxFontFamily family);
  78. virtual void SetStyle(wxFontStyle style);
  79. virtual void SetWeight(wxFontWeight weight);
  80. virtual bool SetFaceName( const wxString& faceName );
  81. virtual void SetUnderlined( bool underlined );
  82. virtual void SetStrikethrough(bool strikethrough);
  83. virtual void SetEncoding(wxFontEncoding encoding);
  84. wxDECLARE_COMMON_FONT_METHODS();
  85. // Set Pango attributes in the specified layout. Currently only
  86. // underlined and strike-through attributes are handled by this function.
  87. //
  88. // If neither of them is specified, returns false, otherwise sets up the
  89. // attributes and returns true.
  90. bool GTKSetPangoAttrs(PangoLayout* layout) const;
  91. // implementation from now on
  92. void Unshare();
  93. // no data :-)
  94. protected:
  95. virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
  96. virtual wxGDIRefData* CreateGDIRefData() const;
  97. virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
  98. virtual wxFontFamily DoGetFamily() const;
  99. private:
  100. void Init();
  101. DECLARE_DYNAMIC_CLASS(wxFont)
  102. };
  103. #endif // _WX_GTK_FONT_H_