44 #include <private/qtextengine_p.h> 45 #include <private/qfontengine_p.h> 48 #include <QtGui/qapplication.h> 251 return !(*
this == other);
402 :
textWidth(-1.0), items(0), itemCount(0), glyphPool(0), positionPool(0), charPool(0),
404 untransformedCoordinates(false)
435 : m_dirtyPen(
false), m_useBackendOptimizations(useBackendOptimizations),
436 m_untransformedCoordinates(untransformedCoordinates), m_currentColor(
Qt::black)
443 && newState.
pen().
color() != m_currentColor) {
445 m_currentColor = newState.
pen().
color();
462 currentItem.
color = m_currentColor;
471 int size = glyphs.
size();
475 m_glyphs.resize(m_glyphs.size() + size);
476 m_positions.resize(m_glyphs.size());
477 m_chars.resize(m_chars.size() + ti.
num_chars);
488 m_items.append(currentItem);
491 virtual void drawPolygon(
const QPointF *,
int , PolygonDrawMode )
497 virtual bool end() {
return true; }
531 bool m_useBackendOptimizations;
532 bool m_untransformedCoordinates;
541 m_paintEngine =
new DrawTextItemRecorder(untransformedCoordinates,
542 useBackendOptimizations);
545 ~DrawTextItemDevice()
547 delete m_paintEngine;
550 int metric(PaintDeviceMetric m)
const 561 case PdmPhysicalDpiX:
565 case PdmPhysicalDpiY:
576 qWarning(
"DrawTextItemDevice::metric: Invalid metric command");
583 return m_paintEngine;
588 return m_paintEngine->glyphs();
593 return m_paintEngine->positions();
598 return m_paintEngine->items();
603 return m_paintEngine->chars();
607 DrawTextItemRecorder *m_paintEngine;
616 if (!preferRichText) {
623 qreal height = -leading;
640 textLayout.
draw(p, topLeftPosition);
643 #ifndef QT_NO_CSSPARSER 652 #ifndef QT_NO_TEXTHTMLPARSER 725 if (m_userData != 0 && !m_userData->ref.deref())
727 if (!m_fontEngine->ref.deref())
733 if (m_fontEngine != 0) {
734 if (!m_fontEngine->ref.deref())
739 if (m_fontEngine != 0)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setTransform(const QTransform &transform, bool combine=false)
Sets the world transformation matrix.
The QPainter class performs low-level painting on widgets and other paint devices.
The QColor class provides colors based on RGB, HSV or CMYK values.
void setTextFormat(Qt::TextFormat textFormat)
Sets the text format of the QStaticText to textFormat.
const T * constData() const
void setText(const QString &string)
Sets the layout's text to the given string.
QPaintEngine::DirtyFlags state() const
Returns a combination of flags identifying the set of properties that need to be updated when updatin...
QStaticText()
Constructs an empty QStaticText.
~QStaticText()
Destroys the QStaticText.
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
#define QT_END_NAMESPACE
This macro expands to.
void setPosition(const QPointF &pos)
Moves the line to position pos.
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...
QFixedPoint * positionPool
QFixedPoint * glyphPositions
Q_GUI_EXPORT int qt_defaultDpiY()
void adjustSize()
Adjusts the document to a reasonable size.
unsigned char untransformedCoordinates
Q_GUI_EXPORT int qt_defaultDpiX()
The QPointF class defines a point in the plane using floating point precision.
void setFont(const QFont &f)
Sets the layout's font to the given font.
The QTextLine class represents a line of text inside a QTextLayout.
void restore()
Restores the current painter state (pops a saved state off the stack).
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
void setPerformanceHint(PerformanceHint performanceHint)
Sets the performance hint of the QStaticText according to the performanceHint provided.
QColor color() const
Returns the color of this pen's brush.
QRectF boundingRect() const
The smallest rectangle that contains all the lines in the layout.
void setLineWidth(qreal width)
Lays out the line with the given width.
bool ref()
Atomically increments the value of this QAtomicInt.
ushort red
Returns the red color component of this color.
The QString class provides a Unicode character string.
QPalette palette
the default color that is used for the text, when no color is specified.
void setText(const QString &text)
Sets the text of the QStaticText to text.
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
The QChar class provides a 16-bit Unicode character.
void setFontEngine(QFontEngine *fe)
void save()
Saves the current painter state (pushes the state onto a stack).
void setDefaultTextOption(const QTextOption &option)
Sets the default text option.
void setTextWidth(qreal textWidth)
Sets the preferred width for this QStaticText.
qreal x() const
Returns the x-coordinate of this point.
QExplicitlySharedDataPointer< QStaticTextPrivate > data
QStaticText & operator=(const QStaticText &)
Assigns other to this QStaticText.
static QStaticTextPrivate * get(const QStaticText *q)
void setPlainText(const QString &text)
Replaces the entire contents of the document with the given plain text.
T * data() const
Returns a pointer to the shared data object.
const QPen & pen() const
Returns the painter's current pen.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
char useBackendOptimizations
bool operator!=(const QStaticText &) const
Compares other to this QStaticText.
PerformanceHint performanceHint() const
Returns which performance hint is set for the QStaticText.
static const QCssKnownValue positions[NumKnownPositionModes - 1]
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
Q_CORE_EXPORT void qWarning(const char *,...)
PerformanceHint
This enum the different performance hints that can be set on the QStaticText.
static const char * data(const QByteArray &arr)
QSizeF size
Returns the actual size of the document.
void setHtml(const QString &html)
Replaces the entire contents of the document with the given HTML-formatted text in the html string...
Qt::TextFormat textFormat() const
Returns the text format of the QStaticText.
void draw(QPainter *p, const QPointF &pos, const QVector< FormatRange > &selections=QVector< FormatRange >(), const QRectF &clip=QRectF()) const
Draws the whole layout on the painter p at the position specified by pos.
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
const T & at(int i) const
Returns the item at index position i in the vector.
bool operator==(const QStaticText &) const
Compares other to this QStaticText.
QTextOption textOption() const
Returns the current text option used to control the layout process.
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
The QTextLayout class is used to lay out and render text.
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.
ushort blue
Returns the blue color component of this color.
qreal leading() const
Returns the leading of the font.
void setTextWidth(qreal width)
The QFont class specifies a font used for drawing text.
QTextLine createLine()
Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise ret...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
qreal textWidth() const
Returns the preferred width for this QStaticText.
void setTextOption(const QTextOption &option)
Sets the text option structure that controls the layout process to the given option.
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
The QAbstractTextDocumentLayout::PaintContext class is a convenience class defining the parameters us...
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
The QTextOption class provides a description of general rich text properties.
void setDocumentMargin(qreal margin)
unsigned char useBackendOptimizations
QSizeF size() const
Returns the size of the rectangle.
qreal y() const
Returns the y-coordinate of this point.
The QPixmap class is an off-screen image representation that can be used as a paint device...
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void setDefaultStyleSheet(const QString &sheet)
The QPaintEngineState class provides information about the active paint engine's current state...
The QFontMetricsF class provides font metrics information.
void setFont(const QFont &f)
Sets the painter's font to the given font.
unsigned char needsRelayout
const T * constData() const
Returns a const pointer to the data stored in the vector.
QPen pen() const
Returns the pen in the current paint engine state.
void endLayout()
Ends the layout process.
QString text() const
Returns the text of the QStaticText.
The QTextItem class provides all the information required to draw text in a custom paint engine...
static const KeyPair *const end
ushort green
Returns the green color component of this color.
int size() const
Returns the number of items in the vector.
QFont font() const
Returns the font that should be used to draw the text.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
qreal height() const
Returns the line's height.
void beginLayout()
Begins the layout process.
void paintText(const QPointF &pos, QPainter *p)
virtual void draw(QPainter *painter, const PaintContext &context)=0
Draws the layout with the given painter using the given context.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.