]>
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$ | |
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 | 31 | class WXDLLEXPORT wxFontData; |
0c5d3e1c VZ |
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 | ||
0c5d3e1c VZ |
70 | // ---------------------------------------------------------------------------- |
71 | // wxFontBase represents a font object | |
72 | // ---------------------------------------------------------------------------- | |
73 | ||
4d85bcd1 | 74 | class WXDLLEXPORT wxFontRefData; |
76e23cdb | 75 | struct WXDLLEXPORT wxNativeFontInfo; |
4d85bcd1 | 76 | |
6f4968e2 | 77 | class WXDLLEXPORT wxFontBase : public wxGDIObject |
0c5d3e1c VZ |
78 | { |
79 | public: | |
80 | // creator function | |
799ea011 | 81 | virtual ~wxFontBase(); |
7826e2dd VZ |
82 | |
83 | // from the font components | |
0c5d3e1c VZ |
84 | static wxFont *New( |
85 | int pointSize, // size of the font in points | |
86 | int family, // see wxFontFamily enum | |
87 | int style, // see wxFontStyle enum | |
88 | int weight, // see wxFontWeight enum | |
89 | bool underlined = FALSE, // not underlined by default | |
90 | const wxString& face = wxEmptyString, // facename | |
91 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ... | |
7826e2dd VZ |
92 | |
93 | // from the (opaque) native font description object | |
94 | static wxFont *New(const wxNativeFontInfo& nativeFontDesc); | |
95 | ||
96 | // from the string representation of wxNativeFontInfo | |
97 | static wxFont *New(const wxString& strNativeFontDesc); | |
0c5d3e1c VZ |
98 | |
99 | // was the font successfully created? | |
100 | bool Ok() const { return m_refData != NULL; } | |
101 | ||
102 | // comparison | |
103 | bool operator == (const wxFont& font) const; | |
104 | bool operator != (const wxFont& font) const; | |
105 | ||
106 | // accessors: get the font characteristics | |
107 | virtual int GetPointSize() const = 0; | |
108 | virtual int GetFamily() const = 0; | |
109 | virtual int GetStyle() const = 0; | |
110 | virtual int GetWeight() const = 0; | |
111 | virtual bool GetUnderlined() const = 0; | |
112 | virtual wxString GetFaceName() const = 0; | |
113 | virtual wxFontEncoding GetEncoding() const = 0; | |
7826e2dd | 114 | virtual wxNativeFontInfo *GetNativeFontInfo() const; |
ab5fe833 | 115 | |
53f6aab7 VZ |
116 | virtual bool IsFixedWidth() const; |
117 | ||
7826e2dd | 118 | wxString GetNativeFontInfoDesc() const; |
ab5fe833 | 119 | wxString GetNativeFontInfoUserDesc() const; |
0c5d3e1c VZ |
120 | |
121 | // change the font characteristics | |
122 | virtual void SetPointSize( int pointSize ) = 0; | |
123 | virtual void SetFamily( int family ) = 0; | |
124 | virtual void SetStyle( int style ) = 0; | |
125 | virtual void SetWeight( int weight ) = 0; | |
126 | virtual void SetFaceName( const wxString& faceName ) = 0; | |
127 | virtual void SetUnderlined( bool underlined ) = 0; | |
128 | virtual void SetEncoding(wxFontEncoding encoding) = 0; | |
30764ab5 | 129 | virtual void SetNativeFontInfo(const wxNativeFontInfo& info); |
ab5fe833 | 130 | |
dccb75b6 | 131 | void SetNativeFontInfo(const wxString& info); |
ab5fe833 | 132 | void SetNativeFontInfoUserDesc(const wxString& info); |
7826e2dd | 133 | |
0c5d3e1c VZ |
134 | // translate the fonts into human-readable string (i.e. GetStyleString() |
135 | // will return "wxITALIC" for an italic font, ...) | |
136 | wxString GetFamilyString() const; | |
137 | wxString GetStyleString() const; | |
138 | wxString GetWeightString() const; | |
139 | ||
140 | // the default encoding is used for creating all fonts with default | |
141 | // encoding parameter | |
142 | static wxFontEncoding GetDefaultEncoding() | |
143 | { return ms_encodingDefault; } | |
144 | static void SetDefaultEncoding(wxFontEncoding encoding) | |
145 | { ms_encodingDefault = encoding; } | |
146 | ||
147 | protected: | |
148 | // get the internal data | |
4d85bcd1 | 149 | wxFontRefData *GetFontData() const |
0c5d3e1c VZ |
150 | { return (wxFontRefData *)m_refData; } |
151 | ||
152 | private: | |
153 | // the currently default encoding: by default, it's the default system | |
154 | // encoding, but may be changed by the application using | |
155 | // SetDefaultEncoding() to make all subsequent fonts created without | |
156 | // specifing encoding parameter using this encoding | |
157 | static wxFontEncoding ms_encodingDefault; | |
158 | }; | |
159 | ||
160 | // include the real class declaration | |
2049ba38 | 161 | #if defined(__WXMSW__) |
0c5d3e1c | 162 | #include "wx/msw/font.h" |
2049ba38 | 163 | #elif defined(__WXMOTIF__) |
0c5d3e1c | 164 | #include "wx/motif/font.h" |
2049ba38 | 165 | #elif defined(__WXGTK__) |
0c5d3e1c | 166 | #include "wx/gtk/font.h" |
1e6feb95 VZ |
167 | #elif defined(__WXMGL__) |
168 | #include "wx/mgl/font.h" | |
34138703 | 169 | #elif defined(__WXMAC__) |
0c5d3e1c | 170 | #include "wx/mac/font.h" |
1777b9bb | 171 | #elif defined(__WXPM__) |
0c5d3e1c | 172 | #include "wx/os2/font.h" |
34138703 | 173 | #elif defined(__WXSTUBS__) |
0c5d3e1c | 174 | #include "wx/stubs/font.h" |
c801d85f KB |
175 | #endif |
176 | ||
0c5d3e1c VZ |
177 | // ---------------------------------------------------------------------------- |
178 | // macros | |
179 | // ---------------------------------------------------------------------------- | |
180 | ||
0c5d3e1c VZ |
181 | #define M_FONTDATA GetFontData() |
182 | ||
c801d85f | 183 | #endif |
34138703 | 184 | // _WX_FONT_H_BASE_ |