5#include <QtCore/qlist.h>
6#include <QtCore/qvarlengtharray.h>
7#include <QtGui/qcolor.h>
8#include <QtGui/qglyphrun.h>
9#include <QtGui/qimage.h>
10#include <QtGui/qtextdocument.h>
11#include <QtGui/qtextlayout.h>
15#ifndef QQUICKTEXTNODEENGINE_P_H
16#define QQUICKTEXTNODEENGINE_P_H
59 BinaryTreeNode(
const QRectF &brect,
const QImage &i, SelectionState selState, qreal a)
65 BinaryTreeNode(
const QGlyphRun &g, SelectionState selState,
const QRectF &brect,
66 const Decorations &decs,
const QColor &c,
const QColor &bc,
const QColor &dc,
67 const QPointF &pos, qreal a);
86 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const QRectF &rect,
const QImage &image, qreal ascent, SelectionState selectionState)
87 { insert(binaryTree,
BinaryTreeNode(rect, image, selectionState, ascent)); }
89 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const QGlyphRun &glyphRun, SelectionState selectionState,
90 Decorations decorations,
const QColor &textColor,
const QColor &backgroundColor,
const QColor &underlineColor,
const QPointF &position);
91 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const BinaryTreeNode &binaryTreeNode);
92 static void inOrder(
const QVarLengthArray<BinaryTreeNode, 16> &binaryTree, QVarLengthArray<
int> *sortedIndexes,
int currentIndex = 0);
101 return fontEngine == otherKey.fontEngine
102 && clipNode == otherKey.clipNode
103 && color == otherKey.color
104 && selectionState == otherKey.selectionState;
115 , m_hasSelection(
false)
116 , m_hasContents(
false)
120 void addTextBlock(QTextDocument *,
const QTextBlock &,
const QPointF &position,
const QColor &textColor,
121 const QColor& anchorColor,
int selectionStart,
int selectionEnd,
const QRectF &viewport = QRectF());
126 if (m_currentLine.isValid())
127 processCurrentLine();
129 m_currentLine = currentLine;
134 m_currentTextDirection = textDirection;
137 void addBorder(
const QRectF &rect, qreal border, QTextFrameFormat::BorderStyle borderStyle,
138 const QBrush &borderBrush);
140 void addImage(
const QRectF &rect,
const QImage &image, qreal ascent,
141 SelectionState selectionState,
142 QTextFrameFormat::Position layoutPosition);
143 int addText(
const QTextBlock &block,
144 const QTextCharFormat &charFormat,
145 const QColor &textColor,
146 const QVarLengthArray<QTextLayout::FormatRange> &colorChanges,
147 int textPos,
int fragmentEnd,
148 int selectionStart,
int selectionEnd);
149 void addTextObject(
const QTextBlock &block,
const QPointF &position,
const QTextCharFormat &format,
150 SelectionState selectionState,
151 QTextDocument *textDocument,
int pos,
156 const QColor &color,
const QColor &backgroundColor,
const QColor &underlineColor,
157 int selectionStart,
int selectionEnd);
160 int selectionStart,
int selectionEnd);
163 QList<BinaryTreeNode *> *imageNodes);
164 void addToSceneGraph(QSGInternalTextNode *parent,
165 QQuickText::TextStyle style = QQuickText::Normal,
166 const QColor &styleColor = QColor());
170 m_selectionColor = selectionColor;
175 m_selectedTextColor = selectedTextColor;
180 m_textColor = textColor;
185 m_anchorColor = anchorColor;
190 m_position = position;
195 m_devicePixelRatio = dpr;
199 struct TextDecoration
201 TextDecoration() : selectionState(Unselected) {}
202 TextDecoration(
const SelectionState &s,
211 SelectionState selectionState;
216 void processCurrentLine();
217 void addTextDecorations(
const QVarLengthArray<TextDecoration> &textDecorations, qreal offset, qreal thickness);
218 void mergeFormats(QTextLayout *textLayout, QVarLengthArray<QTextLayout::FormatRange> *mergedFormats);
220 QColor m_selectionColor;
222 QColor m_backgroundColor;
223 QColor m_decorationColor;
224 QColor m_selectedTextColor;
225 QColor m_anchorColor;
228 QTextLine m_currentLine;
229 Qt::LayoutDirection m_currentTextDirection;
232 QList<QRectF> m_selectionRects;
233 QVarLengthArray<BinaryTreeNode, 16> m_currentLineTree;
235 QList<TextDecoration> m_lines;
236 QVector<BinaryTreeNode> m_processedNodes;
238 qreal m_devicePixelRatio = 1.0;
240 bool m_hasSelection : 1;
241 bool m_hasContents : 1;
242 friend class QSGInternalTextNode;
void addSelectedGlyphs(const QGlyphRun &glyphRun)
void addUnselectedGlyphs(const QGlyphRun &glyphRun)
void addTextObject(const QTextBlock &block, const QPointF &position, const QTextCharFormat &format, SelectionState selectionState, QTextDocument *textDocument, int pos, QTextFrameFormat::Position layoutPosition=QTextFrameFormat::InFlow)
void mergeProcessedNodes(QList< BinaryTreeNode * > *regularNodes, QList< BinaryTreeNode * > *imageNodes)
void addTextBlock(QTextDocument *, const QTextBlock &, const QPointF &position, const QColor &textColor, const QColor &anchorColor, int selectionStart, int selectionEnd, const QRectF &viewport=QRectF())
void addGlyphsInRange(int rangeStart, int rangeEnd, const QColor &color, const QColor &backgroundColor, const QColor &underlineColor, int selectionStart, int selectionEnd)
void setTextColor(const QColor &textColor)
QTextLine currentLine() const
void setCurrentLine(const QTextLine ¤tLine)
int addText(const QTextBlock &block, const QTextCharFormat &charFormat, const QColor &textColor, const QVarLengthArray< QTextLayout::FormatRange > &colorChanges, int textPos, int fragmentEnd, int selectionStart, int selectionEnd)
void setAnchorColor(const QColor &anchorColor)
void addImage(const QRectF &rect, const QImage &image, qreal ascent, SelectionState selectionState, QTextFrameFormat::Position layoutPosition)
void addBorder(const QRectF &rect, qreal border, QTextFrameFormat::BorderStyle borderStyle, const QBrush &borderBrush)
void setPosition(const QPointF &position)
void setDevicePixelRatio(qreal dpr)
void setSelectionColor(const QColor &selectionColor)
void addFrameDecorations(QTextDocument *document, QTextFrame *frame)
void setCurrentTextDirection(Qt::LayoutDirection textDirection)
void addGlyphsForRanges(const QVarLengthArray< QTextLayout::FormatRange > &ranges, int start, int end, int selectionStart, int selectionEnd)
void setSelectedTextColor(const QColor &selectedTextColor)
Q_STATIC_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core")
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
#define QQUICKTEXT_LARGETEXT_THRESHOLD
static bool operator<(const TextNode &n1, const TextNode &n2)
void resetEngine(QQuickTextNodeEngine *engine, const QColor &textColor, const QColor &selectedTextColor, const QColor &selectionColor, qreal dpr)
static const int nodeBreakingSize
\qmlsignal QtQuick::TextEdit::linkActivated(string link)
static void updateNodeTransform(QSGInternalTextNode *node, const QPointF &topLeft)
QQuickTextEditPrivate::Node TextNode
QDebug Q_QUICK_EXPORT operator<<(QDebug debug, const QQuickWindow *item)
bool operator==(const BinaryTreeNodeKey &otherKey) const
BinaryTreeNodeKey(BinaryTreeNode *node)
QQuickDefaultClipNode * clipNode
SelectionState selectionState
static void insert(QVarLengthArray< BinaryTreeNode, 16 > *binaryTree, const QRectF &rect, const QImage &image, qreal ascent, SelectionState selectionState)
QQuickDefaultClipNode * clipNode
BinaryTreeNode(const QGlyphRun &g, SelectionState selState, const QRectF &brect, const Decorations &decs, const QColor &c, const QColor &bc, const QColor &dc, const QPointF &pos, qreal a)
static void inOrder(const QVarLengthArray< BinaryTreeNode, 16 > &binaryTree, QVarLengthArray< int > *sortedIndexes, int currentIndex=0)
BinaryTreeNode(const QRectF &brect, const QImage &i, SelectionState selState, qreal a)
static void insert(QVarLengthArray< BinaryTreeNode, 16 > *binaryTree, const BinaryTreeNode &binaryTreeNode)
static void insert(QVarLengthArray< BinaryTreeNode, 16 > *binaryTree, const QGlyphRun &glyphRun, SelectionState selectionState, Decorations decorations, const QColor &textColor, const QColor &backgroundColor, const QColor &underlineColor, const QPointF &position)