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
****************************************************************************/
31
#include "QtCore/qstring.h"
32
#include "QtCore/qnamespace.h"
33
#include "QtCore/qrect.h"
34
#include "QtCore/qvector.h"
35
#include "QtGui/qcolor.h"
36
#include "QtCore/qobject.h"
37
#include "QtGui/qevent.h"
38
#include "QtGui/qtextformat.h"
48
class Q_GUI_EXPORT QTextInlineObject
51
QTextInlineObject(int i, QTextEngine *e) : itm(i), eng(e) {}
52
inline QTextInlineObject() : itm(0), eng(0) {}
53
inline bool isValid() const { return eng; }
58
qreal descent() const;
61
Qt::LayoutDirection textDirection() const;
63
void setWidth(qreal w);
64
void setAscent(qreal a);
65
void setDescent(qreal d);
67
int textPosition() const;
69
int formatIndex() const;
70
QTextFormat format() const;
73
friend class QTextLayout;
84
class Q_GUI_EXPORT QTextLayout
89
QTextLayout(const QString& text);
90
QTextLayout(const QString& text, const QFont &font, QPaintDevice *paintdevice = 0);
91
QTextLayout(const QTextBlock &b);
94
void setFont(const QFont &f);
97
void setText(const QString& string);
100
void setTextOption(const QTextOption &option);
101
QTextOption textOption() const;
103
void setPreeditArea(int position, const QString &text);
104
int preeditAreaPosition() const;
105
QString preeditAreaText() const;
110
QTextCharFormat format;
112
void setAdditionalFormats(const QList<FormatRange> &overrides);
113
QList<FormatRange> additionalFormats() const;
114
void clearAdditionalFormats();
116
void setCacheEnabled(bool enable);
117
bool cacheEnabled() const;
122
QTextLine createLine();
124
int lineCount() const;
125
QTextLine lineAt(int i) const;
126
QTextLine lineForTextPosition(int pos) const;
132
bool isValidCursorPosition(int pos) const;
133
int nextCursorPosition(int oldPos, CursorMode mode = SkipCharacters) const;
134
int previousCursorPosition(int oldPos, CursorMode mode = SkipCharacters) const;
136
void draw(QPainter *p, const QPointF &pos, const QVector<FormatRange> &selections = QVector<FormatRange>(),
137
const QRectF &clip = QRectF()) const;
138
void drawCursor(QPainter *p, const QPointF &pos, int cursorPosition) const;
140
QPointF position() const;
141
void setPosition(const QPointF &p);
143
QRectF boundingRect() const;
145
qreal minimumWidth() const;
146
qreal maximumWidth() const;
148
QTextEngine *engine() const { return d; }
150
QTextLayout(QTextEngine *e) : d(e) {}
151
Q_DISABLE_COPY(QTextLayout)
153
friend class QPainter;
154
friend class QPSPrinter;
159
class Q_GUI_EXPORT QTextLine
162
inline QTextLine() : i(0), eng(0) {}
163
inline bool isValid() const { return eng; }
169
qreal ascent() const;
170
qreal descent() const;
171
qreal height() const;
173
qreal naturalTextWidth() const;
174
QRectF naturalTextRect() const;
180
enum CursorPosition {
181
CursorBetweenCharacters,
185
/* cursorPos gets set to the valid position */
186
qreal cursorToX(int *cursorPos, Edge edge = Leading) const;
187
inline qreal cursorToX(int cursorPos, Edge edge = Leading) const { return cursorToX(&cursorPos, edge); }
188
int xToCursor(qreal x, CursorPosition = CursorBetweenCharacters) const;
190
void setLineWidth(qreal width);
191
void setNumColumns(int columns);
193
void setPosition(const QPointF &pos);
195
int textStart() const;
196
int textLength() const;
198
int lineNumber() const { return i; }
200
void draw(QPainter *p, const QPointF &point, const QTextLayout::FormatRange *selection = 0) const;
203
QTextLine(int line, QTextEngine *e) : i(line), eng(e) {}
204
void layout_helper(int numGlyphs);
205
friend class QTextLayout;
210
#endif // QTEXTLAYOUT_H