Esempio n. 1
0
void UimToolbarDraggingHandler::drawContents( QPainter* p )
{
    const QStyle::SFlags flags = QStyle::Style_Default | QStyle::Style_Horizontal;
    style().drawPrimitive( QStyle::PE_DockWindowSeparator, p,
                           contentsRect(), colorGroup(), flags );
}
Esempio n. 2
0
void QLCDNumber::internalSetString( const QString& s )
{
    QString buffer;
    int i;
    int len = s.length();
    QBitArray newPoints(ndigits);

    if ( !smallPoint ) {
	if ( len == ndigits )
	    buffer = s;
	else
	    buffer = s.right( ndigits ).rightJustify( ndigits, ' ' );
    } else {
	int  index = -1;
	bool lastWasPoint = TRUE;
	newPoints.clearBit(0);
	for ( i=0; i<len; i++ ) {
	    if ( s[i] == '.' ) {
		if ( lastWasPoint ) {		// point already set for digit?
		    if ( index == ndigits - 1 ) // no more digits
			break;
		    index++;
		    buffer[index] = ' ';	// 2 points in a row, add space
		}
		newPoints.setBit(index);	// set decimal point
		lastWasPoint = TRUE;
	    } else {
		if ( index == ndigits - 1 )
		    break;
		index++;
		buffer[index] = s[i];
		newPoints.clearBit(index);	// decimal point default off
		lastWasPoint = FALSE;
	    }
	}
	if ( index < ((int) ndigits) - 1 ) {
	    for( i=index; i>=0; i-- ) {
		buffer[ndigits - 1 - index + i] = buffer[i];
		newPoints.setBit( ndigits - 1 - index + i,
				   newPoints.testBit(i) );
	    }
	    for( i=0; i<ndigits-index-1; i++ ) {
		buffer[i] = ' ';
		newPoints.clearBit(i);
	    }
	}
    }

    if ( buffer == digitStr )
	return;

    if ( backgroundMode() == FixedPixmap
	 || colorGroup().brush( QColorGroup::Background ).pixmap() ) {
	digitStr = buffer;
	if ( smallPoint )
	    points = newPoints;
	repaint( contentsRect() );
    }
    else {
	QPainter p( this );
	if ( !smallPoint )
	    drawString( buffer, p );
	else
	    drawString( buffer, p, &newPoints );
    }
}
Esempio n. 3
0
QZuesLabel::QZuesLabel(QWidget *parent)
	: QLabel(parent), m_placeholdText("..."), m_type(LABEL_TYPE_NORMAL), m_maqueeTimerId(-1), m_maqueeSpeed(100), m_contentsRect(contentsRect()), m_stepLength(5)
{

}
Esempio n. 4
0
void QBouton::paintEvent(QPaintEvent *event)
{
	// Used for normal buttons
	if (!m_resizeInsteadOfCropping && m_border == 0 && m_progressMax == 0)
	{
		QPushButton::paintEvent(event);
		return;
	}

	QPainter painter(this);
	QRect region = m_smartSizeHint ? contentsRect() : event->rect();
	QSize iconSize = getIconSize(region.width(), region.height());
	int p = m_border;
	int x = region.x();
	int y = region.y();
	int w = iconSize.width() + 2*p;
	int h = iconSize.height() + 2*p;

	// Ignore invalid images
	if (w == 0 || h == 0)
		return;

	// Center the image
	bool center = true;
	if (center)
	{
		x += (region.width() - w) / 2;
		y += (region.height() - h) / 2;
	}

	// Draw image
	QIcon::Mode mode = this->isChecked() ? QIcon::Selected : QIcon::Normal;
	if (w > h)
	{
		icon().paint(&painter, x+p, y+p, w-2*p, w-2*p, Qt::AlignLeft | Qt::AlignTop, mode);
		h = h-((h*2*p)/w)+2*p-1;
	}
	else
	{
		icon().paint(&painter, x+p, y+p, h-2*p, h-2*p, Qt::AlignLeft | Qt::AlignTop, mode);
		w = w-((w*2*p)/h)+2*p-1;
	}

	// Clip borders overflows
	painter.setClipRect(x, y, w, h);

	// Draw progress
	if (m_progressMax > 0 && m_progress > 0 && m_progress != m_progressMax)
	{
		int lineHeight = 6;
		int a = p + lineHeight/2;

		float ratio = (float)m_progress / m_progressMax;
		QPoint p1(qMax(x, 0) + a, qMax(y, 0) + a);
		QPoint p2(p1.x() + (iconSize.width() - a) * ratio, p1.y());

		if (p2.x() > p1.x())
		{
			QPen pen(QColor(0, 200, 0));
			pen.setWidth(lineHeight);
			painter.setPen(pen);
			painter.drawLine(p1, p2);
		}
	}

	// Draw borders
	if (p > 0 && m_penColor.isValid())
	{
		QPen pen(m_penColor);
		pen.setWidth(p*2);
		painter.setPen(pen);
		painter.drawRect(qMax(x,0), qMax(y,0), qMin(w,size().width()), qMin(h,size().height()));
	}
}
Esempio n. 5
0
void ExprCSwatchFrame::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);
    QPainter p(this);
    p.fillRect(contentsRect(),_color);
}
Esempio n. 6
0
void KProgress::rangeChange()
{
	repaint(contentsRect(), FALSE);
	emit percentageChanged(recalcValue(100));
}
Esempio n. 7
0
/*!
   \return Rectangle of the wheel without the outer border
*/
QRect QwtWheel::wheelRect() const
{
    const int bw = d_data->borderWidth;
    return contentsRect().adjusted( bw, bw, -bw, -bw );
}
Esempio n. 8
0
/*!
  \return Bounding rectangle of the pipe ( without borders )
          in widget coordinates
*/
QRect QwtThermo::pipeRect() const
{
    const QRect cr = contentsRect();

    int mbd = 0;
    if ( d_data->scalePos != NoScale )
    {
        int d1, d2;
        scaleDraw()->getBorderDistHint( font(), d1, d2 );
        mbd = qMax( d1, d2 );
    }
    int bw = d_data->borderWidth;

    QRect tRect;
    if ( d_data->orientation == Qt::Horizontal )
    {
        switch ( d_data->scalePos )
        {
            case TopScale:
            {
                tRect.setRect(
                    cr.x() + mbd + bw,
                    cr.y() + cr.height() - d_data->pipeWidth - 2 * bw,
                    cr.width() - 2 * ( bw + mbd ),
                    d_data->pipeWidth 
                );
                break;
            }

            case BottomScale:
            case NoScale: 
            default:   
            {
                tRect.setRect(
                    cr.x() + mbd + bw,
                    cr.y() + d_data->borderWidth,
                    cr.width() - 2 * ( bw + mbd ),
                    d_data->pipeWidth 
                );
                break;
            }
        }
    }
    else // Qt::Vertical
    {
        switch ( d_data->scalePos )
        {
            case RightScale:
            {
                tRect.setRect(
                    cr.x() + bw,
                    cr.y() + mbd + bw,
                    d_data->pipeWidth,
                    cr.height() - 2 * ( bw + mbd ) 
                );
                break;
            }
            case LeftScale:
            case NoScale: 
            default:   
            {
                tRect.setRect(
                    cr.x() + cr.width() - 2 * bw - d_data->pipeWidth,
                    cr.y() + mbd + bw,
                    d_data->pipeWidth,
                    cr.height() - 2 * ( bw + mbd ) );
                break;
            }
        }
    }

    return tRect;
}
Esempio n. 9
0
/* \reimp (GraphicsLayer.h)
*/
void GraphicsLayerTextureMapper::setContentsNeedsDisplay()
{
    notifyChange(DisplayChange);
    addRepaintRect(contentsRect());
}
Esempio n. 10
0
void KstViewLabel::adjustSizeForText(const QRect& w) {
  QRect cr(contentsRect());
  cr.setSize(sizeForText(w));
  setContentsRect(cr);
}
Esempio n. 11
0
void WicdApplet::init()
{
    m_theme->resize(contentsRect().size());
    
    Plasma::ToolTipManager::self()->registerWidget(this);

    //load dataengine
    Plasma::DataEngine *engine = dataEngine("wicd");
    if (!engine->isValid()) {
        setFailedToLaunch(true, i18n("Unable to load the Wicd data engine."));
        return;
    }
    
    setupActions();
    
    //build the popup dialog
    QGraphicsWidget *appletDialog = new QGraphicsWidget(this);
    m_dialoglayout = new QGraphicsLinearLayout(Qt::Vertical);
    
    //Network list
    m_scrollWidget = new Plasma::ScrollWidget(appletDialog);
    m_scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_scrollWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
    m_scrollWidget->setMaximumHeight(400);

    m_networkView = new NetworkView(m_scrollWidget);
    m_scrollWidget->setWidget(m_networkView);

    m_busyWidget = new Plasma::BusyWidget(m_scrollWidget);
    m_busyWidget->hide();

    m_dialoglayout->addItem(m_scrollWidget);
    
    //Separator
    m_dialoglayout->addItem(new Plasma::Separator(appletDialog));
    
    //Bottom bar
    QGraphicsLinearLayout* bottombarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
    
    m_messageBox = new Plasma::Label(appletDialog);
    m_messageBox->setWordWrap(false);
    bottombarLayout->addItem(m_messageBox);
    
    bottombarLayout->addStretch();
    
    m_abortButton = new Plasma::ToolButton(appletDialog);
    m_abortButton->setIcon(KIcon("dialog-cancel"));
    m_abortButton->nativeWidget()->setToolTip(i18n("Abort"));
    connect(m_abortButton, SIGNAL(clicked()), this, SLOT(cancelConnect()));
    bottombarLayout->addItem(m_abortButton);
    
    Plasma::ToolButton *reloadButton = new Plasma::ToolButton(appletDialog);
    reloadButton->nativeWidget()->setToolTip(i18n("Reload"));
    reloadButton->setAction(action("reload"));
    bottombarLayout->addItem(reloadButton);
    
    m_dialoglayout->addItem(bottombarLayout);
    
    appletDialog->setLayout(m_dialoglayout);
    setGraphicsWidget(appletDialog);

    setHasConfigurationInterface(true);
    
    // read config
    configChanged();

    connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(updateColors()));


    //prevent notification on startup
    m_status.State = 10;
    m_isScanning = false;
    //connect dataengine
    m_wicdService = engine->serviceForSource("");
    engine->connectSource("status", this);
    engine->connectSource("daemon", this);
}
Esempio n. 12
0
void KstViewLabel::drawToBuffer(Label::Parsed *lp) {
  _backBuffer.buffer().resize(contentsRect().size());
  _backBuffer.buffer().fill(backgroundColor());
  QPainter p(&_backBuffer.buffer());
  drawToPainter(lp, p);
}
Esempio n. 13
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tTideGraph::paintEvent( QPaintEvent* pEvent )
{
    tTideCurrentGraphBase::paintEvent( pEvent );

    int w = contentsRect().width();
    int h = contentsRect().height();

    QPainter p( this );
    p.setRenderHint( QPainter::Antialiasing, true );
    p.setClipRect( contentsRect() );
    QRect r( QPoint(0,0), contentsRect().size() );

    // lets translate the painter so we can work with a 0,0 origin
    p.save();
    p.translate( contentsRect().topLeft() );

    //###### 1) Paint background and the daylight area
    if(m_SunRiseX <= m_SunSetX)
    {
        // left night
        p.fillRect( 0, 0, m_SunRiseX, h, palette().dark() );
        // day
        p.fillRect( m_SunRiseX, 0, m_SunSetX - m_SunRiseX, h, palette().light() );
        // right night
        p.fillRect( m_SunSetX, 0, w - m_SunSetX, h, palette().dark() );
    }
    else if(m_SunRiseX > m_SunSetX)
    {
        // left day
        p.fillRect( 0, 0, m_SunSetX, h, palette().light() );
        // night
        p.fillRect( m_SunSetX, 0, m_SunRiseX - m_SunSetX, h, palette().dark() );
        // right day
        p.fillRect( m_SunRiseX, 0, w - m_SunRiseX, h, palette().light() );
    }

    //###### 2) Add legend backgrounds
    QColor c = palette().text().color();
    c.setAlpha( 127 );
    p.fillRect( 0, h - BOTTOM_MARGIN_HEIGHT, w, BOTTOM_MARGIN_HEIGHT, QBrush( c ) );
    p.fillRect( 0, 0, LEFT_MARGIN_WIDTH, h, palette().base() );

    // we have finished doing work with a 0,0 origin
    p.restore();

    //###### 3) Left depth legend and grid lines
    p.rotate(-90);

    p.setRenderHint( QPainter::Antialiasing, false );
    c.setAlpha( 63 );
    QPen pen( QBrush( c ), 0 );

    qreal rangeDiv = GetRangeDivision( tConvert::Instance()->ToUser(UNITS_DEPTH, m_HeightUnits, static_cast<float>(m_GraphConfig.m_DeltaY)) );
    float stepSize = tConvert::Instance()->UserToBase( UNITS_DEPTH, static_cast<float>(rangeDiv) );
    stepSize = tConvert::Instance()->BaseToSpecifiedUnits(UNITS_DEPTH, m_HeightUnits, stepSize);

    for( qreal pxY = 0, strY = 0; pxY <= m_GraphConfig.m_MaxY; pxY += stepSize, strY += rangeDiv )
    {
        p.setPen( palette().text().color() );
        p.drawText(RotatedTextELeftMargin(0, pxY, 40), Qt::AlignCenter, QString("%1").arg(strY) );
        p.setPen( pen );
        p.drawLine(RotatedGraphToPixel(0, pxY), RotatedGraphToPixel(1, pxY));
    }
    for( qreal pxY = 0, strY = 0; pxY >= m_GraphConfig.m_MinY; pxY -= stepSize, strY += rangeDiv )
    {
        p.setPen( palette().text().color() );
        p.drawText(RotatedTextELeftMargin(0, pxY, 40), Qt::AlignCenter, QString("%1").arg(strY) );
        p.setPen( pen );
        p.drawLine(RotatedGraphToPixel(0, pxY), RotatedGraphToPixel(1, pxY));
    }
    p.rotate(90);
    p.drawLine( QPointF( GraphToPixel(0.25, 0).x(), 0 ), QPointF( GraphToPixel(0.25, 0).x(), h ) );
    p.drawLine( QPointF( GraphToPixel(0.5, 0).x(), 0 ), QPointF( GraphToPixel(0.5, 0).x(), h ) );
    p.drawLine( QPointF( GraphToPixel(0.75, 0).x(), 0 ), QPointF( GraphToPixel(0.75, 0).x(), h ) );
    p.setRenderHint( QPainter::Antialiasing, true );

    //###### 4) Graph and fill the tides spline
    QPainterPath path;
    path.moveTo( GraphToPixel(0, 0) );
    for( int i = 0; i < m_TideHeights.size(); ++i )
    {
        // source data is in 10 minute intervals => 1/144 of a day
        path.lineTo( GraphToPixel( m_TideHeights.at(i).x(), m_TideHeights.at(i).y() ) );        
    }
    // Close the path
    path.lineTo( GraphToPixel(1, 0) );
    path.lineTo( GraphToPixel(0, 0) );

    //###### 5) Fill graph path
    QLinearGradient gradient(0,0,0,h);
    QColor endColor = palette().highlight().color();
    endColor.setAlpha( 191 );
    QColor midColor = palette().highlight().color().lighter( 130 );
    midColor.setAlpha( 191 );
    gradient.setColorAt(0.0, endColor);
    gradient.setColorAt(0.1, endColor);
    gradient.setColorAt(0.5, midColor);
    gradient.setColorAt(0.9, endColor);
    gradient.setColorAt(1.0, endColor);
    p.fillPath(path, gradient);
    
    p.save();
    QPen penGraph( palette().base().color() );
    penGraph.setWidth(2);
    p.setPen(penGraph);
    p.drawPath(path);
    p.restore();        

    //###### 6) Draw over with text
    p.setPen( palette().base().color() );
    qSort(m_TideExtremes);
    for( int i = 0; i < m_TideExtremes.size(); ++i )
    {
        // Convert time into decimal
        qreal timePos = GetTimeF( m_TideExtremes.at(i).first );

        // Draw on height (and compensate for user units)
        float convertedHeight = tConvert::Instance()->ToUser(UNITS_DEPTH, m_HeightUnits, static_cast<float>(m_TideExtremes.at(i).second) );
        QString unitsString = tConvert::Instance()->GetUnitsString( UNITS_DEPTH );
        QString heightString = QString("%1 ").arg(convertedHeight, 2, 'f', qAbs(convertedHeight) > 1 ? 1 : 2) + unitsString;
        QString timeString = m_TideExtremes.at(i).first.toString( tSystemSettings::Instance()->TimeFormatString() );

        QRect boundRectHeight = TextBoundingRect( timePos, 0, fontMetrics().width( heightString ), eBottomMarginHeight );
        QRect boundRectTime = TextBoundingRect( timePos, 0, fontMetrics().width( timeString ), eBottomMarginTime );

        QPen curPen = p.pen();
        if( i < m_TideExtremes.size() - 1 )
        {
            if( m_TideExtremes[i].second < m_TideExtremes[i+1].second )
            {
                p.setPen(Qt::red);
            }
        }
        else
        {
            if( m_TideExtremes[i].second < m_TideExtremes[i-1].second )
            {
                p.setPen(Qt::red);
            }
        }

        p.drawText( boundRectHeight, Qt::AlignCenter, heightString );
        p.drawText( boundRectTime, Qt::AlignCenter,  timeString );
        p.setPen(curPen);
        // Draw on time

        // Draw triangle
    }

    //####### 7) Draw on the sun times
    //(SUN)
    p.setPen( palette().text().color() );
    if(m_SunRiseTime.isValid())
    {
        QString riseString = tr("Sunrise") + " " + m_SunRiseTime.toString( tSystemSettings::Instance()->TimeFormatString() );
        QRect boundSunRise = TextBoundingRect( GetTimeF( m_SunRiseTime ), m_GraphConfig.m_MinY, fontMetrics().width( riseString ), eSunTime);       
        p.drawText(boundSunRise, Qt::AlignCenter, riseString );
    }

    if(m_SunSetTime.isValid())
    {
        QString sunsetString = tr("Sunset") + " " + m_SunSetTime.toString( tSystemSettings::Instance()->TimeFormatString() );
        QRect boundSunSet = TextBoundingRect( GetTimeF( m_SunSetTime ), m_GraphConfig.m_MinY, fontMetrics().width( sunsetString ), eSunTime);
        p.drawText(boundSunSet, Qt::AlignCenter, sunsetString );
    }

    //####### 8) Draw the time and height for the present time
    tDateTime currentDateTime = tDateTime::currentDateTime(); //QDateTime does not know time zone / local time offset.
    if( m_UseUTCTime )
    {
        currentDateTime = currentDateTime.toUTC();
    }
    if(m_ActiveDate.date() == currentDateTime.date())
    {
        qreal currentTime = GetTimeF( currentDateTime.time() );               
        qreal height = GetHeightAtTime( currentTime );
        float convertedHeight = tConvert::Instance()->ToUser(UNITS_DEPTH, m_HeightUnits, static_cast<float>(height) );

        QString unitsString = tConvert::Instance()->GetUnitsString( UNITS_DEPTH );
        QString heightString = QString("%1 ").arg(convertedHeight, 2, 'f', qAbs(convertedHeight) > 1 ? 1 : 2) + unitsString;
        QString timeString = currentDateTime.time().toString( tSystemSettings::Instance()->TimeFormatString() );

        QRect boundCurrentHeight = TextBoundingRect( currentTime, 0, fontMetrics().width( heightString ), eCurrentHeight );
        QRect boundCurrentTime = TextBoundingRect( currentTime, 0, fontMetrics().width( timeString ), eCurrentTime );            

        p.setPen( palette().text().color() );
        p.drawText( boundCurrentHeight, Qt::AlignCenter, heightString ); 
        p.drawText( boundCurrentTime, Qt::AlignCenter, timeString ); 
        QPen penRed(Qt::red);
        p.setPen(penRed);
        p.setRenderHint( QPainter::Antialiasing, false );
        p.drawLine( GraphToPixel(currentTime, m_GraphConfig.m_MinY).toPoint(),
            GraphToPixel(currentTime, m_GraphConfig.m_MaxY).toPoint() - QPoint(0,1) );
    }

}
Esempio n. 14
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tTideGraph::UpdateGraphConfig()
{
    QRect r = contentsRect();

    qreal extremeHigh = 0.0;
    qreal extremeLow = 0.0;

    if ( m_TideHeights.isEmpty() == false )
    {
        extremeLow = m_TideHeights.at( 0 ).y();
    }

    // A) Find the extremes
    for( int i = 0; i < m_TideHeights.size() ; ++i )
    {
        qreal height = m_TideHeights.at( i ).y();
        // Find extreme high...
        if( height > extremeHigh )
        {
            extremeHigh = height;
        }

        // Find extreme low...
        if( height < extremeLow )
        {
            extremeLow = height;
        }
    }

    ///////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////

    int canvasWidth = r.width() - LEFT_MARGIN_WIDTH;
    int canvasHeight = r.height() - BOTTOM_MARGIN_HEIGHT;

    // Setup the graph configuration...
    qreal padding = 0.1F * (extremeHigh - extremeLow);
    m_GraphConfig.m_MaxY            = extremeHigh + padding;      // Max value to show
    m_GraphConfig.m_MinY            = extremeLow - padding;      // Min value to show
    m_GraphConfig.m_DeltaY          = m_GraphConfig.m_MaxY - m_GraphConfig.m_MinY; 
    m_GraphConfig.m_DistancePerPix  = m_GraphConfig.m_DeltaY / canvasHeight;
    m_GraphConfig.m_PixPerDistance  = canvasHeight / m_GraphConfig.m_DeltaY;
    m_GraphConfig.m_PixPerHour      = canvasWidth / 1.0F; // 24 hours 
    m_GraphConfig.m_HourPerPix      = 1.0F / canvasWidth;
    m_GraphConfig.m_PixelExtentsX   = canvasWidth;
    m_GraphConfig.m_PixelExtentsY   = canvasHeight;
    m_GraphConfig.m_PixelOriginX    = r.x() + LEFT_MARGIN_WIDTH;
    m_GraphConfig.m_PixelOriginY    = r.y();

    ///////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////

    m_SunRiseX = static_cast<int>( GraphToPixel( GetTimeF(m_SunRiseTime), 0).x() ); // @TODO: what if it flips?
    m_SunSetX = static_cast<int>( GraphToPixel( GetTimeF(m_SunSetTime), 0).x() );

    if( !m_SunSetTime.isValid() )
    {
        m_SunSetX = r.x() + r.width();
    }
    if( !m_SunRiseTime.isValid() )
    {
        m_SunRiseX = r.x();
    }
}
Esempio n. 15
0
void KoColorSlider::drawContents( QPainter *painter )
{
    QPixmap checker(8, 8);
    QPainter p(&checker);
    p.fillRect(0, 0, 4, 4, Qt::lightGray);
    p.fillRect(4, 0, 4, 4, Qt::darkGray);
    p.fillRect(0, 4, 4, 4, Qt::darkGray);
    p.fillRect(4, 4, 4, 4, Qt::lightGray);
    p.end();
    QRect contentsRect_(contentsRect());
    painter->fillRect(contentsRect_, QBrush(checker));

    if( !d->upToDate || d->pixmap.isNull() || d->pixmap.width() != contentsRect_.width()
        || d->pixmap.height() != contentsRect_.height() )
    {
        KoColor c = d->minColor; // smart way to fetch colorspace
        QColor color;

        const quint8 *colors[2];
        colors[0] = d->minColor.data();
        colors[1] = d->maxColor.data();

        KoMixColorsOp * mixOp = c.colorSpace()->mixColorsOp();

        QImage image(contentsRect_.width(), contentsRect_.height(), QImage::Format_ARGB32 );

        if( orientation() == Qt::Horizontal ) {
            for (int x = 0; x < contentsRect_.width(); x++) {

                qreal t = static_cast<qreal>(x) / (contentsRect_.width() - 1);

                qint16 colorWeights[2];
                colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
                colorWeights[1] = 255 - colorWeights[0];

                mixOp->mixColors(colors, colorWeights, 2, c.data());

                c.toQColor(&color);

                for (int y = 0; y < contentsRect_.height(); y++)
                image.setPixel(x, y, color.rgba());
            }
        }
        else {
            for (int y = 0; y < contentsRect_.height(); y++) {

                qreal t = static_cast<qreal>(y) / (contentsRect_.height() - 1);

                qint16 colorWeights[2];
                colorWeights[0] = static_cast<quint8>((t) * 255 + 0.5);
                colorWeights[1] = 255 - colorWeights[0];

                mixOp->mixColors(colors, colorWeights, 2, c.data());

                c.toQColor(&color);

                for (int x = 0; x < contentsRect_.width(); x++)
                image.setPixel(x, y, color.rgba());
            }
        }
        d->pixmap = QPixmap::fromImage(image);
        d->upToDate = true;
    }
    painter->drawPixmap( contentsRect_, d->pixmap, QRect( 0, 0, d->pixmap.width(), d->pixmap.height()) );
}
Esempio n. 16
0
void GraphicsLayerTextureMapper::commitLayerChanges()
	{
#if PLATFORM(JS)
		webkitTrace();
#endif
    if (m_changeMask == NoChanges)
        return;

    if (m_changeMask & ChildrenChange) {
        Vector<TextureMapperLayer*> textureMapperLayerChildren;
        toTextureMapperLayerVector(children(), textureMapperLayerChildren);
        m_layer->setChildren(textureMapperLayerChildren);
    }

    if (m_changeMask & MaskLayerChange)
        m_layer->setMaskLayer(toTextureMapperLayer(maskLayer()));

    if (m_changeMask & ReplicaLayerChange)
        m_layer->setReplicaLayer(toTextureMapperLayer(replicaLayer()));

    if (m_changeMask & PositionChange)
        m_layer->setPosition(position());

    if (m_changeMask & AnchorPointChange)
        m_layer->setAnchorPoint(anchorPoint());

    if (m_changeMask & SizeChange)
        m_layer->setSize(size());

    if (m_changeMask & TransformChange)
        m_layer->setTransform(transform());

    if (m_changeMask & ChildrenTransformChange)
        m_layer->setChildrenTransform(childrenTransform());

    if (m_changeMask & Preserves3DChange)
        m_layer->setPreserves3D(preserves3D());

    if (m_changeMask & ContentsRectChange)
        m_layer->setContentsRect(contentsRect());

    if (m_changeMask & MasksToBoundsChange)
        m_layer->setMasksToBounds(masksToBounds());

    if (m_changeMask & DrawsContentChange)
        m_layer->setDrawsContent(drawsContent());

    if (m_changeMask & ContentsVisibleChange)
        m_layer->setContentsVisible(contentsAreVisible());

    if (m_changeMask & ContentsOpaqueChange)
        m_layer->setContentsOpaque(contentsOpaque());

    if (m_changeMask & BackfaceVisibilityChange)
        m_layer->setBackfaceVisibility(backfaceVisibility());

    if (m_changeMask & OpacityChange)
        m_layer->setOpacity(opacity());

    if (m_changeMask & BackgroundColorChange)
        m_layer->setSolidColor(solidColor());

#if ENABLE(CSS_FILTERS)
    if (m_changeMask & FilterChange)
        m_layer->setFilters(filters());
#endif

    if (m_changeMask & BackingStoreChange)
        m_layer->setBackingStore(m_backingStore);

    if (m_changeMask & DebugVisualsChange)
        m_layer->setDebugVisuals(isShowingDebugBorder(), debugBorderColor(), debugBorderWidth(), isShowingRepaintCounter());

    if (m_changeMask & RepaintCountChange)
        m_layer->setRepaintCount(repaintCount());

    if (m_changeMask & ContentChange)
        m_layer->setContentsLayer(platformLayer());

    if (m_changeMask & AnimationChange)
        m_layer->setAnimations(m_animations);

    if (m_changeMask & AnimationStarted)
        client()->notifyAnimationStarted(this, m_animationStartTime);

    if (m_changeMask & FixedToViewporChange)
        m_layer->setFixedToViewport(fixedToViewport());

    if (m_changeMask & IsScrollableChange)
        m_layer->setIsScrollable(isScrollable());

    if (m_changeMask & CommittedScrollOffsetChange)
        m_layer->didCommitScrollOffset(m_committedScrollOffset);

    m_changeMask = NoChanges;
}
bool CoordinatedGraphicsLayer::imageBackingVisible()
{
    ASSERT(m_coordinatedImageBacking);
    return tiledBackingStoreVisibleRect().intersects(IntRect(contentsRect()));
}
Esempio n. 18
0
 MiniSplitterHandle(Qt::Orientation orientation, QSplitter *parent)
         : QSplitterHandle(orientation, parent)
 {
     setMask(QRegion(contentsRect()));
     setAttribute(Qt::WA_MouseNoMask, true);
 }
