Example #1
0
void KstViewPicture::paintSelf(KstPainter& p, const QRegion& bounds) {
  p.save();
  if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) {
    if (p.makingMask()) {
      p.setRasterOp(Qt::OrROP);
    } else {
      const QRegion clip(clipRegion());
      KstBorderedViewObject::paintSelf(p, bounds - _myClipMask);
      p.setClipRegion(bounds & clip);
    }
  } else {
    KstBorderedViewObject::paintSelf(p, bounds);
  }

  const QRect cr(contentsRectForDevice(p));
  if (_image.isNull()) {
    // fill with X
    p.setBrush(QBrush(Qt::gray, Qt::SolidPattern));
    p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
    p.drawRect(cr);
    p.drawLine(cr.topLeft(), cr.bottomRight());
    p.drawLine(cr.topRight(), cr.bottomLeft());
  } else {
    assert(!cr.isNull()); // Null view objects are not allowed.  I want to see
                          // how this happens so it can be fixed.

    if (_iCache.isNull() || _iCache.size() != cr.size()) {
      _iCache = _image.copy();
      if (!_iCache.isNull()) {
        _iCache = _iCache.smoothScale(cr.size());
      }
    }
    if (!_iCache.isNull()) {
      if (p.makingMask()) {
        // which indicates clipping / BW mode
        if (_iCache.hasAlphaBuffer()) {
          p.drawImage(cr.topLeft(), _iCache.createAlphaMask());
        } else {
          p.setBrush(Qt::color1);
          p.drawRect(cr);
        }
      } else {
        p.drawImage(cr.topLeft(), _iCache);
      }
    }
  }
  p.restore();
}
Example #2
0
void KstBorderedViewObject::paintSelf(KstPainter& p, const QRegion& bounds) {
  p.save();
  if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) {
    if (p.makingMask()) {
      p.setRasterOp(Qt::SetROP);
      KstViewObject::paintSelf(p, bounds);
    } else {
      const QRegion clip(clipRegion());
      KstViewObject::paintSelf(p, bounds - clip);
      p.setClipRegion(bounds & clip);
    }
  }
  if (_borderWidth > 0) {
    QRect r;
    const int bw(_borderWidth * p.lineWidthAdjustmentFactor());
    QPen pen(_borderColor, bw);
    p.setBrush(Qt::NoBrush);
    p.setPen(pen);
    r.setX(_geom.left() + _margin + bw / 2);
    r.setY(_geom.top() + _margin + bw / 2);
    r.setWidth(_geom.width() - 2 * _margin - bw + 1);
    r.setHeight(_geom.height() - 2 * _margin - bw + 1);
    p.drawRect(r);
  }
  p.restore();
}
Example #3
0
void KstTopLevelView::pressMoveLayoutModeResize(const QPoint& pos, bool maintainAspect) {
  const QRect old(_prevBand);

  _prevBand = newSize(_pressTarget->geometry(), _pressTarget->_parent->geometry(), _pressDirection, pos, maintainAspect);
  if (_prevBand != old) {
    KstPainter p;
        
    p.begin(_w);
    p.setRasterOp(Qt::NotROP);
    p.setPen(QPen(Qt::black, 0, Qt::DotLine));
    if (old.topLeft() != QPoint(-1, -1)) {
      p.drawRect(old);
    } 
    p.drawRect(_prevBand);
    p.end();
  }
}
Example #4
0
void KstViewLine::drawFocusRect(KstPainter& p) {
  // draw the hotpoints
  QPoint point1, point2;
  
  const int dx = KST_RESIZE_BORDER_W/2;

  const QRect geom(geometry());
  if (_orientation == UpLeft || _orientation == DownRight) {
    point1 = QPoint(geom.left() - dx, geom.top() - dx);
    point2 = QPoint(geom.right() - dx, geom.bottom() - dx);
  } else {
    point1 = QPoint(geom.right() - dx, geom.top() - dx);
    point2 = QPoint(geom.left() - dx, geom.bottom() - dx);
  }
  QRect rect;
  rect.setSize(QSize(2 * dx + 1, 2 * dx + 1));
  rect.moveTopLeft(point1);
  p.drawRect(rect);
  rect.moveTopLeft(point2);
  p.drawRect(rect);
}