1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFont class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/gdicmn.h"
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 class WXDLLIMPEXP_CORE wxFont
: public wxFontBase
27 #if FUTURE_WXWIN_COMPATIBILITY_3_0
32 bool underlined
= false,
33 const wxString
& face
= wxEmptyString
,
34 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
36 (void)Create(size
, (wxFontFamily
)family
, (wxFontStyle
)style
, (wxFontWeight
)weight
, underlined
, face
, encoding
);
44 bool underlined
= false,
45 const wxString
& face
= wxEmptyString
,
46 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
48 Create(size
, family
, style
, weight
, underlined
, face
, encoding
);
51 wxFont(const wxSize
& pixelSize
,
55 bool underlined
= false,
56 const wxString
& face
= wxEmptyString
,
57 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
59 Create(10, family
, style
, weight
, underlined
, face
, encoding
);
60 SetPixelSize(pixelSize
);
67 bool underlined
= false,
68 const wxString
& face
= wxEmptyString
,
69 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
71 return DoCreate(size
, wxDefaultSize
, false, family
, style
,
72 weight
, underlined
, face
, encoding
);
75 #if FUTURE_WXWIN_COMPATIBILITY_3_0
76 wxFont(const wxSize
& pixelSize
,
80 bool underlined
= false,
81 const wxString
& face
= wxEmptyString
,
82 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
84 (void)Create(pixelSize
, (wxFontFamily
)family
, (wxFontStyle
)style
, (wxFontWeight
)weight
,
85 underlined
, face
, encoding
);
89 wxFont(const wxSize
& pixelSize
,
93 bool underlined
= false,
94 const wxString
& face
= wxEmptyString
,
95 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
97 (void)Create(pixelSize
, family
, style
, weight
,
98 underlined
, face
, encoding
);
101 wxFont(const wxNativeFontInfo
& info
, WXHFONT hFont
= 0)
106 wxFont(const wxString
& fontDesc
);
109 bool Create(const wxSize
& pixelSize
,
113 bool underlined
= false,
114 const wxString
& face
= wxEmptyString
,
115 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
)
117 return DoCreate(-1, pixelSize
, true, family
, style
,
118 weight
, underlined
, face
, encoding
);
121 bool Create(const wxNativeFontInfo
& info
, WXHFONT hFont
= 0);
125 // wxFontBase overridden functions
126 virtual wxString
GetNativeFontInfoDesc() const;
127 virtual wxString
GetNativeFontInfoUserDesc() const;
129 // implement base class pure virtuals
130 virtual int GetPointSize() const;
131 virtual wxSize
GetPixelSize() const;
132 virtual bool IsUsingSizeInPixels() const;
133 virtual wxFontFamily
GetFamily() const;
134 virtual wxFontStyle
GetStyle() const;
135 virtual wxFontWeight
GetWeight() const;
136 virtual bool GetUnderlined() const;
137 virtual wxString
GetFaceName() const;
138 virtual wxFontEncoding
GetEncoding() const;
139 virtual const wxNativeFontInfo
*GetNativeFontInfo() const;
141 virtual void SetPointSize(int pointSize
);
142 virtual void SetPixelSize(const wxSize
& pixelSize
);
143 virtual void SetFamily(wxFontFamily family
);
144 virtual void SetStyle(wxFontStyle style
);
145 virtual void SetWeight(wxFontWeight weight
);
146 virtual bool SetFaceName(const wxString
& faceName
);
147 virtual void SetUnderlined(bool underlined
);
148 virtual void SetEncoding(wxFontEncoding encoding
);
150 WXDECLARE_COMPAT_SETTERS
152 virtual bool IsFixedWidth() const;
154 // implementation only from now on
155 // -------------------------------
157 virtual bool IsFree() const;
158 virtual bool RealizeResource();
159 virtual WXHANDLE
GetResourceHandle() const;
160 virtual bool FreeResource(bool force
= false);
162 // for consistency with other wxMSW classes
163 WXHFONT
GetHFONT() const;
166 // real font creation function, used in all cases
167 bool DoCreate(int size
,
168 const wxSize
& pixelSize
,
169 bool sizeUsingPixels
,
173 bool underlined
= false,
174 const wxString
& face
= wxEmptyString
,
175 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
);
177 virtual void DoSetNativeFontInfo(const wxNativeFontInfo
& info
);
179 // implement wxObject virtuals which are used by AllocExclusive()
180 virtual wxGDIRefData
*CreateGDIRefData() const;
181 virtual wxGDIRefData
*CloneGDIRefData(const wxGDIRefData
*data
) const;
184 DECLARE_DYNAMIC_CLASS(wxFont
)
187 #endif // _WX_FONT_H_