1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the text module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#ifndef QFONTMETRICS_H
30
#define QFONTMETRICS_H
32
#include "QtGui/qfont.h"
33
#ifndef QT_INCLUDE_COMPAT
34
#include "QtCore/qrect.h"
45
class Q_GUI_EXPORT QFontMetrics
48
QFontMetrics(const QFont &);
49
QFontMetrics(const QFont &, QPaintDevice *pd);
50
QFontMetrics(const QFontMetrics &);
53
QFontMetrics &operator=(const QFontMetrics &);
59
int lineSpacing() const;
60
int minLeftBearing() const;
61
int minRightBearing() const;
64
bool inFont(QChar) const;
66
int leftBearing(QChar) const;
67
int rightBearing(QChar) const;
68
int width(const QString &, int len = -1) const;
70
int width(QChar) const;
71
int charWidth(const QString &str, int pos) const;
73
QRect boundingRect(QChar) const;
75
QRect boundingRect(const QString &text) const;
76
QRect boundingRect(const QRect &r, int flags, const QString &text, int tabstops=0, int *tabarray=0) const;
77
inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text,
78
int tabstops=0, int *tabarray=0) const
79
{ return boundingRect(QRect(x, y, w, h), flags, text, tabstops, tabarray); }
80
QSize size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
82
int underlinePos() const;
83
int overlinePos() const;
84
int strikeOutPos() const;
85
int lineWidth() const;
87
bool operator==(const QFontMetrics &other);
88
inline bool operator !=(const QFontMetrics &other) { return !operator==(other); }
91
inline QRect boundingRect(const QString &text, int len) const
92
{ return boundingRect(text.left(len)); }
93
inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString& str, int len,
94
int tabstops=0, int *tabarray=0) const
95
{ return boundingRect(QRect(x, y, w, h), flags, str.left(len), tabstops, tabarray); }
96
inline QSize size(int flags, const QString& str, int len, int tabstops=0, int *tabarray=0) const
97
{ return size(flags, str.left(len), tabstops, tabarray); }
100
#if defined(Q_WS_MAC)
101
friend class QFontPrivate;
108
class Q_GUI_EXPORT QFontMetricsF
111
QFontMetricsF(const QFont &);
112
QFontMetricsF(const QFont &, QPaintDevice *pd);
113
QFontMetricsF(const QFontMetrics &);
114
QFontMetricsF(const QFontMetricsF &);
117
QFontMetricsF &operator=(const QFontMetricsF &);
118
QFontMetricsF &operator=(const QFontMetrics &);
120
qreal ascent() const;
121
qreal descent() const;
122
qreal height() const;
123
qreal leading() const;
124
qreal lineSpacing() const;
125
qreal minLeftBearing() const;
126
qreal minRightBearing() const;
127
qreal maxWidth() const;
129
bool inFont(QChar) const;
131
qreal leftBearing(QChar) const;
132
qreal rightBearing(QChar) const;
133
qreal width(const QString &string) const;
135
qreal width(QChar) const;
137
QRectF boundingRect(const QString &string) const;
138
QRectF boundingRect(QChar) const;
139
QRectF boundingRect(const QRectF &r, int flags, const QString& string, int tabstops=0, int *tabarray=0) const;
140
QSizeF size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
142
qreal underlinePos() const;
143
qreal overlinePos() const;
144
qreal strikeOutPos() const;
145
qreal lineWidth() const;
147
bool operator==(const QFontMetricsF &other);
148
inline bool operator !=(const QFontMetricsF &other) { return !operator==(other); }
154
#endif // QFONTMETRICS_H