font.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/font.h
  3. // Purpose: wxFont class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_FONT_H_
  11. #define _WX_FONT_H_
  12. #include "wx/gdicmn.h"
  13. // ----------------------------------------------------------------------------
  14. // wxFont
  15. // ----------------------------------------------------------------------------
  16. class WXDLLIMPEXP_CORE wxFont : public wxFontBase
  17. {
  18. public:
  19. // ctors and such
  20. wxFont() { }
  21. wxFont(const wxFontInfo& info);
  22. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  23. wxFont(int size,
  24. int family,
  25. int style,
  26. int weight,
  27. bool underlined = false,
  28. const wxString& face = wxEmptyString,
  29. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  30. {
  31. (void)Create(size, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
  32. }
  33. #endif
  34. wxFont(int size,
  35. wxFontFamily family,
  36. wxFontStyle style,
  37. wxFontWeight weight,
  38. bool underlined = false,
  39. const wxString& face = wxEmptyString,
  40. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  41. {
  42. Create(size, family, style, weight, underlined, face, encoding);
  43. }
  44. bool Create(int size,
  45. wxFontFamily family,
  46. wxFontStyle style,
  47. wxFontWeight weight,
  48. bool underlined = false,
  49. const wxString& face = wxEmptyString,
  50. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  51. {
  52. return DoCreate(size, wxDefaultSize, false, family, style,
  53. weight, underlined, face, encoding);
  54. }
  55. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  56. wxFont(const wxSize& pixelSize,
  57. int family,
  58. int style,
  59. int weight,
  60. bool underlined = false,
  61. const wxString& face = wxEmptyString,
  62. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  63. {
  64. (void)Create(pixelSize, (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight,
  65. underlined, face, encoding);
  66. }
  67. #endif
  68. wxFont(const wxSize& pixelSize,
  69. wxFontFamily family,
  70. wxFontStyle style,
  71. wxFontWeight weight,
  72. bool underlined = false,
  73. const wxString& face = wxEmptyString,
  74. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  75. {
  76. (void)Create(pixelSize, family, style, weight,
  77. underlined, face, encoding);
  78. }
  79. wxFont(const wxNativeFontInfo& info, WXHFONT hFont = 0)
  80. {
  81. Create(info, hFont);
  82. }
  83. wxFont(const wxString& fontDesc);
  84. bool Create(const wxSize& pixelSize,
  85. wxFontFamily family,
  86. wxFontStyle style,
  87. wxFontWeight weight,
  88. bool underlined = false,
  89. const wxString& face = wxEmptyString,
  90. wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
  91. {
  92. return DoCreate(-1, pixelSize, true, family, style,
  93. weight, underlined, face, encoding);
  94. }
  95. bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
  96. virtual ~wxFont();
  97. // implement base class pure virtuals
  98. virtual int GetPointSize() const;
  99. virtual wxSize GetPixelSize() const;
  100. virtual bool IsUsingSizeInPixels() const;
  101. virtual wxFontStyle GetStyle() const;
  102. virtual wxFontWeight GetWeight() const;
  103. virtual bool GetUnderlined() const;
  104. virtual bool GetStrikethrough() const;
  105. virtual wxString GetFaceName() const;
  106. virtual wxFontEncoding GetEncoding() const;
  107. virtual const wxNativeFontInfo *GetNativeFontInfo() const;
  108. virtual void SetPointSize(int pointSize);
  109. virtual void SetPixelSize(const wxSize& pixelSize);
  110. virtual void SetFamily(wxFontFamily family);
  111. virtual void SetStyle(wxFontStyle style);
  112. virtual void SetWeight(wxFontWeight weight);
  113. virtual bool SetFaceName(const wxString& faceName);
  114. virtual void SetUnderlined(bool underlined);
  115. virtual void SetStrikethrough(bool strikethrough);
  116. virtual void SetEncoding(wxFontEncoding encoding);
  117. wxDECLARE_COMMON_FONT_METHODS();
  118. virtual bool IsFixedWidth() const;
  119. // implementation only from now on
  120. // -------------------------------
  121. virtual bool IsFree() const;
  122. virtual bool RealizeResource();
  123. virtual WXHANDLE GetResourceHandle() const;
  124. virtual bool FreeResource(bool force = false);
  125. // for consistency with other wxMSW classes
  126. WXHFONT GetHFONT() const;
  127. protected:
  128. // real font creation function, used in all cases
  129. bool DoCreate(int size,
  130. const wxSize& pixelSize,
  131. bool sizeUsingPixels,
  132. wxFontFamily family,
  133. wxFontStyle style,
  134. wxFontWeight weight,
  135. bool underlined = false,
  136. const wxString& face = wxEmptyString,
  137. wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
  138. virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
  139. virtual wxFontFamily DoGetFamily() const;
  140. // implement wxObject virtuals which are used by AllocExclusive()
  141. virtual wxGDIRefData *CreateGDIRefData() const;
  142. virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
  143. private:
  144. DECLARE_DYNAMIC_CLASS(wxFont)
  145. };
  146. #endif // _WX_FONT_H_