예제 #1
0
void FinderHomeWidget::paintEvent(QPaintEvent * /*event*/) {
    QPainter painter(this);
    QLinearGradient linearGrad(0, 0, 0, height());
    linearGrad.setColorAt(0, QColor(0x33, 0x33, 0x33));
    linearGrad.setColorAt(.2, QColor(0x43, 0x43, 0x43));
    painter.fillRect(0, 0, width(), height(), QBrush(linearGrad));
}
예제 #2
0
GraphGraphicsView::GraphGraphicsView(QWidget *parent) :
    QGraphicsView(parent)
{
    setScene(&scene);
    resize(1000,500);
    setBackgroundBrush(Qt::white);
    setFocus();

    QLinearGradient linearGrad(-500, -500, 500, 500); // átmenetes ecset
    linearGrad.setColorAt(0, QColor(255, 255, 255));
    linearGrad.setColorAt(1, QColor(192, 192, 192));
    setBackgroundBrush(linearGrad);
    setRenderHint(QPainter::Antialiasing);
    setFrameStyle(QFrame::NoFrame);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    qsrand(QTime::currentTime().msec());

    randomGraph();

    dDialog = new dijkstraDialog();
    source = -1;
    destination = -1;

    QObject::connect(dDialog, SIGNAL(runDijkstraFromTo(int,int)),
                     this, SLOT(runDijkstra(int,int)));
}
예제 #3
0
void tst_QAbstractScrollArea::patternBackground()
{
    QWidget topLevel;
    QScrollArea scrollArea(&topLevel);
    scrollArea.resize(200, 200);
    QWidget widget;
    widget.resize(600, 600);
    scrollArea.setWidget(&widget);
    topLevel.show();

    QLinearGradient linearGrad(QPointF(250, 250), QPointF(300, 300));
    linearGrad.setColorAt(0, Qt::yellow);
    linearGrad.setColorAt(1, Qt::red);
    QBrush bg(linearGrad);
    scrollArea.viewport()->setPalette(QPalette(Qt::black, bg, bg, bg, bg, bg, bg, bg, bg));
    widget.setPalette(Qt::transparent);

    QTest::qWait(50);

    QImage image(200, 200, QImage::Format_ARGB32);
    scrollArea.render(&image);

    QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::yellow).rgb());

    QScrollBar *hbar = scrollArea.horizontalScrollBar();
    hbar->setValue(hbar->maximum());
    QScrollBar *vbar = scrollArea.verticalScrollBar();
    vbar->setValue(vbar->maximum());

    QTest::qWait(50);

    scrollArea.render(&image);
    QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
}
예제 #4
0
void FacebookContactUI::paintFrontView(QPainter *painter, const QRectF &rect)
{
    QPainterPath backgroundPath;
    backgroundPath.addRoundedRect(rect, 6.0, 6.0);

    painter->fillPath(backgroundPath, QColor(235, 235, 235));

    if (d->mSearchBox) {
        QRectF searchBoxRect = QRectF (0.0, d->mScrollView->contentRect().height() + 28,
                                       rect.width(), rect.height());

        QRectF searchBoxLineRect = QRectF (0.0, d->mScrollView->contentRect().height() + 29,
                                       rect.width(), rect.height());

        QPen pen = QPen(QColor(220, 220, 220), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
        painter->setPen(pen);

        QLinearGradient linearGrad(searchBoxRect.topRight(), searchBoxRect.bottomRight());

        linearGrad.setColorAt(0, QColor(93, 103, 114));
        linearGrad.setColorAt(1, QColor(66, 77, 88));

        painter->fillRect(searchBoxRect, linearGrad);
        painter->drawLine(searchBoxRect.topRight(), searchBoxRect.topLeft());
        pen = QPen(QColor(88, 88, 88), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
        painter->setPen(pen);
        painter->drawLine(searchBoxLineRect.topRight(), searchBoxLineRect.topLeft());
    }
}
예제 #5
0
파일: Buttons.cpp 프로젝트: retornaz/aseba
	void AddRemoveButton::paint (QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
	{
		Q_UNUSED(option);
		Q_UNUSED(widget);

 		qreal alpha = pressed ? 255 : 150;
		
		QLinearGradient linearGrad(QPointF(-32, -32), QPointF(32, 32));
		linearGrad.setColorAt(0, QColor(209, 196, 180, alpha));
		linearGrad.setColorAt(1, QColor(167, 151, 128, alpha));
     
		painter->setPen(QColor(147, 134, 115));
		painter->setBrush(linearGrad);
		painter->drawEllipse(-32,-32,64,64);
		
		painter->setPen(QPen(QColor(147, 134, 115),5,Qt::SolidLine,Qt::RoundCap));
		if (add)
		{
			painter->drawLine(-16,0,16,0);
			painter->drawLine(0,-16,0,16);
		}
		else
		{
			painter->drawLine(-11,-11,11,11);
			painter->drawLine(-11,11,11,-11);
		}
	}
예제 #6
0
void dtkSplitterHandle::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QPainter painter(this);
    
    QColor topColor(145, 145, 145);
    QColor bottomColor(142, 142, 142);
    QColor gradientStart(252, 252, 252);
    QColor gradientStop(223, 223, 223);
    
    if (orientation() == Qt::Vertical) {
	painter.setPen(topColor);
	painter.drawLine(0, 0, width(), 0);

	if(m_slim)
	    return;
	
	painter.setPen(bottomColor);
	painter.drawLine(0, height()-1, width(), height()-1);
	
	QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height()-3));
	linearGrad.setColorAt(0, gradientStart);
	linearGrad.setColorAt(1, gradientStop);
	painter.fillRect(QRect(QPoint(0,1), size() - QSize(0, 2)), QBrush(linearGrad));

    } else {
	painter.setPen(topColor);
	painter.drawLine(0, 0, 0, height());
    }
}
void TextPercentDelegate::paint(QPainter *painter,
		const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	double percentage = index.model()->data(index, Qt::UserRole).toDouble();
	QString text = index.model()->data(index).toString();

	painter->save();

	if (option.state & QStyle::State_Selected) {
		painter->fillRect(option.rect, option.palette.highlight());
	}

	QLinearGradient linearGrad(0, option.rect.y(), 0,
			option.rect.y() + 0.5 * option.rect.height());
	linearGrad.setColorAt(0, QColor(58, 129, 15));
	linearGrad.setColorAt(1, QColor(214, 239, 182));
	linearGrad.setSpread(QGradient::ReflectSpread);

	QBrush brush(linearGrad);

	painter->fillRect(option.rect.x(), option.rect.y(),
			(int) (option.rect.width() * percentage), option.rect.height() - 1,
			brush);

	painter->fillRect(option.rect.x(), option.rect.y() + option.rect.height(),
			(int) (option.rect.width() * percentage),
			option.rect.y() + option.rect.height(), Qt::white);

	QItemDelegate::paint(painter, option, index);

	painter->restore();
}
예제 #8
0
// Update parent button's icon
void GridColourPopup::updateParentButtonIcon(QColor colour)
{
	if (!parentMenuButton())
	{
		printf("GridColourPopup: No parent button set, so no icon to update.");
		return;
	}

	QPixmap pixmap(32,32);

	QPainter painter(&pixmap);
	QPen pen;

	// Clear pixmap with white background colour (so that transparent colours are displayed correctly)
// 	painter.setBrush(parentMenuButton()->palette().background());
	painter.setBrush(Qt::white);
	painter.setPen(Qt::NoPen);
	painter.drawRect(-1, -1, 32, 32);

	// Setup gradient - the top-left corner will be the actual opaque colour, and the bottom-right the alpha valued colour
	QLinearGradient linearGrad(QPointF(0, 0), QPointF(16, 16));
	linearGrad.setColorAt(0, QColor(colour.red(), colour.green(), colour.blue(), 255));
	linearGrad.setColorAt(1, colour);
	painter.setBrush(linearGrad);

	// Draw circle
	pen.setWidth(1);
	pen.setColor(Qt::black);
	painter.setPen(pen);
	painter.drawRoundRect(0, 0, 31, 31, 10, 10);

	painter.end();

	parentMenuButton()->setIcon(QIcon(pixmap));
}
예제 #9
0
// Paint the horizontal handle as a gradient, paint
// the vertical handle as a line.
void QMacSplitterHandle::paintEvent(QPaintEvent *e)
{
    Q_UNUSED(e);
    QPainter painter(this);
    painter.setRenderHint(QPainter::SmoothPixmapTransform);
    painter.setWorldMatrixEnabled(false);
    painter.setViewTransformEnabled(false);

    QColor topColor(145, 145, 145);
    QColor bottomColor(142, 142, 142);
    QColor gradientStart(252, 252, 252);
    QColor gradientStop(223, 223, 223);

    if (orientation() == Qt::Vertical) {
        painter.setPen(topColor);
        painter.drawLine(0, 0, width(), 0);
        painter.setPen(bottomColor);
        painter.drawLine(0, height() - 1, width(), height() - 1);

        QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height() -3));
        linearGrad.setColorAt(0, gradientStart);
        linearGrad.setColorAt(1, gradientStop);
        painter.fillRect(QRect(QPoint(0,1), size() - QSize(0, 2)), QBrush(linearGrad));
    } else {
        painter.setPen(topColor);
        painter.drawLine(0, 0, 0, height());
    }
}
예제 #10
0
void Connexion::paint(QPainter *painter,
                      const QStyleOptionGraphicsItem *option,QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    painter->save();

    //MODIFICATION DES COORDONNEES DE DESSINS
    qreal angle = qRadiansToDegrees(qAtan2(n1.y()-n2.y(),n1.x()-n2.x()))+90;
    painter->rotate(angle);
    painter->translate(0, n1.getRadius());

    //DESSIN DE LA CONNEXION
    painter->save();

    QColor c1 = n1.getOwner() != 0 ? n1.getOwner()->getColor() : VACANT_COLOR;
    QColor c2 = n2.getOwner() != 0 ? n2.getOwner()->getColor() : VACANT_COLOR;
    QLinearGradient linearGrad(0, 0, 0, distance);
    linearGrad.setColorAt(0, c1);
    linearGrad.setColorAt(1, c2);
    painter->setPen(Qt::NoPen);
    painter->fillRect(-2, 0, 4, distance, linearGrad);

    painter->restore();

    //DESSIN DES SQUADS

    foreach(Squad *s, lstSquad1To2)
    {
        squadPatern(painter, s);
    }
예제 #11
0
파일: layer.cpp 프로젝트: GraphiXS6/pencil
void Layer::paintSelection( QPainter& painter, int x, int y, int width, int height )
{
    QLinearGradient linearGrad( QPointF( 0, y ), QPointF( 0, y + height ) );
    QSettings settings( "Pencil", "Pencil" );
    QString style = settings.value( "style" ).toString();
    if ( style == "aqua" )
    {
        linearGrad.setColorAt( 0, QColor( 225, 225, 255, 100 ) );
        linearGrad.setColorAt( 0.10, QColor( 225, 225, 255, 80 ) );
        linearGrad.setColorAt( 0.20, QColor( 225, 225, 255, 64 ) );
        linearGrad.setColorAt( 0.35, QColor( 225, 225, 255, 20 ) );
        linearGrad.setColorAt( 0.351, QColor( 0, 0, 0, 32 ) );
        linearGrad.setColorAt( 0.66, QColor( 245, 255, 235, 32 ) );
        linearGrad.setColorAt( 1, QColor( 245, 255, 235, 128 ) );
    }
    else
    {
        linearGrad.setColorAt( 0, QColor( 255, 255, 255, 128 ) );
        linearGrad.setColorAt( 0.49, QColor( 255, 255, 255, 0 ) );
        linearGrad.setColorAt( 0.50, QColor( 0, 0, 0, 0 ) );
        linearGrad.setColorAt( 1, QColor( 0, 0, 0, 48 ) );
    }
    painter.setBrush( linearGrad );
    painter.setPen( Qt::NoPen );
    painter.drawRect( x, y, width, height - 1 );
}
void TrafficGraph::drawTopBarContents(QPainter *p, int x, int width, int height)
{
  //The height is the height of the contents, so this will be one pixel less than the height of the topbar
  double bias = -mNiceMinValue;
  double scaleFac = width / mNiceRange;
  QList<QColor>::Iterator col;
  col = mBeamColors.end();
  /**
   * The top bar shows the current values of all the beam data.
   * This iterates through each different beam and plots the newest data for each
   */
  if ( !mBeamData.isEmpty() ) {
    QList<double> newestData = mBeamData.first();
    for(int i = newestData.count()-1; i >= 0; --i) {
      double newest_datapoint = newestData.at(i);
      int start = x + (int)( bias * scaleFac );
      int end = x + (int)( ( bias += newest_datapoint ) * scaleFac );
      int start2 = qMin(start,end);
      end = qMax(start,end);
      start = start2;

      /* If the rect is wider than 2 pixels we draw only the last
       * pixels with the bright color. The rest is painted with
       * a 50% darker color. */

      p->setPen(Qt::NoPen);
      QLinearGradient  linearGrad( QPointF(start,1), QPointF(end, 1));
      linearGrad.setColorAt(0, mBeamColorsDark[i]);
      linearGrad.setColorAt(1, mBeamColors[i]);
      p->fillRect( start, 1, end - start, height-1, QBrush(linearGrad));
    }
  }
}
예제 #13
0
void xProgressBar::overPaintSelectedChunks(const std::vector<uint32_t>& chunks,const QColor& gradColor_a1,const QColor& gradColor_a2, int width,uint32_t ss) const
{
	QLinearGradient linearGrad(rect.x(), rect.y(), rect.x(), rect.y() + rect.height() - 1);

	linearGrad.setColorAt(0.00, gradColor_a1);
	linearGrad.setColorAt(0.16, gradColor_a2);
	linearGrad.setColorAt(1.00, gradColor_a1);

	painter->setBrush(linearGrad);

		std::cerr << "painting chunks: " ;
	for(uint32_t i=0;i<chunks.size();++i)
		std::cerr << chunks[i] <<  " " ;
	std::cerr << std::endl;


	if(chunks.empty())
		return ;

	int last_i = chunks[0] ;

	for(uint32_t i=1;i<chunks.size();++i)
		if(chunks[i] > chunks[i-1]+1)
		{
			int nb_consecutive_chunks = chunks[i-1] - last_i + 1 ;

			painter->drawRect(rect.x() + hSpan+(int)rint(last_i*width/(float)ss), rect.y() + vSpan, (int)ceil(nb_consecutive_chunks*width/(float)ss), rect.height() - 1 - vSpan * 2);
			last_i = chunks[i] ;
		}
	int nb_consecutive_chunks = chunks.back() - last_i + 1 ;
	painter->drawRect(rect.x() + hSpan+(int)rint(last_i*width/(float)ss), rect.y() + vSpan, (int)ceil(nb_consecutive_chunks*width/(float)ss), rect.height() - 1 - vSpan * 2);
}
예제 #14
0
파일: navbar.cpp 프로젝트: Jinxiaohai/QT
// =============================================================================
//  NavBar: PROTECTED Methods
// =============================================================================
void QfNavBar::paintEvent (QPaintEvent *event)
{
    QWidget::paintEvent(event);

    // Recall Update() if painter area is not complete!
    if (event->rect().x() > 0 || event->rect().y() > 0)
    {
        update();
    }

    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing);
    p.fillRect(event->rect(), d->colorBackground);

    // Draw Selection
    if (d->groupSelected != NULL && d->groupSelected->isExpanded() && d->itemSelected != NULL)
    {
        QPoint pos = d->groupSelected->pos() + d->itemSelected->pos();
        int width = geometry().width();

        int r = d->colorSelection.red();
        int g = d->colorSelection.green();
        int b = d->colorSelection.blue();

        p.fillRect(0, pos.y() - 1, width, 1, QColor(r - 0x26, g - 0x26, b - 0x26));

        QLinearGradient linearGrad(QPointF(0, pos.y()), QPointF(0, pos.y() + d->itemSelected->height()));
        linearGrad.setColorAt(0, d->colorSelection);
        linearGrad.setColorAt(1, QColor(r - 0x3b, g - 0x3b, b - 0x3b));
        p.fillRect(0, pos.y(), width, d->itemSelected->height(), linearGrad);
    }

    p.end();
}
예제 #15
0
void IndicatorItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
    painter->setRenderHint(QPainter::Antialiasing);

    QPen pen(color);
    pen.setWidthF(width);

    int baseX = qMin(start.x(), finish.x());
    int baseY = qMin(start.y(), finish.y());

    QLinearGradient linearGrad(start - QPoint(baseX, baseY),
        finish - QPoint(baseX, baseY));
    QColor start_color(255, 255, 255, 0);
    linearGrad.setColorAt(0, start_color);
    linearGrad.setColorAt(1, color.lighter());


    QBrush brush(linearGrad);
    pen.setBrush(brush);

    painter->setPen(pen);
    painter->drawLine(mapFromScene(start), mapFromScene(finish));

    QPen pen2(QColor(200, 200, 200, 30));
    pen2.setWidth(6);
    painter->setPen(pen2);
    painter->drawLine(mapFromScene(start), mapFromScene(finish));
}
예제 #16
0
void SessionBar::paintEvent(QPaintEvent *)
{
    QPainter painter(this);

    QRect rect(1,1,width()-2,height()-2);

    painter.drawRect(rect);

    SegType mn=min();
    SegType mx=max();
    if (mx < mn)
        return;

    SegType total=mx-mn;
    double px=double(width()-5) / double(total);

    double sx,ex;
    QList<SBSeg>::iterator i;
    for (i=segments.begin();i!=segments.end();++i) {
        SBSeg & seg=*i;
        qint64 mm=seg.session->first(), MM=seg.session->last(), L=MM-mm;
        sx=double(mm - mn) * px;
        ex=double(MM - mn) * px;
        if (ex>width()-5) ex=width()-5;
        ex-=sx;

        int len=L/1000L;
        int h=len/3600;
        int m=(len/60) % 60;
        int s=len % 60;

        QString msg=QString("%1h %2m").arg((short)h,1,10,QChar('0')).arg((short)m,1,10,QChar('0'));//.arg((short)s,2,10,QChar('0'));
        //painter.setBrush(QBrush((*i).color);
        QRect segrect(3+sx,3,ex,height()-6);
        if (seg.session->enabled()) {
            QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height()/2));
            linearGrad.setSpread(QGradient::ReflectSpread);
            QColor col=seg.color;
            if (seg.highlight) col=brighten(col);
            linearGrad.setColorAt(0, col);
            linearGrad.setColorAt(1, brighten(col));
            QBrush brush(linearGrad);
            painter.fillRect(segrect,brush);
        } else {
            if (seg.highlight) {
                QColor col=QColor("#f0f0f0");
                painter.fillRect(segrect,col);
            }
            //msg="Off";
        }
        QRect rect=painter.boundingRect(segrect, Qt::AlignCenter, msg);
        if (rect.width() < segrect.width()) {
            painter.drawText(segrect,Qt::AlignCenter,msg);
        }
        painter.drawRect(segrect);

    }
}
예제 #17
0
파일: node_node.cpp 프로젝트: galek/Magus
/****************************************************************************
**
** Copyright (C) 2014
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <QMessageBox>
#include <QStyleOptionGraphicsItem>
#include <QLinearGradient>
#include <QPen>
#include <QBrush>
#include <QColor>
#include <QPainter>
#include <QPixmap>
#include "node_constants.h"
#include "node_node.h"
#include "node_port.h"
#include "node_editorwidget.h"

namespace Magus
{
    //****************************************************************************/
    QtNode::QtNode(QString title, QGraphicsItem* parent) : QGraphicsPathItem(parent)
    {
        // Header
        mZoom = 1.0f;
        mActiveConnection = 0;
        mUserData = 0;
        mPixmapItem = new QGraphicsPixmapItem(this);
        mImageSet = false;
        mAutoSize = true;
        mIconSize = mZoom * NODE_HEADER_ICON_SIZE;
        mNormalizedWidth = NODE_WIDTH;
        mNormalizedBodyHeight = NODE_BODY_HEIGHT;
        mWidth = mZoom * mNormalizedWidth;
        mHeaderHeight = mZoom * NODE_HEADER_HEIGHT;
        mBodyHeight = mZoom * mNormalizedBodyHeight;
        mPortNameColor = Qt::white;

        QLinearGradient linearGrad(0, 0, 300, NODE_HEADER_HEIGHT);
        linearGrad.setColorAt(0, QColor("#945555"));
        linearGrad.setColorAt(0.2, QColor("#3e3e3e"));
        mHeaderBrush = QBrush(linearGrad);
        setFlag(QGraphicsItem::ItemIsMovable);
        setFlag(QGraphicsItem::ItemIsSelectable);

        // Add icons to the header
        mHeaderTitleIcon = new QGraphicsPixmapItem(this); // MUST be a child of QtNode
        mAction1Icon = new QGraphicsPixmapItem(this); // MUST be a child of QtNode
        mAction2Icon = new QGraphicsPixmapItem(this); // MUST be a child of QtNode
        mHeaderTitleIcon->setScale(0.0f);
        mAction1Icon->setScale(0.0f);
        mAction2Icon->setScale(0.0f);
        mHeaderTitleIcon->setVisible(false);
        mAction1Icon->setVisible(false);
        mAction2Icon->setVisible(false);

        // Body
        mBody = new QGraphicsPathItem(this); // MUST be a child of QtNode
        QPainterPath bodyPath;
        mBody->setBrush(QColor("#3e3e3e"));
        mBody->setFlag(QGraphicsItem::ItemStacksBehindParent);

        // Generic
        setData(NODE_KEY_GRAPHIC_ITEM_TYPE, QVariant(NODE_VALUE_TYPE_NODE));
        mHeaderTitleIcon->setData(NODE_KEY_GRAPHIC_ITEM_TYPE, QVariant(NODE_VALUE_TYPE_HEADER_ICON));
        mAction1Icon->setData(NODE_KEY_GRAPHIC_ITEM_TYPE, QVariant(NODE_VALUE_TYPE_ACTION_1_ICON));
        mAction2Icon->setData(NODE_KEY_GRAPHIC_ITEM_TYPE, QVariant(NODE_VALUE_TYPE_ACTION_2_ICON));
        mBody->setData(NODE_KEY_GRAPHIC_ITEM_TYPE, QVariant(NODE_VALUE_TYPE_NODE_BODY));

        // Set title
        mTitle = title;
        mTitleLabel = new QGraphicsTextItem(this);
        mTitleLabel->setData(NODE_KEY_GRAPHIC_ITEM_TYPE, QVariant(NODE_VALUE_TYPE_HEADER_TITLE));
        mTitleLabel->setPlainText(mTitle);
        mFontHeader.setPointSize(mZoom * NODE_HEADER_TITLE_FONT_SIZE);
        mTitleLabel->setFont(mFontHeader);
        mTitleAlignment = ALIGNED_CENTER;
        adjustWidthForTitle();
    }
