void Tab::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    QBrush brush;
    brush.setStyle(Qt::SolidPattern);
    brush.setColor(backgroundColor());
    painter.setOpacity(1);
    painter.setBrush(brush);
    painter.setPen(Qt::NoPen);
    painter.drawRect(rect());

    paintHalo(&painter);

    QStylePainter style(this);

    if (!icon().isNull()) {
        style.translate(0, 12);
    }

    QStyleOptionButton option;
    initStyleOption(&option);
    option.features |= QStyleOptionButton::Flat;
    option.iconSize = QSize(-1, -1);  // Prevent icon from being drawn twice

    style.drawControl(QStyle::CE_PushButtonLabel, option);

    if (!icon().isNull()) {
        const QSize &size = iconSize();
        QRect iconRect(QPoint((width()-size.width())/2, 0), size);
        icon().paint(&painter, iconRect, Qt::AlignCenter, QIcon::Normal);
    }

    if (!_active) {
        QColor overlayColor = backgroundColor();
        overlayColor.setAlphaF(0.36);

        QBrush overlay;
        overlay.setStyle(Qt::SolidPattern);
        overlay.setColor(overlayColor);
        painter.fillRect(rect(), overlay);
    }

#ifdef DEBUG_LAYOUT
    QPainter debug(this);
    QPen pen;
    pen.setColor(Qt::red);
    pen.setWidth(2);
    debug.setPen(pen);
    debug.setBrush(Qt::NoBrush);
    debug.drawRect(rect());
