]>
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$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
0c5d3e1c VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_FONT_H_BASE_ |
13 | #define _WX_FONT_H_BASE_ | |
c801d85f | 14 | |
0c5d3e1c VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/defs.h" // for wxDEFAULT &c | |
f6bcfd97 | 20 | #include "wx/fontenc.h" // the font encoding constants |
0c5d3e1c | 21 | #include "wx/gdiobj.h" // the base class |
9d7a8e4a | 22 | #include "wx/gdicmn.h" // for wxGDIObjListBase |
0c5d3e1c VZ |
23 | |
24 | // ---------------------------------------------------------------------------- | |
25 | // forward declarations | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
b5dbe15d VS |
28 | class WXDLLIMPEXP_FWD_CORE wxFontData; |
29 | class WXDLLIMPEXP_FWD_CORE wxFontBase; | |
30 | class WXDLLIMPEXP_FWD_CORE wxFont; | |
31 | class WXDLLIMPEXP_FWD_CORE wxSize; | |
0c5d3e1c VZ |
32 | |
33 | // ---------------------------------------------------------------------------- | |
34 | // font constants | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
409d5a58 VZ |
37 | // standard font families: these may be used only for the font creation, it |
38 | // doesn't make sense to query an existing font for its font family as, | |
39 | // especially if the font had been created from a native font description, it | |
40 | // may be unknown | |
0c5d3e1c VZ |
41 | enum wxFontFamily |
42 | { | |
43 | wxFONTFAMILY_DEFAULT = wxDEFAULT, | |
44 | wxFONTFAMILY_DECORATIVE = wxDECORATIVE, | |
45 | wxFONTFAMILY_ROMAN = wxROMAN, | |
46 | wxFONTFAMILY_SCRIPT = wxSCRIPT, | |
47 | wxFONTFAMILY_SWISS = wxSWISS, | |
48 | wxFONTFAMILY_MODERN = wxMODERN, | |
49 | wxFONTFAMILY_TELETYPE = wxTELETYPE, | |
409d5a58 VZ |
50 | wxFONTFAMILY_MAX, |
51 | wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX | |
0c5d3e1c VZ |
52 | }; |
53 | ||
54 | // font styles | |
55 | enum wxFontStyle | |
56 | { | |
57 | wxFONTSTYLE_NORMAL = wxNORMAL, | |
58 | wxFONTSTYLE_ITALIC = wxITALIC, | |
59 | wxFONTSTYLE_SLANT = wxSLANT, | |
60 | wxFONTSTYLE_MAX | |
61 | }; | |
62 | ||
63 | // font weights | |
64 | enum wxFontWeight | |
65 | { | |
66 | wxFONTWEIGHT_NORMAL = wxNORMAL, | |
67 | wxFONTWEIGHT_LIGHT = wxLIGHT, | |
68 | wxFONTWEIGHT_BOLD = wxBOLD, | |
69 | wxFONTWEIGHT_MAX | |
70 | }; | |
71 | ||
01cb1c26 | 72 | // the font flag bits for the new font ctor accepting one combined flags word |
0b70c946 | 73 | enum wxFontFlag |
01cb1c26 VZ |
74 | { |
75 | // no special flags: font with default weight/slant/anti-aliasing | |
76 | wxFONTFLAG_DEFAULT = 0, | |
77 | ||
78 | // slant flags (default: no slant) | |
79 | wxFONTFLAG_ITALIC = 1 << 0, | |
80 | wxFONTFLAG_SLANT = 1 << 1, | |
81 | ||
82 | // weight flags (default: medium) | |
83 | wxFONTFLAG_LIGHT = 1 << 2, | |
84 | wxFONTFLAG_BOLD = 1 << 3, | |
85 | ||
86 | // anti-aliasing flag: force on or off (default: the current system default) | |
87 | wxFONTFLAG_ANTIALIASED = 1 << 4, | |
88 | wxFONTFLAG_NOT_ANTIALIASED = 1 << 5, | |
89 | ||
90 | // underlined/strikethrough flags (default: no lines) | |
91 | wxFONTFLAG_UNDERLINED = 1 << 6, | |
92 | wxFONTFLAG_STRIKETHROUGH = 1 << 7, | |
93 | ||
94 | // the mask of all currently used flags | |
95 | wxFONTFLAG_MASK = wxFONTFLAG_ITALIC | | |
96 | wxFONTFLAG_SLANT | | |
97 | wxFONTFLAG_LIGHT | | |
98 | wxFONTFLAG_BOLD | | |
99 | wxFONTFLAG_ANTIALIASED | | |
100 | wxFONTFLAG_NOT_ANTIALIASED | | |
101 | wxFONTFLAG_UNDERLINED | | |
102 | wxFONTFLAG_STRIKETHROUGH | |
103 | }; | |
104 | ||
0c5d3e1c VZ |
105 | // ---------------------------------------------------------------------------- |
106 | // wxFontBase represents a font object | |
107 | // ---------------------------------------------------------------------------- | |
108 | ||
b5dbe15d | 109 | class WXDLLIMPEXP_FWD_CORE wxNativeFontInfo; |
4d85bcd1 | 110 | |
53a2db12 | 111 | class WXDLLIMPEXP_CORE wxFontBase : public wxGDIObject |
0c5d3e1c VZ |
112 | { |
113 | public: | |
114 | // creator function | |
799ea011 | 115 | virtual ~wxFontBase(); |
7826e2dd VZ |
116 | |
117 | // from the font components | |
0c5d3e1c VZ |
118 | static wxFont *New( |
119 | int pointSize, // size of the font in points | |
120 | int family, // see wxFontFamily enum | |
121 | int style, // see wxFontStyle enum | |
122 | int weight, // see wxFontWeight enum | |
a62848fd | 123 | bool underlined = false, // not underlined by default |
0c5d3e1c VZ |
124 | const wxString& face = wxEmptyString, // facename |
125 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... | |
7826e2dd | 126 | |
01cb1c26 VZ |
127 | // from the font components but using the font flags instead of separate |
128 | // parameters for each flag | |
129 | static wxFont *New(int pointSize, | |
130 | wxFontFamily family, | |
131 | int flags = wxFONTFLAG_DEFAULT, | |
132 | const wxString& face = wxEmptyString, | |
133 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
134 | ||
544229d1 VZ |
135 | // from the font components |
136 | static wxFont *New( | |
137 | const wxSize& pixelSize, // size of the font in pixels | |
138 | int family, // see wxFontFamily enum | |
139 | int style, // see wxFontStyle enum | |
140 | int weight, // see wxFontWeight enum | |
4055ed82 | 141 | bool underlined = false, // not underlined by default |
544229d1 VZ |
142 | const wxString& face = wxEmptyString, // facename |
143 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... | |
144 | ||
145 | // from the font components but using the font flags instead of separate | |
146 | // parameters for each flag | |
147 | static wxFont *New(const wxSize& pixelSize, | |
148 | wxFontFamily family, | |
149 | int flags = wxFONTFLAG_DEFAULT, | |
150 | const wxString& face = wxEmptyString, | |
151 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
152 | ||
7826e2dd VZ |
153 | // from the (opaque) native font description object |
154 | static wxFont *New(const wxNativeFontInfo& nativeFontDesc); | |
155 | ||
156 | // from the string representation of wxNativeFontInfo | |
157 | static wxFont *New(const wxString& strNativeFontDesc); | |
0c5d3e1c | 158 | |
0c5d3e1c | 159 | // comparison |
8f884a0d VZ |
160 | bool operator==(const wxFont& font) const; |
161 | bool operator!=(const wxFont& font) const { return !(*this == font); } | |
0c5d3e1c VZ |
162 | |
163 | // accessors: get the font characteristics | |
164 | virtual int GetPointSize() const = 0; | |
544229d1 VZ |
165 | virtual wxSize GetPixelSize() const; |
166 | virtual bool IsUsingSizeInPixels() const; | |
0c5d3e1c VZ |
167 | virtual int GetFamily() const = 0; |
168 | virtual int GetStyle() const = 0; | |
169 | virtual int GetWeight() const = 0; | |
170 | virtual bool GetUnderlined() const = 0; | |
171 | virtual wxString GetFaceName() const = 0; | |
172 | virtual wxFontEncoding GetEncoding() const = 0; | |
3bf5a59b | 173 | virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0; |
ab5fe833 | 174 | |
53f6aab7 VZ |
175 | virtual bool IsFixedWidth() const; |
176 | ||
7826e2dd | 177 | wxString GetNativeFontInfoDesc() const; |
ab5fe833 | 178 | wxString GetNativeFontInfoUserDesc() const; |
0c5d3e1c VZ |
179 | |
180 | // change the font characteristics | |
181 | virtual void SetPointSize( int pointSize ) = 0; | |
544229d1 | 182 | virtual void SetPixelSize( const wxSize& pixelSize ); |
0c5d3e1c VZ |
183 | virtual void SetFamily( int family ) = 0; |
184 | virtual void SetStyle( int style ) = 0; | |
185 | virtual void SetWeight( int weight ) = 0; | |
0c5d3e1c VZ |
186 | virtual void SetUnderlined( bool underlined ) = 0; |
187 | virtual void SetEncoding(wxFontEncoding encoding) = 0; | |
85ab460e | 188 | virtual bool SetFaceName( const wxString& faceName ); |
9045ad9d VZ |
189 | void SetNativeFontInfo(const wxNativeFontInfo& info) |
190 | { DoSetNativeFontInfo(info); } | |
ab5fe833 | 191 | |
85ab460e VZ |
192 | bool SetNativeFontInfo(const wxString& info); |
193 | bool SetNativeFontInfoUserDesc(const wxString& info); | |
7826e2dd | 194 | |
0c5d3e1c VZ |
195 | // translate the fonts into human-readable string (i.e. GetStyleString() |
196 | // will return "wxITALIC" for an italic font, ...) | |
197 | wxString GetFamilyString() const; | |
198 | wxString GetStyleString() const; | |
199 | wxString GetWeightString() const; | |
200 | ||
2b5f62a0 | 201 | // Unofficial API, don't use |
a62848fd WS |
202 | virtual void SetNoAntiAliasing( bool WXUNUSED(no) = true ) { } |
203 | virtual bool GetNoAntiAliasing() const { return false; } | |
2b5f62a0 | 204 | |
0c5d3e1c VZ |
205 | // the default encoding is used for creating all fonts with default |
206 | // encoding parameter | |
cafbf6fb VZ |
207 | static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } |
208 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
0c5d3e1c VZ |
209 | |
210 | protected: | |
9045ad9d VZ |
211 | // the function called by both overloads of SetNativeFontInfo() |
212 | virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info); | |
213 | ||
0c5d3e1c VZ |
214 | private: |
215 | // the currently default encoding: by default, it's the default system | |
216 | // encoding, but may be changed by the application using | |
217 | // SetDefaultEncoding() to make all subsequent fonts created without | |
3103e8a9 | 218 | // specifying encoding parameter using this encoding |
0c5d3e1c VZ |
219 | static wxFontEncoding ms_encodingDefault; |
220 | }; | |
221 | ||
fc9361e3 VZ |
222 | // wxFontBase <-> wxString utilities, used by wxConfig |
223 | WXDLLIMPEXP_CORE wxString wxToString(const wxFontBase& font); | |
224 | WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font); | |
225 | ||
226 | ||
227 | ||
0c5d3e1c | 228 | // include the real class declaration |
4055ed82 | 229 | #if defined(__WXPALMOS__) |
ffecfa5a JS |
230 | #include "wx/palmos/font.h" |
231 | #elif defined(__WXMSW__) | |
0c5d3e1c | 232 | #include "wx/msw/font.h" |
2049ba38 | 233 | #elif defined(__WXMOTIF__) |
0c5d3e1c | 234 | #include "wx/motif/font.h" |
1be7a35c | 235 | #elif defined(__WXGTK20__) |
0c5d3e1c | 236 | #include "wx/gtk/font.h" |
1be7a35c MR |
237 | #elif defined(__WXGTK__) |
238 | #include "wx/gtk1/font.h" | |
83df96d6 JS |
239 | #elif defined(__WXX11__) |
240 | #include "wx/x11/font.h" | |
1e6feb95 VZ |
241 | #elif defined(__WXMGL__) |
242 | #include "wx/mgl/font.h" | |
b3c86150 VS |
243 | #elif defined(__WXDFB__) |
244 | #include "wx/dfb/font.h" | |
34138703 | 245 | #elif defined(__WXMAC__) |
ef0e9220 | 246 | #include "wx/osx/font.h" |
e64df9bc DE |
247 | #elif defined(__WXCOCOA__) |
248 | #include "wx/cocoa/font.h" | |
1777b9bb | 249 | #elif defined(__WXPM__) |
0c5d3e1c | 250 | #include "wx/os2/font.h" |
c801d85f KB |
251 | #endif |
252 | ||
82cddbd9 FM |
253 | class WXDLLIMPEXP_CORE wxFontList: public wxGDIObjListBase |
254 | { | |
255 | public: | |
256 | wxFont *FindOrCreateFont(int pointSize, | |
257 | wxFontFamily family, | |
258 | wxFontStyle style, | |
259 | wxFontWeight weight, | |
260 | bool underline = false, | |
261 | const wxString& face = wxEmptyString, | |
262 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
020eeaa8 FM |
263 | |
264 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
265 | wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight, | |
266 | bool underline = false, | |
267 | const wxString& face = wxEmptyString, | |
268 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
269 | { return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style, | |
270 | (wxFontWeight)weight, underline, face, encoding); } | |
271 | #endif | |
272 | ||
82cddbd9 FM |
273 | #if WXWIN_COMPATIBILITY_2_6 |
274 | wxDEPRECATED( void AddFont(wxFont*) ); | |
275 | wxDEPRECATED( void RemoveFont(wxFont*) ); | |
276 | #endif | |
277 | }; | |
278 | ||
53a2db12 | 279 | extern WXDLLIMPEXP_DATA_CORE(wxFontList*) wxTheFontList; |
82cddbd9 | 280 | |
c801d85f | 281 | #endif |
34138703 | 282 | // _WX_FONT_H_BASE_ |