예제 #1
0
/*!
  Draw a needle looking like an arrow

  \param painter Painter
  \param palette Palette
  \param colorGroup Color group
  \param center center of the needle
  \param length Length of the needle
  \param width Width of the needle
  \param direction Current Direction
  \param hasKnob With/Without knob
*/
void QwtDialSimpleNeedle::drawArrowNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    const QPoint &center, int length, int width,
    double direction, bool hasKnob )
{
    direction *= M_PI / 180.0;

    painter->save();

    if ( width <= 0 )
    {
        width = ( int )qMax( length * 0.06, 9.0 );
        if ( width % 2 == 0 )
            width++;
    }

    const int peak = 3;
    const QPoint p1( center.x() + 1, center.y() + 1 );
    const QPoint p2 = qwtPolar2Pos( p1, length - peak, direction );
    const QPoint p3 = qwtPolar2Pos( p1, length, direction );

    QPolygon pa( 5 );
    pa.setPoint( 0, qwtPolar2Pos( p1, width / 2, direction - M_PI_2 ) );
    pa.setPoint( 1, qwtPolar2Pos( p2, 1, direction - M_PI_2 ) );
    pa.setPoint( 2, p3 );
    pa.setPoint( 3, qwtPolar2Pos( p2, 1, direction + M_PI_2 ) );
    pa.setPoint( 4, qwtPolar2Pos( p1, width / 2, direction + M_PI_2 ) );

    painter->setPen( Qt::NoPen );
    painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) );
    painter->drawPolygon( pa );

    QPolygon shadowPa( 3 );

    const int colorOffset = 10;

    int i;
    for ( i = 0; i < 3; i++ )
        shadowPa.setPoint( i, pa[i] );

    const QColor midColor = palette.color( colorGroup, QPalette::Mid );

    painter->setPen( midColor.dark( 100 + colorOffset ) );
    painter->drawPolyline( shadowPa );

    for ( i = 0; i < 3; i++ )
        shadowPa.setPoint( i, pa[i + 2] );

    painter->setPen( midColor.dark( 100 - colorOffset ) );
    painter->drawPolyline( shadowPa );

    if ( hasKnob )
    {
        drawKnob( painter, center, qRound( width * 1.3 ),
            palette.brush( colorGroup, QPalette::Base ),
            false );
    }

    painter->restore();
}
예제 #2
0
QPalette CockpitGrid::colorTheme(const QColor &base) const
{
    const QColor background = base.dark(150);
    const QColor foreground = base.dark(200);

    const QColor mid = base.dark(110);
    const QColor dark = base.dark(170);
    const QColor light = base.light(170);
    const QColor text = foreground.light(800);

    QPalette palette;
    for ( int i = 0; i < QPalette::NColorGroups; i++ )
    {
        QPalette::ColorGroup cg = (QPalette::ColorGroup)i;

        palette.setColor(cg, QPalette::Base, base);
        palette.setColor(cg, QPalette::Window, background);
        palette.setColor(cg, QPalette::Mid, mid);
        palette.setColor(cg, QPalette::Light, light);
        palette.setColor(cg, QPalette::Dark, dark);
        palette.setColor(cg, QPalette::Text, text);
        palette.setColor(cg, QPalette::WindowText, foreground);
    }

    return palette;
}
예제 #3
0
/*!
    Draw the needle

    \param painter Painter
    \param length Length of the needle
    \param colorGroup Color group, used for painting
*/
void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter, 
    double length, QPalette::ColorGroup colorGroup ) const
{
    if ( d_style == ThinStyle )
    {
        const double width = qMax( length / 6.0, 3.0 );

        const int colorOffset = 10;

        const QColor light = palette().color( colorGroup, QPalette::Light );
        const QColor dark = palette().color( colorGroup, QPalette::Dark );

        qwtDrawShadedPointer( painter,
            dark.light( 100 + colorOffset ),
            dark.dark( 100 + colorOffset ),
            length, width );
        
        painter->rotate( 180.0 );
    
        qwtDrawShadedPointer( painter,
            light.light( 100 + colorOffset ),
            light.dark( 100 + colorOffset ),
            length, width );
        
        const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base );
        drawKnob( painter, width, baseBrush, true );
    }
    else
    {
        qwtDrawTriangleNeedle( painter, palette(), colorGroup, length );
    }
}
예제 #4
0
파일: krdb.cpp 프로젝트: KDE/kde-workspace
static void applyQtColors( KSharedConfigPtr kglobalcfg, QSettings& settings, QPalette& newPal )
{
  QStringList actcg, inactcg, discg;
  /* export kde color settings */
  int i;
  for (i = 0; i < QPalette::NColorRoles; i++)
     actcg   << newPal.color(QPalette::Active,
                (QPalette::ColorRole) i).name();
  for (i = 0; i < QPalette::NColorRoles; i++)
     inactcg << newPal.color(QPalette::Inactive,
                (QPalette::ColorRole) i).name();
  for (i = 0; i < QPalette::NColorRoles; i++)
     discg   << newPal.color(QPalette::Disabled,
                (QPalette::ColorRole) i).name();

  settings.setValue("/qt/Palette/active", actcg);
  settings.setValue("/qt/Palette/inactive", inactcg);
  settings.setValue("/qt/Palette/disabled", discg);

  // export kwin's colors to qtrc for kstyle to use
  KConfigGroup wmCfgGroup(kglobalcfg, "WM");

  // active colors
  QColor clr = newPal.color( QPalette::Active, QPalette::Background );
  clr = wmCfgGroup.readEntry("activeBackground", clr);
  settings.setValue("/qt/KWinPalette/activeBackground", clr.name());
  if (QPixmap::defaultDepth() > 8)
    clr = clr.dark(110);
  clr = wmCfgGroup.readEntry("activeBlend", clr);
  settings.setValue("/qt/KWinPalette/activeBlend", clr.name());
  clr = newPal.color( QPalette::Active, QPalette::HighlightedText );
  clr = wmCfgGroup.readEntry("activeForeground", clr);
  settings.setValue("/qt/KWinPalette/activeForeground", clr.name());
  clr = newPal.color( QPalette::Active,QPalette::Background );
  clr = wmCfgGroup.readEntry("frame", clr);
  settings.setValue("/qt/KWinPalette/frame", clr.name());
  clr = wmCfgGroup.readEntry("activeTitleBtnBg", clr);
  settings.setValue("/qt/KWinPalette/activeTitleBtnBg", clr.name());

  // inactive colors
  clr = newPal.color(QPalette::Inactive, QPalette::Background);
  clr = wmCfgGroup.readEntry("inactiveBackground", clr);
  settings.setValue("/qt/KWinPalette/inactiveBackground", clr.name());
  if (QPixmap::defaultDepth() > 8)
    clr = clr.dark(110);
  clr = wmCfgGroup.readEntry("inactiveBlend", clr);
  settings.setValue("/qt/KWinPalette/inactiveBlend", clr.name());
  clr = newPal.color(QPalette::Inactive, QPalette::Background).dark();
  clr = wmCfgGroup.readEntry("inactiveForeground", clr);
  settings.setValue("/qt/KWinPalette/inactiveForeground", clr.name());
  clr = newPal.color(QPalette::Inactive, QPalette::Background);
  clr = wmCfgGroup.readEntry("inactiveFrame", clr);
  settings.setValue("/qt/KWinPalette/inactiveFrame", clr.name());
  clr = wmCfgGroup.readEntry("inactiveTitleBtnBg", clr);
  settings.setValue("/qt/KWinPalette/inactiveTitleBtnBg", clr.name());

  KConfigGroup kdeCfgGroup(kglobalcfg, "KDE");
  settings.setValue("/qt/KDE/contrast", kdeCfgGroup.readEntry("contrast", 7));
}
예제 #5
0
static QGradient gradient(const QColor &color, const QRect &rect)
{
    QColor c = color;
    c.setAlpha(160);
    QLinearGradient result(rect.topLeft(), rect.bottomRight());
    result.setColorAt(0, c.dark(150));
    result.setColorAt(0.5, c.light(200));
    result.setColorAt(1, c.dark(150));
    return result;
}
예제 #6
0
QPalette CockpitGrid::colorTheme( const QColor &base ) const
{
    QPalette palette;
    palette.setColor( QPalette::Base, base );
    palette.setColor( QPalette::Window, base.dark( 150 ) );
    palette.setColor( QPalette::Mid, base.dark( 110 ) );
    palette.setColor( QPalette::Light, base.light( 170 ) );
    palette.setColor( QPalette::Dark, base.dark( 170 ) );
    palette.setColor( QPalette::Text, base.dark( 200 ).light( 800 ) );
    palette.setColor( QPalette::WindowText, base.dark( 200 ) );

    return palette;
}
예제 #7
0
void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const
{
    QColor highlight = qxt_p().palette().color(QPalette::Highlight);
    QLinearGradient gradient(x1, y1, x2, y2);
    gradient.setColorAt(0, highlight.dark(120));
    gradient.setColorAt(1, highlight.light(108));
    painter->setBrush(gradient);

    if (orientation == Qt::Horizontal)
        painter->setPen(QPen(highlight.dark(130), 0));
    else
        painter->setPen(QPen(highlight.dark(150), 0));
}
void CSliderMultiPos::setupPainter(QPainter* painter,QPointF point1,QPointF point2,QColor color){

    QLinearGradient gradient(point1,point2);
    gradient.setColorAt(0, color.dark(120));
    gradient.setColorAt(1, color.light(108));
    painter->setBrush(gradient);

    if( this->orientation()==Qt::Horizontal) {
        painter->setPen(QPen(color.dark(130), 0));
    }
    else{
        painter->setPen(QPen(color.dark(150), 0));
    }
}
예제 #9
0
파일: tracing.cpp 프로젝트: goodwinos/pcp
void
TracingItem::setStroke(Chart::Style, QColor color, bool)
{
    const QColor black(Qt::black);
    const QPen outline(black);
    QColor alphaColor(color);
    QColor darkColor;

    darkColor = color.darker(180);
    alphaColor.setAlpha(196);
    QBrush alphaBrush(alphaColor);

    my.pointCurve->setLegendColor(color);

    my.spanSymbol->setWidth(6);
    my.spanSymbol->setBrush(alphaBrush);
    my.spanSymbol->setPen(outline);

    my.dropSymbol->setWidth(1);
    my.dropSymbol->setBrush(Qt::NoBrush);
    my.dropSymbol->setPen(outline);

    my.pointSymbol->setSize(8);
    my.pointSymbol->setColor(color);
    my.pointSymbol->setPen(outline);

    my.selectionSymbol->setSize(8);
    my.selectionSymbol->setColor(color.dark(180));
    my.selectionSymbol->setPen(outline);
}
예제 #10
0
파일: Headers.cpp 프로젝트: KDE/koffice
void KCSelectAllButton::paintEvent(QPaintEvent* event)
{
    // the painter
    QPainter painter(this);
    painter.setClipRect(event->rect());

    // if all cells are selected
    if (m_selection->isAllSelected() &&
            !m_selection->referenceSelectionMode() && m_cellToolIsActive) {
        // selection brush/color
        QColor selectionColor(palette().highlight().color());
        selectionColor.setAlpha(127);
        const QBrush selectionBrush(selectionColor);

        painter.setPen(selectionColor.dark(150));
        painter.setBrush(selectionBrush);
    } else {
        // background brush/color
        const QBrush backgroundBrush(palette().window());
        const QColor backgroundColor(backgroundBrush.color());

        painter.setPen(backgroundColor.dark(150));
        painter.setBrush(backgroundBrush);
    }
    painter.drawRect(rect().adjusted(0, 0, -1, -1));
}
예제 #11
0
void SpreadSheet::updateColor(QTableWidgetItem *item)
{
    QPixmap pix(16, 16);
    QColor col;
    if (item)
        col = item->backgroundColor();
    if (!col.isValid())
        col = palette().base().color();

    QPainter pt(&pix);
    pt.fillRect(0, 0, 16, 16, col);

    QColor lighter = col.light();
    pt.setPen(lighter);
    QPoint lightFrame[] = { QPoint(0, 15), QPoint(0, 0), QPoint(15, 0) };
    pt.drawPolyline(lightFrame, 3);

    pt.setPen(col.dark());
    QPoint darkFrame[] = { QPoint(1, 15), QPoint(15, 15), QPoint(15, 1) };
    pt.drawPolyline(darkFrame, 3);

    pt.end();

    colorAction->setIcon(pix);
}
예제 #12
0
void DominoConfig::loadButtonContourColors() {
	
	QColor background = vBox->paletteBackgroundColor();
	if(useDominoStyleContourColors->isChecked()) {
		QSettings s;
		buttonContourColor->setColor(s.readEntry("/domino/Settings/buttonContourColor", background.dark(250).name()));
		buttonMouseOverContourColor->setColor(s.readEntry("/domino/Settings/buttonMouseOverContourColor", background.dark(250).name()));
		buttonPressedContourColor->setColor(s.readEntry("/domino/Settings/buttonPressedContourColor", background.dark(250).name()));
	}
	else {
		buttonContourColor->setColor(conf->readEntry("buttonContourColor", background.dark(250).name()));
		buttonMouseOverContourColor->setColor(conf->readEntry("buttonMouseOverContourColor", background.dark(250).name()));
		buttonPressedContourColor->setColor(conf->readEntry("buttonPressedContourColor", background.dark(250).name()));
	}
	
}
예제 #13
0
파일: button.cpp 프로젝트: Balex93/telldus
void Button::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {

	if (d->buttonFace) {
		painter->setPen(Qt::NoPen);
		painter->setBrush(QColor(0, 0, 0, 64));
		painter->drawRoundRect(rect().translated(2, 2));

		QLinearGradient gradient(rect().topLeft(), rect().bottomRight());
		const QColor col = d->brush.color();
		gradient.setColorAt(0, col);
		gradient.setColorAt(1, col.dark(200));
		painter->setBrush(gradient);
		painter->setPen(QPen(Qt::black, 1));
		painter->drawRoundRect(rect());

		int flags = Qt::AlignBottom | Qt::AlignLeft | Qt::TextWordWrap;
		QFont font;
		font.setPixelSize(7);
		painter->setFont(font);
		painter->setBrush(Qt::black);
		painter->setPen(Qt::black);
		painter->drawText( rect().adjusted( 10, 10, -10, -10 ), flags, d->text);
	} else {
		painter->setPen(Qt::NoPen);
		painter->setBrush(QColor(0, 0, 0, 128));
		painter->drawRoundRect(rect());
	}

}
예제 #14
0
void SelectAllButton::paint(QPainter* painter, const QRectF& painterRect)
{
    // the painter
    painter->setClipRect(painterRect);

    // if all cells are selected
    if (m_canvasBase->selection()->isAllSelected() &&
            !m_canvasBase->selection()->referenceSelectionMode() && m_cellToolIsActive) {
        // selection brush/color
        QColor selectionColor(palette().highlight().color());
        selectionColor.setAlpha(127);
        const QBrush selectionBrush(selectionColor);

        painter->setPen(selectionColor.dark(150));
        painter->setBrush(selectionBrush);
    } else {
        // background brush/color
        const QBrush backgroundBrush(palette().window());
        const QColor backgroundColor(backgroundBrush.color());

        painter->setPen(backgroundColor.dark(150));
        painter->setBrush(backgroundBrush);
    }
    painter->drawRect(painterRect.adjusted(0, 0, -1, -1));
}
예제 #15
0
QPixmap colorPixmap(int w, int h, QColor c)
{
  static QPixmap* pixs[37];
  static QColor cols[37];
  static bool inited = false;

  if (!inited) {
    for (int i=0;i<37;i++) pixs[i]=0;
    inited = true;
  }
  int hash = (w+h+c.red()+c.green()+c.blue()) % 37;
  if (pixs[hash]) {
    if ((pixs[hash]->width() == w) &&
        (pixs[hash]->height() == h) &&
        (cols[hash] == c))
      return *pixs[hash];

    delete pixs[hash];
  }


  QPixmap* pix = new QPixmap(w, h);
  pix->fill(c);
  QPainter p(pix);
  p.setPen(c.light());
  p.drawLine(0, 0, w-1, 0);
  p.drawLine(0, 0, 0, h-1);
  p.setPen(c.dark());
  p.drawLine(w-1, 0, w-1, h-1);
  p.drawLine(0, h-1, w-1, h-1);

  pixs[hash] = pix;
  cols[hash] = c;
  return *pix;
}
예제 #16
0
void
ResizeCorner::setColor(const QColor &c)
{
    QColor bgc = (c.value() > 100) ? c.dark(130) : c.light(120);
    QPalette pal = palette();
    pal.setColor(backgroundRole(), bgc);
    setPalette(pal);
}
예제 #17
0
void Plot::resizeEvent(QResizeEvent *event)
{
    d_directPainter->reset();
    QwtPlot::resizeEvent(event);

    const QColor color(46, 74, 95);
    const QRect cr = canvas()->contentsRect();
    QLinearGradient gradient(cr.topLeft(), cr.topRight());
    gradient.setColorAt(0.0, color.light(130));
    gradient.setColorAt(0.2, color.dark(110));
    gradient.setColorAt(0.7, color);
    gradient.setColorAt(1.0, color.dark(150));

    QPalette pal = canvas()->palette();
    pal.setBrush(QPalette::Window, QBrush(gradient));
    canvas()->setPalette(pal);
}
예제 #18
0
void KoContextBarButton::paintEvent(QPaintEvent*)
{
    QStylePainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    QStyleOptionToolButton opt;
    initStyleOption(&opt);

    const QColor bgColor = palette().color(QPalette::Highlight);
    QColor color = bgColor.dark(CONTEXTBAR_BACKGROUND_DARKNESS);
    QColor borderColor = bgColor.light(CONTEXTBAR_BORDER_LIGHTNESS);

    if (opt.state & QStyle::State_MouseOver && opt.state & QStyle::State_Enabled) {
            color = color.light(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
            borderColor = borderColor.lighter(CONTEXTBAR_MOUSEOVER_LIGHTNESS);
    }

    const QRectF rectF = QRectF(opt.rect).adjusted(0.5, 0.5, -0.5, -0.5);
    QPainterPath path;
    path.addRoundRect(rectF, CONTEXTBAR_RADIUS, CONTEXTBAR_RADIUS);

    if (m_fadingValue < 255) {
        color.setAlpha(m_fadingValue);
    }

    // Background
    painter.fillPath(path, color);

    if (opt.state & QStyle::State_Raised && opt.state & QStyle::State_Enabled) {
        // Bottom shadow
        QLinearGradient gradient(rectF.bottomLeft(), rectF.bottomLeft() - QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.bottomLeft() + QPoint(3, 0));
        painter.fillPath(path, gradient);
    }
    else {
        // Top shadow
        QLinearGradient gradient(rectF.topLeft(), rectF.topLeft() + QPoint(0, 5));
        gradient.setColorAt(0, QColor::fromHsvF(0, 0, 0, .3));
        gradient.setColorAt(1, Qt::transparent);
        painter.fillPath(path, gradient);

        // Left shadow
        gradient.setFinalStop(rectF.topLeft() + QPoint(5, 0));
        painter.fillPath(path, gradient);
    }

    // Border
    painter.setPen(QPen(borderColor, 0));
    painter.drawPath(path);

    // Content
    painter.drawControl(QStyle::CE_ToolButtonLabel, opt);
}
예제 #19
0
void KColorCombo2::drawColorRect(QPainter &painter, int x, int y, const QColor &color, bool isDefault, int width, int height)
{
	// Fill:
	if (color.isValid())
		painter.fillRect(x /*+ 1*/, y /*+ 1*/, width /*- 2*/, height /*- 2*/, color);
	else {
		// If it's an invalid color, it's for the "Other..." entry: draw a rainbow.
		// If it wasn't for the "Other..." entry, the programmer made a fault, so (s)he will be informed about that visually.
		for (int i = 0; i < width-2; ++i) {
			int hue = i * 360 / (width-2);
			for (int j = 0; j < height-2; ++j) {
				int saturation = 255 - (j * 255 / (height-2));
				painter.setPen( QColor(hue, saturation, /*value=*/255, QColor::Hsv) );
				painter.drawPoint(x + i + 1, y + j + 1);
			}
		}
	}

	// Stroke:
	int dontCare, value;
	color.getHsv(/*hue:*/dontCare, /*saturation:*/dontCare, value);
	QColor stroke = (color.isValid() ? color.dark(125) : palette().color(QPalette::Text));
	painter.setPen(/*color);//*/stroke);
	painter.drawLine(x + 1,         y,              x + width - 2, y);
	painter.drawLine(x,             y + 1,          x,             y + height - 2);
	painter.drawLine(x + 1,         y + height - 1, x + width - 2, y + height - 1);
	painter.drawLine(x + width - 1, y + 1,          x + width - 1, y + height - 2);

	// Round corners:
	QColor antialiasing;
	if (color.isValid()) {
		antialiasing = Tool_mixColors(color, stroke);
		painter.setPen(antialiasing);
		painter.drawPoint(x + 1,         y + 1);
		painter.drawPoint(x + 1,         y + height - 2);
		painter.drawPoint(x + width - 2, y + height - 2);
		painter.drawPoint(x + width - 2, y + 1);
	} else {
		// The two top corners:
		antialiasing = Tool_mixColors(Qt::red, stroke);
		painter.setPen(antialiasing);
		painter.drawPoint(x + 1,         y + 1);
		painter.drawPoint(x + width - 2, y + 1);
		// The two bottom ones:
		antialiasing = Tool_mixColors(Qt::white, stroke);
		painter.setPen(antialiasing);
		painter.drawPoint(x + 1,         y + height - 2);
		painter.drawPoint(x + width - 2, y + height - 2);
	}

	// Mark default color:
	if (isDefault) {
		painter.setPen(stroke);
		painter.drawLine(x + 1, y + height - 2, x + width - 2, y + 1);
	}
}
예제 #20
0
void KNoteTip::setColor(const QColor &fg, const QColor &bg)
{
    QPalette newpalette = palette();
    newpalette.setColor(QColorGroup::Background, bg);
    newpalette.setColor(QColorGroup::Foreground, fg);
    newpalette.setColor(QColorGroup::Base,       bg);   // text background
    newpalette.setColor(QColorGroup::Text,       fg);   // text color
    newpalette.setColor(QColorGroup::Button,     bg);

    // the shadow
    newpalette.setColor(QColorGroup::Midlight, bg.light(110));
    newpalette.setColor(QColorGroup::Shadow, bg.dark(116));
    newpalette.setColor(QColorGroup::Light, bg.light(180));
    newpalette.setColor(QColorGroup::Dark, bg.dark(108));
    setPalette(newpalette);

    // set the text color
    mPreview->setColor(fg);
}
예제 #21
0
//! [0]
RoundRectItem::RoundRectItem(const QRectF &bounds, const QColor &color,
                             QGraphicsItem *parent)
    : QGraphicsObject(parent), fillRect(false), bounds(bounds)
{
    gradient.setStart(bounds.topLeft());
    gradient.setFinalStop(bounds.bottomRight());
    gradient.setColorAt(0, color);
    gradient.setColorAt(1, color.dark(200));
    setCacheMode(ItemCoordinateCache);
}
예제 #22
0
void CommonItemMECS::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(widget);

    QColor fillColor = (option->state & QStyle::State_Selected) ? color.dark(150) : color;
    if (option->state & QStyle::State_MouseOver)
        fillColor = fillColor.light(125);

    QPen oldPen = painter->pen();
    QPen pen = oldPen;
    int width = 0;
    if (option->state & QStyle::State_Selected)
        width += 2;

    pen.setWidth(width);
    pen.setColor(Qt::white);
    QBrush b = painter->brush();
    if (m_backgroundImage.isEmpty())
    {
        painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100)));
        painter->drawRect(boundingRect());
        painter->setBrush(b);
    }
    else
    {
        QPen oldPenBorder = painter->pen();
        QPen *penBorder = new QPen(Qt::red);
        penBorder->setWidth(3);
        penBorder->setStyle(Qt::DotLine);
        painter->setPen(*penBorder);
        painter->drawRect(boundingRect());
        painter->drawImage(boundingRect().topLeft(), *m_backGroundImageCache);
        painter->setPen(oldPenBorder);
    }

    painter->setPen(pen);
    painter->drawText(boundingRect(), m_itemFlags, m_text);
    painter->setPen(oldPen);

    if (m_removed)
    {
        QPen oldPenBorder = painter->pen();
        QPen *penBorder = new QPen(Qt::red);
        penBorder->setWidth(3);
        penBorder->setStyle(Qt::SolidLine);
        painter->setPen(*penBorder);
        painter->drawLine(boundingRect().topLeft(), boundingRect().bottomRight());
        painter->drawLine(boundingRect().bottomLeft(), boundingRect().topRight());
        painter->setPen(oldPenBorder);
    }