Esempio n. 19
0
void KProgress::drawContents(QPainter *p)
{
	QRect cr = contentsRect(), er = cr;
	fr = cr;
	QBrush fb(bar_color), eb(backgroundColor());

	if (bar_pixmap)
		fb.setPixmap(*bar_pixmap);

	if (backgroundPixmap())
		eb.setPixmap(*backgroundPixmap());

	switch (bar_style) {
		case Solid:
			if (orient == Horizontal) {
				fr.setWidth(recalcValue(cr.width()));
				er.setLeft(fr.right() + 1);
			} else {
				fr.setTop(cr.bottom() - recalcValue(cr.height()));
				er.setBottom(fr.top() - 1);
			}
				
			p->setBrushOrigin(cr.topLeft());
			p->fillRect(fr, fb);
			p->fillRect(er, eb);
			
			break;
			
		case Blocked:
			const int margin = 2;
			int max, num, dx, dy;
			if (orient == Horizontal) {
				fr.setHeight(cr.height() - 2 * margin);
				fr.setWidth((int)(0.67 * fr.height()));
				fr.moveTopLeft(QPoint(cr.left() + margin, cr.top() + margin));
				dx = fr.width() + margin;
				dy = 0;
				max = (cr.width() - margin) / (fr.width() + margin) + 1;
				num = recalcValue(max);
			} else {
				fr.setWidth(cr.width() - 2 * margin);
				fr.setHeight((int)(0.67 * fr.width()));
				fr.moveBottomLeft(QPoint(cr.left() + margin, cr.bottom() - margin));
				dx = 0;
				dy = - (fr.height() + margin);
				max = (cr.height() - margin) / (fr.height() + margin) + 1;
				num = recalcValue(max);
			}
			p->setClipRect(cr.x() + margin, cr.y() + margin, 
						   cr.width() - margin, cr.height() - margin);
			for (int i = 0; i < num; i++) {
				p->setBrushOrigin(fr.topLeft());
				p->fillRect(fr, fb);
				fr.moveBy(dx, dy);
			}
			
			if (num != max) {
				if (orient == Horizontal) 
					er.setLeft(fr.right() + 1);
				else
					er.setBottom(fr.bottom() + 1);
				if (!er.isNull()) {
					p->setBrushOrigin(cr.topLeft());
					p->fillRect(er, eb);
				}
			}
			
			break;
	}	
				
	if (text_enabled && bar_style != Blocked)
		drawText(p);
		
}			
Esempio n. 20
0
/*!
  \brief Adjust plot content to its current size.
  \sa resizeEvent()
*/
void QwtPlot::updateLayout()
{
    d_data->layout->activate( this, contentsRect() );

    QRect titleRect = d_data->layout->titleRect().toRect();
    QRect footerRect = d_data->layout->footerRect().toRect();
    QRect scaleRect[QwtPlot::axisCnt];
    for ( int axisId = 0; axisId < axisCnt; axisId++ )
        scaleRect[axisId] = d_data->layout->scaleRect( axisId ).toRect();
    QRect legendRect = d_data->layout->legendRect().toRect();
    QRect canvasRect = d_data->layout->canvasRect().toRect();

    // resize and show the visible widgets

    if ( !d_data->titleLabel->text().isEmpty() )
    {
        d_data->titleLabel->setGeometry( titleRect );
        if ( !d_data->titleLabel->isVisibleTo( this ) )
            d_data->titleLabel->show();
    }
    else
        d_data->titleLabel->hide();

    if ( !d_data->footerLabel->text().isEmpty() )
    {
        d_data->footerLabel->setGeometry( footerRect );
        if ( !d_data->footerLabel->isVisibleTo( this ) )
            d_data->footerLabel->show();
    }
    else
        d_data->footerLabel->hide();

    for ( int axisId = 0; axisId < axisCnt; axisId++ )
    {
        if ( axisEnabled( axisId ) )
        {
            axisWidget( axisId )->setGeometry( scaleRect[axisId] );

#if 1
            if ( axisId == xBottom || axisId == xTop )
            {
                // do we need this code any longer ???

                QRegion r( scaleRect[axisId] );
                if ( axisEnabled( yLeft ) )
                    r = r.subtracted( QRegion( scaleRect[yLeft] ) );
                if ( axisEnabled( yRight ) )
                    r = r.subtracted( QRegion( scaleRect[yRight] ) );
                r.translate( -scaleRect[ axisId ].x(),
                             -scaleRect[axisId].y() );

                axisWidget( axisId )->setMask( r );
            }
#endif
            if ( !axisWidget( axisId )->isVisibleTo( this ) )
                axisWidget( axisId )->show();
        }
        else
            axisWidget( axisId )->hide();
    }

    if ( d_data->legend )
    {
        if ( d_data->legend->isEmpty() )
        {
            d_data->legend->hide();
        }
        else
        {
            d_data->legend->setGeometry( legendRect );
            d_data->legend->show();
        }
    }

    d_data->canvas->setGeometry( canvasRect );
}
Esempio n. 21
0
void MosaicLayout::refreshLayout(const QRect& rect)
{ 
  //item size
  int itemHSize, itemVSize;
  int totalSpacing = spacing() * itemsList.count();
  // horizontal max number of items
  int HMaxItems = contentsRect().width() / (minItemHSize + totalSpacing);  
  bool oneRow = false;
  if (HMaxItems >= itemsList.count()) 
  {
    HMaxItems = itemsList.count(); 
    if (HMaxItems == 0)
      HMaxItems += 1; // one avoid division by 0
    oneRow = true;
  }
  // horizontal dimension that could be added to each item
  // since there is room
  int HPlusSize = ( contentsRect().width()  -
  (minItemHSize * HMaxItems) ) / HMaxItems;
  //TODO: check this, too many operations
  if (oneRow)  
  {
    if (minItemHSize + HPlusSize > maxItemHSize)
      itemHSize = maxItemHSize;
    else
      itemHSize = minItemHSize + HPlusSize;
  }
  else {
    if (HPlusSize + minItemHSize > maxItemHSize)
      itemHSize = minItemHSize;
    else
      itemHSize = minItemHSize + HPlusSize;
  }
  
  //repeat same story for vertical size
  int VMaxItems = contentsRect().height()  / (minItemVSize + totalSpacing);
  int VPlusSize = ( contentsRect().height() %
  (minItemVSize * VMaxItems) ) / VMaxItems;
  if (VPlusSize + minItemVSize > maxItemVSize)
    itemVSize = minItemVSize;
  else
    itemVSize = minItemVSize + VPlusSize;
  //next lines add widgets to layout
    // absolute position to set
    int x = 0;
    int y = 0;
    
    // count of horizontal added items,
    // increment it for each added item and
    // when it reachs HMaxItems set it and
    // x to zero
    int HCountItem = 0;
    QLayoutItem *item;
    foreach (item, itemsList) {
      item->setGeometry(QRect(QPoint(x,y),QPoint(itemHSize+x,itemVSize+y)));
      HCountItem++;
      if (HCountItem >= HMaxItems) {
	HCountItem = x = 0;
	y += itemVSize + spacing();
      }
      else
	x += itemHSize + spacing();
    }
void
QvisAbstractOpacityBar::drawFilledCurveWithSelection(float *curve, bool *mask, int nc,
    const QColor &curveOn,  float curveOnOpacity,
    const QColor &curveOff, float curveOffOpacity,
    const QColor &binLines, bool  drawBinLines,
    float range[2], float minval, float maxval)
{
    int w = contentsRect().width();
    int h = contentsRect().height();
    QRgb BL = binLines.rgb();

    for (int x = 0; x < w; x++)
    {
        float tx = float(x) / float(w-1);
        int   cx = qMin((nc-1), int(tx * nc));
        float yval = curve[cx];
        //qDebug("tx=%g, cx=%d, yval=%g", tx, cx, yval);

        // Determine whether we will need to draw the column
        bool drawColumn = true;
        if(mask != NULL)
            drawColumn = mask[cx];
        else
        {
            // Restrict the columns we draw to a range.
            float xval = (1.f-tx)*range[0] + tx*range[1];
            if(xval < minval || xval > maxval)
                drawColumn = false;
        }

        // Determine the proper color and opacity to use for the column
        // based on whether we're drawing it.
        QRgb color;
        float opacity;
        if(drawColumn)
        {
            color = curveOn.rgb();
            opacity = curveOnOpacity; 
        }
        else
        {
            color = curveOff.rgb();
            opacity = curveOffOpacity; 
        }

        // Draw the column
        if(opacity == 1.f)
        {
            // Draw full opacity.
            for (int y = 0; y < h; y++)
            { 
                float yval2 = 1 - float(y)/float(h-1);
                if (yval2 <= yval)
                    image->setPixel(x, y, color); 
            }
        }
        else if(opacity > 0.f)
        {
            // Blend the column with the background.
            for (int y = 0; y < h; y++)
            { 
                float yval2 = 1 - float(y)/float(h-1);
                if (yval2 <= yval)
                {
                    QRgb p = image->pixel(x, y);
                    int r = int((1.f - opacity)*float(qRed(p))   + opacity*float(qRed(color)));
                    int g = int((1.f - opacity)*float(qGreen(p)) + opacity*float(qGreen(color)));
                    int b = int((1.f - opacity)*float(qBlue(p))  + opacity*float(qBlue(color)));
                    image->setPixel(x,y, qRgb(r,g,b));
                }
            }
        }

        if(drawBinLines)
        {
            int yv = int((1.-yval) * (h-1));
            yv = qMin(yv, h-1);
            image->setPixel(x, yv, BL);
        }
    }

    // Draw the bin dividers
    if(drawBinLines)
    {
        for(int i = 1; i < histTextureSize+1; ++i)
        {
            float t = float(i) / float(histTextureSize);
            int x = int(t * w);
            if(x < w)
            {
                for (int y = 0; y < h; y++)
                    image->setPixel(x,y, BL);
            }
        }
    }
}
Esempio n. 23
0
void QIStateStatusBarIndicator::drawContents(QPainter *pPainter)
{
    if (m_icons.contains(m_iState))
        pPainter->drawPixmap(contentsRect().topLeft(), m_icons.value(m_iState).pixmap(m_size));
}
Esempio n. 24
0
void ItemButton::paintEvent(QPaintEvent *event) {
	QStylePainter p(this);
	QStyleOptionButton option;
	QRect margins = contentsRect();
	QFontMetrics fontMetrics(p.font());
	int textHeight = 0;
	int textWidth = 0;
	int priceWidth = fontMetrics.boundingRect(price).width();


	option.initFrom(this);

	if (isDown())
		option.state |= QStyle::State_Sunken;
	else
		option.state |= QStyle::State_Raised;

	if (isChecked())
		option.state |= QStyle::State_On;

	//Draw button
	p.drawControl(QStyle::CE_PushButtonBevel, option);

	//int iconWidth = iconSize().height() > iconSize().width() ? iconSize().height() : iconSize().width();
	int iconWidth = margins.right();
	textWidth = fontMetrics.boundingRect(description).width();
	if (margins.right() - iconWidth < textWidth) {
		qDebug() << "Resizing";
		iconWidth = margins.right() - textWidth;
	}

	int iconHeight = margins.bottom();
	QSize size = icon().availableSizes().first();
	if (iconWidth > iconHeight) {
		iconWidth = iconHeight;
	}
	size.scale(iconWidth, iconHeight, Qt::KeepAspectRatio);
	setIconSize(size);
	qDebug() << size;

	//Draw icon
	if(isEnabled())
		p.drawPixmap(margins.left() + (iconWidth - iconSize().width())/2, (margins.height() - iconSize().height())/2 + margins.top(), icon().pixmap(iconSize(), QIcon::Normal));
	else
		p.drawPixmap(margins.left() + (iconWidth - iconSize().width())/2, (margins.height() - iconSize().height())/2 + margins.top(), icon().pixmap(iconSize(), QIcon::Disabled));

	//Draw title text
	textHeight = fontMetrics.boundingRect(text()).height();
	textWidth = fontMetrics.boundingRect(text()).width();

	if (textWidth > margins.width() - iconWidth - margins.left()) {
		QFont font = p.font();
		font.setPixelSize((double)font.pixelSize() * (margins.width() - iconWidth - margins.left()) / textWidth);
		p.setFont(font);
	}

	p.drawText(QRect(margins.left()*2 + iconWidth, margins.top(), margins.width() - iconWidth, textHeight), Qt::AlignLeft|Qt::TextSingleLine, text());

	p.setFont(this->font());

	//Draw price text
	p.drawText(QRect(margins.right() - priceWidth, margins.top(), priceWidth, margins.height()), Qt::AlignRight|Qt::TextSingleLine|Qt::AlignVCenter, price);

	//Resize font
	QFont font = p.font();
	font.setPixelSize((int)(font.pixelSize() * 0.75));
	//font.setPointSizeF((font.pointSizeF() * 0.75));
	p.setFont(font);

	//Draw description text
	fontMetrics = QFontMetrics(p.font());
	textHeight = fontMetrics.boundingRect(description).height();
	textWidth = fontMetrics.boundingRect(description).width();
	p.drawText(QRect(margins.left()*2 + iconWidth, margins.bottom() - textHeight, margins.width() - iconWidth, textHeight), Qt::AlignLeft|Qt::TextSingleLine, description);
}
void CodeEditor::resizeEvent(QResizeEvent *e)
{
    QPlainTextEdit::resizeEvent(e);
    QRect cr = contentsRect();
    lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
Esempio n. 26
0
void CustomLabel::paintEvent(QPaintEvent * pe)
{
	if ((!text().isEmpty()) &&
			(textFormat() == Qt::PlainText ||
			 (textFormat() == Qt::AutoText && !Qt::mightBeRichText(text()))))
	{
		QPainter painter(this);
		QRectF lr = contentsRect();
		lr.moveBottom(lr.bottom() - 1); // angry and dirty hack!
		QStyleOption opt;
		opt.initFrom(this);
		int align = QStyle::visualAlignment(text().isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, alignment());
		int flags = align | (!text().isRightToLeft() ? Qt::TextForceLeftToRight : Qt::TextForceRightToLeft);
		if (wordWrap())
			flags |= Qt::TextWordWrap;
		switch (shadowType)
		{
		case NoShadow:
			flags |= TF_NOSHADOW;
			break;
		case DarkShadow:
			flags |= TF_DARKSHADOW;
			break;
		case LightShadow:
			flags |= TF_LIGHTSHADOW;
			break;
		default:
			break;
		}
		QString textToDraw = text();
		int textWidth = lr.width();
		// eliding text
		// TODO: move to text change / resize event handler, make textToDraw a member
		if (elideMode() != Qt::ElideNone)
		{
			QFontMetrics fm = fontMetrics();
			if (!wordWrap())
			{
				textToDraw = fm.elidedText(text(), elideMode(), textWidth);
			}
			else if (elideMode() == Qt::ElideRight)
			{
				// multiline elide
				int pxPerLine = fontMetrics().lineSpacing();
				int lines = lr.height() / pxPerLine + 1;
#ifdef DEBUG_ENABLED
//				if (lines > 1)
//				{
//					qDebug() << pxPerLine << lines << lr << fm.height() << font().toString();
//				}
#endif
#ifdef Q_WS_MAC // mac hack, dunno why
				//lines--;
				// TODO: debug this!!!
#endif
				QStringList srcLines = text().split("\n");
				QStringList dstLines;
				foreach (QString srcLine, srcLines)
				{
					int w = fm.width(srcLine);
					if (w >= textWidth)
					{
						QStringList tmpList = srcLine.split(' ');
						QString s;
						int i = 0;
						while (i < tmpList.count())
						{
							if (fm.width(s + " " + tmpList.at(i)) >= textWidth)
							{
								if (!s.isEmpty())
								{
									dstLines += s;
									s = QString::null;
								}
							}
							if (!s.isEmpty())
							{
								s += " ";
							}
							s += tmpList.at(i);
							i++;
						}
						dstLines += s;
					}
					else
					{
						dstLines += srcLine;
					}
				}
Esempio n. 27
0
void TetrixBoard::drawPauseScreen(QPainter *painter)
{
    painter->drawText(contentsRect(), Qt::AlignCenter, tr("Pause"));
}
Esempio n. 28
0
void TiledBackingStore::createTiles()
{
    if (m_contentsFrozen)
        return;
    
    IntRect visibleRect = mapFromContents(m_client->tiledBackingStoreVisibleRect());
    m_previousVisibleRect = visibleRect;

    if (visibleRect.isEmpty())
        return;

    // Remove tiles that extend outside the current contents rect.
    dropOverhangingTiles();

    IntRect keepRect = visibleRect;
    // Inflates to both sides, so divide inflate delta by 2
    keepRect.inflateX(visibleRect.width() * (m_keepAreaMultiplier.width() - 1.f) / 2);
    keepRect.inflateY(visibleRect.height() * (m_keepAreaMultiplier.height() - 1.f) / 2);
    keepRect.intersect(contentsRect());
    
    dropTilesOutsideRect(keepRect);
    
    IntRect coverRect = visibleRect;
    // Inflates to both sides, so divide inflate delta by 2
    coverRect.inflateX(visibleRect.width() * (m_coverAreaMultiplier.width() - 1.f) / 2);
    coverRect.inflateY(visibleRect.height() * (m_coverAreaMultiplier.height() - 1.f) / 2);
    coverRect.intersect(contentsRect());
    
    // Search for the tile position closest to the viewport center that does not yet contain a tile. 
    // Which position is considered the closest depends on the tileDistance function.
    double shortestDistance = std::numeric_limits<double>::infinity();
    Vector<Tile::Coordinate> tilesToCreate;
    unsigned requiredTileCount = 0;
    Tile::Coordinate topLeft = tileCoordinateForPoint(coverRect.location());
    Tile::Coordinate bottomRight = tileCoordinateForPoint(IntPoint(coverRect.maxX(), coverRect.maxY()));
    for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
        for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
            Tile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
            if (tileAt(currentCoordinate))
                continue;
            ++requiredTileCount;
            // Distance is 0 for all currently visible tiles.
            double distance = tileDistance(visibleRect, currentCoordinate);
            if (distance > shortestDistance)
                continue;
            if (distance < shortestDistance) {
                tilesToCreate.clear();
                shortestDistance = distance;
            }
            tilesToCreate.append(currentCoordinate);
        }
    }
    
    // Now construct the tile(s)
    unsigned tilesToCreateCount = tilesToCreate.size();
    for (unsigned n = 0; n < tilesToCreateCount; ++n) {
        Tile::Coordinate coordinate = tilesToCreate[n];
        setTile(coordinate, Tile::create(this, coordinate));
    }
    requiredTileCount -= tilesToCreateCount;
    
    // Paint the content of the newly created tiles
    if (tilesToCreateCount)
        updateTileBuffers();

    // Keep creating tiles until the whole coverRect is covered.
    if (requiredTileCount)
        m_tileCreationTimer->startOneShot(m_tileCreationDelay);
}
Esempio n. 29
0
void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) 
{
    bool hackStyledBackground = false;

    if ( withBackground && testAttribute( Qt::WA_StyledBackground ) 
        && testPaintAttribute( HackStyledBackground ) )
    {
        // Antialiasing rounded borders is done by
        // inserting pixels with colors between the 
        // border color and the color on the canvas,
        // When the border is painted before the plot items
        // these colors are interpolated for the canvas
        // and the plot items need to be clipped excluding
        // the anialiased pixels. In situations, where
        // the plot items fill the area at the rounded
        // borders this is noticeable.
        // The only way to avoid these annoying "artefacts"
        // is to paint the border on top of the plot items.

        if ( d_data->styleSheet.hasBorder &&
            !d_data->styleSheet.borderPath.isEmpty() )
        {
            // We have a border with at least one rounded corner
            hackStyledBackground = true;
        }
    }

    if ( withBackground )
    {
        painter->save();

        if ( testAttribute( Qt::WA_StyledBackground ) )
        {
            if ( hackStyledBackground )
            {
                // paint background without border

                painter->setPen( Qt::NoPen );
                painter->setBrush( d_data->styleSheet.background.brush ); 
                painter->setBrushOrigin( d_data->styleSheet.background.origin );
                painter->setClipPath( d_data->styleSheet.borderPath );
                painter->drawRect( contentsRect() );
            }
            else
            {
                qwtDrawStyledBackground( this, painter );
            }
        }
        else if ( autoFillBackground() )
        {
            painter->setPen( Qt::NoPen );
            painter->setBrush( palette().brush( backgroundRole() ) );

            if ( d_data->borderRadius > 0.0 )
            {
                if ( frameWidth() > 0 )
                {
                    painter->setClipPath( borderPath( rect() ) );
                    painter->drawRect( rect() );
                }
                else
                {
                    painter->setRenderHint( QPainter::Antialiasing, true );
                    painter->drawPath( borderPath( rect() ) );
                }
            }
            else
            {
                painter->drawRect( contentsRect() );
            }
        }

        painter->restore();
    }

    painter->save();

    if ( !d_data->styleSheet.borderPath.isEmpty() )
    {
        painter->setClipPath( 
            d_data->styleSheet.borderPath, Qt::IntersectClip );
    }
    else
    {
        if ( d_data->borderRadius > 0.0 )
            painter->setClipPath( borderPath( rect() ), Qt::IntersectClip );
        else
            painter->setClipRect( contentsRect(), Qt::IntersectClip );
    }

    plot()->drawCanvas( painter );

    painter->restore();

    if ( withBackground && hackStyledBackground )
    {
        // Now paint the border on top
        QStyleOptionFrame opt;
        opt.initFrom(this);
        style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, this);
    }
}
/*! \reimp

First copies a background image of the hue donut and its
    background color onto the frame, then draws the color triangle,
    and finally the selectors.
*/
void QtColorTriangle::paintEvent(QPaintEvent *e)
{
    QPainter p(this);
    if (e->rect().intersects(contentsRect()))
        p.setClipRegion(e->region().intersect(contentsRect()));
    if (mustGenerateBackground) {
	genBackground();
	mustGenerateBackground = false;
    }

    // Blit the static generated background with the hue gradient onto
    // the double buffer.
    QImage buf = bg.copy();

    // Draw the trigon
    int h,s,v;
    curColor.getHsv(&h, &s, &v);

    // Find the color with only the hue, and max value and saturation
    QColor hueColor;
    hueColor.setHsv(curHue, 255, 255);

    // Draw the triangle
    drawTrigon(&buf, pa, pb, pc, hueColor);

    // Slow step: convert the image to a pixmap
    QPixmap pix = QPixmap::fromImage(buf);
    QPainter painter(&pix);
    painter.setRenderHint(QPainter::Antialiasing);

    // Draw an outline of the triangle
    QColor halfAlpha(0, 0, 0, 128);
    painter.setPen(QPen(halfAlpha, 0));
    painter.drawLine(pa, pb);
    painter.drawLine(pb, pc);
    painter.drawLine(pc, pa);
    
    int ri, gi, bi;
    hueColor.getRgb(&ri, &gi, &bi);
    if ((ri * 30) + (gi * 59) + (bi * 11) > 12800)
	painter.setPen(QPen(Qt::black, penWidth));
    else
	painter.setPen(QPen(Qt::white, penWidth));
    painter.drawEllipse((int) (pd.x() - ellipseSize / 2.0),
			(int) (pd.y() - ellipseSize / 2.0),
			ellipseSize, ellipseSize);

    curColor.getRgb(&ri, &gi, &bi);

    // Find a color for painting the selector based on the brightness
    // value of the color.
    if ((ri * 30) + (gi * 59) + (bi * 11) > 12800)
	painter.setPen(QPen(Qt::black, penWidth));
    else
	painter.setPen(QPen(Qt::white, penWidth));

    // Draw the selector ellipse.
    painter.drawEllipse(QRectF(selectorPos.x() - ellipseSize / 2.0,
                               selectorPos.y() - ellipseSize / 2.0,
                               ellipseSize + 0.5, ellipseSize + 0.5));

    // Blit
    p.drawPixmap(contentsRect().topLeft(), pix);
}