예제 #18
0
TextPercentDelegate::TextPercentDelegate(QObject *parent) :
		QItemDelegate(parent)
{
	QLinearGradient linearGrad(0, 0, 0, 20);
	linearGrad.setColorAt(0, Qt::white);
	linearGrad.setColorAt(1, Qt::green);

	m_qBrush = new QBrush(linearGrad);
}
예제 #19
0
void MeterSlider::resizeEvent(QResizeEvent* /*ev*/)
      {
      int h  = height();
      int kh = sliderSize().height();
      int mh  = h - kh;
      int mw = _meterWidth / _channel;

      onPm  = QPixmap(mw, mh);
      offPm = QPixmap(mw, mh);

      double range = maxValue() - minValue();
      int h1 = mh - lrint((maxValue() - redScale) * mh / range);
      int h2 = mh - lrint((maxValue() - yellowScale) * mh / range);

      QColor yellowRed;
	yellowRed.setHsv(QColor(Qt::yellow).hue()-8,
		     QColor(Qt::yellow).saturation(),
		     QColor(Qt::yellow).value());
	QColor yellRedRed;
	yellRedRed.setHsv(QColor(Qt::yellow).hue()-16,
		      QColor(Qt::yellow).saturation(),
		      QColor(Qt::yellow).value());

	QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, mh));
	linearGrad.setColorAt(0, Qt::red);
	linearGrad.setColorAt(1-(double)(h1-5)/(double)mh, yellRedRed);
	linearGrad.setColorAt(1-(double)(h1-6)/(double)mh, yellowRed);
	linearGrad.setColorAt(1-(double)h2/(double)mh, Qt::yellow);
	linearGrad.setColorAt(1, Qt::green);

	QColor darkYellowRed;
	darkYellowRed.setHsv(QColor(Qt::darkYellow).hue()-8,
			 QColor(Qt::darkYellow).saturation(),
			 QColor(Qt::darkYellow).value());
	QColor darkYellRedRed;
	darkYellRedRed.setHsv(QColor(Qt::darkYellow).hue()-16,
			  QColor(Qt::darkYellow).saturation(),
			  QColor(Qt::darkYellow).value());
	QLinearGradient linearDarkGrad(QPointF(0, 0), QPointF(0, mh));
	linearDarkGrad.setColorAt(0, Qt::darkRed);
	linearDarkGrad.setColorAt(1-(double)(h1-5)/(double)mh, darkYellRedRed);
	linearDarkGrad.setColorAt(1-(double)(h1-6)/(double)mh, darkYellowRed);
	linearDarkGrad.setColorAt(1-(double)h2/(double)mh, Qt::darkYellow);
	linearDarkGrad.setColorAt(1, Qt::darkGreen);

      QPainter p;
      p.begin(&onPm);
      p.fillRect(0, 0, mw, mh, linearGrad);
      p.end();
      p.begin(&offPm);
	p.fillRect(0, 0, mw, mh, linearDarkGrad);
      p.end();
      }
