1 | /****************************************************************************
|
---|
2 | ** $Id: qfont.h 8 2005-11-16 19:36:46Z dmik $
|
---|
3 | **
|
---|
4 | ** Definition of QFont class
|
---|
5 | **
|
---|
6 | ** Created : 940514
|
---|
7 | **
|
---|
8 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
|
---|
9 | **
|
---|
10 | ** This file is part of the kernel module of the Qt GUI Toolkit.
|
---|
11 | **
|
---|
12 | ** This file may be distributed under the terms of the Q Public License
|
---|
13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
---|
14 | ** LICENSE.QPL included in the packaging of this file.
|
---|
15 | **
|
---|
16 | ** This file may be distributed and/or modified under the terms of the
|
---|
17 | ** GNU General Public License version 2 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
19 | ** packaging of this file.
|
---|
20 | **
|
---|
21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
22 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
23 | ** Agreement provided with the Software.
|
---|
24 | **
|
---|
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
27 | **
|
---|
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
29 | ** information about Qt Commercial License Agreements.
|
---|
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
32 | **
|
---|
33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
34 | ** not clear to you.
|
---|
35 | **
|
---|
36 | **********************************************************************/
|
---|
37 |
|
---|
38 | #ifndef QFONT_H
|
---|
39 | #define QFONT_H
|
---|
40 |
|
---|
41 | #ifndef QT_H
|
---|
42 | #include "qwindowdefs.h"
|
---|
43 | #include "qstring.h"
|
---|
44 | #endif // QT_H
|
---|
45 |
|
---|
46 |
|
---|
47 | class QFontPrivate; /* don't touch */
|
---|
48 | class QStringList;
|
---|
49 | class QTextFormatCollection;
|
---|
50 |
|
---|
51 | class Q_EXPORT QFont
|
---|
52 | {
|
---|
53 | public:
|
---|
54 | enum StyleHint {
|
---|
55 | Helvetica, SansSerif = Helvetica,
|
---|
56 | Times, Serif = Times,
|
---|
57 | Courier, TypeWriter = Courier,
|
---|
58 | OldEnglish, Decorative = OldEnglish,
|
---|
59 | System,
|
---|
60 | AnyStyle
|
---|
61 | };
|
---|
62 |
|
---|
63 | enum StyleStrategy {
|
---|
64 | PreferDefault = 0x0001,
|
---|
65 | PreferBitmap = 0x0002,
|
---|
66 | PreferDevice = 0x0004,
|
---|
67 | PreferOutline = 0x0008,
|
---|
68 | ForceOutline = 0x0010,
|
---|
69 | PreferMatch = 0x0020,
|
---|
70 | PreferQuality = 0x0040,
|
---|
71 | PreferAntialias = 0x0080,
|
---|
72 | NoAntialias = 0x0100,
|
---|
73 | OpenGLCompatible = 0x0200
|
---|
74 | };
|
---|
75 |
|
---|
76 | enum Weight {
|
---|
77 | Light = 25,
|
---|
78 | Normal = 50,
|
---|
79 | DemiBold = 63,
|
---|
80 | Bold = 75,
|
---|
81 | Black = 87
|
---|
82 | };
|
---|
83 |
|
---|
84 | enum Stretch {
|
---|
85 | UltraCondensed = 50,
|
---|
86 | ExtraCondensed = 62,
|
---|
87 | Condensed = 75,
|
---|
88 | SemiCondensed = 87,
|
---|
89 | Unstretched = 100,
|
---|
90 | SemiExpanded = 112,
|
---|
91 | Expanded = 125,
|
---|
92 | ExtraExpanded = 150,
|
---|
93 | UltraExpanded = 200
|
---|
94 | };
|
---|
95 |
|
---|
96 | // default font
|
---|
97 | QFont();
|
---|
98 | // specific font
|
---|
99 | #ifdef Q_QDOC
|
---|
100 | QFont( const QString &family, int pointSize = 12, int weight = Normal,
|
---|
101 | bool italic = FALSE );
|
---|
102 | #else
|
---|
103 | QFont( const QString &family, int pointSize = -1, int weight = -1,
|
---|
104 | bool italic = FALSE );
|
---|
105 | #endif
|
---|
106 | // copy constructor
|
---|
107 | QFont( const QFont & );
|
---|
108 |
|
---|
109 | ~QFont();
|
---|
110 |
|
---|
111 | QString family() const;
|
---|
112 | void setFamily( const QString &);
|
---|
113 |
|
---|
114 | int pointSize() const;
|
---|
115 | float pointSizeFloat() const;
|
---|
116 | void setPointSize( int );
|
---|
117 | void setPointSizeFloat( float );
|
---|
118 |
|
---|
119 | int pixelSize() const;
|
---|
120 | void setPixelSize( int );
|
---|
121 | void setPixelSizeFloat( float );
|
---|
122 |
|
---|
123 | int weight() const;
|
---|
124 | void setWeight( int );
|
---|
125 |
|
---|
126 | bool bold() const;
|
---|
127 | void setBold( bool );
|
---|
128 |
|
---|
129 | bool italic() const;
|
---|
130 | void setItalic( bool );
|
---|
131 |
|
---|
132 | bool underline() const;
|
---|
133 | void setUnderline( bool );
|
---|
134 |
|
---|
135 | bool overline() const;
|
---|
136 | void setOverline( bool );
|
---|
137 |
|
---|
138 | bool strikeOut() const;
|
---|
139 | void setStrikeOut( bool );
|
---|
140 |
|
---|
141 | bool fixedPitch() const;
|
---|
142 | void setFixedPitch( bool );
|
---|
143 |
|
---|
144 | StyleHint styleHint() const;
|
---|
145 | StyleStrategy styleStrategy() const;
|
---|
146 | void setStyleHint( StyleHint, StyleStrategy = PreferDefault );
|
---|
147 | void setStyleStrategy( StyleStrategy s );
|
---|
148 |
|
---|
149 | int stretch() const;
|
---|
150 | void setStretch( int );
|
---|
151 |
|
---|
152 | // is raw mode still needed?
|
---|
153 | bool rawMode() const;
|
---|
154 | void setRawMode( bool );
|
---|
155 |
|
---|
156 | // dupicated from QFontInfo
|
---|
157 | bool exactMatch() const;
|
---|
158 |
|
---|
159 | QFont &operator=( const QFont & );
|
---|
160 | bool operator==( const QFont & ) const;
|
---|
161 | bool operator!=( const QFont & ) const;
|
---|
162 | bool isCopyOf( const QFont & ) const;
|
---|
163 |
|
---|
164 |
|
---|
165 | #if defined (Q_WS_WIN)
|
---|
166 | HFONT handle() const;
|
---|
167 | #elif defined (Q_WS_PM)
|
---|
168 | //@@TODO (dmik): do we actually need any handle?
|
---|
169 | // PFATTRS handle() const;
|
---|
170 | void selectTo( HPS hps ) const;
|
---|
171 | #else // !Q_WS_WIN && !Q_WS_PM
|
---|
172 | Qt::HANDLE handle() const;
|
---|
173 | #endif // Q_WS_WIN
|
---|
174 |
|
---|
175 |
|
---|
176 | // needed for X11
|
---|
177 | void setRawName( const QString & );
|
---|
178 | QString rawName() const;
|
---|
179 |
|
---|
180 | QString key() const;
|
---|
181 |
|
---|
182 | QString toString() const;
|
---|
183 | bool fromString(const QString &);
|
---|
184 |
|
---|
185 | #ifndef QT_NO_STRINGLIST
|
---|
186 | static QString substitute(const QString &);
|
---|
187 | static QStringList substitutes(const QString &);
|
---|
188 | static QStringList substitutions();
|
---|
189 | static void insertSubstitution(const QString&, const QString &);
|
---|
190 | static void insertSubstitutions(const QString&, const QStringList &);
|
---|
191 | static void removeSubstitution(const QString &);
|
---|
192 | #endif //QT_NO_STRINGLIST
|
---|
193 | static void initialize();
|
---|
194 | static void cleanup();
|
---|
195 | #ifndef Q_WS_QWS
|
---|
196 | static void cacheStatistics();
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | #if defined(Q_WS_QWS)
|
---|
200 | void qwsRenderToDisk(bool all=TRUE);
|
---|
201 | #endif
|
---|
202 |
|
---|
203 |
|
---|
204 | // a copy of this lives in qunicodetables.cpp, as we can't include
|
---|
205 | // qfont.h it in tools/. Do not modify without changing the script
|
---|
206 | // enum in qunicodetable_p.h aswell.
|
---|
207 | enum Script {
|
---|
208 | // European Alphabetic Scripts
|
---|
209 | Latin,
|
---|
210 | Greek,
|
---|
211 | Cyrillic,
|
---|
212 | Armenian,
|
---|
213 | Georgian,
|
---|
214 | Runic,
|
---|
215 | Ogham,
|
---|
216 | SpacingModifiers,
|
---|
217 | CombiningMarks,
|
---|
218 |
|
---|
219 | // Middle Eastern Scripts
|
---|
220 | Hebrew,
|
---|
221 | Arabic,
|
---|
222 | Syriac,
|
---|
223 | Thaana,
|
---|
224 |
|
---|
225 | // South and Southeast Asian Scripts
|
---|
226 | Devanagari,
|
---|
227 | Bengali,
|
---|
228 | Gurmukhi,
|
---|
229 | Gujarati,
|
---|
230 | Oriya,
|
---|
231 | Tamil,
|
---|
232 | Telugu,
|
---|
233 | Kannada,
|
---|
234 | Malayalam,
|
---|
235 | Sinhala,
|
---|
236 | Thai,
|
---|
237 | Lao,
|
---|
238 | Tibetan,
|
---|
239 | Myanmar,
|
---|
240 | Khmer,
|
---|
241 |
|
---|
242 | // East Asian Scripts
|
---|
243 | Han,
|
---|
244 | Hiragana,
|
---|
245 | Katakana,
|
---|
246 | Hangul,
|
---|
247 | Bopomofo,
|
---|
248 | Yi,
|
---|
249 |
|
---|
250 | // Additional Scripts
|
---|
251 | Ethiopic,
|
---|
252 | Cherokee,
|
---|
253 | CanadianAboriginal,
|
---|
254 | Mongolian,
|
---|
255 |
|
---|
256 | // Symbols
|
---|
257 | CurrencySymbols,
|
---|
258 | LetterlikeSymbols,
|
---|
259 | NumberForms,
|
---|
260 | MathematicalOperators,
|
---|
261 | TechnicalSymbols,
|
---|
262 | GeometricSymbols,
|
---|
263 | MiscellaneousSymbols,
|
---|
264 | EnclosedAndSquare,
|
---|
265 | Braille,
|
---|
266 |
|
---|
267 | Unicode,
|
---|
268 |
|
---|
269 | // some scripts added in Unicode 3.2
|
---|
270 | Tagalog,
|
---|
271 | Hanunoo,
|
---|
272 | Buhid,
|
---|
273 | Tagbanwa,
|
---|
274 |
|
---|
275 | KatakanaHalfWidth,
|
---|
276 |
|
---|
277 | // from Unicode 4.0
|
---|
278 | Limbu,
|
---|
279 | TaiLe,
|
---|
280 |
|
---|
281 | // End
|
---|
282 | #if !defined(Q_QDOC)
|
---|
283 | NScripts,
|
---|
284 | UnknownScript = NScripts,
|
---|
285 |
|
---|
286 | NoScript,
|
---|
287 |
|
---|
288 | // ----------------------------------------
|
---|
289 | // Dear User, you can see values > NScript,
|
---|
290 | // but they are internal - do not touch.
|
---|
291 |
|
---|
292 | Han_Japanese,
|
---|
293 | Han_SimplifiedChinese,
|
---|
294 | Han_TraditionalChinese,
|
---|
295 | Han_Korean,
|
---|
296 |
|
---|
297 | LastPrivateScript
|
---|
298 | #endif
|
---|
299 | };
|
---|
300 |
|
---|
301 | QString defaultFamily() const;
|
---|
302 | QString lastResortFamily() const;
|
---|
303 | QString lastResortFont() const;
|
---|
304 |
|
---|
305 | #ifndef QT_NO_COMPAT
|
---|
306 |
|
---|
307 | static QFont defaultFont();
|
---|
308 | static void setDefaultFont( const QFont & );
|
---|
309 |
|
---|
310 | #endif // QT_NO_COMPAT
|
---|
311 |
|
---|
312 | QFont resolve( const QFont & ) const;
|
---|
313 |
|
---|
314 | protected:
|
---|
315 | // why protected?
|
---|
316 | bool dirty() const;
|
---|
317 | int deciPointSize() const;
|
---|
318 |
|
---|
319 | private:
|
---|
320 | QFont( QFontPrivate *, QPaintDevice *pd );
|
---|
321 |
|
---|
322 | void detach();
|
---|
323 |
|
---|
324 | #if defined(Q_WS_MAC)
|
---|
325 | void macSetFont(QPaintDevice *);
|
---|
326 | #elif defined(Q_WS_X11)
|
---|
327 | void x11SetScreen( int screen = -1 );
|
---|
328 | int x11Screen() const;
|
---|
329 | #endif
|
---|
330 |
|
---|
331 | friend class QFontMetrics;
|
---|
332 | friend class QFontInfo;
|
---|
333 | friend class QPainter;
|
---|
334 | friend class QPSPrinterFont;
|
---|
335 | friend class QApplication;
|
---|
336 | friend class QWidget;
|
---|
337 | friend class QTextFormatCollection;
|
---|
338 | friend class QTextLayout;
|
---|
339 | friend class QTextItem;
|
---|
340 |
|
---|
341 | #ifndef QT_NO_DATASTREAM
|
---|
342 | friend Q_EXPORT QDataStream &operator<<( QDataStream &, const QFont & );
|
---|
343 | friend Q_EXPORT QDataStream &operator>>( QDataStream &, QFont & );
|
---|
344 | #endif
|
---|
345 |
|
---|
346 | QFontPrivate *d;
|
---|
347 | };
|
---|
348 |
|
---|
349 |
|
---|
350 | inline bool QFont::bold() const
|
---|
351 | { return weight() > Normal; }
|
---|
352 |
|
---|
353 |
|
---|
354 | inline void QFont::setBold( bool enable )
|
---|
355 | { setWeight( enable ? Bold : Normal ); }
|
---|
356 |
|
---|
357 |
|
---|
358 |
|
---|
359 |
|
---|
360 | /*****************************************************************************
|
---|
361 | QFont stream functions
|
---|
362 | *****************************************************************************/
|
---|
363 |
|
---|
364 | #ifndef QT_NO_DATASTREAM
|
---|
365 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QFont & );
|
---|
366 | Q_EXPORT QDataStream &operator>>( QDataStream &, QFont & );
|
---|
367 | #endif
|
---|
368 |
|
---|
369 |
|
---|
370 | #endif // QFONT_H
|
---|