7#include <private/qtextengine_p.h>
8#include <private/qfontengine_p.h>
156void QStaticText::detach()
158 if (
data->ref.loadRelaxed() != 1)
212 &&
data->textWidth ==
other.data->textWidth));
221 return !(*
this ==
other);
326 return data->textOption;
356 return data->textWidth;
366 if (
data->needsRelayout)
368 return data->actualSize;
373 needsRelayout(true), useBackendOptimizations(
false), textFormat(
Qt::AutoText),
374 untransformedCoordinates(
false)
381 needsRelayout(true), useBackendOptimizations(
other.useBackendOptimizations),
382 textFormat(
other.textFormat), untransformedCoordinates(
other.untransformedCoordinates)
395 return q->data.data();
403 DrawTextItemRecorder(
bool untransformedCoordinates,
bool useBackendOptimizations)
404 : m_dirtyPen(
false), m_useBackendOptimizations(useBackendOptimizations),
405 m_untransformedCoordinates(untransformedCoordinates), m_currentColor(0, 0, 0, 0)
412 &&
newState.pen().color() != m_currentColor) {
414 m_currentColor =
newState.pen().color();
429 currentItem.
color = m_currentColor;
442 m_glyphs.resize(m_glyphs.size() +
size);
443 m_positions.resize(m_glyphs.size());
451 m_items.append(currentItem);
460 virtual bool end()
override {
return true; }
488 bool m_useBackendOptimizations;
489 bool m_untransformedCoordinates;
496 DrawTextItemDevice(
bool untransformedCoordinates,
bool useBackendOptimizations)
498 m_paintEngine =
new DrawTextItemRecorder(untransformedCoordinates,
499 useBackendOptimizations);
502 ~DrawTextItemDevice()
504 delete m_paintEngine;
507 int metric(PaintDeviceMetric
m)
const override
539 qWarning(
"DrawTextItemDevice::metric: Invalid metric command");
546 return m_paintEngine;
551 return m_paintEngine->glyphs();
556 return m_paintEngine->positions();
561 return m_paintEngine->items();
565 DrawTextItemRecorder *m_paintEngine;
574 if (!preferRichText) {
587 line.setLeadingIncluded(
true);
595 if (
line.leading() < 0)
602 textLayout.
draw(
p, topLeftPosition);
605#ifndef QT_NO_CSSPARSER
612 document.setDefaultFont(
font);
613 document.setDocumentMargin(0.0);
614#ifndef QT_NO_TEXTHTMLPARSER
615 document.setHtml(
text);
617 document.setPlainText(
text);
622 document.adjustSize();
626 p->translate(topLeftPosition);
629 document.documentLayout()->draw(
p,
ctx);
IOBluetoothDevice * device
The QColor class provides colors based on RGB, HSV or CMYK values.
int alpha() const noexcept
Returns the alpha color component of this color.
int red() const noexcept
Returns the red color component of this color.
int blue() const noexcept
Returns the blue color component of this color.
int green() const noexcept
Returns the green color component of this color.
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
qsizetype size() const noexcept
const_pointer constData() const noexcept
const_reference at(qsizetype i) const noexcept
@ PdmDevicePixelRatioScaled
virtual int metric(PaintDeviceMetric metric) const
virtual QPaintEngine * paintEngine() const =0
static qreal devicePixelRatioFScale()
The QPaintEngineState class provides information about the active paint engine's current state....
virtual void updateState(const QPaintEngineState &state)=0
Reimplement this function to update the state of a paint engine.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)=0
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.
virtual bool begin(QPaintDevice *pdev)=0
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
virtual bool end()=0
Reimplement this function to finish painting on the current paint device.
virtual Type type() const =0
Reimplement this function to return the paint engine \l{Type}.
The QPainter class performs low-level painting on widgets and other paint devices.
void setFont(const QFont &f)
Sets the painter's font to the given font.
void setTransform(const QTransform &transform, bool combine=false)
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr QSizeF size() const noexcept
Returns the size of the rectangle.
char useBackendOptimizations
QFixedPoint * glyphPositions
void setFontEngine(QFontEngine *fe)
unsigned char useBackendOptimizations
void paintText(const QPointF &pos, QPainter *p, const QColor &pen)
static QStaticTextPrivate * get(const QStaticText *q)
unsigned char needsRelayout
QFixedPoint * positionPool
unsigned char untransformedCoordinates
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
void setText(const QString &text)
Sets the text of the QStaticText to text.
QStaticText()
Constructs an empty QStaticText.
QTextOption textOption() const
Returns the current text option used to control the layout process.
void setTextWidth(qreal textWidth)
Sets the preferred width for this QStaticText.
qreal textWidth() const
Returns the preferred width for this QStaticText.
Qt::TextFormat textFormat() const
Returns the text format of the QStaticText.
void prepare(const QTransform &matrix=QTransform(), const QFont &font=QFont())
Prepares the QStaticText object for being painted with the given matrix and the given font to avoid o...
PerformanceHint performanceHint() const
Returns which performance hint is set for the QStaticText.
bool operator!=(const QStaticText &) const
Compares other to this QStaticText.
QStaticText & operator=(const QStaticText &)
Assigns other to this QStaticText.
void setTextFormat(Qt::TextFormat textFormat)
Sets the text format of the QStaticText to textFormat.
~QStaticText()
Destroys the QStaticText.
void setPerformanceHint(PerformanceHint performanceHint)
Sets the performance hint of the QStaticText according to the performanceHint provided.
QSizeF size() const
Returns the size of the bounding rect for this QStaticText.
void setTextOption(const QTextOption &textOption)
Sets the text option structure that controls the layout process to the given textOption.
QString text() const
Returns the text of the QStaticText.
bool operator==(const QStaticText &) const
Compares other to this QStaticText.
PerformanceHint
This enum the different performance hints that can be set on the QStaticText.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
\reentrant \inmodule QtGui
QFont font() const
Returns the font that should be used to draw the text.
void setFont(const QFont &f)
Sets the layout's font to the given font.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
void beginLayout()
Begins the layout process.
void setCacheEnabled(bool enable)
Enables caching of the complete layout information if enable is true; otherwise disables layout cachi...
void setText(const QString &string)
Sets the layout's text to the given string.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
void draw(QPainter *p, const QPointF &pos, const QList< FormatRange > &selections=QList< FormatRange >(), const QRectF &clip=QRectF()) const
Draws the whole layout on the painter p at the position specified by pos.
void endLayout()
Ends the layout process.
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
constexpr size_type size() const noexcept
const T * constData() const
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLenum GLenum transform
GLdouble GLdouble GLdouble GLdouble q
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
\reentrant \inmodule QtGui