]> git.saurik.com Git - wxWidgets.git/blame - include/wx/font.h
Make wxString::WorstEncodingCase take a const wxMBConv&
[wxWidgets.git] / include / wx / font.h
CommitLineData
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
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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 31class WXDLLEXPORT wxFontData;
0c5d3e1c
VZ
32class WXDLLEXPORT wxFontBase;
33class WXDLLEXPORT wxFont;
dcb139ff 34class WXDLLEXPORT wxSize;
0c5d3e1c
VZ
35
36// ----------------------------------------------------------------------------
37// font constants
38// ----------------------------------------------------------------------------
39
409d5a58
VZ
40// standard font families: these may be used only for the font creation, it
41// doesn't make sense to query an existing font for its font family as,
42// especially if the font had been created from a native font description, it
43// may be unknown
0c5d3e1c
VZ
44enum wxFontFamily
45{
46 wxFONTFAMILY_DEFAULT = wxDEFAULT,
47 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
48 wxFONTFAMILY_ROMAN = wxROMAN,
49 wxFONTFAMILY_SCRIPT = wxSCRIPT,
50 wxFONTFAMILY_SWISS = wxSWISS,
51 wxFONTFAMILY_MODERN = wxMODERN,
52 wxFONTFAMILY_TELETYPE = wxTELETYPE,
409d5a58
VZ
53 wxFONTFAMILY_MAX,
54 wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
0c5d3e1c
VZ
55};
56
57// font styles
58enum wxFontStyle
59{
60 wxFONTSTYLE_NORMAL = wxNORMAL,
61 wxFONTSTYLE_ITALIC = wxITALIC,
62 wxFONTSTYLE_SLANT = wxSLANT,
63 wxFONTSTYLE_MAX
64};
65
66// font weights
67enum wxFontWeight
68{
69 wxFONTWEIGHT_NORMAL = wxNORMAL,
70 wxFONTWEIGHT_LIGHT = wxLIGHT,
71 wxFONTWEIGHT_BOLD = wxBOLD,
72 wxFONTWEIGHT_MAX
73};
74
01cb1c26
VZ
75// the font flag bits for the new font ctor accepting one combined flags word
76enum
77{
78 // no special flags: font with default weight/slant/anti-aliasing
79 wxFONTFLAG_DEFAULT = 0,
80
81 // slant flags (default: no slant)
82 wxFONTFLAG_ITALIC = 1 << 0,
83 wxFONTFLAG_SLANT = 1 << 1,
84
85 // weight flags (default: medium)
86 wxFONTFLAG_LIGHT = 1 << 2,
87 wxFONTFLAG_BOLD = 1 << 3,
88
89 // anti-aliasing flag: force on or off (default: the current system default)
90 wxFONTFLAG_ANTIALIASED = 1 << 4,
91 wxFONTFLAG_NOT_ANTIALIASED = 1 << 5,
92
93 // underlined/strikethrough flags (default: no lines)
94 wxFONTFLAG_UNDERLINED = 1 << 6,
95 wxFONTFLAG_STRIKETHROUGH = 1 << 7,
96
97 // the mask of all currently used flags
98 wxFONTFLAG_MASK = wxFONTFLAG_ITALIC |
99 wxFONTFLAG_SLANT |
100 wxFONTFLAG_LIGHT |
101 wxFONTFLAG_BOLD |
102 wxFONTFLAG_ANTIALIASED |
103 wxFONTFLAG_NOT_ANTIALIASED |
104 wxFONTFLAG_UNDERLINED |
105 wxFONTFLAG_STRIKETHROUGH
106};
107
0c5d3e1c
VZ
108// ----------------------------------------------------------------------------
109// wxFontBase represents a font object
110// ----------------------------------------------------------------------------
111
4d85bcd1 112class WXDLLEXPORT wxFontRefData;
76e23cdb 113struct WXDLLEXPORT wxNativeFontInfo;
4d85bcd1 114
6f4968e2 115class WXDLLEXPORT wxFontBase : public wxGDIObject
0c5d3e1c
VZ
116{
117public:
118 // creator function
799ea011 119 virtual ~wxFontBase();
7826e2dd
VZ
120
121 // from the font components
0c5d3e1c
VZ
122 static wxFont *New(
123 int pointSize, // size of the font in points
124 int family, // see wxFontFamily enum
125 int style, // see wxFontStyle enum
126 int weight, // see wxFontWeight enum
a62848fd 127 bool underlined = false, // not underlined by default
0c5d3e1c
VZ
128 const wxString& face = wxEmptyString, // facename
129 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
7826e2dd 130
01cb1c26
VZ
131 // from the font components but using the font flags instead of separate
132 // parameters for each flag
133 static wxFont *New(int pointSize,
134 wxFontFamily family,
135 int flags = wxFONTFLAG_DEFAULT,
136 const wxString& face = wxEmptyString,
137 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
138
544229d1
VZ
139 // from the font components
140 static wxFont *New(
141 const wxSize& pixelSize, // size of the font in pixels
142 int family, // see wxFontFamily enum
143 int style, // see wxFontStyle enum
144 int weight, // see wxFontWeight enum
145 bool underlined = FALSE, // not underlined by default
146 const wxString& face = wxEmptyString, // facename
147 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
148
149 // from the font components but using the font flags instead of separate
150 // parameters for each flag
151 static wxFont *New(const wxSize& pixelSize,
152 wxFontFamily family,
153 int flags = wxFONTFLAG_DEFAULT,
154 const wxString& face = wxEmptyString,
155 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
156
7826e2dd
VZ
157 // from the (opaque) native font description object
158 static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
159
160 // from the string representation of wxNativeFontInfo
161 static wxFont *New(const wxString& strNativeFontDesc);
0c5d3e1c
VZ
162
163 // was the font successfully created?
164 bool Ok() const { return m_refData != NULL; }
165
166 // comparison
167 bool operator == (const wxFont& font) const;
168 bool operator != (const wxFont& font) const;
169
170 // accessors: get the font characteristics
171 virtual int GetPointSize() const = 0;
544229d1
VZ
172 virtual wxSize GetPixelSize() const;
173 virtual bool IsUsingSizeInPixels() const;
0c5d3e1c
VZ
174 virtual int GetFamily() const = 0;
175 virtual int GetStyle() const = 0;
176 virtual int GetWeight() const = 0;
177 virtual bool GetUnderlined() const = 0;
178 virtual wxString GetFaceName() const = 0;
179 virtual wxFontEncoding GetEncoding() const = 0;
3bf5a59b 180 virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
ab5fe833 181
53f6aab7
VZ
182 virtual bool IsFixedWidth() const;
183
7826e2dd 184 wxString GetNativeFontInfoDesc() const;
ab5fe833 185 wxString GetNativeFontInfoUserDesc() const;
0c5d3e1c
VZ
186
187 // change the font characteristics
188 virtual void SetPointSize( int pointSize ) = 0;
544229d1 189 virtual void SetPixelSize( const wxSize& pixelSize );
0c5d3e1c
VZ
190 virtual void SetFamily( int family ) = 0;
191 virtual void SetStyle( int style ) = 0;
192 virtual void SetWeight( int weight ) = 0;
193 virtual void SetFaceName( const wxString& faceName ) = 0;
194 virtual void SetUnderlined( bool underlined ) = 0;
195 virtual void SetEncoding(wxFontEncoding encoding) = 0;
9045ad9d
VZ
196 void SetNativeFontInfo(const wxNativeFontInfo& info)
197 { DoSetNativeFontInfo(info); }
ab5fe833 198
dccb75b6 199 void SetNativeFontInfo(const wxString& info);
ab5fe833 200 void SetNativeFontInfoUserDesc(const wxString& info);
7826e2dd 201
0c5d3e1c
VZ
202 // translate the fonts into human-readable string (i.e. GetStyleString()
203 // will return "wxITALIC" for an italic font, ...)
204 wxString GetFamilyString() const;
205 wxString GetStyleString() const;
206 wxString GetWeightString() const;
207
2b5f62a0 208 // Unofficial API, don't use
a62848fd
WS
209 virtual void SetNoAntiAliasing( bool WXUNUSED(no) = true ) { }
210 virtual bool GetNoAntiAliasing() const { return false; }
2b5f62a0 211
0c5d3e1c
VZ
212 // the default encoding is used for creating all fonts with default
213 // encoding parameter
cafbf6fb
VZ
214 static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
215 static void SetDefaultEncoding(wxFontEncoding encoding);
0c5d3e1c
VZ
216
217protected:
218 // get the internal data
4d85bcd1 219 wxFontRefData *GetFontData() const
0c5d3e1c 220 { return (wxFontRefData *)m_refData; }
9045ad9d
VZ
221
222 // the function called by both overloads of SetNativeFontInfo()
223 virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
224
0c5d3e1c
VZ
225private:
226 // the currently default encoding: by default, it's the default system
227 // encoding, but may be changed by the application using
228 // SetDefaultEncoding() to make all subsequent fonts created without
229 // specifing encoding parameter using this encoding
230 static wxFontEncoding ms_encodingDefault;
231};
232
233// include the real class declaration
ffecfa5a
JS
234#if defined(__PALMOS__)
235 #include "wx/palmos/font.h"
236#elif defined(__WXMSW__)
0c5d3e1c 237 #include "wx/msw/font.h"
2049ba38 238#elif defined(__WXMOTIF__)
0c5d3e1c 239 #include "wx/motif/font.h"
2049ba38 240#elif defined(__WXGTK__)
0c5d3e1c 241 #include "wx/gtk/font.h"
83df96d6
JS
242#elif defined(__WXX11__)
243 #include "wx/x11/font.h"
1e6feb95
VZ
244#elif defined(__WXMGL__)
245 #include "wx/mgl/font.h"
34138703 246#elif defined(__WXMAC__)
0c5d3e1c 247 #include "wx/mac/font.h"
e64df9bc
DE
248#elif defined(__WXCOCOA__)
249 #include "wx/cocoa/font.h"
1777b9bb 250#elif defined(__WXPM__)
0c5d3e1c 251 #include "wx/os2/font.h"
c801d85f
KB
252#endif
253
0c5d3e1c
VZ
254// ----------------------------------------------------------------------------
255// macros
256// ----------------------------------------------------------------------------
257
0c5d3e1c
VZ
258#define M_FONTDATA GetFontData()
259
c801d85f 260#endif
34138703 261 // _WX_FONT_H_BASE_