#endif
}
Exemplo n.º 2
0
static void
drawSelectionSquare( QPainter* painter, const QRect& rect, const QBrush& brush )
{
    painter->save();
    painter->setPen( QPen( brush.color().darker(), 1 ) );
    QColor highlightColor = QPalette().highlight().color();
    highlightColor = highlightColor.lighter( 500 );
    highlightColor.setAlpha( 120 );
    painter->setBrush( highlightColor );
    painter->translate( .5, .5 );
    painter->drawRoundedRect( rect.adjusted( 0, 0, -1, -1 ), CORNER_RADIUS, CORNER_RADIUS );
    painter->translate( -.5, -.5 );
    painter->restore();
}
Exemplo n.º 3
0
void FrameLoaderClientQt::transitionToCommittedForNewPage()
{
    ASSERT(m_frame);
    ASSERT(m_webFrame);

    QBrush brush = m_webFrame->page()->palette().brush(QPalette::Base);
    QColor backgroundColor = brush.style() == Qt::SolidPattern ? brush.color() : QColor();

    QWebPage* page = m_webFrame->page();
    const QSize preferredLayoutSize = page->preferredContentsSize();

    ScrollbarMode hScrollbar = (ScrollbarMode) m_webFrame->scrollBarPolicy(Qt::Horizontal);
    ScrollbarMode vScrollbar = (ScrollbarMode) m_webFrame->scrollBarPolicy(Qt::Vertical);
    bool hLock = hScrollbar != ScrollbarAuto;
    bool vLock = vScrollbar != ScrollbarAuto;

    m_frame->createView(m_webFrame->page()->viewportSize(),
                        backgroundColor, !backgroundColor.alpha(),
                        preferredLayoutSize.isValid() ? IntSize(preferredLayoutSize) : IntSize(),
                        preferredLayoutSize.isValid(),
                        hScrollbar, hLock,
                        vScrollbar, vLock);
}
Exemplo n.º 4
0
// ---------------------------------------------------------------------
bool SymbolWidget::getBrush(const QString& s, QBrush& Brush, int i)
{
  bool ok;
  QString n;

  n = s.section(' ',i,i);    // fill color
  QColor co;
  co.setNamedColor(n);
  Brush.setColor(co);
  if(!Brush.color().isValid()) return false;

  i++;
  n = s.section(' ',i,i);    // fill style
  Brush.setStyle((Qt::BrushStyle)n.toInt(&ok));
  if(!ok) return false;

  i++;
  n = s.section(' ',i,i);    // filled
  if(n.toInt(&ok) == 0) Brush.setStyle(Qt::NoBrush);
  if(!ok) return false;

  return true;
}
Exemplo n.º 5
0
void koregui::ShaderInputItem::paint(QPainter* painter,
                                     const QStyleOptionGraphicsItem* option,
                                     QWidget* widget) {
  QPen p;
  p.setColor(QColor(44,44,44));
  p.setWidth(2);

  QBrush b;
  switch(_input->type) {
    case GL_FLOAT_MAT4:
      b.setColor(Qt::GlobalColor::green);
      break;
    default : b.setColor(Qt::GlobalColor::red);
  }
  b.setStyle(Qt::BrushStyle::SolidPattern);
  painter->setBrush(b);
  painter->setPen(p);
  if(_mouseover) {
    painter->drawRect(-2, -2, 16, 16);
  } else {
    painter->drawRect(0, 0, 12, 12);
  }
}
Exemplo n.º 6
0
void BitmapImage::drawEllipse(QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
    int width = pen.width();
    setCompositionModeBounds(rectangle.adjusted(-width, -width, width, width).toRect(), true, cm);
    if (brush.style() == Qt::RadialGradientPattern)
    {
        QRadialGradient* gradient = (QRadialGradient*)brush.gradient();
        gradient->setCenter(gradient->center() - mBounds.topLeft());
        gradient->setFocalPoint(gradient->focalPoint() - mBounds.topLeft());
    }
    if (!image()->isNull())
    {
        QPainter painter(image());

        painter.setRenderHint(QPainter::Antialiasing, antialiasing);
        painter.setPen(pen);
        painter.setBrush(brush);
        painter.setCompositionMode(cm);
        painter.drawEllipse(rectangle.translated(-mBounds.topLeft()));
        painter.end();
    }
    modification();
}
Exemplo n.º 7
0
void fillOpaqueRect(QPainter *painter, const QRect &rect, const QBrush &brush)
{
    if (!brush.isOpaque()) {
        QPixmap chessboardPattern(16, 16);
        QPainter patternPainter(&chessboardPattern);
        patternPainter.fillRect(0, 0, 8, 8, Qt::black);
        patternPainter.fillRect(8, 8, 8, 8, Qt::black);
        patternPainter.fillRect(0, 8, 8, 8, Qt::white);
        patternPainter.fillRect(8, 0, 8, 8, Qt::white);
        patternPainter.end();
        painter->fillRect(rect, QBrush(chessboardPattern));
    }
    painter->fillRect(rect, brush);
}
Exemplo n.º 8
0
void TargetList::editRow(int row, QString fileName, QString name, QString coordinates, QString description)
{
    // Creates image preview item
    QBrush brush;
    QImage brushImage;
    if (fileName == "")
        brushImage.load(defaultImagePath);
    else
        brushImage.load(fileName);
    // Resize image
    int width = 100;
    int height = 100;
    QImage scaledBrushImage = brushImage.scaled(width, height, Qt::IgnoreAspectRatio);
    // Apply resized image
    brush.setTextureImage(scaledBrushImage);

    rows->at(row)->image->setBackground(brush);
    rows->at(row)->name->setText(name);
    rows->at(row)->coord->setText(coordinates);
    rows->at(row)->desc->setText(description);

    refreshTable();
}
Exemplo n.º 9
0
void QQuickTextNodeEngine::addBorder(const QRectF &rect, qreal border,
                                     QTextFrameFormat::BorderStyle borderStyle,
                                     const QBrush &borderBrush)
{
    QColor color = borderBrush.color();

    // Currently we don't support other styles than solid
    Q_UNUSED(borderStyle);

    m_backgrounds.append(qMakePair(QRectF(rect.left(), rect.top(), border, rect.height() + border), color));
    m_backgrounds.append(qMakePair(QRectF(rect.left() + border, rect.top(), rect.width(), border), color));
    m_backgrounds.append(qMakePair(QRectF(rect.right(), rect.top() + border, border, rect.height() - border), color));
    m_backgrounds.append(qMakePair(QRectF(rect.left() + border, rect.bottom(), rect.width(), border), color));
}
Exemplo n.º 10
0
void MythRenderOpenGL1::DrawRectPriv(const QRect &area, const QBrush &fillBrush,
                                     const QPen &linePen, int alpha)
{
    SetBlend(true);
    DisableTextures();
    EnableShaderObject(0);
    glEnableClientState(GL_VERTEX_ARRAY);

    int lineWidth = linePen.width();
    QRect r(area.left() + lineWidth, area.top() + lineWidth,
            area.width() - (lineWidth * 2), area.height() - (lineWidth * 2));

    if (fillBrush.style() != Qt::NoBrush)
    {
        int a = 255 * (((float)alpha / 255.0f) *
                       ((float)fillBrush.color().alpha() / 255.0f));
        SetColor(fillBrush.color().red(), fillBrush.color().green(),
                 fillBrush.color().blue(), a);
        GLfloat *vertices = GetCachedVertices(GL_TRIANGLE_STRIP, r);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    }

    if (linePen.style() != Qt::NoPen)
    {
        int a = 255 * (((float)alpha / 255.0f) *
                       ((float)linePen.color().alpha() / 255.0f));
        SetColor(linePen.color().red(), linePen.color().green(),
                 linePen.color().blue(), a);
        glLineWidth(linePen.width());
        GLfloat *vertices = GetCachedVertices(GL_LINE_LOOP, r);
        glVertexPointer(2, GL_FLOAT, 0, vertices);
        glDrawArrays(GL_LINE_LOOP, 0, 4);
    }

    glDisableClientState(GL_VERTEX_ARRAY);
}
Exemplo n.º 11
0
void QgsComposerUtils::drawArrowHead( QPainter *p, const double x, const double y, const double angle, const double arrowHeadWidth )
{
  if ( !p )
  {
    return;
  }

  double angleRad = angle / 180.0 * M_PI;
  QPointF middlePoint( x, y );
  //rotate both arrow points
  QPointF p1 = QPointF( -arrowHeadWidth / 2.0, arrowHeadWidth );
  QPointF p2 = QPointF( arrowHeadWidth / 2.0, arrowHeadWidth );

  QPointF p1Rotated, p2Rotated;
  p1Rotated.setX( p1.x() * cos( angleRad ) + p1.y() * -sin( angleRad ) );
  p1Rotated.setY( p1.x() * sin( angleRad ) + p1.y() * cos( angleRad ) );
  p2Rotated.setX( p2.x() * cos( angleRad ) + p2.y() * -sin( angleRad ) );
  p2Rotated.setY( p2.x() * sin( angleRad ) + p2.y() * cos( angleRad ) );

  QPolygonF arrowHeadPoly;
  arrowHeadPoly << middlePoint;
  arrowHeadPoly << QPointF( middlePoint.x() + p1Rotated.x(), middlePoint.y() + p1Rotated.y() );
  arrowHeadPoly << QPointF( middlePoint.x() + p2Rotated.x(), middlePoint.y() + p2Rotated.y() );

  p->save();

  QPen arrowPen = p->pen();
  arrowPen.setJoinStyle( Qt::RoundJoin );
  QBrush arrowBrush = p->brush();
  arrowBrush.setStyle( Qt::SolidPattern );
  p->setPen( arrowPen );
  p->setBrush( arrowBrush );
  arrowBrush.setStyle( Qt::SolidPattern );
  p->drawPolygon( arrowHeadPoly );

  p->restore();
}
Exemplo n.º 12
0
void CanvasStyle::applyFillColor(GraphicsContext* context) const
{
    if (!context)
        return;
    switch (m_type) {
    case RGBA:
        context->setFillColor(m_rgba, ColorSpaceDeviceRGB);
        break;
    case CMYKA: {
        // FIXME: Do this through platform-independent GraphicsContext API.
        // We'll need a fancier Color abstraction to support CMYKA correctly
#if USE(CG)
        CGContextSetCMYKFillColor(context->platformContext(), m_cmyka->c, m_cmyka->m, m_cmyka->y, m_cmyka->k, m_cmyka->a);
#elif PLATFORM(QT)
        QBrush currentBrush = context->platformContext()->brush();
        QColor clr;
        clr.setCmykF(m_cmyka->c, m_cmyka->m, m_cmyka->y, m_cmyka->k, m_cmyka->a);
        currentBrush.setColor(clr);
        context->platformContext()->setBrush(currentBrush);
#else
        context->setFillColor(m_cmyka->rgba, ColorSpaceDeviceRGB);
#endif
        break;
    }
    case Gradient:
        context->setFillGradient(canvasGradient()->gradient());
        break;
    case ImagePattern:
        context->setFillPattern(canvasPattern()->pattern());
        break;
    case CurrentColor:
    case CurrentColorWithOverrideAlpha:
    case Invalid:
        ASSERT_NOT_REACHED();
        break;
    }
}
Exemplo n.º 13
0
void WaveDisplay::paintEvent( QPaintEvent *ev )
{
	UNUSED(ev);
	
	QPainter painter( this );
	painter.setRenderHint( QPainter::Antialiasing );

	QBrush brush = QBrush(Qt::red, m_Background);
	brush.setStyle(Qt::TexturePattern);
	painter.setBrush(brush);
	painter.drawRect(0, 0, width(), height());
	
	if( m_pLayer ){
		painter.setPen( QColor( 102, 150, 205 ) );
		int VCenter = height() / 2;
		for ( int x = 0; x < width(); x++ ) {
			painter.drawLine( x, VCenter, x, m_pPeakData[x] + VCenter );
			painter.drawLine( x, VCenter, x, -m_pPeakData[x] + VCenter );
		}
		
	}
	
	QFont font;
	font.setWeight( 63 );
	painter.setFont( font );
	painter.setPen( QColor( 255 , 255, 255, 200 ) );
	
	if( m_SampleNameAlignment == Qt::AlignCenter ){
		painter.drawText( 0, 0, width(), 20, m_SampleNameAlignment, m_sSampleName );
	} 
	else if( m_SampleNameAlignment == Qt::AlignLeft )
	{
		// Use a small offnset iso. starting directly at the left border
		painter.drawText( 20, 0, width(), 20, m_SampleNameAlignment, m_sSampleName );
	}
	
}
Exemplo n.º 14
0
MainWindow::MainWindow() {
  /* Create a  pen object for the line item. */
  QPen pen;
  pen.setStyle(Qt::DashDotLine); // use dash-do-line style : "-.--"
  pen.setWidth(3);
  pen.setBrush(Qt::green);  // use Green color
  pen.setCapStyle(Qt::RoundCap);  // set round style of  end points of line.

  m_view = new QGraphicsView(this);
  this->setCentralWidget(m_view); // Add the view object into main window.

  QObject::connect(&m_timeLine, SIGNAL(frameChanged(int)), this, SLOT(animate(int)));
  m_timeLine.setDuration(5000);  // 5 seconds
  m_timeLine.setFrameRange(0, 100);
  m_timeLine.setCurveShape(QTimeLine::LinearCurve); // set the velocity change mode of animation

  m_scene.addText("Hello, world!")->setPos(5.0, 5.0);  // Create a Text item.
  QGraphicsLineItem *line = m_scene.addLine(10, 90, 250, 250, pen);   // Create a Line item.

  m_rect_x = START_X;
  m_rect_y = START_Y;
  m_rect = m_scene.addRect(QRectF(m_rect_x, m_rect_y, 50, 50));    // Create a Rectangle item.

   /* Create a brush object to paint the Rectangle item. */
  QBrush brush;
  brush.setColor(Qt::darkGray);
  brush.setStyle(Qt::SolidPattern);
  m_rect->setBrush(brush);

  /* Set the Rectangle's opacity */
  m_opacity = 1;
  m_rect->setOpacity(m_opacity);

  m_view->setScene(&m_scene);  // Add scene into the view object

  m_timeLine.start();
}
Exemplo n.º 15
0
//! [0]
void NorwegianWoodStyle::polish(QPalette &palette)
{
    QColor brown(212, 140, 95);
    QColor beige(236, 182, 120);
    QColor slightlyOpaqueBlack(0, 0, 0, 63);

    QPixmap backgroundImage(":/images/woodbackground.png");
    QPixmap buttonImage(":/images/woodbutton.png");
    QPixmap midImage = buttonImage;

    QPainter painter;
    painter.begin(&midImage);
    painter.setPen(Qt::NoPen);
    painter.fillRect(midImage.rect(), slightlyOpaqueBlack);
    painter.end();
//! [0]

//! [1]
    palette = QPalette(brown);

    palette.setBrush(QPalette::BrightText, Qt::white);
    palette.setBrush(QPalette::Base, beige);
    palette.setBrush(QPalette::Highlight, Qt::darkGreen);
    setTexture(palette, QPalette::Button, buttonImage);
    setTexture(palette, QPalette::Mid, midImage);
    setTexture(palette, QPalette::Window, backgroundImage);

    QBrush brush = palette.background();
    brush.setColor(brush.color().dark());

    palette.setBrush(QPalette::Disabled, QPalette::WindowText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Text, brush);
    palette.setBrush(QPalette::Disabled, QPalette::ButtonText, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Base, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Button, brush);
    palette.setBrush(QPalette::Disabled, QPalette::Mid, brush);
}
Exemplo n.º 16
0
void DiagramSettings::Private::changeBackgroundColor()
{
    if ( m_chart && m_chart->coordinatePlane() && m_chart->coordinatePlane()->diagram() )
    {
        BackgroundAttributes bat = m_chart->coordinatePlane()->backgroundAttributes();
        bat.setVisible( true );
        ui->visibleBtn->setChecked( true );

        if ( ui->color->isChecked() )
        {

            QBrush setBrush = bat.brush();
            const QColor color = QColorDialog::getColor( setBrush.color(), qq, tr( "Choose new color" ) );
            if ( !color.isValid() )
                return;
            bat.setBrush( color );
            QPalette palette = ui->diagramBackground->palette();
            palette.setBrush( QPalette::Button, color );
            ui->diagramBackground->setPalette( palette );
        }
        else if ( ui->textureBtn->isChecked() )
        {
            //QBrush setBrush = m_chart->coordinatePlane()->diagram()->brush( index );
            QImage texture;

            const QString filename = QFileDialog::getOpenFileName( qq, tr( "Choose Texture" ), QString(), tr( "Images (*.png *.xpm *.jpg)" ) );
            if ( filename.isEmpty() )
                return;
            texture = QImage( filename );
            bat.setBrush( texture );
            QPalette palette = ui->diagramBackground->palette();
            palette.setBrush( QPalette::Button, QBrush( texture ) );
            ui->diagramBackground->setPalette( palette );
        }
        else
        {
            QBrush setBrush = bat.brush();
            QGradient grad;
            QLinearGradient lGrad;
            lGrad.setColorAt( 0, Qt::black );
            lGrad.setColorAt( 1, setBrush.color() );
            grad = lGrad;

            if ( setBrush.gradient() )
                grad = *setBrush.gradient();
            const QGradient &color = GradientDialog::getGradient( grad, qq, tr( "Choose new color" ) );
            bat.setBrush( color );
            QPalette palette = ui->diagramBackground->palette();
            palette.setBrush( QPalette::Button, QBrush( color ) );
            ui->diagramBackground->setPalette( palette );
        }
        bat.setVisible( true );
        m_chart->coordinatePlane()->setBackgroundAttributes( bat );
        qq->update();
    }
}
Exemplo n.º 17
0
DesktopBackgroundDialog::DesktopBackgroundDialog(RazorSettings * cfg, int screen, int desktop, QSize desktopSize, const QBrush & brush, QWidget * parent)
    : QDialog(parent),
      m_desktopSize(desktopSize),
      m_type(RazorWorkSpaceManager::BackgroundColor),
      m_config(cfg),
      m_screen(screen),
      m_desktop(desktop)
{
    setupUi(this);
    // center it to current desktop
    move(parent->geometry().center() - geometry().center());
    
    // read current wallpaper brush
    if (brush.texture().isNull())
    {
        m_color = brush.color();
        preview();
    }
    else
    {
        QPixmap p = brush.texture().scaled(previewLabel->size(), Qt::IgnoreAspectRatio, Qt::FastTransformation);
        previewLabel->setPixmap(p);
    }

    connect(colorButton, SIGNAL(clicked()),
            this, SLOT(colorButton_clicked()));
    connect(wallpaperButton, SIGNAL(clicked()),
            this, SLOT(wallpaperButton_clicked()));
    connect(systemButton, SIGNAL(clicked()),
            this, SLOT(systemButton_clicked()));
    connect(keepAspectCheckBox, SIGNAL(toggled(bool)),
            this, SLOT(preview()));

    buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
    keepAspectCheckBox->setEnabled(false);
}
Exemplo n.º 18
0
void mainWidget::paintEvent(QPaintEvent *)
{
    QBitmap bitmap(this->size());
    bitmap.fill();
    QPainter painter(&bitmap);
    painter.setBrush(QBrush(Qt::black));
    painter.drawRoundedRect(bitmap.rect(),5,5);
    setMask(bitmap);

    QPixmap pixmap(this->size());
    pixmap.fill();
    painter.end();
    painter.begin(&pixmap);
    painter.setRenderHints(QPainter::Antialiasing,true);
    QBrush brush;
    brush.setStyle(Qt::TexturePattern);
    brush.setTextureImage(QImage(bkPicName));
    painter.setBrush(brush);
    painter.setPen(Qt::black);
    painter.drawRoundedRect(rect(),5,5);
    painter.end();
    painter.begin(this);
    painter.drawPixmap(this->rect(),pixmap);
}
Exemplo n.º 19
0
QString KoOdfGraphicStyles::saveOdfHatchStyle(KoGenStyles& mainStyles, const QBrush &brush)
{
    KoGenStyle hatchStyle(KoGenStyle::HatchStyle /*no family name*/);
    hatchStyle.addAttribute("draw:color", brush.color().name());
    //hatchStyle.addAttribute( "draw:distance", m_distance ); not implemented into kpresenter
    switch (brush.style()) {
    case Qt::HorPattern:
        hatchStyle.addAttribute("draw:style", "single");
        hatchStyle.addAttribute("draw:rotation", 0);
        break;
    case Qt::BDiagPattern:
        hatchStyle.addAttribute("draw:style", "single");
        hatchStyle.addAttribute("draw:rotation", 450);
        break;
    case Qt::VerPattern:
        hatchStyle.addAttribute("draw:style", "single");
        hatchStyle.addAttribute("draw:rotation", 900);
        break;
    case Qt::FDiagPattern:
        hatchStyle.addAttribute("draw:style", "single");
        hatchStyle.addAttribute("draw:rotation", 1350);
        break;
    case Qt::CrossPattern:
        hatchStyle.addAttribute("draw:style", "double");
        hatchStyle.addAttribute("draw:rotation", 0);
        break;
    case Qt::DiagCrossPattern:
        hatchStyle.addAttribute("draw:style", "double");
        hatchStyle.addAttribute("draw:rotation", 450);
        break;
    default:
        break;
    }

    return mainStyles.insert(hatchStyle, "hatch");
}
/*
 * Configures display properties of the List view attached to this model
 */
