1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFont class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "font.h"
19 #include "wx/gdiobj.h"
22 class WXDLLEXPORT wxFont
;
24 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
26 friend class WXDLLEXPORT wxFont
;
29 wxFontRefData(const wxFontRefData
& data
);
39 // A list of XFontStructs indexed by scale (*100)
40 wxList m_fontsByScale
;
43 #define M_FONTDATA ((wxFontRefData *)m_refData)
45 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
48 class WXDLLEXPORT wxFont
: public wxGDIObject
50 DECLARE_DYNAMIC_CLASS(wxFont
)
53 wxFont(int pointSize
, int family
, int style
, int weight
, bool underlined
= FALSE
, const wxString
& faceName
= wxEmptyString
);
54 inline wxFont(const wxFont
& font
) { Ref(font
); }
55 inline wxFont(const wxFont
* font
) { if (font
) Ref(*font
); }
59 bool Create(int pointSize
, int family
, int style
, int weight
, bool underlined
= FALSE
, const wxString
& faceName
= wxEmptyString
);
61 virtual bool Ok() const { return (m_refData
!= NULL
) ; }
63 inline int GetPointSize() const { return M_FONTDATA
->m_pointSize
; }
64 inline int GetFamily() const { return M_FONTDATA
->m_family
; }
65 inline int GetStyle() const { return M_FONTDATA
->m_style
; }
66 inline int GetWeight() const { return M_FONTDATA
->m_weight
; }
67 wxString
GetFamilyString() const ;
68 wxString
GetFaceName() const ;
69 wxString
GetStyleString() const ;
70 wxString
GetWeightString() const ;
71 inline bool GetUnderlined() const { return M_FONTDATA
->m_underlined
; }
73 void SetPointSize(int pointSize
);
74 void SetFamily(int family
);
75 void SetStyle(int style
);
76 void SetWeight(int weight
);
77 void SetFaceName(const wxString
& faceName
);
78 void SetUnderlined(bool underlined
);
80 inline wxFont
& operator = (const wxFont
& font
) { if (*this == font
) return (*this); Ref(font
); return *this; }
81 inline bool operator == (const wxFont
& font
) { return m_refData
== font
.m_refData
; }
82 inline bool operator != (const wxFont
& font
) { return m_refData
!= font
.m_refData
; }
86 // Find an existing, or create a new, XFontStruct
87 // based on this wxFont and the given scale. Append the
88 // font to list in the private data for future reference.
90 // TODO This is a very basic implementation, that doesn't
91 // allow for different facenames, and also doesn't do a mapping
92 // between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
93 // and the fonts that are available on a particular system.
94 // Maybe we need to scan the user's machine to build up a profile
95 // of the fonts and a mapping file.
97 WXFontStructPtr
FindOrCreateFontStruct(double scale
= 1.0);
98 WXFontStructPtr
LoadQueryFont(int pointSize
, int family
, int style
,
99 int weight
, bool underlined
);
101 bool RealizeResource();