source: trunk/src/gui/text/qfontmetrics.h@ 371

Last change on this file since 371 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

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