]> git.saurik.com Git - wxWidgets.git/blob - include/wx/font.h
OS/2 updates for debugging and statusbar processing
[wxWidgets.git] / include / wx / font.h
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
12 #ifndef _WX_FONT_H_BASE_
13 #define _WX_FONT_H_BASE_
14
15 #ifdef __GNUG__
16 #pragma interface "fontbase.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // headers
21 // ----------------------------------------------------------------------------
22
23 #include "wx/defs.h" // for wxDEFAULT &c
24 #include "wx/fontenc.h" // the font encoding constants
25 #include "wx/gdiobj.h" // the base class
26
27 // ----------------------------------------------------------------------------
28 // forward declarations
29 // ----------------------------------------------------------------------------
30
31 class WXDLLEXPORT wxFontData;
32 class WXDLLEXPORT wxFontBase;
33 class WXDLLEXPORT wxFont;
34
35 // ----------------------------------------------------------------------------
36 // font constants
37 // ----------------------------------------------------------------------------
38
39 // standard font families
40 enum 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,
49 wxFONTFAMILY_MAX
50 };
51
52 // font styles
53 enum wxFontStyle
54 {
55 wxFONTSTYLE_NORMAL = wxNORMAL,
56 wxFONTSTYLE_ITALIC = wxITALIC,
57 wxFONTSTYLE_SLANT = wxSLANT,
58 wxFONTSTYLE_MAX
59 };
60
61 // font weights
62 enum wxFontWeight
63 {
64 wxFONTWEIGHT_NORMAL = wxNORMAL,
65 wxFONTWEIGHT_LIGHT = wxLIGHT,
66 wxFONTWEIGHT_BOLD = wxBOLD,
67 wxFONTWEIGHT_MAX
68 };
69
70 // ----------------------------------------------------------------------------
71 // wxFontBase represents a font object
72 // ----------------------------------------------------------------------------
73
74 class WXDLLEXPORT wxFontRefData;
75
76 class WXDLLEXPORT wxFontBase : public wxGDIObject
77 {
78 public:
79 // creator function
80 static wxFont *New(
81 int pointSize, // size of the font in points
82 int family, // see wxFontFamily enum
83 int style, // see wxFontStyle enum
84 int weight, // see wxFontWeight enum
85 bool underlined = FALSE, // not underlined by default
86 const wxString& face = wxEmptyString, // facename
87 wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
88
89 // was the font successfully created?
90 bool Ok() const { return m_refData != NULL; }
91
92 // comparison
93 bool operator == (const wxFont& font) const;
94 bool operator != (const wxFont& font) const;
95
96 // accessors: get the font characteristics
97 virtual int GetPointSize() const = 0;
98 virtual int GetFamily() const = 0;
99 virtual int GetStyle() const = 0;
100 virtual int GetWeight() const = 0;
101 virtual bool GetUnderlined() const = 0;
102 virtual wxString GetFaceName() const = 0;
103 virtual wxFontEncoding GetEncoding() const = 0;
104
105 // change the font characteristics
106 virtual void SetPointSize( int pointSize ) = 0;
107 virtual void SetFamily( int family ) = 0;
108 virtual void SetStyle( int style ) = 0;
109 virtual void SetWeight( int weight ) = 0;
110 virtual void SetFaceName( const wxString& faceName ) = 0;
111 virtual void SetUnderlined( bool underlined ) = 0;
112 virtual void SetEncoding(wxFontEncoding encoding) = 0;
113
114 // translate the fonts into human-readable string (i.e. GetStyleString()
115 // will return "wxITALIC" for an italic font, ...)
116 wxString GetFamilyString() const;
117 wxString GetStyleString() const;
118 wxString GetWeightString() const;
119
120 // the default encoding is used for creating all fonts with default
121 // encoding parameter
122 static wxFontEncoding GetDefaultEncoding()
123 { return ms_encodingDefault; }
124 static void SetDefaultEncoding(wxFontEncoding encoding)
125 { ms_encodingDefault = encoding; }
126
127 protected:
128 // get the internal data
129 wxFontRefData *GetFontData() const
130 { return (wxFontRefData *)m_refData; }
131
132 private:
133 // the currently default encoding: by default, it's the default system
134 // encoding, but may be changed by the application using
135 // SetDefaultEncoding() to make all subsequent fonts created without
136 // specifing encoding parameter using this encoding
137 static wxFontEncoding ms_encodingDefault;
138 };
139
140 // include the real class declaration
141 #if defined(__WXMSW__)
142 #include "wx/msw/font.h"
143 #elif defined(__WXMOTIF__)
144 #include "wx/motif/font.h"
145 #elif defined(__WXGTK__)
146 #include "wx/gtk/font.h"
147 #elif defined(__WXQT__)
148 #include "wx/qt/font.h"
149 #elif defined(__WXMAC__)
150 #include "wx/mac/font.h"
151 #elif defined(__WXPM__)
152 #include "wx/os2/font.h"
153 #elif defined(__WXSTUBS__)
154 #include "wx/stubs/font.h"
155 #endif
156
157 // ----------------------------------------------------------------------------
158 // macros
159 // ----------------------------------------------------------------------------
160
161 #define M_FONTDATA GetFontData()
162
163 #endif
164 // _WX_FONT_H_BASE_