1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFontBase class: the interface of wxFont
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FONT_H_BASE_
13 #define _WX_FONT_H_BASE_
16 #pragma interface "fontbase.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 #include "wx/defs.h" // for wxDEFAULT &c
24 #include "wx/fontenc.h" // the font encoding constants
25 #include "wx/gdiobj.h" // the base class
27 // ----------------------------------------------------------------------------
28 // forward declarations
29 // ----------------------------------------------------------------------------
31 class WXDLLEXPORT wxFontData
;
32 class WXDLLEXPORT wxFontBase
;
33 class WXDLLEXPORT wxFont
;
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 // standard font families
42 wxFONTFAMILY_DEFAULT
= wxDEFAULT
,
43 wxFONTFAMILY_DECORATIVE
= wxDECORATIVE
,
44 wxFONTFAMILY_ROMAN
= wxROMAN
,
45 wxFONTFAMILY_SCRIPT
= wxSCRIPT
,
46 wxFONTFAMILY_SWISS
= wxSWISS
,
47 wxFONTFAMILY_MODERN
= wxMODERN
,
48 wxFONTFAMILY_TELETYPE
= wxTELETYPE
,
55 wxFONTSTYLE_NORMAL
= wxNORMAL
,
56 wxFONTSTYLE_ITALIC
= wxITALIC
,
57 wxFONTSTYLE_SLANT
= wxSLANT
,
64 wxFONTWEIGHT_NORMAL
= wxNORMAL
,
65 wxFONTWEIGHT_LIGHT
= wxLIGHT
,
66 wxFONTWEIGHT_BOLD
= wxBOLD
,
70 // ----------------------------------------------------------------------------
71 // wxFontBase represents a font object
72 // ----------------------------------------------------------------------------
74 class WXDLLEXPORT wxFontRefData
;
75 struct WXDLLEXPORT wxNativeFontInfo
;
77 class WXDLLEXPORT wxFontBase
: public wxGDIObject
81 virtual ~wxFontBase();
83 // from the font components
85 int pointSize
, // size of the font in points
86 int family
, // see wxFontFamily enum
87 int style
, // see wxFontStyle enum
88 int weight
, // see wxFontWeight enum
89 bool underlined
= FALSE
, // not underlined by default
90 const wxString
& face
= wxEmptyString
, // facename
91 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
); // ISO8859-X, ...
93 // from the (opaque) native font description object
94 static wxFont
*New(const wxNativeFontInfo
& nativeFontDesc
);
96 // from the string representation of wxNativeFontInfo
97 static wxFont
*New(const wxString
& strNativeFontDesc
);
99 // was the font successfully created?
100 bool Ok() const { return m_refData
!= NULL
; }
103 bool operator == (const wxFont
& font
) const;
104 bool operator != (const wxFont
& font
) const;
106 // accessors: get the font characteristics
107 virtual int GetPointSize() const = 0;
108 virtual int GetFamily() const = 0;
109 virtual int GetStyle() const = 0;
110 virtual int GetWeight() const = 0;
111 virtual bool GetUnderlined() const = 0;
112 virtual wxString
GetFaceName() const = 0;
113 virtual wxFontEncoding
GetEncoding() const = 0;
114 virtual wxNativeFontInfo
*GetNativeFontInfo() const;
116 wxString
GetNativeFontInfoDesc() const;
117 wxString
GetNativeFontInfoUserDesc() const;
119 // change the font characteristics
120 virtual void SetPointSize( int pointSize
) = 0;
121 virtual void SetFamily( int family
) = 0;
122 virtual void SetStyle( int style
) = 0;
123 virtual void SetWeight( int weight
) = 0;
124 virtual void SetFaceName( const wxString
& faceName
) = 0;
125 virtual void SetUnderlined( bool underlined
) = 0;
126 virtual void SetEncoding(wxFontEncoding encoding
) = 0;
127 virtual void SetNativeFontInfo(const wxNativeFontInfo
& info
);
129 void SetNativeFontInfo(const wxString
& info
);
130 void SetNativeFontInfoUserDesc(const wxString
& info
);
132 // translate the fonts into human-readable string (i.e. GetStyleString()
133 // will return "wxITALIC" for an italic font, ...)
134 wxString
GetFamilyString() const;
135 wxString
GetStyleString() const;
136 wxString
GetWeightString() const;
138 // the default encoding is used for creating all fonts with default
139 // encoding parameter
140 static wxFontEncoding
GetDefaultEncoding()
141 { return ms_encodingDefault
; }
142 static void SetDefaultEncoding(wxFontEncoding encoding
)
143 { ms_encodingDefault
= encoding
; }
146 // get the internal data
147 wxFontRefData
*GetFontData() const
148 { return (wxFontRefData
*)m_refData
; }
151 // the currently default encoding: by default, it's the default system
152 // encoding, but may be changed by the application using
153 // SetDefaultEncoding() to make all subsequent fonts created without
154 // specifing encoding parameter using this encoding
155 static wxFontEncoding ms_encodingDefault
;
158 // include the real class declaration
159 #if defined(__WXMSW__)
160 #include "wx/msw/font.h"
161 #elif defined(__WXMOTIF__)
162 #include "wx/motif/font.h"
163 #elif defined(__WXGTK__)
164 #include "wx/gtk/font.h"
165 #elif defined(__WXMGL__)
166 #include "wx/mgl/font.h"
167 #elif defined(__WXMAC__)
168 #include "wx/mac/font.h"
169 #elif defined(__WXPM__)
170 #include "wx/os2/font.h"
171 #elif defined(__WXSTUBS__)
172 #include "wx/stubs/font.h"
175 // ----------------------------------------------------------------------------
177 // ----------------------------------------------------------------------------
179 #define M_FONTDATA GetFontData()