void KstViewLabel::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) { int absFontSizeOld = _absFontSize; QRect cr(contentsRectForPainter(p)); cr.setSize(sizeForText(_parent->geometry())); setContentsRectForPainter(p, cr); KstBorderedViewObject::paintSelf(p, bounds); p.translate(cr.left(), cr.top()); if (!_transparent) { p.fillRect(0, 0, cr.width(), cr.height(), backgroundColor()); } drawToPainter(_parsed, p); _absFontSize = absFontSizeOld; } else { if (p.makingMask()) { KstBorderedViewObject::paintSelf(p, bounds); p.setRasterOp(Qt::SetROP); const QRect cr(contentsRect()); // slow but preserves antialiasing... QBitmap bm = _backBuffer.buffer().createHeuristicMask(false); bm.setMask(bm); p.drawPixmap(cr.left(), cr.top(), bm, 0, 0, cr.width(), cr.height()); } else { const QRegion clip(clipRegion()); KstBorderedViewObject::paintSelf(p, bounds); p.setClipRegion(bounds & clip); _backBuffer.paintInto(p, contentsRect()); } } p.restore(); }
void KstViewLegend::paintSelf(KstPainter& p, const QRegion& bounds) { if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) { p.save(); QRect cr(contentsRectForPainter(p)); cr.setSize(sizeForText(_parent->geometry())); setContentsRectForPainter(p, cr); KstBorderedViewObject::paintSelf(p, bounds); p.translate(cr.left(), cr.top()); if (!_transparent) { p.fillRect(0, 0, cr.width(), cr.height(), _backgroundColor); } drawToPainter(p); p.restore(); } else { const QRect cr(contentsRect()); if (p.makingMask()) { p.setCompositionMode(QPainter::CompositionMode_Source); } else { const QRegion clip(clipRegion()); KstBorderedViewObject::paintSelf(p, bounds - _myClipMask); p.setClipRegion(bounds & clip); } _backBuffer.paintInto(p, cr); } }
void QgsLayoutItemLabel::adjustSizeToText() { QSizeF newSize = sizeForText(); //keep alignment point constant double xShift = 0; double yShift = 0; itemShiftAdjustSize( newSize.width(), newSize.height(), xShift, yShift ); //update rect for data defined size and position attemptSetSceneRect( QRectF( pos().x() + xShift, pos().y() + yShift, newSize.width(), newSize.height() ) ); }
void KstViewLegend::adjustSizeForText(const QRect& w) { QRect cr(contentsRect()); cr.setSize(sizeForText(w)); setContentsRect(cr); }