~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/text/qfontmetrics.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the text module of the Qt Toolkit.
 
6
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
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.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef QFONTMETRICS_H
 
30
#define QFONTMETRICS_H
 
31
 
 
32
#include "QtGui/qfont.h"
 
33
#ifndef QT_INCLUDE_COMPAT
 
34
#include "QtCore/qrect.h"
 
35
#endif
 
36
 
 
37
#ifdef Q_WS_QWS
 
38
class QFontEngine;
 
39
#endif
 
40
 
 
41
class QTextCodec;
 
42
class QRect;
 
43
 
 
44
 
 
45
class Q_GUI_EXPORT QFontMetrics
 
46
{
 
47
public:
 
48
    QFontMetrics(const QFont &);
 
49
    QFontMetrics(const QFont &, QPaintDevice *pd);
 
50
    QFontMetrics(const QFontMetrics &);
 
51
    ~QFontMetrics();
 
52
 
 
53
    QFontMetrics &operator=(const QFontMetrics &);
 
54
 
 
55
    int ascent() const;
 
56
    int descent() const;
 
57
    int height() const;
 
58
    int leading() const;
 
59
    int lineSpacing() const;
 
60
    int minLeftBearing() const;
 
61
    int minRightBearing() const;
 
62
    int maxWidth() const;
 
63
 
 
64
    bool inFont(QChar) const;
 
65
 
 
66
    int leftBearing(QChar) const;
 
67
    int rightBearing(QChar) const;
 
68
    int width(const QString &, int len = -1) const;
 
69
 
 
70
    int width(QChar) const;
 
71
    int charWidth(const QString &str, int pos) const;
 
72
 
 
73
    QRect boundingRect(QChar) const;
 
74
 
 
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;
 
81
 
 
82
    int underlinePos() const;
 
83
    int overlinePos() const;
 
84
    int strikeOutPos() const;
 
85
    int lineWidth() const;
 
86
 
 
87
    bool operator==(const QFontMetrics &other);
 
88
    inline bool operator !=(const QFontMetrics &other) { return !operator==(other); }
 
89
 
 
90
#ifdef QT3_SUPPORT
 
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); }
 
98
#endif
 
99
private:
 
100
#if defined(Q_WS_MAC)
 
101
    friend class QFontPrivate;
 
102
#endif
 
103
 
 
104
    QFontPrivate *d;
 
105
};
 
106
 
 
107
 
 
108
class Q_GUI_EXPORT QFontMetricsF
 
109
{
 
110
public:
 
111
    QFontMetricsF(const QFont &);
 
112
    QFontMetricsF(const QFont &, QPaintDevice *pd);
 
113
    QFontMetricsF(const QFontMetrics &);
 
114
    QFontMetricsF(const QFontMetricsF &);
 
115
    ~QFontMetricsF();
 
116
 
 
117
    QFontMetricsF &operator=(const QFontMetricsF &);
 
118
    QFontMetricsF &operator=(const QFontMetrics &);
 
119
 
 
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;
 
128
 
 
129
    bool inFont(QChar) const;
 
130
 
 
131
    qreal leftBearing(QChar) const;
 
132
    qreal rightBearing(QChar) const;
 
133
    qreal width(const QString &string) const;
 
134
 
 
135
    qreal width(QChar) const;
 
136
 
 
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;
 
141
 
 
142
    qreal underlinePos() const;
 
143
    qreal overlinePos() const;
 
144
    qreal strikeOutPos() const;
 
145
    qreal lineWidth() const;
 
146
 
 
147
    bool operator==(const QFontMetricsF &other);
 
148
    inline bool operator !=(const QFontMetricsF &other) { return !operator==(other); }
 
149
 
 
150
private:
 
151
    QFontPrivate *d;
 
152
};
 
153
 
 
154
#endif // QFONTMETRICS_H