/*!
    \reimp
*/
void QProgressBar::drawContents( QPainter *p )
{
    const QRect bar = contentsRect();

    QSharedDoubleBuffer buffer( p, bar.x(), bar.y(), bar.width(), bar.height() );

    QPoint pn = backgroundOffset();
    buffer.painter()->setBrushOrigin( -pn.x(), -pn.y() );

    const QPixmap *bpm = paletteBackgroundPixmap();
    if ( bpm )
	buffer.painter()->fillRect( bar, QBrush( paletteBackgroundColor(), *bpm ) );
    else
	buffer.painter()->fillRect( bar, paletteBackgroundColor() );
    buffer.painter()->setFont( p->font() );

    QStyle::SFlags flags = QStyle::Style_Default;
    if (isEnabled())
	flags |= QStyle::Style_Enabled;
    if (hasFocus())
	flags |= QStyle::Style_HasFocus;

    style().drawControl(QStyle::CE_ProgressBarGroove, buffer.painter(), this,
			QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarGroove, this), this ),
			colorGroup(), flags);

    style().drawControl(QStyle::CE_ProgressBarContents, buffer.painter(), this,
			QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarContents, this), this ),
			colorGroup(), flags);

    if (percentageVisible())
	style().drawControl(QStyle::CE_ProgressBarLabel, buffer.painter(), this,
			    QStyle::visualRect(style().subRect(QStyle::SR_ProgressBarLabel, this), this ),
			    colorGroup(), flags);
}
Exemple #2
0
void QWidget::erase( const QRegion& reg )
{
    //this is experimental, I need to test more, but it seems in unclipped mode erasing shouldn't happen????
    if ( backgroundMode() == NoBackground || testWFlags(WPaintUnclipped) )
	return;

    bool unclipped = testWFlags( WPaintUnclipped );
    clearWFlags( WPaintUnclipped );
    QPainter p(this);
    p.setClipRegion( reg );
    if ( extra && extra->bg_pix ) {
	if ( !extra->bg_pix->isNull() ) {
	    QPoint offset = backgroundOffset();
	    int xoff = offset.x();
	    int yoff = offset.y();

	    p.drawTiledPixmap(rect(),*extra->bg_pix,
			      QPoint(xoff%extra->bg_pix->width(),
				     yoff%extra->bg_pix->height()));
	}
    } else {
	p.fillRect(rect(),bg_col);
    }
    if ( unclipped )
	setWFlags( WPaintUnclipped );
}
static Layer*
FindBackgroundLayer(ReadbackLayer* aLayer, nsIntPoint* aOffset)
{
  gfx::Matrix transform;
  if (!aLayer->GetTransform().Is2D(&transform) ||
      transform.HasNonIntegerTranslation())
    return nullptr;
  nsIntPoint transformOffset(int32_t(transform._31), int32_t(transform._32));

  for (Layer* l = aLayer->GetPrevSibling(); l; l = l->GetPrevSibling()) {
    gfx::Matrix backgroundTransform;
    if (!l->GetTransform().Is2D(&backgroundTransform) ||
        gfx::ThebesMatrix(backgroundTransform).HasNonIntegerTranslation())
      return nullptr;

    nsIntPoint backgroundOffset(int32_t(backgroundTransform._31), int32_t(backgroundTransform._32));
    IntRect rectInBackground(transformOffset - backgroundOffset, aLayer->GetSize());
    const nsIntRegion visibleRegion = l->GetEffectiveVisibleRegion().ToUnknownRegion();
    if (!visibleRegion.Intersects(rectInBackground))
      continue;
    // Since l is present in the background, from here on we either choose l
    // or nothing.
    if (!visibleRegion.Contains(rectInBackground))
      return nullptr;

    if (l->GetEffectiveOpacity() != 1.0 ||
        l->HasMaskLayers() ||
        !(l->GetContentFlags() & Layer::CONTENT_OPAQUE))
    {
      return nullptr;
    }

    // cliprects are post-transform
    const Maybe<ParentLayerIntRect>& clipRect = l->GetEffectiveClipRect();
    if (clipRect && !clipRect->Contains(ViewAs<ParentLayerPixel>(IntRect(transformOffset, aLayer->GetSize()))))
      return nullptr;

    Layer::LayerType type = l->GetType();
    if (type != Layer::TYPE_COLOR && type != Layer::TYPE_PAINTED)
      return nullptr;

    *aOffset = backgroundOffset - transformOffset;
    return l;
  }

  return nullptr;
}
static Layer*
FindBackgroundLayer(ReadbackLayer* aLayer, nsIntPoint* aOffset)
{
  gfxMatrix transform;
  if (!aLayer->GetTransform().Is2D(&transform) ||
      transform.HasNonIntegerTranslation())
    return nullptr;
  nsIntPoint transformOffset(int32_t(transform.x0), int32_t(transform.y0));

  for (Layer* l = aLayer->GetPrevSibling(); l; l = l->GetPrevSibling()) {
    gfxMatrix backgroundTransform;
    if (!l->GetTransform().Is2D(&backgroundTransform) ||
        backgroundTransform.HasNonIntegerTranslation())
      return nullptr;

    nsIntPoint backgroundOffset(int32_t(backgroundTransform.x0), int32_t(backgroundTransform.y0));
    nsIntRect rectInBackground(transformOffset - backgroundOffset, aLayer->GetSize());
    const nsIntRegion& visibleRegion = l->GetEffectiveVisibleRegion();
    if (!visibleRegion.Intersects(rectInBackground))
      continue;
    // Since l is present in the background, from here on we either choose l
    // or nothing.
    if (!visibleRegion.Contains(rectInBackground))
      return nullptr;

    if (l->GetEffectiveOpacity() != 1.0 ||
        !(l->GetContentFlags() & Layer::CONTENT_OPAQUE))
      return nullptr;

    // cliprects are post-transform
    const nsIntRect* clipRect = l->GetEffectiveClipRect();
    if (clipRect && !clipRect->Contains(nsIntRect(transformOffset, aLayer->GetSize())))
      return nullptr;

    Layer::LayerType type = l->GetType();
    if (type != Layer::TYPE_COLOR && type != Layer::TYPE_THEBES)
      return nullptr;

    *aOffset = backgroundOffset - transformOffset;
    return l;
  }

  return nullptr;
}
Exemple #5
0
void AppletHandleButton::drawButton( QPainter* p )
{
    QPixmap* bgPixmap = colorGroup().brush(QColorGroup::Background).pixmap();
    if (bgPixmap)
    {
        QPoint origin = backgroundOffset();
        p->drawTiledPixmap(0, 0, width(), height(), *bgPixmap, origin.x(), origin.y());
    }
    else
    {
        QBrush brush = colorGroup().brush(QColorGroup::Background);
        p->fillRect(rect(), brush);
    }

    if (!KickerSettings::transparent())
    {
        if (m_parent->orientation() == Horizontal)
        {
            if (kapp->reverseLayout())
            {
                // paint it on the right-hand side
                style().drawPrimitive(QStyle::PE_PanelDockWindow,
                                      p, QRect(width() - 2, 0, 2, height()),
                                      colorGroup(), QStyle::Style_Horizontal);
            }
            else
            {
                style().drawPrimitive(QStyle::PE_PanelDockWindow,
                                      p, QRect(0, 0, 2, height()),
                                      colorGroup(), QStyle::Style_Horizontal);
            }
        }
        else
        {
            //vertical, paint it on top
            style().drawPrimitive(QStyle::PE_PanelDockWindow,
                                  p, QRect(0, 0, width(), 2),
                                  colorGroup(), QStyle::Style_Horizontal);
        }
    }

    int w = width();
    int h = height();
    if (m_parent->orientation() == Horizontal)
    {
        if (!kapp->reverseLayout())
        {
            p->translate(2, 0);
        }
        w -= 2;
    }
    else
    {
        p->translate(0, 2);
        h -= 2;
    }

    p->drawPixmap((w - pixmap()->width()) / 2,
                  (h - pixmap()->height()) / 2,
                  *pixmap());

    --w;
    --h;

    if (m_moveMouse && !isDown())
    {
        p->setPen(white);
        p->moveTo(0, h);
        p->lineTo(0, 0);
        p->lineTo(w, 0);

        p->setPen(colorGroup().dark());
        p->lineTo(w, h);
        p->lineTo(0, h);
    }

    if (isOn() || isDown())
    {
        p->setPen(colorGroup().dark());
        p->moveTo(0, h);
        p->lineTo(0, 0);
        p->lineTo(w, 0);

        p->setPen(white);
        p->lineTo(w, h);
        p->lineTo(0, h);
    }
}