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 // wxNativeFontInfo is platform-specific font representation
72 // ----------------------------------------------------------------------------
74 // this struct should be considered as opaque font description only used by
75 // the native functions, the user code can only get the objects of this type
76 // from somewhere and pass it somewhere else (possibly save them somewhere
77 // using ToString() and restore them using FromString())
78 struct WXDLLEXPORT wxNativeFontInfo
80 #if defined(__WXGTK__)
82 #else // other platforms
84 // This is a generic implementation that should work on all ports
85 // without specific support by the port.
93 wxFontEncoding encoding
;
96 // it is important to be able to serialize wxNativeFontInfo objects to be
97 // able to store them (in config file, for example)
98 bool FromString(const wxString
& s
);
99 wxString
ToString() const;
102 WXDLLEXPORT_DATA(extern wxNativeFontInfo
) wxNullNativeFontInfo
;
104 // ----------------------------------------------------------------------------
105 // wxFontBase represents a font object
106 // ----------------------------------------------------------------------------
108 class WXDLLEXPORT wxFontRefData
;
110 class WXDLLEXPORT wxFontBase
: public wxGDIObject
115 int pointSize
, // size of the font in points
116 int family
, // see wxFontFamily enum
117 int style
, // see wxFontStyle enum
118 int weight
, // see wxFontWeight enum
119 bool underlined
= FALSE
, // not underlined by default
120 const wxString
& face
= wxEmptyString
, // facename
121 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
); // ISO8859-X, ...
122 static wxFont
*New(const wxNativeFontInfo
& info
);
124 // was the font successfully created?
125 bool Ok() const { return m_refData
!= NULL
; }
128 bool operator == (const wxFont
& font
) const;
129 bool operator != (const wxFont
& font
) const;
131 // accessors: get the font characteristics
132 virtual int GetPointSize() const = 0;
133 virtual int GetFamily() const = 0;
134 virtual int GetStyle() const = 0;
135 virtual int GetWeight() const = 0;
136 virtual bool GetUnderlined() const = 0;
137 virtual wxString
GetFaceName() const = 0;
138 virtual wxFontEncoding
GetEncoding() const = 0;
139 virtual wxNativeFontInfo
GetNativeFontInfo() const;
141 // change the font characteristics
142 virtual void SetPointSize( int pointSize
) = 0;
143 virtual void SetFamily( int family
) = 0;
144 virtual void SetStyle( int style
) = 0;
145 virtual void SetWeight( int weight
) = 0;
146 virtual void SetFaceName( const wxString
& faceName
) = 0;
147 virtual void SetUnderlined( bool underlined
) = 0;
148 virtual void SetEncoding(wxFontEncoding encoding
) = 0;
149 virtual void SetNativeFontInfo(const wxNativeFontInfo
& info
);
151 // translate the fonts into human-readable string (i.e. GetStyleString()
152 // will return "wxITALIC" for an italic font, ...)
153 wxString
GetFamilyString() const;
154 wxString
GetStyleString() const;
155 wxString
GetWeightString() const;
157 // the default encoding is used for creating all fonts with default
158 // encoding parameter
159 static wxFontEncoding
GetDefaultEncoding()
160 { return ms_encodingDefault
; }
161 static void SetDefaultEncoding(wxFontEncoding encoding
)
162 { ms_encodingDefault
= encoding
; }
165 // get the internal data
166 wxFontRefData
*GetFontData() const
167 { return (wxFontRefData
*)m_refData
; }
170 // the currently default encoding: by default, it's the default system
171 // encoding, but may be changed by the application using
172 // SetDefaultEncoding() to make all subsequent fonts created without
173 // specifing encoding parameter using this encoding
174 static wxFontEncoding ms_encodingDefault
;
177 // include the real class declaration
178 #if defined(__WXMSW__)
179 #include "wx/msw/font.h"
180 #elif defined(__WXMOTIF__)
181 #include "wx/motif/font.h"
182 #elif defined(__WXGTK__)
183 #include "wx/gtk/font.h"
184 #elif defined(__WXQT__)
185 #include "wx/qt/font.h"
186 #elif defined(__WXMAC__)
187 #include "wx/mac/font.h"
188 #elif defined(__WXPM__)
189 #include "wx/os2/font.h"
190 #elif defined(__WXSTUBS__)
191 #include "wx/stubs/font.h"
194 // ----------------------------------------------------------------------------
196 // ----------------------------------------------------------------------------
198 #define M_FONTDATA GetFontData()