1 #ifndef QCP_ITEM_RICH_TEXT 2 #define QCP_ITEM_RICH_TEXT 5 #include <QTextDocument> 9 Q_PROPERTY(QString text READ text WRITE setText)
25 QPointF pos(position->pixelPoint());
26 QTransform transform = painter->transform();
27 transform.translate(pos.x(), pos.y());
28 if (!qFuzzyIsNull(mRotation))
29 transform.rotate(mRotation);
31 QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|mTextAlignment, mText);
32 QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(), mPadding.right(), mPadding.bottom());
33 QPointF textPos =
getTextDrawPoint(QPointF(0, 0), textBoxRect, mPositionAlignment);
34 textRect.moveTopLeft(textPos.toPoint()+QPoint(mPadding.left(), mPadding.top()));
35 textBoxRect.moveTopLeft(textPos.toPoint());
36 qreal clipPadF =
mainPen().widthF();
37 int clipPad = (int)clipPadF;
38 QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
39 if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(
clipRect())))
41 painter->setTransform(transform);
47 painter->drawRect(textBoxRect);
49 painter->setBrush(Qt::NoBrush);
52 doc.drawContents(painter);
58 #endif // QCP_ITEM_RICH_TEXT virtual void draw(QCPPainter *painter)
Definition: qcpitemrichtext.hh:23
QTextDocument doc
Definition: qcpitemrichtext.hh:56
Definition: qcustomplot.h:3421
void setPen(const QPen &pen)
#define QCP_LIB_DECL
Definition: qcustomplot.h:87
Definition: qcustomplot.h:1680
virtual ~QCPItemRichText()
Definition: qcpitemrichtext.hh:13
Definition: qcpitemrichtext.hh:7
Definition: qcustomplot.h:312
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
void setText(const QString &text)
Definition: qcpitemrichtext.hh:15
void setText(const QString &text)
QCPItemRichText(QCustomPlot *parentPlot)
Definition: qcpitemrichtext.hh:11
QColor color() const
Definition: qcustomplot.h:3444
virtual QRect clipRect() const