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