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