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#include <QtCore/qspan.h>
17#ifndef QQUICKTEXTNODEENGINE_P_H
18#define QQUICKTEXTNODEENGINE_P_H
61 BinaryTreeNode(
const QRectF &brect,
const QImage &i, SelectionState selState, qreal a)
67 BinaryTreeNode(
const QGlyphRun &g, SelectionState selState,
const QRectF &brect,
68 const Decorations &decs, QTextCharFormat::UnderlineStyle us,
69 const QColor &c,
const QColor &bc,
const QColor &dc,
70 const QPointF &pos, qreal a);
90 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const QRectF &rect,
const QImage &image, qreal ascent, SelectionState selectionState)
91 { insert(binaryTree,
BinaryTreeNode(rect, image, selectionState, ascent)); }
93 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
94 const QGlyphRun &glyphRun, SelectionState selectionState,
95 Decorations decorations, QTextCharFormat::UnderlineStyle underlineStyle,
96 const QColor &textColor,
const QColor &backgroundColor,
97 const QColor &underlineColor,
const QPointF &position);
98 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const BinaryTreeNode &binaryTreeNode);
99 static void inOrder(
const QVarLengthArray<BinaryTreeNode, 16> &binaryTree, QVarLengthArray<
int> *sortedIndexes,
int currentIndex = 0);
108 return fontEngine == otherKey.fontEngine
109 && clipNode == otherKey.clipNode
110 && color == otherKey.color
111 && selectionState == otherKey.selectionState;
122 , m_hasSelection(
false)
123 , m_hasContents(
false)
127 void addTextBlock(QTextDocument *,
const QTextBlock &,
const QPointF &position,
const QColor &textColor,
128 const QColor& anchorColor,
int selectionStart,
int selectionEnd,
const QRectF &viewport = QRectF());
133 if (m_currentLine.isValid())
134 processCurrentLine();
136 m_currentLine = currentLine;
141 m_currentTextDirection = textDirection;
144 void addBorder(
const QRectF &rect, qreal border, QTextFrameFormat::BorderStyle borderStyle,
145 const QBrush &borderBrush);
147 void addImage(
const QRectF &rect,
const QImage &image, qreal ascent,
148 SelectionState selectionState,
149 QTextFrameFormat::Position layoutPosition);
150 int addText(
const QTextBlock &block,
151 const QTextCharFormat &charFormat,
152 const QColor &textColor,
153 const QVarLengthArray<QTextLayout::FormatRange> &colorChanges,
154 int textPos,
int fragmentEnd,
155 int selectionStart,
int selectionEnd);
156 void addTextObject(
const QTextBlock &block,
const QPointF &position,
const QTextCharFormat &format,
157 SelectionState selectionState,
158 QTextDocument *textDocument,
int pos,
163 QTextCharFormat::UnderlineStyle underlineStyle,
164 const QColor &color,
const QColor &backgroundColor,
165 const QColor &underlineColor,
int selectionStart,
int selectionEnd);
168 int selectionStart,
int selectionEnd);
171 QVarLengthArray<BinaryTreeNode *, 8> *imageNodes);
172 void addToSceneGraph(QSGInternalTextNode *parent,
173 QSGInternalTextNode::RecycleBin *recycleBin,
174 QQuickText::TextStyle style = QQuickText::Normal,
175 const QColor &styleColor = QColor());
179 m_selectionColor = selectionColor;
184 m_selectedTextColor = selectedTextColor;
189 m_textColor = textColor;
194 m_anchorColor = anchorColor;
199 m_position = position;
204 m_devicePixelRatio = dpr;
208 struct TextDecoration
210 TextDecoration() : selectionState(Unselected) {}
211 TextDecoration(
const SelectionState &s,
const QRectF &r,
const QColor &c,
212 QTextCharFormat::UnderlineStyle us = QTextCharFormat::NoUnderline)
213 : selectionState(s), underlineStyle(us), rect(r), color(c)
217 SelectionState selectionState;
218 QTextCharFormat::UnderlineStyle underlineStyle = QTextCharFormat::NoUnderline;
223 void processCurrentLine();
224 void addTextDecorations(QSpan<
const TextDecoration> textDecorations, qreal offset, qreal thickness);
225 void mergeFormats(QTextLayout *textLayout, QVarLengthArray<QTextLayout::FormatRange> *mergedFormats);
227 QColor m_selectionColor;
229 QColor m_backgroundColor;
230 QColor m_decorationColor;
231 QColor m_selectedTextColor;
232 QColor m_anchorColor;
236 QTextLine m_currentLine;
237 Qt::LayoutDirection m_currentTextDirection;
240 QList<QRectF> m_selectionRects;
241 QVarLengthArray<BinaryTreeNode, 16> m_currentLineTree;
243 QList<TextDecoration> m_lines;
244 QList<BinaryTreeNode> m_processedNodes;
246 qreal m_devicePixelRatio = 1.0;
248 bool m_hasSelection : 1;
249 bool m_hasContents : 1;
250 friend class QSGInternalTextNode;
void addSelectedGlyphs(const QGlyphRun &glyphRun)
void addUnselectedGlyphs(const QGlyphRun &glyphRun)
void mergeProcessedNodes(QVarLengthArray< BinaryTreeNode *, 8 > *regularNodes, QVarLengthArray< BinaryTreeNode *, 8 > *imageNodes)
void addTextObject(const QTextBlock &block, const QPointF &position, const QTextCharFormat &format, SelectionState selectionState, QTextDocument *textDocument, int pos, QTextFrameFormat::Position layoutPosition=QTextFrameFormat::InFlow)
void addTextBlock(QTextDocument *, const QTextBlock &, const QPointF &position, const QColor &textColor, const QColor &anchorColor, int selectionStart, int selectionEnd, const QRectF &viewport=QRectF())
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 addGlyphsInRange(int rangeStart, int rangeEnd, QTextCharFormat::UnderlineStyle underlineStyle, const QColor &color, const QColor &backgroundColor, const QColor &underlineColor, int selectionStart, int selectionEnd)
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)
Combined button and popup list for selecting options.
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
#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)
BinaryTreeNodeKey(BinaryTreeNode *node)
bool operator==(const BinaryTreeNodeKey &otherKey) const
QQuickDefaultClipNode * clipNode
BinaryTreeNode(const QGlyphRun &g, SelectionState selState, const QRectF &brect, const Decorations &decs, QTextCharFormat::UnderlineStyle us, const QColor &c, const QColor &bc, const QColor &dc, const QPointF &pos, qreal a)
QTextCharFormat::UnderlineStyle underlineStyle
SelectionState selectionState
static void insert(QVarLengthArray< BinaryTreeNode, 16 > *binaryTree, const QRectF &rect, const QImage &image, qreal ascent, SelectionState selectionState)
QQuickDefaultClipNode * clipNode
static void insert(QVarLengthArray< BinaryTreeNode, 16 > *binaryTree, const QGlyphRun &glyphRun, SelectionState selectionState, Decorations decorations, QTextCharFormat::UnderlineStyle underlineStyle, const QColor &textColor, const QColor &backgroundColor, const QColor &underlineColor, const QPointF &position)
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)