MCPcopy Create free account
hub / github.com/cutechess/cutechess / getTextDrawPoint

Method getTextDrawPoint

projects/gui/3rdparty/qcustomplot/qcustomplot.cpp:29879–29894  ·  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

29877 drawn at that point, the lower left corner of the resulting text rect is at \a pos.
29878*/
29879QPointF QCPItemText::getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
29880{
29881 if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop))
29882 return pos;
29883
29884 QPointF result = pos; // start at top left
29885 if (positionAlignment.testFlag(Qt::AlignHCenter))
29886 result.rx() -= rect.width()/2.0;
29887 else if (positionAlignment.testFlag(Qt::AlignRight))
29888 result.rx() -= rect.width();
29889 if (positionAlignment.testFlag(Qt::AlignVCenter))
29890 result.ry() -= rect.height()/2.0;
29891 else if (positionAlignment.testFlag(Qt::AlignBottom))
29892 result.ry() -= rect.height();
29893 return result;
29894}
29895
29896/*! \internal
29897

Callers

nothing calls this directly

Calls 2

widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected