1 #ifndef QCP_ITEM_RICH_TEXT
2 #define QCP_ITEM_RICH_TEXT
5 #include <QTextDocument>
9 Q_PROPERTY(QString text READ text WRITE setText)
22 QPointF pos(position->pixelPoint());
23 QTransform transform = painter->transform();
24 transform.translate(pos.x(), pos.y());
25 if (!qFuzzyIsNull(mRotation)) transform.rotate(mRotation);
27 QRect textRect = painter->fontMetrics().boundingRect(
28 0, 0, 0, 0, Qt::TextDontClip | mTextAlignment, mText);
29 QRect textBoxRect = textRect.adjusted(-mPadding.left(), -mPadding.top(),
30 mPadding.right(), mPadding.bottom());
32 QPointF(0, 0), textBoxRect,
34 textRect.moveTopLeft(textPos.toPoint() +
35 QPoint(mPadding.left(), mPadding.top()));
36 textBoxRect.moveTopLeft(textPos.toPoint());
37 qreal clipPadF =
mainPen().widthF();
38 int clipPad = (int)clipPadF;
40 textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
41 if (transform.mapRect(boundingRect)
42 .intersects(painter->transform().mapRect(clipRect()))) {
43 painter->setTransform(transform);
44 if ((
mainBrush().style() != Qt::NoBrush &&
46 (
mainPen().style() != Qt::NoPen &&
mainPen().color().alpha() != 0)) {
49 painter->drawRect(textBoxRect);
51 painter->setBrush(Qt::NoBrush);
54 doc.drawContents(painter);
Definition: qcpitemrichtext.hh:7
QCPItemRichText(QCustomPlot *parentPlot)
Definition: qcpitemrichtext.hh:11
QTextDocument doc
Definition: qcpitemrichtext.hh:58
virtual void draw(QCPPainter *painter)
Definition: qcpitemrichtext.hh:21
virtual ~QCPItemRichText()
Definition: qcpitemrichtext.hh:12
void setText(const QString &text)
Definition: qcpitemrichtext.hh:14
Definition: qcustomplot.h:3877
QColor color() const
Definition: qcustomplot.h:3901
void setText(const QString &text)
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
Definition: qcustomplot.h:414
void setPen(const QPen &pen)
Definition: qcustomplot.h:1925
#define QCP_LIB_DECL
Definition: qcustomplot.h:87