00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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);
00116 bool operator==(const QFontMetrics &other) const;
00117 inline bool operator !=(const QFontMetrics &other) { return !operator==(other); }
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);
00187 bool operator==(const QFontMetricsF &other) const;
00188 inline bool operator !=(const QFontMetricsF &other) { return !operator==(other); }
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