//! Redraw the canvas, and focus rect
void QwtPlotCanvas::drawContents(QPainter *painter)
{
    if ( cacheMode() && d_cache 
        && d_cache->size() == contentsRect().size() )
    {
        painter->drawPixmap(contentsRect().topLeft(), *d_cache);
    }
    else
        drawCanvas(painter);

#ifndef QWT_NO_COMPAT
    if ( d_outlineActive )
        drawOutline(*painter); // redraw outline
#endif

    if ( hasFocus() && focusIndicator() == CanvasFocusIndicator )
    {
        const int margin = 1;
        QRect focusRect = contentsRect();
        focusRect.setRect(focusRect.x() + margin, focusRect.y() + margin,
            focusRect.width() - 2 * margin, focusRect.height() - 2 * margin);

        drawFocusIndicator(painter, focusRect);
    }
}
void QwtPlotCanvas::drawCanvas(QPainter *painter)
{
    if ( !contentsRect().isValid() )
        return;

    QRect clipRect = contentsRect();
    if ( !cacheMode() || !QwtPaintBuffer::isEnabled() )
    {
        // If we don´t need the paint buffer as cache we can
        // use the clip for painting to the buffer too. 

        if ( painter && !painter->clipRegion().isNull() )
            clipRect = painter->clipRegion().boundingRect();
    }

    QwtPaintBuffer paintBuffer(this, clipRect, painter);
    ((QwtPlot *)parent())->drawCanvas(paintBuffer.painter());

    if ( cacheMode() )
    {
        if ( d_cache == NULL )
        {
            d_cache = new QPixmap(contentsRect().size());
#if QT_VERSION >= 300
#ifdef Q_WS_X11
            if ( d_cache->x11Screen() != x11Screen() )
                d_cache->x11SetScreen(x11Screen());
#endif
#endif
        }
        else
            d_cache->resize(contentsRect().size());

        if ( QwtPaintBuffer::isEnabled() )
            *d_cache = paintBuffer.buffer();
        else
        {
            d_cache->fill(this, 0, 0);
            QPainter cachePainter(d_cache);
            cachePainter.translate(-contentsRect().x(),
                -contentsRect().y());
            ((QwtPlot *)parent())->drawCanvas(&cachePainter);
        }
    }
}
示例#3
0
int QMovie::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 13)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 13;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = speed(); break;
        case 1: *reinterpret_cast< CacheMode*>(_v) = cacheMode(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSpeed(*reinterpret_cast< int*>(_v)); break;
        case 1: setCacheMode(*reinterpret_cast< CacheMode*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}