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: these may be used only for the font creation, it
40 // doesn't make sense to query an existing font for its font family as,
41 // especially if the font had been created from a native font description, it
45 wxFONTFAMILY_DEFAULT
= wxDEFAULT
,
46 wxFONTFAMILY_DECORATIVE
= wxDECORATIVE
,
47 wxFONTFAMILY_ROMAN
= wxROMAN
,
48 wxFONTFAMILY_SCRIPT
= wxSCRIPT
,
49 wxFONTFAMILY_SWISS
= wxSWISS
,
50 wxFONTFAMILY_MODERN
= wxMODERN
,
51 wxFONTFAMILY_TELETYPE
= wxTELETYPE
,
53 wxFONTFAMILY_UNKNOWN
= wxFONTFAMILY_MAX
59 wxFONTSTYLE_NORMAL
= wxNORMAL
,
60 wxFONTSTYLE_ITALIC
= wxITALIC
,
61 wxFONTSTYLE_SLANT
= wxSLANT
,
68 wxFONTWEIGHT_NORMAL
= wxNORMAL
,
69 wxFONTWEIGHT_LIGHT
= wxLIGHT
,
70 wxFONTWEIGHT_BOLD
= wxBOLD
,
74 // ----------------------------------------------------------------------------
75 // wxFontBase represents a font object
76 // ----------------------------------------------------------------------------
78 class WXDLLEXPORT wxFontRefData
;
79 struct WXDLLEXPORT wxNativeFontInfo
;
81 class WXDLLEXPORT wxFontBase
: public wxGDIObject
85 virtual ~wxFontBase();
87 // from the font components
89 int pointSize
, // size of the font in points
90 int family
, // see wxFontFamily enum
91 int style
, // see wxFontStyle enum
92 int weight
, // see wxFontWeight enum
93 bool underlined
= FALSE
, // not underlined by default
94 const wxString
& face
= wxEmptyString
, // facename
95 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
); // ISO8859-X, ...
97 // from the (opaque) native font description object
98 static wxFont
*New(const wxNativeFontInfo
& nativeFontDesc
);
100 // from the string representation of wxNativeFontInfo
101 static wxFont
*New(const wxString
& strNativeFontDesc
);
103 // was the font successfully created?
104 bool Ok() const { return m_refData
!= NULL
; }
107 bool operator == (const wxFont
& font
) const;
108 bool operator != (const wxFont
& font
) const;
110 // accessors: get the font characteristics
111 virtual int GetPointSize() const = 0;
112 virtual int GetFamily() const = 0;
113 virtual int GetStyle() const = 0;
114 virtual int GetWeight() const = 0;
115 virtual bool GetUnderlined() const = 0;
116 virtual wxString
GetFaceName() const = 0;
117 virtual wxFontEncoding
GetEncoding() const = 0;
118 virtual wxNativeFontInfo
*GetNativeFontInfo() const;
120 virtual bool IsFixedWidth() const;
122 wxString
GetNativeFontInfoDesc() const;
123 wxString
GetNativeFontInfoUserDesc() const;
125 // change the font characteristics
126 virtual void SetPointSize( int pointSize
) = 0;
127 virtual void SetFamily( int family
) = 0;
128 virtual void SetStyle( int style
) = 0;
129 virtual void SetWeight( int weight
) = 0;
130 virtual void SetFaceName( const wxString
& faceName
) = 0;
131 virtual void SetUnderlined( bool underlined
) = 0;
132 virtual void SetEncoding(wxFontEncoding encoding
) = 0;
133 virtual void SetNativeFontInfo(const wxNativeFontInfo
& info
);
135 void SetNativeFontInfo(const wxString
& info
);
136 void SetNativeFontInfoUserDesc(const wxString
& info
);
138 // translate the fonts into human-readable string (i.e. GetStyleString()
139 // will return "wxITALIC" for an italic font, ...)
140 wxString
GetFamilyString() const;
141 wxString
GetStyleString() const;
142 wxString
GetWeightString() const;
144 // the default encoding is used for creating all fonts with default
145 // encoding parameter
146 static wxFontEncoding
GetDefaultEncoding()
147 { return ms_encodingDefault
; }
148 static void SetDefaultEncoding(wxFontEncoding encoding
)
149 { ms_encodingDefault
= encoding
; }
152 // get the internal data
153 wxFontRefData
*GetFontData() const
154 { return (wxFontRefData
*)m_refData
; }
157 // the currently default encoding: by default, it's the default system
158 // encoding, but may be changed by the application using
159 // SetDefaultEncoding() to make all subsequent fonts created without
160 // specifing encoding parameter using this encoding
161 static wxFontEncoding ms_encodingDefault
;
164 // include the real class declaration
165 #if defined(__WXMSW__)
166 #include "wx/msw/font.h"
167 #elif defined(__WXMOTIF__)
168 #include "wx/motif/font.h"
169 #elif defined(__WXGTK__)
170 #include "wx/gtk/font.h"
171 #elif defined(__WXMGL__)
172 #include "wx/mgl/font.h"
173 #elif defined(__WXMAC__)
174 #include "wx/mac/font.h"
175 #elif defined(__WXPM__)
176 #include "wx/os2/font.h"
177 #elif defined(__WXSTUBS__)
178 #include "wx/stubs/font.h"
181 // ----------------------------------------------------------------------------
183 // ----------------------------------------------------------------------------
185 #define M_FONTDATA GetFontData()