return;

}
void QwtAnalogClock::initClock()
{
    setWrapping( true );
    setReadOnly( true );

    setOrigin( 270.0 );
    setRange( 0.0, 60.0 * 60.0 * 12.0 ); // seconds
    setScale( -1, 5, 60.0 * 60.0 );

    setScaleComponents(
        QwtAbstractScaleDraw::Ticks | QwtAbstractScaleDraw::Labels );
    setScaleTicks( 1, 0, 8 );
    scaleDraw()->setSpacing( 8 );

    QColor knobColor = palette().color( QPalette::Active, QPalette::Text );
    knobColor = knobColor.dark( 120 );

    QColor handColor;
    int width;

    for ( int i = 0; i < NHands; i++ )
    {
        if ( i == SecondHand )
        {
            width = 2;
            handColor = knobColor.dark( 120 );
        }
        else
        {
            width = 8;
            handColor = knobColor;
        }

        QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
            QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
        hand->setWidth( width );

        d_hand[i] = NULL;
        setHand( ( Hand )i, hand );
    }
}
예제 #24
0
void BlockAnalyzer::drawBackground() {
  const QColor bg = palette().color(QPalette::Background);
  const QColor bgdark = bg.dark(112);

  m_background.fill(bg);

  QPainter p(&m_background);
  for (int x = 0; (uint)x < m_columns; ++x)
    for (int y = 0; (uint)y < m_rows; ++y)
      p.fillRect(x * (WIDTH + 1), y * (HEIGHT + 1) + m_y, WIDTH, HEIGHT,
                 bgdark);
}
bool TrafficGraph::addBeam( const QColor &color )
{
  QLinkedList< QList<double> >::Iterator it;
  //When we add a new beam, go back and set the data for this beam to 0 for all the other times. This is because it makes it easier for
  //moveSensors
  for(it = mBeamData.begin(); it != mBeamData.end(); ++it) {
    (*it).append(0);
  }
  mBeamColors.append(color);
  mBeamColorsDark.append(color.dark(150));
  return true;
}
예제 #26
0
LEDButton::LEDButton(const QColor& col, bool state, QWidget *parent) :
    QWidget(parent),
    led_state(state)
{
    d = new LEDButton::LEDButtonPrivate;
    d->dark_factor = 300;
    d->offcolor = col.dark(300);
    d->off_map = 0;
    d->on_map = 0;

    setColor(col);
}
예제 #27
0
void MainWindow::paintEvent(QPaintEvent*)
{
    const QPoint start(width()/2, 0);
    const QPoint finalStop(width()/2, height());
    QLinearGradient gradient(start, finalStop);
    const QColor qtGreen(102, 176, 54);
    gradient.setColorAt(0, qtGreen.dark());
    gradient.setColorAt(0.5, qtGreen);
    gradient.setColorAt(1, qtGreen.dark());

    QPainter p(this);
    p.fillRect(0, 0, width(), height(), gradient);

    QFont headerFont("Sans Serif", 12, QFont::Bold);
    QFont normalFont("Sans Serif", 9, QFont::Normal);

    // draw it twice for shadow effect
    p.setFont(headerFont);
    QRect headerRect(1, 1, width(), 25);
    p.setPen(Qt::black);
    p.drawText(headerRect, Qt::AlignCenter, m_station.name());

    headerRect.moveTopLeft(QPoint(0, 0));
    p.setPen(Qt::white);
    p.drawText(headerRect, Qt::AlignCenter, m_station.name());

    p.setFont(normalFont);
    int pos = 40;
    for (int i = 0; i < m_times.count() && i < 9; ++i) {
        p.setPen(Qt::black);
        p.drawText(51, pos + 1, m_times.at(i).time());
        p.drawText(101, pos + 1, m_times.at(i).direction());

        p.setPen(Qt::white);
        p.drawText(50, pos, m_times.at(i).time());
        p.drawText(100, pos, m_times.at(i).direction());

        pos += 18;
    }
}
예제 #28
0
// This does the colour transition magic. (You say "Oh, is that it?")
// This may be made configurable at a later stage
void QuartzHandler::drawBlocks(KPixmap *pi, KPixmap &p, const QColor &c1, const QColor &c2)
{
    QPainter px;

    px.begin(pi);

    // Draw a background gradient first
    KPixmapEffect::gradient(p, c1, c2, KPixmapEffect::HorizontalGradient);

    int factor = (pi->height() - 2) / 4;
    int square = factor - (factor + 2) / 4;

    int x = pi->width() - 5 * factor - square;
    int y = (pi->height() - 4 * factor) / 2;

    px.fillRect(x, y, square, square, c1.light(120));
    px.fillRect(x, y + factor, square, square, c1);
    px.fillRect(x, y + 2 * factor, square, square, c1.light(110));
    px.fillRect(x, y + 3 * factor, square, square, c1);

    px.fillRect(x + factor, y, square, square, c1.light(110));
    px.fillRect(x + factor, y + factor, square, square, c2.light(110));
    px.fillRect(x + factor, y + 2 * factor, square, square, c1.light(120));
    px.fillRect(x + factor, y + 3 * factor, square, square, c2.light(130));

    px.fillRect(x + 2 * factor, y + factor, square, square, c1.light(110));
    px.fillRect(x + 2 * factor, y + 2 * factor, square, square, c2.light(120));
    px.fillRect(x + 2 * factor, y + 3 * factor, square, square, c2.light(150));

    px.fillRect(x + 3 * factor, y, square, square, c1.dark(110));
    px.fillRect(x + 3 * factor, y + 2 * factor, square, square, c2.light(120));
    px.fillRect(x + 3 * factor, y + 3 * factor, square, square, c1.dark(120));

    px.fillRect(x + 4 * factor, y + factor, square, square, c1.light(110));
    px.fillRect(x + 4 * factor, y + 3 * factor, square, square, c1.dark(110));

    px.fillRect(x + 5 * factor, y + 2 * factor, square, square, c2.light(120));
    px.fillRect(x + 5 * factor, y + 3 * factor, square, square, c2.light(110));
}
예제 #29
0
static void qwtDrawTriangleNeedle( QPainter *painter,
    const QPalette &palette, QPalette::ColorGroup colorGroup,
    double length )
{
    const double width = qRound( length / 3.0 );

    QPainterPath path[4];

    path[0].lineTo( length, 0.0 );
    path[0].lineTo( 0.0, width / 2 );

    path[1].lineTo( length, 0.0 );
    path[1].lineTo( 0.0, -width / 2 );

    path[2].lineTo( -length, 0.0 );
    path[2].lineTo( 0.0, width / 2 );

    path[3].lineTo( -length, 0.0 );
    path[3].lineTo( 0.0, -width / 2 );


    const int colorOffset =  10;
    const QColor darkColor = palette.color( colorGroup, QPalette::Dark );
    const QColor lightColor = palette.color( colorGroup, QPalette::Light );

    QColor color[4];
    color[0] = darkColor.light( 100 + colorOffset );
    color[1] = darkColor.dark( 100 + colorOffset );
    color[2] = lightColor.light( 100 + colorOffset );
    color[3] = lightColor.dark( 100 + colorOffset );

    painter->setPen( Qt::NoPen );

    for ( int i = 0; i < 4; i++ )
    {
        painter->setBrush( color[i] );
        painter->drawPath( path[i] );
    }
}
예제 #30
0
파일: dss.cpp 프로젝트: Qaaaf/earlgrey
void HDDRank::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(widget);

    QColor c = (load > 60)? Qt::red : Qt::green;

    c = (option->state & QStyle::State_Selected) ? c.dark(150) : c;
    if (option->state & QStyle::State_MouseOver)
        c = c.light(125);

    painter->drawRect(QRectF(0, 0, 60, 100));
    painter->fillRect(QRectF(0, 100-load, 60, load), c);
}