]>
Commit | Line | Data |
---|---|---|
0c5d3e1c VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/font.h | |
3 | // Purpose: wxFontBase class: the interface of wxFont | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 20.09.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) wxWindows team | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_FONT_H_BASE_ |
13 | #define _WX_FONT_H_BASE_ | |
c801d85f | 14 | |
af49c4b8 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
1b68e0b5 RR |
16 | #pragma interface "fontbase.h" |
17 | #endif | |
18 | ||
0c5d3e1c VZ |
19 | // ---------------------------------------------------------------------------- |
20 | // headers | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #include "wx/defs.h" // for wxDEFAULT &c | |
f6bcfd97 | 24 | #include "wx/fontenc.h" // the font encoding constants |
0c5d3e1c VZ |
25 | #include "wx/gdiobj.h" // the base class |
26 | ||
27 | // ---------------------------------------------------------------------------- | |
28 | // forward declarations | |
29 | // ---------------------------------------------------------------------------- | |
30 | ||
7beba2fc | 31 | class WXDLLEXPORT wxFontData; |
0c5d3e1c VZ |
32 | class WXDLLEXPORT wxFontBase; |
33 | class WXDLLEXPORT wxFont; | |
34 | ||
35 | // ---------------------------------------------------------------------------- | |
36 | // font constants | |
37 | // ---------------------------------------------------------------------------- | |
38 | ||
409d5a58 VZ |
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 | |
42 | // may be unknown | |
0c5d3e1c VZ |
43 | enum wxFontFamily |
44 | { | |
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, | |
409d5a58 VZ |
52 | wxFONTFAMILY_MAX, |
53 | wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX | |
0c5d3e1c VZ |
54 | }; |
55 | ||
56 | // font styles | |
57 | enum wxFontStyle | |
58 | { | |
59 | wxFONTSTYLE_NORMAL = wxNORMAL, | |
60 | wxFONTSTYLE_ITALIC = wxITALIC, | |
61 | wxFONTSTYLE_SLANT = wxSLANT, | |
62 | wxFONTSTYLE_MAX | |
63 | }; | |
64 | ||
65 | // font weights | |
66 | enum wxFontWeight | |
67 | { | |
68 | wxFONTWEIGHT_NORMAL = wxNORMAL, | |
69 | wxFONTWEIGHT_LIGHT = wxLIGHT, | |
70 | wxFONTWEIGHT_BOLD = wxBOLD, | |
71 | wxFONTWEIGHT_MAX | |
72 | }; | |
73 | ||
01cb1c26 VZ |
74 | // the font flag bits for the new font ctor accepting one combined flags word |
75 | enum | |
76 | { | |
77 | // no special flags: font with default weight/slant/anti-aliasing | |
78 | wxFONTFLAG_DEFAULT = 0, | |
79 | ||
80 | // slant flags (default: no slant) | |
81 | wxFONTFLAG_ITALIC = 1 << 0, | |
82 | wxFONTFLAG_SLANT = 1 << 1, | |
83 | ||
84 | // weight flags (default: medium) | |
85 | wxFONTFLAG_LIGHT = 1 << 2, | |
86 | wxFONTFLAG_BOLD = 1 << 3, | |
87 | ||
88 | // anti-aliasing flag: force on or off (default: the current system default) | |
89 | wxFONTFLAG_ANTIALIASED = 1 << 4, | |
90 | wxFONTFLAG_NOT_ANTIALIASED = 1 << 5, | |
91 | ||
92 | // underlined/strikethrough flags (default: no lines) | |
93 | wxFONTFLAG_UNDERLINED = 1 << 6, | |
94 | wxFONTFLAG_STRIKETHROUGH = 1 << 7, | |
95 | ||
96 | // the mask of all currently used flags | |
97 | wxFONTFLAG_MASK = wxFONTFLAG_ITALIC | | |
98 | wxFONTFLAG_SLANT | | |
99 | wxFONTFLAG_LIGHT | | |
100 | wxFONTFLAG_BOLD | | |
101 | wxFONTFLAG_ANTIALIASED | | |
102 | wxFONTFLAG_NOT_ANTIALIASED | | |
103 | wxFONTFLAG_UNDERLINED | | |
104 | wxFONTFLAG_STRIKETHROUGH | |
105 | }; | |
106 | ||
0c5d3e1c VZ |
107 | // ---------------------------------------------------------------------------- |
108 | // wxFontBase represents a font object | |
109 | // ---------------------------------------------------------------------------- | |
110 | ||
4d85bcd1 | 111 | class WXDLLEXPORT wxFontRefData; |
76e23cdb | 112 | struct WXDLLEXPORT wxNativeFontInfo; |
4d85bcd1 | 113 | |
6f4968e2 | 114 | class WXDLLEXPORT wxFontBase : public wxGDIObject |
0c5d3e1c VZ |
115 | { |
116 | public: | |
117 | // creator function | |
799ea011 | 118 | virtual ~wxFontBase(); |
7826e2dd VZ |
119 | |
120 | // from the font components | |
0c5d3e1c VZ |
121 | static wxFont *New( |
122 | int pointSize, // size of the font in points | |
123 | int family, // see wxFontFamily enum | |
124 | int style, // see wxFontStyle enum | |
125 | int weight, // see wxFontWeight enum | |
126 | bool underlined = FALSE, // not underlined by default | |
127 | const wxString& face = wxEmptyString, // facename | |
128 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... | |
7826e2dd | 129 | |
01cb1c26 VZ |
130 | // from the font components but using the font flags instead of separate |
131 | // parameters for each flag | |
132 | static wxFont *New(int pointSize, | |
133 | wxFontFamily family, | |
134 | int flags = wxFONTFLAG_DEFAULT, | |
135 | const wxString& face = wxEmptyString, | |
136 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
137 | ||
7826e2dd VZ |
138 | // from the (opaque) native font description object |
139 | static wxFont *New(const wxNativeFontInfo& nativeFontDesc); | |
140 | ||
141 | // from the string representation of wxNativeFontInfo | |
142 | static wxFont *New(const wxString& strNativeFontDesc); | |
0c5d3e1c VZ |
143 | |
144 | // was the font successfully created? | |
145 | bool Ok() const { return m_refData != NULL; } | |
146 | ||
147 | // comparison | |
148 | bool operator == (const wxFont& font) const; | |
149 | bool operator != (const wxFont& font) const; | |
150 | ||
151 | // accessors: get the font characteristics | |
152 | virtual int GetPointSize() const = 0; | |
153 | virtual int GetFamily() const = 0; | |
154 | virtual int GetStyle() const = 0; | |
155 | virtual int GetWeight() const = 0; | |
156 | virtual bool GetUnderlined() const = 0; | |
157 | virtual wxString GetFaceName() const = 0; | |
158 | virtual wxFontEncoding GetEncoding() const = 0; | |
7826e2dd | 159 | virtual wxNativeFontInfo *GetNativeFontInfo() const; |
ab5fe833 | 160 | |
53f6aab7 VZ |
161 | virtual bool IsFixedWidth() const; |
162 | ||
7826e2dd | 163 | wxString GetNativeFontInfoDesc() const; |
ab5fe833 | 164 | wxString GetNativeFontInfoUserDesc() const; |
0c5d3e1c VZ |
165 | |
166 | // change the font characteristics | |
167 | virtual void SetPointSize( int pointSize ) = 0; | |
168 | virtual void SetFamily( int family ) = 0; | |
169 | virtual void SetStyle( int style ) = 0; | |
170 | virtual void SetWeight( int weight ) = 0; | |
171 | virtual void SetFaceName( const wxString& faceName ) = 0; | |
172 | virtual void SetUnderlined( bool underlined ) = 0; | |
173 | virtual void SetEncoding(wxFontEncoding encoding) = 0; | |
30764ab5 | 174 | virtual void SetNativeFontInfo(const wxNativeFontInfo& info); |
ab5fe833 | 175 | |
dccb75b6 | 176 | void SetNativeFontInfo(const wxString& info); |
ab5fe833 | 177 | void SetNativeFontInfoUserDesc(const wxString& info); |
7826e2dd | 178 | |
0c5d3e1c VZ |
179 | // translate the fonts into human-readable string (i.e. GetStyleString() |
180 | // will return "wxITALIC" for an italic font, ...) | |
181 | wxString GetFamilyString() const; | |
182 | wxString GetStyleString() const; | |
183 | wxString GetWeightString() const; | |
184 | ||
2b5f62a0 VZ |
185 | // Unofficial API, don't use |
186 | virtual void SetNoAntiAliasing( bool no = TRUE ) { } | |
187 | virtual bool GetNoAntiAliasing() { return FALSE; } | |
188 | ||
0c5d3e1c VZ |
189 | // the default encoding is used for creating all fonts with default |
190 | // encoding parameter | |
cafbf6fb VZ |
191 | static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } |
192 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
0c5d3e1c VZ |
193 | |
194 | protected: | |
195 | // get the internal data | |
4d85bcd1 | 196 | wxFontRefData *GetFontData() const |
0c5d3e1c | 197 | { return (wxFontRefData *)m_refData; } |
2b5f62a0 | 198 | |
0c5d3e1c VZ |
199 | private: |
200 | // the currently default encoding: by default, it's the default system | |
201 | // encoding, but may be changed by the application using | |
202 | // SetDefaultEncoding() to make all subsequent fonts created without | |
203 | // specifing encoding parameter using this encoding | |
204 | static wxFontEncoding ms_encodingDefault; | |
205 | }; | |
206 | ||
207 | // include the real class declaration | |
2049ba38 | 208 | #if defined(__WXMSW__) |
0c5d3e1c | 209 | #include "wx/msw/font.h" |
2049ba38 | 210 | #elif defined(__WXMOTIF__) |
0c5d3e1c | 211 | #include "wx/motif/font.h" |
2049ba38 | 212 | #elif defined(__WXGTK__) |
0c5d3e1c | 213 | #include "wx/gtk/font.h" |
83df96d6 JS |
214 | #elif defined(__WXX11__) |
215 | #include "wx/x11/font.h" | |
1e6feb95 VZ |
216 | #elif defined(__WXMGL__) |
217 | #include "wx/mgl/font.h" | |
34138703 | 218 | #elif defined(__WXMAC__) |
0c5d3e1c | 219 | #include "wx/mac/font.h" |
1777b9bb | 220 | #elif defined(__WXPM__) |
0c5d3e1c | 221 | #include "wx/os2/font.h" |
c801d85f KB |
222 | #endif |
223 | ||
0c5d3e1c VZ |
224 | // ---------------------------------------------------------------------------- |
225 | // macros | |
226 | // ---------------------------------------------------------------------------- | |
227 | ||
0c5d3e1c VZ |
228 | #define M_FONTDATA GetFontData() |
229 | ||
c801d85f | 230 | #endif |
34138703 | 231 | // _WX_FONT_H_BASE_ |