]> git.saurik.com Git - wxWidgets.git/blame - include/wx/font.h
A little different fix for how to delay the call to __wxCleanup
[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$
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
1b68e0b5
RR
15#ifdef __GNUG__
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;
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
43enum 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
57enum wxFontStyle
58{
59 wxFONTSTYLE_NORMAL = wxNORMAL,
60 wxFONTSTYLE_ITALIC = wxITALIC,
61 wxFONTSTYLE_SLANT = wxSLANT,
62 wxFONTSTYLE_MAX
63};
64
65// font weights
66enum wxFontWeight
67{
68 wxFONTWEIGHT_NORMAL = wxNORMAL,
69 wxFONTWEIGHT_LIGHT = wxLIGHT,
70 wxFONTWEIGHT_BOLD = wxBOLD,
71 wxFONTWEIGHT_MAX
72};
73
0c5d3e1c
VZ
74// ----------------------------------------------------------------------------
75// wxFontBase represents a font object
76// ----------------------------------------------------------------------------
77
4d85bcd1 78class WXDLLEXPORT wxFontRefData;
76e23cdb 79struct WXDLLEXPORT wxNativeFontInfo;
4d85bcd1 80
6f4968e2 81class WXDLLEXPORT wxFontBase : public wxGDIObject
0c5d3e1c
VZ
82{
83public:
84 // creator function
799ea011 85 virtual ~wxFontBase();
7826e2dd
VZ
86
87 // from the font components
0c5d3e1c
VZ
88 static wxFont *New(
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, ...
7826e2dd
VZ
96
97 // from the (opaque) native font description object
98 static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
99
100 // from the string representation of wxNativeFontInfo
101 static wxFont *New(const wxString& strNativeFontDesc);
0c5d3e1c
VZ
102
103 // was the font successfully created?
104 bool Ok() const { return m_refData != NULL; }
105
106 // comparison
107 bool operator == (const wxFont& font) const;
108 bool operator != (const wxFont& font) const;
109
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;
7826e2dd 118 virtual wxNativeFontInfo *GetNativeFontInfo() const;
ab5fe833 119
53f6aab7
VZ
120 virtual bool IsFixedWidth() const;
121
7826e2dd 122 wxString GetNativeFontInfoDesc() const;
ab5fe833 123 wxString GetNativeFontInfoUserDesc() const;
0c5d3e1c
VZ
124
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;
30764ab5 133 virtual void SetNativeFontInfo(const wxNativeFontInfo& info);
ab5fe833 134
dccb75b6 135 void SetNativeFontInfo(const wxString& info);
ab5fe833 136 void SetNativeFontInfoUserDesc(const wxString& info);
7826e2dd 137
0c5d3e1c
VZ
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;
143
144 // the default encoding is used for creating all fonts with default
145 // encoding parameter
cafbf6fb
VZ
146 static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
147 static void SetDefaultEncoding(wxFontEncoding encoding);
0c5d3e1c
VZ
148
149protected:
150 // get the internal data
4d85bcd1 151 wxFontRefData *GetFontData() const
0c5d3e1c
VZ
152 { return (wxFontRefData *)m_refData; }
153
154private:
155 // the currently default encoding: by default, it's the default system
156 // encoding, but may be changed by the application using
157 // SetDefaultEncoding() to make all subsequent fonts created without
158 // specifing encoding parameter using this encoding
159 static wxFontEncoding ms_encodingDefault;
160};
161
162// include the real class declaration
2049ba38 163#if defined(__WXMSW__)
0c5d3e1c 164 #include "wx/msw/font.h"
2049ba38 165#elif defined(__WXMOTIF__)
0c5d3e1c 166 #include "wx/motif/font.h"
2049ba38 167#elif defined(__WXGTK__)
0c5d3e1c 168 #include "wx/gtk/font.h"
83df96d6
JS
169#elif defined(__WXX11__)
170 #include "wx/x11/font.h"
1e6feb95
VZ
171#elif defined(__WXMGL__)
172 #include "wx/mgl/font.h"
34138703 173#elif defined(__WXMAC__)
0c5d3e1c 174 #include "wx/mac/font.h"
1777b9bb 175#elif defined(__WXPM__)
0c5d3e1c 176 #include "wx/os2/font.h"
34138703 177#elif defined(__WXSTUBS__)
0c5d3e1c 178 #include "wx/stubs/font.h"
c801d85f
KB
179#endif
180
0c5d3e1c
VZ
181// ----------------------------------------------------------------------------
182// macros
183// ----------------------------------------------------------------------------
184
0c5d3e1c
VZ
185#define M_FONTDATA GetFontData()
186
c801d85f 187#endif
34138703 188 // _WX_FONT_H_BASE_