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, QTextCharFormat::UnderlineStyle us,
67 const QColor &c,
const QColor &bc,
const QColor &dc,
68 const QPointF &pos, qreal a);
88 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const QRectF &rect,
const QImage &image, qreal ascent, SelectionState selectionState)
89 { insert(binaryTree,
BinaryTreeNode(rect, image, selectionState, ascent)); }
91 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
92 const QGlyphRun &glyphRun, SelectionState selectionState,
93 Decorations decorations, QTextCharFormat::UnderlineStyle underlineStyle,
94 const QColor &textColor,
const QColor &backgroundColor,
95 const QColor &underlineColor,
const QPointF &position);
96 static void insert(QVarLengthArray<BinaryTreeNode, 16> *binaryTree,
const BinaryTreeNode &binaryTreeNode);
97 static void inOrder(
const QVarLengthArray<BinaryTreeNode, 16> &binaryTree, QVarLengthArray<
int> *sortedIndexes,
int currentIndex = 0);
106 return fontEngine == otherKey.fontEngine
107 && clipNode == otherKey.clipNode
108 && color == otherKey.color
109 && selectionState == otherKey.selectionState;
120 , m_hasSelection(
false)
121 , m_hasContents(
false)
125 void addTextBlock(QTextDocument *,
const QTextBlock &,
const QPointF &position,
const QColor &textColor,
126 const QColor& anchorColor,
int selectionStart,
int selectionEnd,
const QRectF &viewport = QRectF());
131 if (m_currentLine.isValid())
132 processCurrentLine();
134 m_currentLine = currentLine;
139 m_currentTextDirection = textDirection;
142 void addBorder(
const QRectF &rect, qreal border, QTextFrameFormat::BorderStyle borderStyle,
143 const QBrush &borderBrush);
145 void addImage(
const QRectF &rect,
const QImage &image, qreal ascent,
146 SelectionState selectionState,
147 QTextFrameFormat::Position layoutPosition);
148 int addText(
const QTextBlock &block,
149 const QTextCharFormat &charFormat,
150 const QColor &textColor,
151 const QVarLengthArray<QTextLayout::FormatRange> &colorChanges,
152 int textPos,
int fragmentEnd,
153 int selectionStart,
int selectionEnd);
154 void addTextObject(
const QTextBlock &block,
const QPointF &position,
const QTextCharFormat &format,
155 SelectionState selectionState,
156 QTextDocument *textDocument,
int pos,
161 QTextCharFormat::UnderlineStyle underlineStyle,
162 const QColor &color,
const QColor &backgroundColor,
163 const QColor &underlineColor,
int selectionStart,
int selectionEnd);
166 int selectionStart,
int selectionEnd);
169 QList<BinaryTreeNode *> *imageNodes);
170 void addToSceneGraph(QSGInternalTextNode *parent,
171 QQuickText::TextStyle style = QQuickText::Normal,
172 const QColor &styleColor = QColor());
176 m_selectionColor = selectionColor;
181 m_selectedTextColor = selectedTextColor;
186 m_textColor = textColor;
191 m_anchorColor = anchorColor;
196 m_position = position;
201 m_devicePixelRatio = dpr;
205 struct TextDecoration
207 TextDecoration() : selectionState(Unselected) {}
208 TextDecoration(
const SelectionState &s,
const QRectF &r,
const QColor &c,
209 QTextCharFormat::UnderlineStyle us = QTextCharFormat::NoUnderline)
210 : selectionState(s), underlineStyle(us), rect(r), color(c)
214 SelectionState selectionState;
215 QTextCharFormat::UnderlineStyle underlineStyle = QTextCharFormat::NoUnderline;
220 void processCurrentLine();
221 void addTextDecorations(
const QVarLengthArray<TextDecoration> &textDecorations, qreal offset, qreal thickness);
222 void mergeFormats(QTextLayout *textLayout, QVarLengthArray<QTextLayout::FormatRange> *mergedFormats);
224 QColor m_selectionColor;
226 QColor m_backgroundColor;
227 QColor m_decorationColor;
228 QColor m_selectedTextColor;
229 QColor m_anchorColor;
233 QTextLine m_currentLine;
234 Qt::LayoutDirection m_currentTextDirection;
237 QList<QRectF> m_selectionRects;
238 QVarLengthArray<BinaryTreeNode, 16> m_currentLineTree;
240 QList<TextDecoration> m_lines;
241 QList<BinaryTreeNode> m_processedNodes;
243 qreal m_devicePixelRatio = 1.0;
245 bool m_hasSelection : 1;
246 bool m_hasContents : 1;
247 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 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)