MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / getTextDrawPoint

Method getTextDrawPoint

qcustomplot/qcustomplot.cpp:29088–29103  ·  view source on GitHub ↗

! \internal Returns the point that must be given to the QPainter::drawText function (which expects the top left point of the text rect), according to the position \a pos, the text bounding box \a rect and the requested \a positionAlignment. For example, if \a positionAlignment is Qt::AlignLeft | Qt::AlignBottom the returned point will be shifted upward by the height of \a

Source from the content-addressed store, hash-verified

29086 drawn at that point, the lower left corner of the resulting text rect is at \a pos.
29087*/
29088QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
29089{
29090 if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop))
29091 return pos;
29092
29093 QPointF result = pos; // start at top left
29094 if (positionAlignment.testFlag(Qt::AlignHCenter))
29095 result.rx() -= rect.width()/2.0;
29096 else if (positionAlignment.testFlag(Qt::AlignRight))
29097 result.rx() -= rect.width();
29098 if (positionAlignment.testFlag(Qt::AlignVCenter))
29099 result.ry() -= rect.height()/2.0;
29100 else if (positionAlignment.testFlag(Qt::AlignBottom))
29101 result.ry() -= rect.height();
29102 return result;
29103}
29104
29105/*! \internal
29106

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected