Update spec to build Qt 5.0
[profile/ivi/qtbase.git] / src / gui / text / qfontmetrics.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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
56
57 class QTextCodec;
58 class QRect;
59
60
61 class Q_GUI_EXPORT QFontMetrics
62 {
63 public:
64     explicit QFontMetrics(const QFont &);
65     QFontMetrics(const QFont &, QPaintDevice *pd);
66     QFontMetrics(const QFontMetrics &);
67     ~QFontMetrics();
68
69     QFontMetrics &operator=(const QFontMetrics &);
70 #ifdef Q_COMPILER_RVALUE_REFS
71     inline QFontMetrics &operator=(QFontMetrics &&other)
72     { qSwap(d, other.d); return *this; }
73 #endif
74
75     void swap(QFontMetrics &other) { qSwap(d, other.d); }
76
77     int ascent() const;
78     int descent() const;
79     int height() const;
80     int leading() const;
81     int lineSpacing() const;
82     int minLeftBearing() const;
83     int minRightBearing() const;
84     int maxWidth() const;
85
86     int xHeight() const;
87     int averageCharWidth() const;
88
89     bool inFont(QChar) const;
90     bool inFontUcs4(uint ucs4) const;
91
92     int leftBearing(QChar) const;
93     int rightBearing(QChar) const;
94     int width(const QString &, int len = -1) const;
95     int width(const QString &, int len, int flags) const;
96
97     int width(QChar) const;
98     int charWidth(const QString &str, int pos) const;
99
100     QRect boundingRect(QChar) const;
101
102     QRect boundingRect(const QString &text) const;
103     QRect boundingRect(const QRect &r, int flags, const QString &text, int tabstops=0, int *tabarray=0) const;
104     inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text,
105                               int tabstops=0, int *tabarray=0) const
106         { return boundingRect(QRect(x, y, w, h), flags, text, tabstops, tabarray); }
107     QSize size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
108
109     QRect tightBoundingRect(const QString &text) const;
110
111     QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags = 0) const;
112
113     int underlinePos() const;
114     int overlinePos() const;
115     int strikeOutPos() const;
116     int lineWidth() const;
117
118     bool operator==(const QFontMetrics &other) const;
119     inline bool operator !=(const QFontMetrics &other) const { return !operator==(other); }
120
121 private:
122     friend class QFontMetricsF;
123     friend class QStackTextEngine;
124
125     QExplicitlySharedDataPointer<QFontPrivate> d;
126 };
127
128 Q_DECLARE_SHARED(QFontMetrics)
129
130 class Q_GUI_EXPORT QFontMetricsF
131 {
132 public:
133     explicit QFontMetricsF(const QFont &);
134     QFontMetricsF(const QFont &, QPaintDevice *pd);
135     QFontMetricsF(const QFontMetrics &);
136     QFontMetricsF(const QFontMetricsF &);
137     ~QFontMetricsF();
138
139     QFontMetricsF &operator=(const QFontMetricsF &);
140     QFontMetricsF &operator=(const QFontMetrics &);
141 #ifdef Q_COMPILER_RVALUE_REFS
142     inline QFontMetricsF &operator=(QFontMetricsF &&other)
143     { qSwap(d, other.d); return *this; }
144 #endif
145
146     void swap(QFontMetricsF &other) { qSwap(d, other.d); }
147
148     qreal ascent() const;
149     qreal descent() const;
150     qreal height() const;
151     qreal leading() const;
152     qreal lineSpacing() const;
153     qreal minLeftBearing() const;
154     qreal minRightBearing() const;
155     qreal maxWidth() const;
156
157     qreal xHeight() const;
158     qreal averageCharWidth() const;
159
160     bool inFont(QChar) const;
161     bool inFontUcs4(uint ucs4) const;
162
163     qreal leftBearing(QChar) const;
164     qreal rightBearing(QChar) const;
165     qreal width(const QString &string) const;
166
167     qreal width(QChar) const;
168
169     QRectF boundingRect(const QString &string) const;
170     QRectF boundingRect(QChar) const;
171     QRectF boundingRect(const QRectF &r, int flags, const QString& string, int tabstops=0, int *tabarray=0) const;
172     QSizeF size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
173
174     QRectF tightBoundingRect(const QString &text) const;
175
176     QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags = 0) const;
177
178     qreal underlinePos() const;
179     qreal overlinePos() const;
180     qreal strikeOutPos() const;
181     qreal lineWidth() const;
182
183     bool operator==(const QFontMetricsF &other) const;
184     inline bool operator !=(const QFontMetricsF &other) const { return !operator==(other); }
185
186 private:
187     QExplicitlySharedDataPointer<QFontPrivate> d;
188 };
189
190 Q_DECLARE_SHARED(QFontMetricsF)
191
192 QT_END_NAMESPACE
193
194 QT_END_HEADER
195
196 #endif // QFONTMETRICS_H