6#include <QtGui/qcolor.h>
7#include <QtGui/qevent.h>
8#include <QtGui/qglyphrun.h>
9#include <QtGui/qtextcursor.h>
10#include <QtGui/qtextformat.h>
11#include <QtGui/qtguiglobal.h>
13#include <QtCore/qlist.h>
14#include <QtCore/qnamespace.h>
15#include <QtCore/qobject.h>
16#include <QtCore/qrect.h>
17#include <QtCore/qstring.h>
36 QTextInlineObject(
int i, QTextEngine *e) : itm(i), eng(e) {}
37 inline QTextInlineObject() : itm(0), eng(
nullptr) {}
38 inline bool isValid()
const {
return eng; }
43 qreal descent()
const;
46 Qt::LayoutDirection textDirection()
const;
48 void setWidth(qreal w);
49 void setAscent(qreal a);
50 void setDescent(qreal d);
52 int textPosition()
const;
54 int formatIndex()
const;
55 QTextFormat format()
const;
58 friend class QTextLayout;
72 enum GlyphRunRetrievalFlag : quint16 {
73 RetrieveGlyphIndexes = 0x1,
74 RetrieveGlyphPositions = 0x2,
75 RetrieveStringIndexes = 0x4,
78 DefaultRetrievalFlags = RetrieveGlyphIndexes | RetrieveGlyphPositions,
81 Q_DECLARE_FLAGS(GlyphRunRetrievalFlags, GlyphRunRetrievalFlag)
85 QTextLayout(
const QString& text);
86 QTextLayout(
const QString &text,
const QFont &font,
const QPaintDevice *paintdevice =
nullptr);
87 QTextLayout(
const QTextBlock &b);
90 void setFont(
const QFont &f);
94 void setRawFont(
const QRawFont &rawFont);
97 void setText(
const QString& string);
100 void setTextOption(
const QTextOption &option);
101 const QTextOption &textOption()
const;
103 void setPreeditArea(
int position,
const QString &text);
104 int preeditAreaPosition()
const;
105 QString preeditAreaText()
const;
110 QTextCharFormat format;
112 friend bool operator==(
const FormatRange &lhs,
const FormatRange &rhs)
113 {
return lhs.start == rhs.start && lhs.length == rhs.length && lhs.format == rhs.format; }
114 friend bool operator!=(
const FormatRange &lhs,
const FormatRange &rhs)
115 {
return !operator==(lhs, rhs); }
117 void setFormats(
const QList<FormatRange> &overrides);
118 QList<FormatRange> formats()
const;
121 void setCacheEnabled(
bool enable);
122 bool cacheEnabled()
const;
124 void setCursorMoveStyle(Qt::CursorMoveStyle style);
125 Qt::CursorMoveStyle cursorMoveStyle()
const;
131 QTextLine createLine();
133 int lineCount()
const;
134 QTextLine lineAt(
int i)
const;
135 QTextLine lineForTextPosition(
int pos)
const;
141 bool isValidCursorPosition(
int pos)
const;
142 int nextCursorPosition(
int oldPos, CursorMode mode = SkipCharacters)
const;
143 int previousCursorPosition(
int oldPos, CursorMode mode = SkipCharacters)
const;
144 int leftCursorPosition(
int oldPos)
const;
145 int rightCursorPosition(
int oldPos)
const;
147 void draw(QPainter *p,
const QPointF &pos,
148 const QList<FormatRange> &selections = QList<FormatRange>(),
149 const QRectF &clip = QRectF())
const;
150 void drawCursor(QPainter *p,
const QPointF &pos,
int cursorPosition)
const;
151 void drawCursor(QPainter *p,
const QPointF &pos,
int cursorPosition,
int width)
const;
153 QPointF position()
const;
154 void setPosition(
const QPointF &p);
156 QRectF boundingRect()
const;
158 qreal minimumWidth()
const;
159 qreal maximumWidth()
const;
161#if !defined(QT_NO_RAWFONT)
163# if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
164 QList<QGlyphRun> glyphRuns(
int from,
int length, GlyphRunRetrievalFlags flags)
const;
165 QList<QGlyphRun> glyphRuns(
int from = -1,
int length = -1)
const;
167 QList<QGlyphRun> glyphRuns(
int from = -1,
169 GlyphRunRetrievalFlags flags = DefaultRetrievalFlags)
const;
173 QTextEngine *engine()
const {
return d; }
174 void setFlags(
int flags);
176 QTextLayout(QTextEngine *e) : d(e) {}
177 Q_DISABLE_COPY(QTextLayout)
179 friend class QPainter;
180 friend class QGraphicsSimpleTextItemPrivate;
181 friend class QGraphicsSimpleTextItem;
182 friend void qt_format_text(
const QFont &font,
const QRectF &_r,
int tf,
int alignment,
const QTextOption *,
const QString& str,
183 QRectF *brect,
int tabstops,
int* tabarray,
int tabarraylen,
187Q_DECLARE_TYPEINFO(QTextLayout::FormatRange, Q_RELOCATABLE_TYPE);
188Q_DECLARE_OPERATORS_FOR_FLAGS(QTextLayout::GlyphRunRetrievalFlags)
190class Q_GUI_EXPORT QTextLine
193 inline QTextLine() : index(0), eng(
nullptr) {}
194 inline bool isValid()
const {
return eng; }
200 qreal ascent()
const;
201 qreal descent()
const;
202 qreal height()
const;
203 qreal leading()
const;
205 void setLeadingIncluded(
bool included);
206 bool leadingIncluded()
const;
208 qreal naturalTextWidth()
const;
209 qreal horizontalAdvance()
const;
210 QRectF naturalTextRect()
const;
216 enum CursorPosition {
217 CursorBetweenCharacters,
222 qreal cursorToX(
int *cursorPos, Edge edge = Leading)
const;
223 inline qreal cursorToX(
int cursorPos, Edge edge = Leading)
const {
return cursorToX(&cursorPos, edge); }
224 int xToCursor(qreal x, CursorPosition = CursorBetweenCharacters)
const;
226 void setLineWidth(qreal width);
227 void setNumColumns(
int columns);
228 void setNumColumns(
int columns, qreal alignmentWidth);
230 void setPosition(
const QPointF &pos);
231 QPointF position()
const;
233 int textStart()
const;
234 int textLength()
const;
236 int lineNumber()
const {
return index; }
238 void draw(QPainter *painter,
const QPointF &position)
const;
240#if !defined(QT_NO_RAWFONT)
241# if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
242 QList<QGlyphRun> glyphRuns(
int from,
int length, QTextLayout::GlyphRunRetrievalFlags flags)
const;
243 QList<QGlyphRun> glyphRuns(
int from = -1,
int length = -1)
const;
245 QList<QGlyphRun> glyphRuns(
int from = -1,
247 QTextLayout::GlyphRunRetrievalFlags flags = QTextLayout::DefaultRetrievalFlags)
const;
252 QTextLine(
int line, QTextEngine *e) : index(line), eng(e) {}
253 void layout_helper(
int numGlyphs);
254 void draw_internal(QPainter *p,
const QPointF &pos,
255 const QTextLayout::FormatRange *selection)
const;
257 friend class QTextLayout;
258 friend class QTextFragment;
QPainterPathStroker(const QPen &pen)
Creates a new stroker based on pen.
void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation)
QPaintEngineEx * extended
QPaintDevice * helper_device
void initFrom(const QPaintDevice *device)
void draw_helper(const QPainterPath &path, DrawOperation operation=StrokeAndFillDraw)
void drawStretchedGradient(const QPainterPath &path, DrawOperation operation)
QTransform hidpiScaleTransform() const
QTransform viewTransform() const
qreal effectiveDevicePixelRatio() const
void drawGlyphs(const QPointF &decorationPosition, const quint32 *glyphArray, QFixedPoint *positionArray, int glyphCount, QFontEngine *fontEngine, bool overline=false, bool underline=false, bool strikeOut=false)
\inmodule QtCore\reentrant
Q_GUI_EXPORT bool qt_isExtendedRadialGradient(const QBrush &brush)
#define QPaintEngine_OpaqueBackground
void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, const QString &str, QRectF *brect, int tabstops, int *ta, int tabarraylen, QPainter *painter)
static void qt_draw_decoration_for_glyphs(QPainter *painter, const QPointF &decorationPosition, const glyph_t *glyphArray, const QFixedPoint *positions, int glyphCount, QFontEngine *fontEngine, bool underline, bool overline, bool strikeOut)
static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QFontEngine *fe, QTextEngine *textEngine, QTextCharFormat::UnderlineStyle underlineStyle, QTextItem::RenderFlags flags, qreal width, const QTextCharFormat &charFormat)
static bool needsEmulation(const QBrush &brush)
static bool needsResolving(const QBrush &brush)
void qt_format_text(const QFont &font, const QRectF &_r, int tf, const QTextOption *option, const QString &str, QRectF *brect, int tabstops, int *tabarray, int tabarraylen, QPainter *painter)
static QPointF roundInDeviceCoordinates(const QPointF &p, const QTransform &m)
QPixmap qt_pixmapForBrush(int style, bool invert)
static bool is_brush_transparent(const QBrush &brush)
void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, int alignment, const QTextOption *option, const QString &str, QRectF *brect, int tabstops, int *ta, int tabarraylen, QPainter *painter)
static QBrush stretchGradientToUserSpace(const QBrush &brush, const QRectF &boundingRect)
static bool qt_painter_thread_test(int devType, int engineType, const char *what)
static void qt_cleanup_painter_state(QPainterPrivate *d)
static QGradient::CoordinateMode coordinateMode(const QBrush &brush)
static uint line_emulation(uint emulation)
static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
#define QGradient_StretchToDevice
static bool is_pen_transparent(const QPen &pen)
bool qHasPixmapTexture(const QBrush &)
Q_GUI_EXPORT void qt_draw_helper(QPainterPrivate *p, const QPainterPath &path, QPainterPrivate::DrawOperation operation)