font.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk1/font.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef __GTKFONTH__
  9. #define __GTKFONTH__
  10. #include "wx/hash.h"
  11. // ----------------------------------------------------------------------------
  12. // classes
  13. // ----------------------------------------------------------------------------
  14. class WXDLLIMPEXP_FWD_CORE wxDC;
  15. class WXDLLIMPEXP_FWD_CORE wxPaintDC;
  16. class WXDLLIMPEXP_FWD_CORE wxWindow;
  17. class WXDLLIMPEXP_FWD_CORE wxFont;
  18. // ----------------------------------------------------------------------------
  19. // wxFont
  20. // ----------------------------------------------------------------------------
  21. class WXDLLIMPEXP_CORE wxFont : public wxFontBase
  22. {
  23. public:
  24. // ctors and such
  25. wxFont() { }
  26. wxFont(const wxFontInfo& info)
  27. {
  28. Create(info.GetPointSize(),
  29. info.GetFamily(),
  30. info.GetStyle(),
  31. info.GetWeight(),
  32. info.IsUnderlined(),
  33. info.GetFaceName(),
  34. info.GetEncoding());
  35. if ( info.IsUsingSizeInPixels() )
  36. SetPixelSize(info.GetPixelSize());
  37. }
  38. wxFont(const wxString& fontname)
  39. {
  40. Create(fontname);
  41. }
  42. wxFont(const wxNativeFontInfo& info);
  43. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  44. wxFont(int size,
  45. int family,
  46. int style,
  47. int weight,
  48. bool underlined = false,
  49. const wxString& face = wxEmptyString,
  50. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  51. {
  52. (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
  53. }
  54. #endif
  55. wxFont(int size,
  56. wxFontFamily family,
  57. wxFontStyle style,
  58. wxFontWeight weight,
  59. bool underlined = false,
  60. const wxString& face = wxEmptyString,
  61. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  62. {
  63. Create(size, family, style, weight, underlined, face, encoding);
  64. }
  65. wxFont(const wxSize& pixelSize,
  66. wxFontFamily family,
  67. wxFontStyle style,
  68. wxFontWeight weight,
  69. bool underlined = false,
  70. const wxString& face = wxEmptyString,
  71. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  72. {
  73. Create(10, family, style, weight, underlined, face, encoding);
  74. SetPixelSize(pixelSize);
  75. }
  76. bool Create(int size,
  77. wxFontFamily family,
  78. wxFontStyle style,
  79. wxFontWeight weight,
  80. bool underlined = false,
  81. const wxString& face = wxEmptyString,
  82. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  83. // wxGTK-specific
  84. bool Create(const wxString& fontname);
  85. virtual ~wxFont();
  86. // implement base class pure virtuals
  87. virtual int GetPointSize() const;
  88. virtual wxFontStyle GetStyle() const;
  89. virtual wxFontWeight GetWeight() const;
  90. virtual wxString GetFaceName() const;
  91. virtual bool GetUnderlined() const;
  92. virtual wxFontEncoding GetEncoding() const;
  93. virtual const wxNativeFontInfo *GetNativeFontInfo() const;
  94. virtual bool IsFixedWidth() const;
  95. virtual void SetPointSize( int pointSize );
  96. virtual void SetFamily(wxFontFamily family);
  97. virtual void SetStyle(wxFontStyle style);
  98. virtual void SetWeight(wxFontWeight weight);
  99. virtual bool SetFaceName( const wxString& faceName );
  100. virtual void SetUnderlined( bool underlined );
  101. virtual void SetEncoding(wxFontEncoding encoding);
  102. wxDECLARE_COMMON_FONT_METHODS();
  103. // implementation from now on
  104. void Unshare();
  105. GdkFont* GetInternalFont(float scale = 1.0) const;
  106. protected:
  107. virtual wxGDIRefData *CreateGDIRefData() const;
  108. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  109. virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
  110. virtual wxFontFamily DoGetFamily() const;
  111. private:
  112. DECLARE_DYNAMIC_CLASS(wxFont)
  113. };
  114. #endif // __GTKFONTH__