]>
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 | ||
15 | #ifdef __GNUG__ | |
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(); | |
84 | protected: | |
85 | // common part of all ctors | |
86 | void Init(int size, | |
87 | int family, | |
88 | int style, | |
89 | int weight, | |
90 | bool underlined, | |
91 | const wxString& faceName, | |
92 | wxFontEncoding encoding); | |
93 | ||
94 | // font characterstics | |
f2af4afb GD |
95 | int m_fontId; |
96 | int m_pointSize; | |
97 | int m_family; | |
98 | int m_style; | |
99 | int m_weight; | |
100 | bool m_underlined; | |
101 | wxString m_faceName; | |
e7549107 | 102 | wxFontEncoding m_encoding; |
477594f7 | 103 | |
f2af4afb GD |
104 | public: |
105 | short m_macFontNum; | |
106 | short m_macFontSize; | |
107 | unsigned char m_macFontStyle; | |
108 | wxUint32 m_macATSUFontID; | |
109 | public: | |
110 | void MacFindFont() ; | |
e7549107 | 111 | }; |
519cb848 SC |
112 | // ---------------------------------------------------------------------------- |
113 | // wxFont | |
114 | // ---------------------------------------------------------------------------- | |
115 | ||
116 | class WXDLLEXPORT wxFont : public wxFontBase | |
0dbd6262 | 117 | { |
0dbd6262 | 118 | public: |
519cb848 SC |
119 | // ctors and such |
120 | wxFont() { Init(); } | |
f2af4afb GD |
121 | wxFont(const wxFont& font) |
122 | : wxFontBase() | |
123 | { | |
124 | Init(); | |
125 | Ref(font); | |
126 | } | |
519cb848 SC |
127 | |
128 | wxFont(int size, | |
129 | int family, | |
130 | int style, | |
131 | int weight, | |
132 | bool underlined = FALSE, | |
133 | const wxString& face = wxEmptyString, | |
134 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) | |
135 | { | |
136 | Init(); | |
137 | ||
138 | (void)Create(size, family, style, weight, underlined, face, encoding); | |
139 | } | |
140 | ||
3b7e6277 GD |
141 | wxFont(const wxNativeFontInfo& info) |
142 | { | |
143 | Init(); | |
144 | ||
145 | (void)Create(info); | |
146 | } | |
147 | ||
148 | wxFont(const wxString& fontDesc); | |
149 | ||
519cb848 SC |
150 | bool Create(int size, |
151 | int family, | |
152 | int style, | |
153 | int weight, | |
154 | bool underlined = FALSE, | |
155 | const wxString& face = wxEmptyString, | |
156 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT); | |
157 | ||
3b7e6277 GD |
158 | bool Create(const wxNativeFontInfo& info); |
159 | ||
519cb848 SC |
160 | virtual ~wxFont(); |
161 | ||
162 | // assignment | |
163 | wxFont& operator=(const wxFont& font); | |
164 | ||
165 | // implement base class pure virtuals | |
166 | virtual int GetPointSize() const; | |
167 | virtual int GetFamily() const; | |
168 | virtual int GetStyle() const; | |
169 | virtual int GetWeight() const; | |
170 | virtual bool GetUnderlined() const; | |
171 | virtual wxString GetFaceName() const; | |
172 | virtual wxFontEncoding GetEncoding() const; | |
173 | ||
174 | virtual void SetPointSize(int pointSize); | |
175 | virtual void SetFamily(int family); | |
176 | virtual void SetStyle(int style); | |
177 | virtual void SetWeight(int weight); | |
178 | virtual void SetFaceName(const wxString& faceName); | |
179 | virtual void SetUnderlined(bool underlined); | |
180 | virtual void SetEncoding(wxFontEncoding encoding); | |
181 | ||
182 | // implementation only from now on | |
183 | // ------------------------------- | |
184 | ||
519cb848 | 185 | virtual bool RealizeResource(); |
0dbd6262 | 186 | |
519cb848 SC |
187 | protected: |
188 | // common part of all ctors | |
189 | void Init(); | |
0dbd6262 | 190 | |
519cb848 | 191 | void Unshare(); |
0dbd6262 | 192 | |
519cb848 SC |
193 | private: |
194 | DECLARE_DYNAMIC_CLASS(wxFont) | |
0dbd6262 SC |
195 | }; |
196 | ||
197 | #endif | |
198 | // _WX_FONT_H_ |