Example #1
0
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);
  }
}
Example #2
0
void KstViewArrow::paintSelf(KstPainter& p, const QRegion& bounds) {
  p.save();
  if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) {
    if (p.makingMask()) {
      p.setCompositionMode(QPainter::CompositionMode_Source);
    } else {
      const QRegion clip(clipRegion());
      KstViewLine::paintSelf(p, bounds - _myClipMask);
      p.setClipRegion(bounds & clip);
    }
  } else {
      KstViewLine::paintSelf(p, bounds);
  }
  
  if (hasArrow()) {
    QPoint to = KstViewLine::to();
    QPoint from = KstViewLine::from();    
    const int w = width() * p.lineWidthAdjustmentFactor();
    QPen pen(_foregroundColor, w);
    
    pen.setCapStyle(capStyle());
    p.setPen(pen);
    p.setBrush(_foregroundColor);
    
    if (_hasToArrow) {      
      paintArrow(p, to, from, w, _toArrowScaling);
    }
    if (_hasFromArrow) {      
      paintArrow(p, from, to, w, _fromArrowScaling);
    }
  }
  p.restore();
}