1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QFONTMETRICS_H
|
---|
43 | #define QFONTMETRICS_H
|
---|
44 |
|
---|
45 | #include <QtGui/qfont.h>
|
---|
46 | #include <QtCore/qsharedpointer.h>
|
---|
47 | #ifndef QT_INCLUDE_COMPAT
|
---|
48 | #include <QtCore/qrect.h>
|
---|
49 | #endif
|
---|
50 |
|
---|
51 | QT_BEGIN_HEADER
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | QT_MODULE(Gui)
|
---|
56 |
|
---|
57 | #ifdef Q_WS_QWS
|
---|
58 | class QFontEngine;
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | class QTextCodec;
|
---|
62 | class QRect;
|
---|
63 |
|
---|
64 |
|
---|
65 | class Q_GUI_EXPORT QFontMetrics
|
---|
66 | {
|
---|
67 | public:
|
---|
68 | QFontMetrics(const QFont &);
|
---|
69 | QFontMetrics(const QFont &, QPaintDevice *pd);
|
---|
70 | QFontMetrics(const QFontMetrics &);
|
---|
71 | ~QFontMetrics();
|
---|
72 |
|
---|
73 | QFontMetrics &operator=(const QFontMetrics &);
|
---|
74 |
|
---|
75 | int ascent() const;
|
---|
76 | int descent() const;
|
---|
77 | int height() const;
|
---|
78 | int leading() const;
|
---|
79 | int lineSpacing() const;
|
---|
80 | int minLeftBearing() const;
|
---|
81 | int minRightBearing() const;
|
---|
82 | int maxWidth() const;
|
---|
83 |
|
---|
84 | int xHeight() const;
|
---|
85 | int averageCharWidth() const;
|
---|
86 |
|
---|
87 | bool inFont(QChar) const;
|
---|
88 |
|
---|
89 | int leftBearing(QChar) const;
|
---|
90 | int rightBearing(QChar) const;
|
---|
91 | int width(const QString &, int len = -1) const;
|
---|
92 | int width(const QString &, int len, int flags) const;
|
---|
93 |
|
---|
94 | int width(QChar) const;
|
---|
95 | int charWidth(const QString &str, int pos) const;
|
---|
96 |
|
---|
97 | QRect boundingRect(QChar) const;
|
---|
98 |
|
---|
99 | QRect boundingRect(const QString &text) const;
|
---|
100 | QRect boundingRect(const QRect &r, int flags, const QString &text, int tabstops=0, int *tabarray=0) const;
|
---|
101 | inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text,
|
---|
102 | int tabstops=0, int *tabarray=0) const
|
---|
103 | { return boundingRect(QRect(x, y, w, h), flags, text, tabstops, tabarray); }
|
---|
104 | QSize size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
|
---|
105 |
|
---|
106 | QRect tightBoundingRect(const QString &text) const;
|
---|
107 |
|
---|
108 | QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags = 0) const;
|
---|
109 |
|
---|
110 | int underlinePos() const;
|
---|
111 | int overlinePos() const;
|
---|
112 | int strikeOutPos() const;
|
---|
113 | int lineWidth() const;
|
---|
114 |
|
---|
115 | bool operator==(const QFontMetrics &other); // 5.0 - remove me
|
---|
116 | bool operator==(const QFontMetrics &other) const;
|
---|
117 | inline bool operator !=(const QFontMetrics &other) { return !operator==(other); } // 5.0 - remove me
|
---|
118 | inline bool operator !=(const QFontMetrics &other) const { return !operator==(other); }
|
---|
119 |
|
---|
120 | #ifdef QT3_SUPPORT
|
---|
121 | inline QRect boundingRect(const QString &text, int len) const
|
---|
122 | { return boundingRect(text.left(len)); }
|
---|
123 | inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString& str, int len,
|
---|
124 | int tabstops=0, int *tabarray=0) const
|
---|
125 | { return boundingRect(QRect(x, y, w, h), flags, str.left(len), tabstops, tabarray); }
|
---|
126 | inline QSize size(int flags, const QString& str, int len, int tabstops=0, int *tabarray=0) const
|
---|
127 | { return size(flags, str.left(len), tabstops, tabarray); }
|
---|
128 | #endif
|
---|
129 | private:
|
---|
130 | #if defined(Q_WS_MAC)
|
---|
131 | friend class QFontPrivate;
|
---|
132 | #endif
|
---|
133 | friend class QFontMetricsF;
|
---|
134 | friend class QStackTextEngine;
|
---|
135 |
|
---|
136 | QExplicitlySharedDataPointer<QFontPrivate> d;
|
---|
137 | };
|
---|
138 |
|
---|
139 |
|
---|
140 | class Q_GUI_EXPORT QFontMetricsF
|
---|
141 | {
|
---|
142 | public:
|
---|
143 | QFontMetricsF(const QFont &);
|
---|
144 | QFontMetricsF(const QFont &, QPaintDevice *pd);
|
---|
145 | QFontMetricsF(const QFontMetrics &);
|
---|
146 | QFontMetricsF(const QFontMetricsF &);
|
---|
147 | ~QFontMetricsF();
|
---|
148 |
|
---|
149 | QFontMetricsF &operator=(const QFontMetricsF &);
|
---|
150 | QFontMetricsF &operator=(const QFontMetrics &);
|
---|
151 |
|
---|
152 | qreal ascent() const;
|
---|
153 | qreal descent() const;
|
---|
154 | qreal height() const;
|
---|
155 | qreal leading() const;
|
---|
156 | qreal lineSpacing() const;
|
---|
157 | qreal minLeftBearing() const;
|
---|
158 | qreal minRightBearing() const;
|
---|
159 | qreal maxWidth() const;
|
---|
160 |
|
---|
161 | qreal xHeight() const;
|
---|
162 | qreal averageCharWidth() const;
|
---|
163 |
|
---|
164 | bool inFont(QChar) const;
|
---|
165 |
|
---|
166 | qreal leftBearing(QChar) const;
|
---|
167 | qreal rightBearing(QChar) const;
|
---|
168 | qreal width(const QString &string) const;
|
---|
169 |
|
---|
170 | qreal width(QChar) const;
|
---|
171 |
|
---|
172 | QRectF boundingRect(const QString &string) const;
|
---|
173 | QRectF boundingRect(QChar) const;
|
---|
174 | QRectF boundingRect(const QRectF &r, int flags, const QString& string, int tabstops=0, int *tabarray=0) const;
|
---|
175 | QSizeF size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
|
---|
176 |
|
---|
177 | QRectF tightBoundingRect(const QString &text) const;
|
---|
178 |
|
---|
179 | QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags = 0) const;
|
---|
180 |
|
---|
181 | qreal underlinePos() const;
|
---|
182 | qreal overlinePos() const;
|
---|
183 | qreal strikeOutPos() const;
|
---|
184 | qreal lineWidth() const;
|
---|
185 |
|
---|
186 | bool operator==(const QFontMetricsF &other); // 5.0 - remove me
|
---|
187 | bool operator==(const QFontMetricsF &other) const;
|
---|
188 | inline bool operator !=(const QFontMetricsF &other) { return !operator==(other); } // 5.0 - remove me
|
---|
189 | inline bool operator !=(const QFontMetricsF &other) const { return !operator==(other); }
|
---|
190 |
|
---|
191 | private:
|
---|
192 | QExplicitlySharedDataPointer<QFontPrivate> d;
|
---|
193 | };
|
---|
194 |
|
---|
195 | QT_END_NAMESPACE
|
---|
196 |
|
---|
197 | QT_END_HEADER
|
---|
198 |
|
---|
199 | #endif // QFONTMETRICS_H
|
---|