QVariant ActivityModel::data(const QModelIndex &index, int role) const {
	switch (role) {
	case Qt::DisplayRole:
		if (!index.isValid()) {
			return QVariant();
		}

		if (index.row() >= string_list_.size()) {
			return QVariant();
		}

		return string_list_.at(index.row());
		break;

	case Qt::TextAlignmentRole:
		if (index.row() == tag_row_ && index.column() == 0) { return Qt::AlignCenter; }
		break;

	case Qt::FontRole:
		if (index.row() == tag_row_ && index.column() == 0) {
			QFont font;
			font.setItalic(true);
			return font;
		}
		break;

	case Qt::ForegroundRole:
		QBrush text;
		if (index.row() == 0) {
			text.setColor(Qt::gray);
			return text;
		}
		break;
	}
	return QVariant();
}
Exemplo n.º 21
0
QVariant AttributesModel::defaultHeaderData( int section, Qt::Orientation orientation, int role ) const
{
    // Default values if nothing else matches

    const int dataset = section / d->dataDimension;

    switch ( role ) {
    case Qt::DisplayRole:
        //TODO for KChart 3.0: return QString::number( dataset + 1 );
        return QVariant( (orientation == Qt::Vertical ? QStringLiteral("Series ") : QStringLiteral("Item ")) + QString::number( dataset )) ;
    case KChart::DatasetBrushRole:
        return d->palette.getBrush( dataset );
    case KChart::DatasetPenRole:
        // if no per model override was set, use the (possibly default) color set for the brush
        if ( !modelData( role ).isValid() ) {
            QBrush brush = headerData( section, orientation, DatasetBrushRole ).value< QBrush >();
            return QPen( brush.color() );
        }
    default:
        break;
    }

    return QVariant();
}
Exemplo n.º 22
0
/*! 
  Fill the area between the curve and the baseline with 
  the curve brush

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param pa Polygon

  \sa setBrush(), setBaseline(), setCurveType()
*/
void QwtPlotCurve::fillCurve(QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    QwtPolygon &pa) const
{
    if ( d_data->brush.style() == Qt::NoBrush )
        return;

    closePolyline(xMap, yMap, pa);
    if ( pa.count() <= 2 ) // a line can't be filled
        return;

    QBrush b = d_data->brush;
    if ( !b.color().isValid() )
        b.setColor(d_data->pen.color());

    painter->save();

    painter->setPen(QPen(Qt::NoPen));
    painter->setBrush(b);

    QwtPainter::drawPolygon(painter, pa);

    painter->restore();
}
Exemplo n.º 23
0
void QEmulationPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
{
    QPainterState *s = state();

    if (s->bgMode == Qt::OpaqueMode && pen.style() > Qt::SolidLine) {
        QPen bgPen = pen;
        bgPen.setBrush(s->bgBrush);
        bgPen.setStyle(Qt::SolidLine);
        real_engine->stroke(path, bgPen);
    }


    QBrush brush = pen.brush();
    Qt::BrushStyle style = qbrush_style(brush);
    if (style >= Qt::LinearGradientPattern && style <= Qt::ConicalGradientPattern) {
        const QGradient *g = brush.gradient();
        if (g->coordinateMode() > QGradient::LogicalMode) {
            QPaintEngineEx::stroke(path, pen);
            return;
        }
    }

    real_engine->stroke(path, pen);
}
Exemplo n.º 24
0
QPixmap KisLightSource::createBackground()
{
    QPen pen;
    QBrush brush;
    QPixmap harhar(m_icondiameter, m_icondiameter);
    harhar.fill(QColor(0,0,0,0));

    QPainter painter(&harhar);

    painter.setBackgroundMode(Qt::TransparentMode);
    painter.setRenderHint(QPainter::Antialiasing, 0x08);

    pen.setWidth(1);
    pen.setColor(QColor(0, 0, 0, 150));

    brush.setStyle(Qt::SolidPattern);
    brush.setColor(m_color);

    painter.setBrush(brush);
    painter.setPen(pen);
    painter.drawEllipse(1, 1, m_icondiameter-2, m_icondiameter-2);

    return harhar;
}
subObservationVisualiserBase::subObservationVisualiserBase(const context& contextObj, float pointSize)
    :pointSize(pointSize), contextObj(contextObj),standardPointsItem(NULL), standardLinesItem(NULL), backgroundItem(NULL)
{
    //We don't run this if there are no vertex positions
    if(contextObj.getVertexPositions().size() == 0)
    {
        std::cout << "Specified graph did not have vertex positions, exiting..." << std::endl;
        QTimer::singleShot(0, this, SLOT(close()));
        return;
    }
    initialiseControls();

    QPen pen(Qt::NoPen);
    QColor grey("grey");
    grey.setAlphaF(0.5);
    QBrush brush;
    brush.setColor(grey);
    brush.setStyle(Qt::SolidPattern);
    backgroundItem = new QGraphicsRectItem(minX, minY, maxX - minX, maxY - minY, NULL);
    backgroundItem->setPen(pen);
    backgroundItem->setBrush(brush);
    backgroundItem->setZValue(-1);
    graphicsScene->addItem(backgroundItem);
}
Exemplo n.º 26
0
ColorSchemePrivate::ColorSchemePrivate(QPalette::ColorGroup state,
                                       const char* group, SetDefaultColors defaults, const QBrush& tint) {
      _contrast = 1.0; // KGlobalSettings::contrastF( config );

      // loaded-from-config colors
      _brushes.bg[0] = SET_DEFAULT(NormalBackground);
      _brushes.bg[1] = SET_DEFAULT(AlternateBackground);

      // adjustment
      _brushes.bg[0] = ColorUtils::tint(_brushes.bg[0].color(), tint.color(), 0.4);
      _brushes.bg[1] = ColorUtils::tint(_brushes.bg[1].color(), tint.color(), 0.4);

      // the rest
      init(state, group, defaults);
      }
