]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: font.h | |
3 | // Purpose: wxFont class | |
519cb848 | 4 | // Author: Julian Smart |
0dbd6262 | 5 | // Modified by: |
519cb848 | 6 | // Created: 01/02/97 |
0dbd6262 | 7 | // RCS-ID: $Id$ |
519cb848 SC |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
0dbd6262 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_FONT_H_ | |
13 | #define _WX_FONT_H_ | |
14 | ||
af49c4b8 | 15 | #if defined(__GNUG__) && !defined(__APPLE__) |
519cb848 | 16 | #pragma interface "font.h" |
0dbd6262 SC |
17 | #endif |
18 | ||
e7549107 SC |
19 | class WXDLLEXPORT wxFontRefData: public wxGDIRefData |
20 | { | |
21 | friend class WXDLLEXPORT wxFont; | |
22 | public: | |
23 | wxFontRefData() | |
f2af4afb GD |
24 | : m_fontId(0) |
25 | , m_pointSize(10) | |
26 | , m_family(wxDEFAULT) | |
27 | , m_style(wxNORMAL) | |
28 | , m_weight(wxNORMAL) | |
29 | , m_underlined(FALSE) | |
30 | , m_faceName("Geneva") | |
31 | , m_encoding(wxFONTENCODING_DEFAULT) | |
32 | , m_macFontNum(0) | |
33 | , m_macFontSize(0) | |
34 | , m_macFontStyle(0) | |
35 | , m_macATSUFontID() | |
e7549107 | 36 | { |
7c74e7fe SC |
37 | Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, |
38 | "Geneva", wxFONTENCODING_DEFAULT); | |
e7549107 | 39 | } |
0dbd6262 | 40 | |
e7549107 | 41 | wxFontRefData(const wxFontRefData& data) |
f2af4afb GD |
42 | : wxGDIRefData() |
43 | , m_fontId(data.m_fontId) | |
44 | , m_pointSize(data.m_pointSize) | |
45 | , m_family(data.m_family) | |
46 | , m_style(data.m_style) | |
47 | , m_weight(data.m_weight) | |
48 | , m_underlined(data.m_underlined) | |
49 | , m_faceName(data.m_faceName) | |
50 | , m_encoding(data.m_encoding) | |
51 | , m_macFontNum(data.m_macFontNum) | |
52 | , m_macFontSize(data.m_macFontSize) | |
53 | , m_macFontStyle(data.m_macFontStyle) | |
54 | , m_macATSUFontID(data.m_macATSUFontID) | |
e7549107 SC |
55 | { |
56 | Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight, | |
57 | data.m_underlined, data.m_faceName, data.m_encoding); | |
e7549107 SC |
58 | } |
59 | ||
60 | wxFontRefData(int size, | |
61 | int family, | |
62 | int style, | |
63 | int weight, | |
64 | bool underlined, | |
65 | const wxString& faceName, | |
66 | wxFontEncoding encoding) | |
f2af4afb GD |
67 | : m_fontId(0) |
68 | , m_pointSize(size) | |
69 | , m_family(family) | |
70 | , m_style(style) | |
71 | , m_weight(weight) | |
72 | , m_underlined(underlined) | |
73 | , m_faceName(faceName) | |
74 | , m_encoding(encoding) | |
75 | , m_macFontNum(0) | |
76 | , m_macFontSize(0) | |
77 | , m_macFontStyle(0) | |
78 | , m_macATSUFontID(0) | |
e7549107 SC |
79 | { |
80 | Init(size, family, style, weight, underlined, faceName, encoding); | |
81 | } | |
82 | ||
83 | virtual ~wxFontRefData(); | |
ac17f9b1 SC |
84 | void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; } |
85 | bool GetNoAntiAliasing() { return m_noAA; } | |
86 | ||
e7549107 SC |
87 | protected: |
88 | // common part of all ctors | |
89 | void Init(int size, | |
90 | int family, | |
91 | int style, | |
92 | int weight, | |
93 | bool underlined, | |
94 | const wxString& faceName, | |
95 | wxFontEncoding encoding); | |
96 | ||
97 | // font characterstics | |
f2af4afb GD |
98 | int m_fontId; |
99 | int m_pointSize; | |
100 | int m_family; | |
101 | int m_style; | |
102 | int m_weight; | |
103 | bool m_underlined; | |
104 | wxString m_faceName; | |
e7549107 | 105 | wxFontEncoding m_encoding; |
ac17f9b1 | 106 | bool m_noAA; // No anti-aliasing |
477594f7 | 107 | |
f2af4afb | 108 | public: |
d921af51 JS |
109 | short m_macFontNum; |
110 | short m_macFontSize; | |
f2af4afb GD |
111 | unsigned char m_macFontStyle; |
112 | wxUint32 m_macATSUFontID; | |
113 | public: | |
d921af51 | 114 | void MacFindFont() ; |
e7549107 | 115 | }; |
519cb848 SC |
116 | // ---------------------------------------------------------------------------- |
117 | // wxFont | |
118 | // ---------------------------------------------------------------------------- | |
119 | ||
120 | class WXDLLEXPORT wxFont : public wxFontBase | |
0dbd6262 | 121 | { |
0dbd6262 | 122 | public: |
519cb848 SC |
123 | // ctors and such |
124 | wxFont() { Init(); } | |
f2af4afb GD |
125 | wxFont(const wxFont& font) |
126 | : wxFontBase() | |
127 | { | |
128 | Init(); | |
129 | Ref(font); | |
130 | } | |
519cb848 SC |
131 | |
132 | wxFont(int size, | |
133 | int family, | |
134 | int style, | |
135 | int weight, | |
136 | bool underlined = FALSE, | |
137 | const wxString& face = wxEmptyString, | |
138 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
139 | { | |
140 | Init(); | |
141 | ||
142 | (void)Create(size, family, style, weight, underlined, face, encoding); | |
143 | } | |
144 | ||
3b7e6277 GD |
145 | wxFont(const wxNativeFontInfo& info) |
146 | { | |
147 | Init(); | |
148 | ||
149 | (void)Create(info); | |
150 | } | |
151 | ||
152 | wxFont(const wxString& fontDesc); | |
153 | ||
519cb848 SC |
154 | bool Create(int size, |
155 | int family, | |
156 | int style, | |
157 | int weight, | |
158 | bool underlined = FALSE, | |
159 | const wxString& face = wxEmptyString, | |
160 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
161 | ||
3b7e6277 GD |
162 | bool Create(const wxNativeFontInfo& info); |
163 | ||
519cb848 SC |
164 | virtual ~wxFont(); |
165 | ||
166 | // assignment | |
167 | wxFont& operator=(const wxFont& font); | |
168 | ||
169 | // implement base class pure virtuals | |
170 | virtual int GetPointSize() const; | |
171 | virtual int GetFamily() const; | |
172 | virtual int GetStyle() const; | |
173 | virtual int GetWeight() const; | |
174 | virtual bool GetUnderlined() const; | |
175 | virtual wxString GetFaceName() const; | |
176 | virtual wxFontEncoding GetEncoding() const; | |
177 | ||
178 | virtual void SetPointSize(int pointSize); | |
179 | virtual void SetFamily(int family); | |
180 | virtual void SetStyle(int style); | |
181 | virtual void SetWeight(int weight); | |
182 | virtual void SetFaceName(const wxString& faceName); | |
183 | virtual void SetUnderlined(bool underlined); | |
184 | virtual void SetEncoding(wxFontEncoding encoding); | |
185 | ||
186 | // implementation only from now on | |
187 | // ------------------------------- | |
188 | ||
519cb848 | 189 | virtual bool RealizeResource(); |
0dbd6262 | 190 | |
ac17f9b1 SC |
191 | // Unofficial API, don't use |
192 | virtual void SetNoAntiAliasing( bool noAA = TRUE ) ; | |
193 | virtual bool GetNoAntiAliasing() ; | |
519cb848 SC |
194 | protected: |
195 | // common part of all ctors | |
196 | void Init(); | |
0dbd6262 | 197 | |
519cb848 | 198 | void Unshare(); |
0dbd6262 | 199 | |
519cb848 SC |
200 | private: |
201 | DECLARE_DYNAMIC_CLASS(wxFont) | |
0dbd6262 SC |
202 | }; |
203 | ||
204 | #endif | |
205 | // _WX_FONT_H_ |