- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qfontmetrics.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QFONTMETRICS_H
    00043 #define QFONTMETRICS_H
    00044
    00045 #include <QtGui/qfont.h>
    00046 #include <QtCore/qsharedpointer.h>
    00047 #ifndef QT_INCLUDE_COMPAT
    00048 #include <QtCore/qrect.h>
    00049 #endif
    00050
    00051 QT_BEGIN_HEADER
    00052
    00053 QT_BEGIN_NAMESPACE
    00054
    00055 QT_MODULE(Gui)
    00056
    00057 #ifdef Q_WS_QWS
    00058 class QFontEngine;
    00059 #endif
    00060
    00061 class QTextCodec;
    00062 class QRect;
    00063
    00064
    00065 class Q_GUI_EXPORT QFontMetrics
    00066 {
    00067 public:
    00068     QFontMetrics(const QFont &);
    00069     QFontMetrics(const QFont &, QPaintDevice *pd);
    00070     QFontMetrics(const QFontMetrics &);
    00071     ~QFontMetrics();
    00072
    00073     QFontMetrics &operator=(const QFontMetrics &);
    00074
    00075     int ascent() const;
    00076     int descent() const;
    00077     int height() const;
    00078     int leading() const;
    00079     int lineSpacing() const;
    00080     int minLeftBearing() const;
    00081     int minRightBearing() const;
    00082     int maxWidth() const;
    00083
    00084     int xHeight() const;
    00085     int averageCharWidth() const;
    00086
    00087     bool inFont(QChar) const;
    00088
    00089     int leftBearing(QChar) const;
    00090     int rightBearing(QChar) const;
    00091     int width(const QString &, int len = -1) const;
    00092     int width(const QString &, int len, int flags) const;
    00093
    00094     int width(QChar) const;
    00095     int charWidth(const QString &str, int pos) const;
    00096
    00097     QRect boundingRect(QChar) const;
    00098
    00099     QRect boundingRect(const QString &text) const;
    00100     QRect boundingRect(const QRect &r, int flags, const QString &text, int tabstops=0, int *tabarray=0) const;
    00101     inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text,
    00102                               int tabstops=0, int *tabarray=0) const
    00103         { return boundingRect(QRect(x, y, w, h), flags, text, tabstops, tabarray); }
    00104     QSize size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
    00105
    00106     QRect tightBoundingRect(const QString &text) const;
    00107
    00108     QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags = 0) const;
    00109
    00110     int underlinePos() const;
    00111     int overlinePos() const;
    00112     int strikeOutPos() const;
    00113     int lineWidth() const;
    00114
    00115     bool operator==(const QFontMetrics &other); // 5.0 - remove me
    00116     bool operator==(const QFontMetrics &other) const;
    00117     inline bool operator !=(const QFontMetrics &other) { return !operator==(other); } // 5.0 - remove me
    00118     inline bool operator !=(const QFontMetrics &other) const { return !operator==(other); }
    00119
    00120 #ifdef QT3_SUPPORT
    00121     inline QRect boundingRect(const QString &text, int len) const
    00122         { return boundingRect(text.left(len)); }
    00123     inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString& str, int len,
    00124                               int tabstops=0, int *tabarray=0) const
    00125         { return boundingRect(QRect(x, y, w, h), flags, str.left(len), tabstops, tabarray); }
    00126     inline QSize size(int flags, const QString& str, int len, int tabstops=0, int *tabarray=0) const
    00127         { return size(flags, str.left(len), tabstops, tabarray); }
    00128 #endif
    00129 private:
    00130 #if defined(Q_WS_MAC)
    00131     friend class QFontPrivate;
    00132 #endif
    00133     friend class QFontMetricsF;
    00134     friend class QStackTextEngine;
    00135
    00136     QExplicitlySharedDataPointer<QFontPrivate> d;
    00137 };
    00138
    00139
    00140 class Q_GUI_EXPORT QFontMetricsF
    00141 {
    00142 public:
    00143     QFontMetricsF(const QFont &);
    00144     QFontMetricsF(const QFont &, QPaintDevice *pd);
    00145     QFontMetricsF(const QFontMetrics &);
    00146     QFontMetricsF(const QFontMetricsF &);
    00147     ~QFontMetricsF();
    00148
    00149     QFontMetricsF &operator=(const QFontMetricsF &);
    00150     QFontMetricsF &operator=(const QFontMetrics &);
    00151
    00152     qreal ascent() const;
    00153     qreal descent() const;
    00154     qreal height() const;
    00155     qreal leading() const;
    00156     qreal lineSpacing() const;
    00157     qreal minLeftBearing() const;
    00158     qreal minRightBearing() const;
    00159     qreal maxWidth() const;
    00160
    00161     qreal xHeight() const;
    00162     qreal averageCharWidth() const;
    00163
    00164     bool inFont(QChar) const;
    00165
    00166     qreal leftBearing(QChar) const;
    00167     qreal rightBearing(QChar) const;
    00168     qreal width(const QString &string) const;
    00169
    00170     qreal width(QChar) const;
    00171
    00172     QRectF boundingRect(const QString &string) const;
    00173     QRectF boundingRect(QChar) const;
    00174     QRectF boundingRect(const QRectF &r, int flags, const QString& string, int tabstops=0, int *tabarray=0) const;
    00175     QSizeF size(int flags, const QString& str, int tabstops=0, int *tabarray=0) const;
    00176
    00177     QRectF tightBoundingRect(const QString &text) const;
    00178
    00179     QString elidedText(const QString &text, Qt::TextElideMode mode, qreal width, int flags = 0) const;
    00180
    00181     qreal underlinePos() const;
    00182     qreal overlinePos() const;
    00183     qreal strikeOutPos() const;
    00184     qreal lineWidth() const;
    00185
    00186     bool operator==(const QFontMetricsF &other); // 5.0 - remove me
    00187     bool operator==(const QFontMetricsF &other) const;
    00188     inline bool operator !=(const QFontMetricsF &other) { return !operator==(other); } // 5.0 - remove me
    00189     inline bool operator !=(const QFontMetricsF &other) const { return !operator==(other); }
    00190
    00191 private:
    00192     QExplicitlySharedDataPointer<QFontPrivate> d;
    00193 };
    00194
    00195 QT_END_NAMESPACE
    00196
    00197 QT_END_HEADER
    00198
    00199 #endif // QFONTMETRICS_H