void vktraceviewer_QTimelineItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    vktrace_trace_packet_header* pHeader = (vktrace_trace_packet_header*)index.internalPointer();

    if (pHeader->entrypoint_end_time <= pHeader->entrypoint_begin_time)
    {
        return;
    }

    painter->save();
    {
        vktraceviewer_QTimelineView* pTimeline = (vktraceviewer_QTimelineView*)parent();
        if (pTimeline != NULL)
        {
            QRectF rect = option.rect;

            if (rect.width() == 0)
            {
                rect.setWidth(1);
            }

            float duration = u64ToFloat(pHeader->entrypoint_end_time - pHeader->entrypoint_begin_time);
            float durationRatio = duration / pTimeline->getMaxItemDuration();
            int intensity = std::min(255, (int)(durationRatio * 255.0f));
            QColor color(intensity, 255-intensity, 0);

            // add gradient to the items better distinguish between the end of one and beginning of the next
            QLinearGradient linearGrad(rect.center(), rect.bottomRight());
            linearGrad.setColorAt(0, color);
            linearGrad.setColorAt(1, color.darker(150));

            painter->setBrush(linearGrad);
            painter->setPen(Qt::NoPen);

            painter->drawRect(rect);

            if (rect.width() >= 2)
            {
                // draw shadow and highlight around the item
                painter->setPen(color.darker(175));
                painter->drawLine(rect.right()-1, rect.top(), rect.right()-1, rect.bottom()-1);
                painter->drawLine(rect.right()-1, rect.bottom()-1, rect.left(), rect.bottom()-1);

                painter->setPen(color.lighter());
                painter->drawLine(rect.left(), rect.bottom()-1, rect.left(), rect.top());
                painter->drawLine(rect.left(), rect.top(), rect.right()-1, rect.top());
            }
        }
    }

    painter->restore();
}
예제 #21
0
void OSItem::paintEvent(QPaintEvent * event)
{
  QPainter p(this);

  if( m_type == LIST_ITEM )
  {
    if( m_selected )
    {
      QLinearGradient linearGrad(QPointF(0,0), QPointF(0,rect().height()));
      linearGrad.setColorAt(0, QColor(113,153,200,255));
      linearGrad.setColorAt(0.10, QColor(113,153,200,150));
      linearGrad.setColorAt(0.15, QColor(210,222,236,150));
      linearGrad.setColorAt(1.00, QColor(210,222,236,150));

      QBrush brush(linearGrad);
      p.setBrush(brush);
      p.setPen(Qt::NoPen);

      p.drawRect(0,0,rect().width(),rect().height() - 1);
    }

    p.setPen(QPen(Qt::black));
    p.drawLine(0,rect().height() - 1,rect().width(),rect().height() - 1);
  }
  else if( m_type == LIBRARY_ITEM )
  {
    QPen pen(QColor(128,128,128));
    pen.setStyle(Qt::SolidLine);
    pen.setWidth(1);
    p.setPen(pen);
    p.setBrush(QColor(206,206,206));
    p.drawRoundedRect(5,4,rect().width() - 10,rect().height() - 10,10,10);
  }
  else if( m_type == DROPZONE_SQUARE || m_type == DROPZONE_RECTANGLE )
  {
    QPen pen(QColor(128,128,128));
    pen.setStyle(Qt::SolidLine);
    pen.setWidth(1);
    p.setPen(pen);
    p.setBrush(QColor(206,206,206));
    p.drawRoundedRect(0,0,rect().width() - 1,rect().height() - 1,10,10);
  }

  if( m_useLargeIcon )
  {
    QRect _rect = rect();
    QRect newRect(_rect.x() + 7,_rect.y() + 7,_rect.width() - 14,_rect.height() - 14);

    p.drawPixmap(newRect,m_largePixmap);  
  }
}
예제 #22
0
파일: OSItem.cpp 프로젝트: NREL/OpenStudio
void OSItem::paintEvent(QPaintEvent * event)
{
  QPainter p(this);

  if( m_osItemType == OSItemType::ListItem )
  {
    if( m_selected )
    {
      QLinearGradient linearGrad(QPointF(0,0), QPointF(0,rect().height()));
      linearGrad.setColorAt(0, QColor(113,153,200,255));
      linearGrad.setColorAt(0.10, QColor(113,153,200,150));
      linearGrad.setColorAt(0.15, QColor(210,222,236,150));
      linearGrad.setColorAt(1.00, QColor(210,222,236,150));

      QBrush brush(linearGrad);
      p.setBrush(brush);
      p.setPen(Qt::NoPen);

      p.drawRect(0,0,rect().width(),rect().height() - 1);
    }

    p.setPen(QPen(Qt::black));
    p.drawLine(0,rect().height() - 1,rect().width(),rect().height() - 1);
  }
  else if( m_osItemType == OSItemType::LibraryItem )
  {
    QPen pen(QColor(128,128,128));
    pen.setStyle(Qt::SolidLine);
    pen.setWidth(1);
    p.setPen(pen);
    p.setBrush(QColor(206,206,206));
    p.drawRoundedRect(5,4,rect().width() - 10,rect().height() - 10,10,10);
  }
  else if( m_osItemType == OSItemType::DropzoneSquare || m_osItemType == OSItemType::DropzoneRectangle )
  {
    QPen pen(QColor(128,128,128));
    pen.setStyle(Qt::SolidLine);
    pen.setWidth(1);
    p.setPen(pen);
    p.setBrush(QColor(206,206,206));
    p.drawRoundedRect(0,0,rect().width() - 1,rect().height() - 1,10,10);
  }

  if( m_useLargeIcon )
  {
    QRect _rect = rect();
    QRect newRect(_rect.x() + 7,_rect.y() + 7,_rect.width() - 14,_rect.height() - 14);

    p.drawPixmap(newRect,m_largePixmap);
  }
}
예제 #23
0
void Layer::paintSelection(QPainter& painter, int x, int y, int width, int height)
{
    QLinearGradient linearGrad(QPointF(0, y), QPointF(0, y + height));
    QSettings settings("Pencil","Pencil");
    QString style = settings.value("style").toString();
    if (style == "aqua")
    {
        linearGrad.setColorAt(0, QColor(225,225,255,100) );
        linearGrad.setColorAt(0.10, QColor(225,225,255,80) );
        linearGrad.setColorAt(0.20, QColor(225,225,255,64) );
        linearGrad.setColorAt(0.35, QColor(225,225,255,20) );
        linearGrad.setColorAt(0.351, QColor(0,0,0,32) );
        linearGrad.setColorAt(0.66, QColor(245,255,235,32) );
        linearGrad.setColorAt(1, QColor(245,255,235,128) );
    }
    else
    {
        linearGrad.setColorAt(0, QColor(255,255,255,128) );
        linearGrad.setColorAt(0.49, QColor(255,255,255,0) );
        linearGrad.setColorAt(0.50, QColor(0,0,0,0) );
        linearGrad.setColorAt(1, QColor(0,0,0,48) );

        /*linearGrad.setColorAt(0, QColor(255,255,255,128) );
        linearGrad.setColorAt(0.10, QColor(255,255,255,64) );
        linearGrad.setColorAt(0.49, QColor(0,0,0,32) );
        linearGrad.setColorAt(0.50, QColor(0,0,0,32) );
        linearGrad.setColorAt(0.70, QColor(245,255,245,32) );
        linearGrad.setColorAt(1, QColor(245,255,245,128) );*/

        /*linearGrad.setColorAt(0, QColor(255,255,255,128) );
        linearGrad.setColorAt(0.10, QColor(255,255,255,64) );
        linearGrad.setColorAt(0.20, QColor(0,0,0,32) );
        linearGrad.setColorAt(0.40, QColor(0,0,0,0) );
        linearGrad.setColorAt(0.41, QColor(255,255,255,0) );
        linearGrad.setColorAt(1, QColor(255,255,255,128) );*/
    }
    painter.setBrush( linearGrad );
    painter.setPen( Qt::NoPen );
    painter.drawRect(x, y, width, height-1);
    //painter.setBrush( Qt::NoBrush );
    //painter.setPen(QPen(QBrush(QColor(0,0,0,100)), 1, Qt::SolidLine, Qt::RoundCap,Qt::RoundJoin));
    //painter.drawRect(x, y-1, width, height);
    /*if (style == "aqua") {
    	QColor col;
    	if (type == BITMAP) col = QColor(65,65,122);
    	if (type == VECTOR) col = QColor(50,102,75);
    	if (type == SOUND) col = QColor(122,65,65);
    	painter.setPen(col);
    	painter.drawLine(x,y-1, x+width, y-1);
    }*/
}
void QMeter::drawCoverGlass(QPainter *painter)
{
    painter->save();
    QLinearGradient linearGrad(QPointF(-15, -45), QPointF(90, 75));
    linearGrad.setColorAt(0, QColor(255,255,255,30));
    linearGrad.setColorAt(0.3, QColor(120,120,120,20));
    QBrush brush=QBrush(linearGrad);
    QPen pen;
    pen = QColor(0,0,0,0);
    pen.setBrush(brush);
    pen.setWidth(0);
    painter->setPen(pen);
    painter->setBrush(brush);
    painter->drawEllipse(-45,-45,90,90);
    painter->restore();
}
예제 #25
0
파일: hwmap.cpp 프로젝트: GhostAlgorithm/hw
void HWMap::onClientDisconnect()
{    
    QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128));
    linearGrad.setColorAt(1, QColor(0, 0, 192));
    linearGrad.setColorAt(0, QColor(66, 115, 225));

    if (readbuffer.size() == 128 * 32 + 1)
    {
        quint8 *buf = (quint8*) readbuffer.constData();
        QImage im(buf, 256, 128, QImage::Format_Mono);
        im.setNumColors(2);

        QPixmap px(QSize(256, 128));
        QPixmap pxres(px.size());
        QPainter p(&pxres);

        px.fill(Qt::yellow);
        QBitmap bm = QBitmap::fromImage(im);
        px.setMask(bm);

        p.fillRect(pxres.rect(), linearGrad);
        p.drawPixmap(0, 0, px);

        emit HHLimitReceived(buf[128 * 32]);
        emit ImageReceived(px);
    } else if (readbuffer.size() == 128 * 256 + 1)
    {
        QVector<QRgb> colorTable;
        colorTable.resize(256);
        for(int i = 0; i < 256; ++i)
            colorTable[i] = qRgba(255, 255, 0, i);

        const quint8 *buf = (const quint8*) readbuffer.constData();
        QImage im(buf, 256, 128, QImage::Format_Indexed8);
        im.setColorTable(colorTable);

        QPixmap px = QPixmap::fromImage(im, Qt::ColorOnly);
        QPixmap pxres(px.size());
        QPainter p(&pxres);

        p.fillRect(pxres.rect(), linearGrad);
        p.drawPixmap(0, 0, px);

        emit HHLimitReceived(buf[128 * 256]);
        emit ImageReceived(px);
    }
}
예제 #26
0
void Lighting::setupScene()
{
    m_scene.setSceneRect(-300, -200, 600, 460);

    QLinearGradient linearGrad(QPointF(-100, -100), QPointF(100, 100));
    linearGrad.setColorAt(0, QColor(255, 255, 255));
    linearGrad.setColorAt(1, QColor(192, 192, 255));
    setBackgroundBrush(linearGrad);

    QRadialGradient radialGrad(30, 30, 30);
    radialGrad.setColorAt(0, Qt::yellow);
    radialGrad.setColorAt(0.2, Qt::yellow);
    radialGrad.setColorAt(1, Qt::transparent);

    QPixmap pixmap(60, 60);
    pixmap.fill(Qt::transparent);

    QPainter painter(&pixmap);
    painter.setPen(Qt::NoPen);
    painter.setBrush(radialGrad);
    painter.drawEllipse(0, 0, 60, 60);
    painter.end();

    m_lightSource = m_scene.addPixmap(pixmap);
    m_lightSource->setZValue(2);

    for (int i = -2; i < 3; ++i)
        for (int j = -2; j < 3; ++j) {
            QAbstractGraphicsShapeItem *item;
            if ((i + j) & 1)
                item = new QGraphicsEllipseItem(0, 0, 50, 50);
            else
                item = new QGraphicsRectItem(0, 0, 50, 50);

            item->setPen(QPen(Qt::black, 1));
            item->setBrush(QBrush(Qt::white));
            QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect;
            effect->setBlurRadius(8);
            item->setGraphicsEffect(effect);
            item->setZValue(1);
            item->setPos(i * 80, j * 80);
            m_scene.addItem(item);
            m_items << item;
        }


}
예제 #27
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 QMeter::drawCrown(QPainter *painter)
{

    painter->save();
    QRectF rectangle(-47, -47, 94, 94);
    int startAngle = 30 * 16;
    int spanAngle = 390 * 16;
    QLinearGradient linearGrad(QPointF(-47, -47), QPointF(94, 94));
    linearGrad.setColorAt(0, Qt::white);
    linearGrad.setColorAt(0.3, QColor(60,60,60,250));
    QPen pen;
    QBrush brush=QBrush(linearGrad);
    pen.setBrush(brush);
    pen.setWidth(3);
    painter->setPen(pen);
    painter->drawArc(rectangle, startAngle, spanAngle);
    painter->restore();
}
예제 #29
0
int main()
{
    QWidget anyPaintDevice;
    {
        // PEN SNIPPET
        QPainter painter;
        QPen pen(Qt::red, 2);                 // red solid line, 2 pixels wide
        painter.begin(&anyPaintDevice);   // paint something
        painter.setPen(pen);              // set the red, wide pen
        painter.drawRect(40,30, 200,100); // draw a rectangle
        painter.setPen(Qt::blue);             // set blue pen, 0 pixel width
        painter.drawLine(40,30, 240,130); // draw a diagonal in rectangle
        painter.end();                    // painting done
    }

    {
        // BRUSH SNIPPET
        QPainter painter;
        QBrush brush(Qt::yellow);           // yellow solid pattern
        painter.begin(&anyPaintDevice);   // paint something
        painter.setBrush(brush);          // set the yellow brush
        painter.setPen(Qt::NoPen);        // do not draw outline
        painter.drawRect(40,30, 200,100); // draw filled rectangle
        painter.setBrush(Qt::NoBrush);    // do not fill
        painter.setPen(Qt::black);            // set black pen, 0 pixel width
        painter.drawRect(10,10, 30,20);   // draw rectangle outline
        painter.end();                    // painting done
    }

    // LINEAR
//! [0]
    QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
    linearGrad.setColorAt(0, Qt::black);
    linearGrad.setColorAt(1, Qt::white);
//! [0]

    // RADIAL
//! [1]
    QRadialGradient radialGrad(QPointF(100, 100), 100);
    radialGrad.setColorAt(0, Qt::red);
    radialGrad.setColorAt(0.5, Qt::blue);
    radialGrad.setColorAt(1, Qt::green);
//! [1]
}
void QMeter::drawNeedle(QPainter *painter)
{
    // hat shadow
//    painter->setPen(Qt::NoPen);
//    painter->setBrush(QColor(120,120,120,10));
//    painter->drawEllipse(-5, -6, 14, 14);
    // end hat shadow

	painter->save();

	painter->rotate(-90.0); 
	QPolygon pts;
    pts.setPoints( 3, -2,0,  2,0,  0,30 );
    QPolygon shadow;
    shadow.setPoints(3, -1,0, 1,0, 0,29);
	int degRotate=0;

    degRotate = (int)( m_startAngle+(m_endAngle-m_startAngle)/(m_maxValue-m_minValue)*(m_value-m_minValue) );	 
	 
	painter->rotate( -degRotate );
    QRadialGradient haloGradient(0, 0, 20, 0, 0);
    haloGradient.setColorAt(0.0, QColor(255,120,120));
    haloGradient.setColorAt(1.0, QColor(200,20,20));
    QColor color=QColor(Qt::darkRed);
    color.setAlpha(90);
    painter->setPen(color);
	painter->setBrush(haloGradient);
	painter->drawConvexPolygon( pts );

    painter->setBrush(QColor(255,120,120));
    painter->drawConvexPolygon( shadow );

	painter->restore();
	
    // draw needle hat
    QLinearGradient linearGrad(QPointF(-7, -7), QPointF(14, 14));
    linearGrad.setColorAt(0, Qt::white);
    linearGrad.setColorAt(1, Qt::black);
    painter->setPen(Qt::NoPen);
    painter->setBrush(linearGrad);
    painter->drawEllipse(-7, -7, 14, 14);

}