Exemplo n.º 27
0
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void OriginSymbol::drawOriginSymbol(const Map::Canvas*, QPainter& painter) {
	painter.save();

	QPen pen;
	pen.setColor(_color);
	pen.setWidth(4);
	pen.setJoinStyle(Qt::MiterJoin);
	painter.setPen(pen);

	QBrush brush;
	brush.setColor(_color);
	brush.setStyle(Qt::NoBrush);
	if ( isFilled() )
		brush.setStyle(Qt::SolidPattern);

	/*
	QBrush brush;
	brush.setStyle(Qt::SolidPattern);
	if ( isFilled() )
		brush.setColor(_color);
	else
		brush.setColor(QColor(_color.red(), _color.green(), _color.blue(), 64));
	*/

	painter.setBrush(brush);

	const QSize& size = Seiscomp::Gui::Map::Symbol::size();
	int height = size.height(),
	    width = size.width(),
	    r = int(width / 2);
	QRect rect(_mapPosition.x() - r, _mapPosition.y() - r, width, height);
	_poly = rect;
	painter.drawEllipse(rect);

	painter.restore();
}
Exemplo n.º 28
0
void KisVisualEllipticalSelectorShape::drawCursor()
{
    //qDebug() << this << "KisVisualEllipticalSelectorShape::drawCursor: image needs update" << imagesNeedUpdate();
    QPointF cursorPoint = convertShapeCoordinateToWidgetCoordinate(getCursorPosition());
    QImage fullSelector = getImageMap();
    QColor col = getColorFromConverter(getCurrentColor());
    QPainter painter;
    painter.begin(&fullSelector);
    painter.setRenderHint(QPainter::Antialiasing);
    QRect innerRect(m_barWidth, m_barWidth, width()-(m_barWidth*2), height()-(m_barWidth*2));

    painter.save();
    painter.setCompositionMode(QPainter::CompositionMode_Clear);
    QPen pen;
    pen.setWidth(5);
    painter.setPen(pen);
    painter.drawEllipse(QRect(0,0,width(),height()));

    if (getDimensions()==KisVisualColorSelectorShape::onedimensional) {
        painter.setBrush(Qt::SolidPattern);
        painter.drawEllipse(innerRect);
    }
    painter.restore();

    QBrush fill;
    fill.setStyle(Qt::SolidPattern);

    int cursorwidth = 5;

    if (m_type==KisVisualEllipticalSelectorShape::borderMirrored) {
        painter.setPen(Qt::white);
        fill.setColor(Qt::white);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
        QPoint mirror(innerRect.center().x()+(innerRect.center().x()-cursorPoint.x()),cursorPoint.y());
        painter.drawEllipse(mirror, cursorwidth, cursorwidth);
        fill.setColor(col);
        painter.setPen(Qt::black);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth-1, cursorwidth-1);
        painter.drawEllipse(mirror, cursorwidth-1, cursorwidth-1);

    } else {
        painter.setPen(Qt::white);
        fill.setColor(Qt::white);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
        fill.setColor(col);
        painter.setPen(Qt::black);
        painter.setBrush(fill);
        painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0);
    }
    painter.end();
    setFullImage(fullSelector);
}
Exemplo n.º 29
0
void MythOpenGLPainter::DrawRoundRect(const QRect &area, int cornerRadius,
                                      const QBrush &fillBrush,
                                      const QPen &linePen, int alpha)
{
    if (realRender && realRender->RectanglesAreAccelerated())
    {
        if (fillBrush.style() == Qt::SolidPattern ||
            fillBrush.style() == Qt::NoBrush)
        {
            realRender->DrawRoundRect(area, cornerRadius, fillBrush,
                                      linePen, alpha);
            return;
        }
    }
    MythPainter::DrawRoundRect(area, cornerRadius, fillBrush, linePen, alpha);
}
void QPicturePaintEngine::updateBrush(const QBrush &brush)
{
    Q_D(QPicturePaintEngine);
#ifdef QT_PICTURE_DEBUG
    qDebug() << " -> updateBrush(): style:" << brush.style();
#endif
    int pos;
    SERIALIZE_CMD(QPicturePrivate::PdcSetBrush);
    if (d->pic_d->in_memory_only) {
        int index = d->pic_d->brush_list.size();
        d->pic_d->brush_list.append(brush);
        d->s << index;
    } else {
        d->s << brush;
    }
    writeCmdLength(pos, QRect(), false);
}