QDebug operator<<(QDebug dbg, const KChart::BackgroundAttributes& ba)
{
    dbg << "KChart::BackgroundAttributes("
	<< "visible="<<ba.isVisible()
	<< "brush="<<ba.brush()
	<< "pixmapmode="<<ba.pixmapMode()
	<< "pixmap="<<ba.pixmap().cacheKey()
	<< ")";
    return dbg;
}
示例#2
0
void Legend::setBackgroundBrush(const QBrush &brush)
{
    d->backgroundBrush = brush;

    // KChart
    KChart::BackgroundAttributes attributes = d->kdLegend->backgroundAttributes();
    attributes.setVisible(true);
    attributes.setBrush(brush);
    d->kdLegend->setBackgroundAttributes(attributes);

    d->pixmapRepaintRequested = true;
}
示例#3
0
void Legend::setBackgroundColor(const QColor &color)
{
    d->backgroundBrush.setColor(color);

    // KChart
    KChart::BackgroundAttributes attributes = d->kdLegend->backgroundAttributes();
    attributes.setVisible(true);
    QBrush brush = attributes.brush();
    brush.setColor(color);
    attributes.setBrush(brush);
    d->kdLegend->setBackgroundAttributes(attributes);

    d->pixmapRepaintRequested = true;
}
示例#4
0
/* static */
void AbstractAreaBase::paintBackgroundAttributes( QPainter& painter, const QRect& rect,
    const KChart::BackgroundAttributes& attributes )
{
    if ( !attributes.isVisible() ) return;

    /* first draw the brush (may contain a pixmap)*/
    if ( Qt::NoBrush != attributes.brush().style() ) {
        KChart::PainterSaver painterSaver( &painter );
        painter.setPen( Qt::NoPen );
        const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) );
        painter.setBrushOrigin( newTopLeft );
        painter.setBrush( attributes.brush() );
        painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) );
    }
    /* next draw the backPixmap over the brush */
    if ( !attributes.pixmap().isNull() &&
        attributes.pixmapMode() != BackgroundAttributes::BackgroundPixmapModeNone ) {
        QPointF ol = rect.topLeft();
        if ( BackgroundAttributes::BackgroundPixmapModeCentered == attributes.pixmapMode() )
        {
            ol.setX( rect.center().x() - attributes.pixmap().width() / 2 );
            ol.setY( rect.center().y() - attributes.pixmap().height()/ 2 );
            painter.drawPixmap( ol, attributes.pixmap() );
        } else {
            QMatrix m;
            qreal zW = (qreal)rect.width()  / (qreal)attributes.pixmap().width();
            qreal zH = (qreal)rect.height() / (qreal)attributes.pixmap().height();
            switch ( attributes.pixmapMode() ) {
            case BackgroundAttributes::BackgroundPixmapModeScaled:
            {
                qreal z;
                z = qMin( zW, zH );
                m.scale( z, z );
            }
            break;
            case BackgroundAttributes::BackgroundPixmapModeStretched:
                m.scale( zW, zH );
                break;
            default:
                ; // Cannot happen, previously checked
            }
            QPixmap pm = attributes.pixmap().transformed( m );
            ol.setX( rect.center().x() - pm.width() / 2 );
            ol.setY( rect.center().y() - pm.height()/ 2 );
            painter.drawPixmap( ol, pm );
        }
    }
}