MCPcopy Create free account
hub / github.com/ZhuYanzhen1/miniFOC / getTextDrawPoint

Method getTextDrawPoint

tools/qcustomplot.cpp:29846–29861  ·  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

29844 drawn at that point, the lower left corner of the resulting text rect is at \a pos.
29845*/
29846QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
29847{
29848 if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop))
29849 return pos;
29850
29851 QPointF result = pos; // start at top left
29852 if (positionAlignment.testFlag(Qt::AlignHCenter))
29853 result.rx() -= rect.width()/2.0;
29854 else if (positionAlignment.testFlag(Qt::AlignRight))
29855 result.rx() -= rect.width();
29856 if (positionAlignment.testFlag(Qt::AlignVCenter))
29857 result.ry() -= rect.height()/2.0;
29858 else if (positionAlignment.testFlag(Qt::AlignBottom))
29859 result.ry() -= rect.height();
29860 return result;
29861}
29862
29863/*! \internal
29864

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected