Exemplo n.º 1
0
void CursorPair::draw_markers(QPainter &p,
	const QRect &rect, unsigned int prefix)
{
	compute_text_size(p, prefix);
	QRectF delta_rect(get_label_rect(rect));

	const int radius = delta_rect.height() / 2;
	const QRectF text_rect(delta_rect.intersected(
		rect).adjusted(radius, 0, -radius, 0));
	if(text_rect.width() >= _text_size.width())
	{
		const int highlight_radius = delta_rect.height() / 2 - 2;

		p.setBrush(Cursor::FillColour);
		p.setPen(Cursor::LineColour);
		p.drawRoundedRect(delta_rect, radius, radius);

		delta_rect.adjust(1, 1, -1, -1);
		p.setPen(Cursor::HighlightColour);
		p.drawRoundedRect(delta_rect, highlight_radius, highlight_radius);

		p.setPen(Cursor::TextColour);
		p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
			Ruler::format_time(_second.time() - _first.time(), prefix, 2));
	}

	// Paint the cursor markers
	_first.paint_label(p, rect, prefix);
	_second.paint_label(p, rect, prefix);
}
Exemplo n.º 2
0
void ZLamp::Render(QPainter &painter)
{
  // Set Lamp color intensities
  if (!lampLit) {
    lampColor.setHsv(lampColor.hue(), lampColor.saturation(), lampColor.value()*0.2);
  }
  lampColorLow.setHsv(lampColor.hue(), lampColor.saturation(), lampColor.value()*0.8);

  // Set Lamp gradients
  lampGradient.setColorAt(0.0, lampColor);
  lampGradient.setColorAt(1.0, lampColorLow);

  // Draw everything
  painter.setRenderHint(QPainter::Antialiasing);

  painter.setPen(Qt::NoPen);
  painter.setBrush(bezelGradient);
  painter.drawRoundedRect(bezelRect, bezelWidth, bezelWidth);

  painter.setPen(Qt::NoPen);
  painter.setBrush(lampGradient);
  painter.drawRoundedRect(lampRect, lampRadius, lampRadius);

  painter.setPen(Qt::black);
  painter.setFont(lampFont);
  painter.drawText(lampRect, Qt::AlignCenter ,lampText);

}
Exemplo n.º 3
0
void TrackAnnotation::paint(QPainter &painter) {
//    qDebug() << "TrackAnnotation::paint";
    //qDebug() << "range.chromosome: " << range.chromosome;
    if (!data.items.contains(range.chromosome)) return;

    QList <AnnotationItem *> items;
    //qDebug() << "nGene: " << data.items[range.chromosome].size();
    for (int i = 0; i < data.items[range.chromosome].size(); i++) {
        if (data.items[range.chromosome][i]->from > range.to) continue;
        if (data.items[range.chromosome][i]->to < range.from) continue;
        items.append(data.items[range.chromosome][i]);
    }

    painter.setPen(Qt::black);
    painter.setFont(QFont("Arial", 9));
    long w = range.to - range.from + 1;
    double s = 1.0 * width / w;
    for (int i = 0; i < items.size(); i++) {
        long f = (items[i]->from - range.from) * s;
        long t = (items[i]->to - range.from + 1) * s;
        if (f < 0) f = 0;
        if (t > width) t = width;
        long yoff = items[i]->parent ? 20 : 0;
        long h = 15;
        painter.setPen(Qt::NoPen);
        painter.setBrush(Qt::NoBrush);
        bool show_text = false;
        if (items[i]->type == "gene") { painter.setPen(Qt::black); show_text = true; }
        else if (items[i]->type == "repeat") { h = 6; painter.setBrush(Qt::blue); }
        else if (items[i]->type == "cds") { yoff += 8; h = 6; painter.setBrush(Qt::red); }
        // else if (items[i]->type == "exon") { h = 6; painter.setBrush(Qt::blue); }
        else if (items[i]->type == "exon") { continue; }
        else if (items[i]->type == "mrna") { continue; } // Don't draw
        else { yoff += 8; painter.setBrush(Qt::yellow); show_text = true; } // Everything else goes there...

        QRect r (label_offset + f, top + 2 + yoff, t-f, h);
        items[i]->display = r;
        painter.drawRoundedRect(r,5,5);
        if (show_text) {
            painter.setPen(Qt::black);
            r.setTop(r.top()+2);
            painter.drawText(r, Qt::AlignCenter, items[i]->name);
        }
        if (r.width() >= 20 && (items[i]->type=="repeat" || items[i]->type=="cds")) {
            QString s = items[i]->strand == '+' ? QString::fromUtf8("→") : QString::fromUtf8("←");
            painter.setPen(Qt::white);
            painter.setFont(QFont("Arial", 11));
            painter.drawText(r, Qt::AlignCenter, s);
            painter.setFont(QFont("Arial", 9));
        }
    }

    painter.setPen(Qt::lightGray);
    painter.setBrush(Qt::NoBrush);
    painter.drawRoundedRect(QRect(label_offset,top,width-1,height-1),5,5);
}
Exemplo n.º 4
0
void IndicatorLight::createLabel(int w, int h) {
    if(_glowEnabled && this->scene()) {

        // Draw label glow
        QPixmap pixmap = QPixmap(w,h);
        pixmap.fill(Qt::transparent);
        QPainter painter;
        painter.begin(&pixmap); {
            setupPainter(&painter);
            painter.setBrush(_labelColor);
            painter.setPen(Qt::NoPen);
            painter.drawRoundedRect(0,0,w,h,20,20);
        } painter.end();

        // Setup the graphics item for glow
        // This has a special z-value ontop of other graphics items so that it can glow above the panel cover...
        if(_labelGlowItem) {
            this->scene()->removeItem(_labelGlowItem);
        }
        _labelGlowItem = new QGraphicsPixmapItem(NULL);
        _labelGlowItem->setPixmap(pixmap);
        _labelGlowItem->setOpacity(_glowStrength/100.0);
        _labelGlowItem->setX(this->x());
        _labelGlowItem->setY(this->y());
        _labelGlowItem->setZValue(PANEL_PANELITEM_GLOW_ZVALUE);
        QGraphicsBlurEffect *effect = new QGraphicsBlurEffect(this);
        effect->setBlurRadius(40);
        _labelGlowItem->setGraphicsEffect(effect);
        this->scene()->addItem(_labelGlowItem);
    }
}
Exemplo n.º 5
0
void QUProfileController::drawLoadingMessage(QPainter & p)
{
    if( avail() < m_total || m_total == 0)
    {
        p.save();
        p.setFont ( m_captionFont);
        p.setOpacity(1);
        QString txt = QString( "Loading %1/%2").arg( avail()).arg(m_total);
        QRectF anchor( m_buffer.width()/2.0, m_buffer.height()/2.0, 1, 1);
        QRectF brect = p.boundingRect(
                    anchor,  Qt::AlignCenter | Qt::TextDontClip,
                    txt);
        brect.adjust( -3, -3, 3, 3);
        QColor bg( 255, 255, 255, 225);
        QColor border( 128, 0, 0, 225);
        p.setPen( border);
        p.setBrush( bg);
        p.drawRoundedRect( brect, 5, 5);
        p.setPen( QColor(0, 0, 0));
        p.drawText(anchor,  Qt::AlignCenter | Qt::TextDontClip,
                   txt);
        p.setPen( QPen(QColor( 0, 0, 0, 128), 1, Qt::DashLine));
        p.restore();
    }
}
Exemplo n.º 6
0
    bool eventFilter(QObject *pO, QEvent *event)
    {
        if ( event->type() == QEvent::Paint) {
            QWidget* pW = qobject_cast<QWidget*>(pO);
            QColor backColor = NotificationServerSettings::instance()->value("notification_backgroundColor").value<QColor>();
            float fOpacity = NotificationServerSettings::instance()->value("notification_opacity").value<float>();
            QPainter painter ( pW );
            painter.setRenderHint(QPainter::Antialiasing);
            painter.setRenderHint(QPainter::HighQualityAntialiasing);

            // corners
            const int kShadowCornerSize = scShadowSize + scRadiusSize;
            painter.drawPixmap(0, 0, shadowsCorners.at(0));
            painter.drawPixmap(pW->width() - kShadowCornerSize, 0, shadowsCorners.at(1));
            painter.drawPixmap(pW->width() - kShadowCornerSize, pW->height() - kShadowCornerSize, shadowsCorners.at(2));
            painter.drawPixmap(0, pW->height() - kShadowCornerSize, shadowsCorners.at(3));

            //edges
            painter.drawTiledPixmap(kShadowCornerSize, 0,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(0));
            painter.drawTiledPixmap(pW->width() - scShadowSize, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(1));
            painter.drawTiledPixmap(kShadowCornerSize, pW->height() - scShadowSize,pW->width() - kShadowCornerSize*2, scShadowSize,shadowsEdges.at(2));
            painter.drawTiledPixmap(0, kShadowCornerSize,scShadowSize, pW->height() - kShadowCornerSize*2,shadowsEdges.at(3));


            // rounded pixmap
            painter.setBrush(backColor);
            painter.setPen(backColor);
            painter.setOpacity(fOpacity);
            painter.drawRoundedRect(scShadowSize,scShadowSize,pW->width()-2*scShadowSize, pW->height()-2*scShadowSize,scRadiusSize,scRadiusSize);
        }
    }
Exemplo n.º 7
0
  void Paint( QPainter& painter, int x, int y ) const {
    painter.save();

    QRect rect( x, y, Width(), Height() );
    painter.setClipRect( rect );

    // BG
    QPen pen = QPen( QColor( 160, 160, 160 ) );
    pen.setWidth( 3 );
    painter.setPen( pen );
    painter.setBrush( QBrush( QColor( 70, 70, 70, 175 ) ) );
    painter.drawRoundedRect( rect, 10, 10 );

    // Title
    y += Padding();
    painter.setPen( QPen( Qt::white) );
    painter.setFont( mTitleFont );
    painter.drawText( x, y, Width(), TitleHeight(), Qt::AlignCenter | Qt::AlignVCenter | Qt::TextDontClip, mTitle );
    y += TitleHeight() + RowSpacing();

    // Lines
    painter.setPen( QPen( Qt::white) );
    painter.setFont( mRowFont );
    for( const QVariantMap& it : mHistory ) {
      int mx = x + Padding();
      DrawMana( painter, mx, y, RowHeight(), RowHeight(), it["mana"].toInt() );
      int cx = mx + RowHeight() + 5;
      DrawCardLine( painter, cx, y, RowWidth() - cx, RowHeight(), it["name"].toString(), it["count"].toInt() );
      y += RowHeight();
      y += RowSpacing();
    }

    painter.restore();
  }
Exemplo n.º 8
0
QPixmap LeechCraft::Util::DrawOverlayText (QPixmap px,
		const QString& text, QFont font, const QPen& pen, const QBrush& brush)
{
	const auto& iconSize = px.size ();

	const auto fontHeight = px.height () * 0.45;
	font.setPixelSize (std::max (6., fontHeight));

	const QFontMetrics fm (font);
	const auto width = fm.width (text) + 2. * px.width () / 10.;
	const auto height = fm.height () + 2. * px.height () / 10.;
	const bool tooSmall = width > iconSize.width ();

	const QRect textRect (iconSize.width () - width, iconSize.height () - height, width, height);

	QPainter p (&px);
	p.setBrush (brush);
	p.setFont (font);
	p.setPen (pen);
	p.setRenderHint (QPainter::Antialiasing);
	p.setRenderHint (QPainter::TextAntialiasing);
	p.setRenderHint (QPainter::HighQualityAntialiasing);
	p.drawRoundedRect (textRect, 4, 4);
	p.drawText (textRect,
			Qt::AlignCenter,
			tooSmall ? "#" : text);
	p.end ();

	return px;
}
Exemplo n.º 9
0
void Services::drawRoundRect(QPainter& p, QRectF sizeRect, int borderSize, int borderRadius, QColor borderColor) {
  QPen pen;
  pen.setWidth(borderSize);
  pen.setColor(borderColor);
  pen.setJoinStyle(Qt::RoundJoin);

  p.setPen(pen);
  p.setBrush(Qt::NoBrush);

  QRectF rect(sizeRect.x() - borderSize/2, sizeRect.y() - borderSize/2,
              sizeRect.width() + borderSize, sizeRect.height() + borderSize);

  if (borderSize % 2 == 0)
    p.drawRoundedRect(rect, borderSize, borderSize);
  else
    p.drawRoundedRect(rect.translated(0.5, 0.5), borderRadius, borderRadius);
}
Exemplo n.º 10
0
void ContactListEdit::addContactEntry(const QString& contactText, const bts::addressbook::contact& c)
  {
  QFont        default_font;
  default_font.setPointSize( default_font.pointSize() - 1 );
  QFontMetrics font_metrics(default_font);
  QRect        bounding = font_metrics.boundingRect(contactText);
  int          completion_width = font_metrics.width(contactText);
  int          completion_height = bounding.height();

  completion_width += 20;

  QImage   completion_image(completion_width, completion_height + 4, QImage::Format_ARGB32);
  completion_image.fill(QColor(0, 0, 0, 0) );
  QPainter painter;
  painter.begin(&completion_image);
  painter.setFont(default_font);
  painter.setRenderHint(QPainter::Antialiasing);

  QBrush brush(Qt::SolidPattern);
  brush.setColor( QColor( 205, 220, 241 ) );
  QPen  pen;

  bool isKeyhoteeFounder = Contact::isKeyhoteeFounder(c);

  if (isKeyhoteeFounder)
    {
    QLinearGradient grad(QPointF(0, 0), QPointF(0, 1));
    grad.setCoordinateMode(QGradient::ObjectBoundingMode);
    grad.setColorAt(0.3, QColor(231, 190, 66));
    grad.setColorAt(1.0, QColor(103, 51, 1));
    brush = QBrush(grad);
    pen.setColor( QColor( 103, 51, 1 ) );
    }
  else
    {
    brush.setColor( QColor( 205, 220, 241 ) );
    pen.setColor( QColor( 105,110,180 ) );
    }

  painter.setBrush(brush);
  painter.setPen(pen);
  painter.drawRoundedRect(0, 0, completion_width - 1, completion_image.height() - 1, 8, 8,
    Qt::AbsoluteSize);
  painter.setPen(QPen());
  painter.drawText(QPoint(10, completion_height - 2), contactText);

  QTextCursor text_cursor = textCursor();
  uint32_t    prefix_len = _completer->completionPrefix().length();
  for (uint32_t i = 0; i < prefix_len; ++i)
    text_cursor.deletePreviousChar();
     // int extra = completion.length() -
  // tc.movePosition(QTextCursor::Left);
  // tc.movePosition(QTextCursor::EndOfWord);
  // tc.insertText(completion.right(extra));
  text_cursor.insertImage(completion_image, contactText);
  text_cursor.insertText(" ");
  setTextCursor(text_cursor);
  }
Exemplo n.º 11
0
void Scene::drawTransRect(QPainter& painter, const QRect& rectangle, QColor borderColor, 
	QColor backgroundColor, qreal opacity) {

	painter.setOpacity(opacity);
	painter.setPen(QPen(borderColor, 2));
	painter.setBrush(backgroundColor);
	int radius = 5;
	painter.drawRoundedRect(rectangle, radius, radius);
}
Exemplo n.º 12
0
void
DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& pal, QRect& r, qreal opacity )
{   
    p.setBackgroundMode( Qt::TransparentMode );
    p.setRenderHint( QPainter::Antialiasing );
    p.setOpacity( opacity );
    
    QPen pen( pal.dark().color(), .5 );
    p.setPen( pen );
    p.setBrush( pal.highlight() );
    
    p.drawRoundedRect( r, 10, 10 );
    
    p.setOpacity( opacity + .2 );
    p.setBrush( QBrush() );
    p.setPen( pen );
    p.drawRoundedRect( r, 10, 10 );
}
Exemplo n.º 13
0
void MainWindow::redrawBorders()
{
    QBitmap objBitmap(size());
    QPainter painter;
    QRect rect(position(), QPoint(position().x() + width(), position().y() + height()));
    painter.fillRect(rect,Qt::white);
    painter.setBrush(QColor(0,0,0));
    painter.drawRoundedRect(rect,10,10);
    setMask(objBitmap);
}
Exemplo n.º 14
0
void GuiBadgeIcon::paintEvent(QPaintEvent *)
{
  QRectF rectangle(18, 10, height, height);
  QPainter paint;
  paint.begin(this);
  paint.setPen(color);
  paint.setBrush(QBrush(color, Qt::SolidPattern));
  paint.setRenderHint(QPainter::Antialiasing,true);
  paint.drawRoundedRect(rectangle, 7, 7);
  paint.end();
}
Exemplo n.º 15
0
void IScene::drawTransRect(QPainter &p, const QRect &r, QColor borderColor, QColor bgColor, qreal op)
{
    p.setOpacity(op);
    p.setPen(QPen(borderColor, 2));
    p.setBrush(bgColor);
#if QT_VERSION >= 0x040400
    p.drawRoundedRect(r, 5,5);
#else
    p.drawRect(r);
#endif
}
Exemplo n.º 16
0
void GuiCombWidget::paintEvent(QPaintEvent *)
{
  QRectF rectangle(0, 0, this->width(), this->height());
  QPainter paint;
  paint.begin(this);
  paint.setPen(QPen(Qt::NoPen));
  paint.setBrush(QBrush(window_color,Qt::SolidPattern));

  paint.drawRoundedRect(rectangle,5,5);
  paint.end();
}
Exemplo n.º 17
0
void
DynamicWidget::paintRoundedFilledRect( QPainter& p, QPalette& /* pal */, QRect& r, qreal opacity )
{
    p.setBackgroundMode( Qt::TransparentMode );
    p.setRenderHint( QPainter::Antialiasing );
    p.setOpacity( opacity );

    QColor c( 30, 30, 30 );

    QPen pen( c.darker(), .5 );
    p.setPen( pen );
    p.setBrush( c );

    p.drawRoundedRect( r, 10, 10 );

    p.setOpacity( opacity + .2 );
    p.setBrush( QBrush() );
    p.setPen( pen );
    p.drawRoundedRect( r, 10, 10 );
}
Exemplo n.º 18
0
void GuiColorPicker::paintEvent(QPaintEvent *)
{
  QRectF rectangle(1, 1, 18, 18);
  QPainter paint;

  paint.begin(this);
  paint.setPen(QColor(my_color->red()*0.8,my_color->green()*0.8,my_color->blue()*0.8));
  paint.setBrush(QBrush(*my_color,Qt::SolidPattern));
  paint.setRenderHint(QPainter::Antialiasing,true);
  paint.drawRoundedRect(rectangle,5,5);
  paint.end();
}
Exemplo n.º 19
0
void ChartBase::draw_tooltip(QPainter& painter, const QPoint& mouse_position) const
{
    size_t point_index;

    if (!on_chart(mouse_position, point_index))
        return;

    const int ShiftX = 2;
    const int ShiftY = 2;
    const int MarginX = 8;
    const int MarginY = 5;
    const int FrameMargin = 3;
    const qreal CornerRadius = 2.0;
    const int Opacity = 180;
    const QColor TextColor(210, 210, 210, Opacity);
    const QColor BorderColor(40, 40, 40, Opacity);
    const QColor BackgroundColor(80, 80, 80, Opacity);

    if (m_tooltip_formatter.get() == 0)
        return;

    const Vector2d& point = m_original_points[point_index];
    const QString text = m_tooltip_formatter->format(point);
    const QRect text_rect = painter.fontMetrics().boundingRect(QRect(), Qt::AlignCenter, text);

    QRect tooltip_rect(
        mouse_position.x() + ShiftX,
        mouse_position.y() - text_rect.height() - 2 * MarginY - ShiftY,
        text_rect.width() + 2 * MarginX,
        text_rect.height() + 2 * MarginY);

    if (tooltip_rect.left() < FrameMargin)
        tooltip_rect.moveLeft(FrameMargin);

    if (tooltip_rect.top() < FrameMargin)
        tooltip_rect.moveTop(FrameMargin);

    const int MaxRight = painter.window().right() - FrameMargin;
    if (tooltip_rect.right() > MaxRight)
        tooltip_rect.moveRight(MaxRight);

    const int MaxBottom = painter.window().bottom() - FrameMargin;
    if (tooltip_rect.bottom() > MaxBottom)
        tooltip_rect.moveBottom(MaxBottom);

    painter.setPen(BorderColor);
    painter.setBrush(QBrush(BackgroundColor));
    painter.drawRoundedRect(tooltip_rect, CornerRadius, CornerRadius);

    painter.setPen(TextColor);
    painter.drawText(tooltip_rect, Qt::AlignCenter, text);
}
Exemplo n.º 20
0
    void paintEvent( QPaintEvent* event )
    {
        QPainter p;
        p.begin( this );

        QFontMetrics fm( font() );

        p.setPen( QColor( 0xa6a6a6 ) );
        p.setBrush( QColor( 0xdedede ) );
        p.drawRoundedRect( rect().adjusted( 0, 0, -1, -1 ), 4, 4 );

        int indent = fm.width( tr( "%L1 plays" ).arg( 999999 ) );
        int chunk = ( (width() - indent ) * m_plays ) / m_maxPlays;
        int adjust = indent + chunk - width();
        p.setPen( QColor( 0x2a8bad ) );
        p.setBrush( QColor( 0x34bae8 ) );
        p.drawRoundedRect( rect().adjusted( 0, 0, adjust - 1, -1 ), 4, 4 );

        p.end();

        QLabel::paintEvent( event );
    }
Exemplo n.º 21
0
void AbstractInputWidget::drawTrack(QPainter& _p, double _left, double _right) const
{
  QRectF _progressRect = rect();
  _p.setBrush(QBrush(colorSet().window()));
  _p.drawRoundedRect(_progressRect,4,4);

  if (_left > _right) std::swap(_left,_right);

  _progressRect.setLeft(_left);
  _progressRect.setRight(_right);
  _p.setBrush(QBrush(colorSet().highlight()));
  _p.drawRect(_progressRect);
}
void PerformancePainter::drawBackground(QPainter &qp)
{
    //  //Declare a painter and a pen used for drawing
    //  QPainter qp(this);
      qp.setPen(QColor(255,255,255,255));
      qp.setBrush(m_backgroundColor);

      //Draw the background
      qp.drawRoundedRect(0,0,m_width-1,m_height-1,
                           3,3
                           ,Qt::AbsoluteSize);


}
Exemplo n.º 23
0
void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &p,
	int h, double x, int y) const
{
	const QString text = a.annotations().empty() ?
		QString() : a.annotations().back();
	const double w = min((double)p.boundingRect(QRectF(), 0, text).width(),
		0.0) + h;
	const QRectF rect(x - w / 2, y - h / 2, w, h);

	p.drawRoundedRect(rect, h / 2, h / 2);

	p.setPen(Qt::black);
	p.drawText(rect, Qt::AlignCenter | Qt::AlignVCenter, text);
}
    void FieldEditor::paintEvent(QPaintEvent * event)
    {
        if (this->_highlight == true)
        {
            QPainter * painter = new QPainter(this);
            painter->setRenderHint(QPainter::TextAntialiasing, true);
            painter->setPen(QColor(0,0,0,0));
            painter->setBrush(QColor(207,217,227,150));
            painter->drawRoundedRect(this->rect().adjusted(0,0,-1,-1), 5,5);
            delete painter;
        }

        this->QLabel::paintEvent(event);
    }
Exemplo n.º 25
0
void LineWait::drawLineWait(QPainter &p)
{
    //根据100*100的大小进行画,在paintEvent中进行过缩放
    p.save();
    p.setPen(Qt::NoPen);
    QColor color = m_color;
    for(int i = 0; i<=10; ++i)
    {
      color.setAlphaF(1.0*i/10);
      p.setBrush(QBrush(color));
      p.drawRoundedRect(50*2/5, -3, 50*3/5, 6, 2, 2);
      p.rotate(36);
    }
    p.restore();
}
Exemplo n.º 26
0
    void PreviewContentWidget::renderPreloaderBubble(QPainter &p)
    {
        p.save();

        auto bodyBrush = (
            isOutgoing() ?
                Ui::MessageStyle::getOutgoingBodyColorA(0.7) :
                Ui::MessageStyle::getIncomingBodyColorA(0.7)
        );

        p.setBrush(bodyBrush);

        p.drawRoundedRect(getPreviewScaledRect(), Ui::MessageStyle::getBorderRadius(), Ui::MessageStyle::getBorderRadius());

        p.restore();
    }
Exemplo n.º 27
0
 void operator()
     ( QPainter & painter
     , const DrawRoundedRect & d
     ) const
 {
     painter.setPen( d.pen );
     painter.setBrush( d.brush );
     painter.drawRoundedRect
         ( d.rect
         , d.xRadius
         , d.yRadius
         , d.absolute
             ? Qt::AbsoluteSize
             : Qt::RelativeSize
         );
 }
Exemplo n.º 28
0
void ItemImage::drawGradientRectangle( QPainter& painter, QRect& rect, QColor baseColor )
{
    QColor baseLighter = baseColor.lighter( 175 );
    QColor gradientStart = QColor( baseLighter.red(), baseLighter.green(), baseLighter.blue(), 150 );
    QColor gradientEnd = QColor( baseColor.red(), baseColor.green(), baseColor.blue(), 150 );
    QLinearGradient linearGrad( QPointF( 0, 0 ), QPointF( 0, 1 ) );
    linearGrad.setColorAt( 0, gradientStart );
    linearGrad.setColorAt( 1, gradientEnd );
    linearGrad.setCoordinateMode( QGradient::ObjectBoundingMode );
    painter.setBrush( linearGrad );
    painter.setPen( QPen( baseColor ) );
    painter.drawRoundedRect( rect, 2.7, 2.7 );
    /*painter.drawRect( rect );
    painter.setBrush( QColor( 0x00, 0x00, 0xFF, 100 ) );
    painter.setPen( QPen( QColor(0x00, 0x00, 0xFF ) ) );
    painter.drawRect( rect );*/
}
void HoverPoints::paintPoints()
{
    QPainter p;
    p.begin(m_widget);
    p.setRenderHint(QPainter::Antialiasing);
  
    p.setBrush(m_gradient);
    //p.setBrush(QColor(230,230,230));
    p.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
    p.drawRoundedRect(QRect(1, 1, m_widget->width() - 2, m_widget->height() - 2), 4.0, 4.0);
   
    p.setBrush(QBrush());
   
    if (m_connectionPen.style() != Qt::NoPen && m_connectionType != NoConnection) {
        p.setPen(m_connectionPen);

        if (m_connectionType == CurveConnection) {
            QPainterPath path;
            path.moveTo(m_points.at(0));
            for (int i=1; i<m_points.size(); ++i) {
                QPointF p1 = m_points.at(i-1);
                QPointF p2 = m_points.at(i);
                qreal distance = p2.x() - p1.x();

                path.cubicTo(p1.x() + distance / 2, p1.y(),
                             p1.x() + distance / 2, p2.y(),
                             p2.x(), p2.y());
            }
            p.drawPath(path);
        } else {
            p.drawPolyline(m_points);
        }
    }

    p.setPen(m_pointPen);
    p.setBrush(m_pointBrush);

    for (int i=0; i<m_points.size(); ++i) {
        QRectF bounds = pointBoundingRect(i);
        if (m_shape == CircleShape)
            p.drawEllipse(bounds);
        else
            p.drawRect(bounds);
    }
}
void QgsVectorGradientColorRampV2Dialog::setStopColor( QTreeWidgetItem* item, QColor color )
{
  QSize iconSize( 16, 16 );
  QPixmap pixmap( iconSize );
  pixmap.fill( QColor( 0, 0, 0, 0 ) );
  QRect rect( 1, 1, iconSize.width() - 2, iconSize.height() - 2 );

  // draw a slightly rounded rectangle
  QPainter p;
  p.begin( &pixmap );
  p.setPen( Qt::NoPen );
  p.setRenderHint( QPainter::Antialiasing );
  p.setBrush( color );
  p.drawRoundedRect( rect, 4, 4 );
  p.end();

  item->setIcon( 0, QIcon( pixmap ) );
  item->setData( 0, StopColorRole, color );
  item->setText( 0, color.name() );
}