Пример #1
0
//-----------------------------------------------------------------------------
// Function: RibbonGroup::paintEvent()
//-----------------------------------------------------------------------------
void RibbonGroup::paintEvent(QPaintEvent* /*event*/)
{
    QPainter painter(this);

    // Draw the base gradient.
    QLinearGradient gradient(rect().topLeft(), rect().bottomLeft());
	gradient.setColorAt(0.0, RibbonTheme::GRADIENTTOP);
	gradient.setColorAt(0.1, Qt::white);
	gradient.setColorAt(0.3, RibbonTheme::GRADIENTTOP);
	gradient.setColorAt(1.0, RibbonTheme::GRADIENTBOTTOM);

    painter.setRenderHints(QPainter::Antialiasing);
    painter.fillRect(rect(), gradient);

    // Draw a nice frame around the group area.
	painter.setPen(QPen(RibbonTheme::GROUPTITLEGRADIENTTOP, 1));
    painter.drawRect(rect());

    // Draw the title background.
    QRect titleRect = rect();
    titleRect.setTop(rect().height() - TITLE_HEIGHT);

    QLinearGradient titleGradient(titleRect.topLeft(), titleRect.bottomLeft());
	titleGradient.setColorAt(0.0, RibbonTheme::GROUPTITLEGRADIENTTOP);
	titleGradient.setColorAt(1.0, RibbonTheme::GROUPTITLEGRADIENTBOTTOM);

    painter.fillRect(titleRect, titleGradient);

    // Draw the title text.
    QTextOption opt;
    opt.setAlignment(Qt::AlignCenter);

	painter.setPen(QPen(RibbonTheme::GROUPTITLETEXT));
    painter.drawText(titleRect, title_, opt);
}
Пример #2
0
void SelectionItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
	if(!m_selection->pasteImage().isNull()) {
		if(m_shape.size() == 4) {
			QPolygonF src({
				QPointF(0, 0),
				QPointF(m_selection->pasteImage().width(), 0),
				QPointF(m_selection->pasteImage().width(), m_selection->pasteImage().height()),
				QPointF(0, m_selection->pasteImage().height())
			});

			QTransform t;
			if(QTransform::quadToQuad(src, m_shape, t)) {
				painter->save();
				painter->setTransform(t, true);
				painter->drawImage(0, 0, m_selection->pasteImage());
				painter->restore();
			} else
				qWarning("Couldn't transform pasted image!");

		} else {
			qWarning("Pasted selection item with non-rectangular polygon!");
		}
	}

	painter->setClipRect(boundingRect().adjusted(-1, -1, 1, 1));

	QPen pen;
	pen.setWidth(qApp->devicePixelRatio());
	pen.setColor(Qt::white);
	pen.setStyle(Qt::DashLine);
	pen.setDashOffset(m_marchingants);
	pen.setCosmetic(true);
	painter->setPen(pen);
	painter->setCompositionMode(QPainter::RasterOp_SourceXorDestination);

	if(m_selection->isClosed())
		painter->drawPolygon(m_shape);
	else
		painter->drawPolyline(m_shape);

	// Draw resizing handles
	if(m_selection->isClosed()) {
		QRect rect = m_selection->boundingRect();

		pen.setWidth(m_selection->handleSize());
		pen.setStyle(Qt::SolidLine);
		painter->setPen(pen);
		painter->drawPoint(rect.topLeft());
		painter->drawPoint(rect.topLeft() + QPointF(rect.width()/2, 0));
		painter->drawPoint(rect.topRight());

		painter->drawPoint(rect.topLeft() + QPointF(0, rect.height()/2));
		painter->drawPoint(rect.topRight() + QPointF(0, rect.height()/2));

		painter->drawPoint(rect.bottomLeft());
		painter->drawPoint(rect.bottomLeft() + QPointF(rect.width()/2, 0));
		painter->drawPoint(rect.bottomRight());
	}
}
Пример #3
0
QRegion BusyDialog::roundedRect(const QRect &rect, int round)
{
    QRegion region;

    // middle and borders
    region += rect.adjusted(round, 0, -round, 0);
    region += rect.adjusted(0, round, 0, -round);

    // top left
    QRect corner(rect.topLeft(), QSize(round*2, round*2));
    region += QRegion(corner, QRegion::Ellipse);

    // top right
    corner.moveTopRight(rect.topRight());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom left
    corner.moveBottomLeft(rect.bottomLeft());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom right
    corner.moveBottomRight(rect.bottomRight());
    region += QRegion(corner, QRegion::Ellipse);

    return region;
}
Пример #4
0
QCursor core::common::getCursor(const QPoint &pos, const QRect &rect, int clearance, const QCursor &defCursor, bool ignoreCorners)
{
	double
			distTopLeft = math::distance(pos, rect.topLeft()),
			distTopRight = math::distance(pos, rect.topRight()),
			distBottomRight = math::distance(pos, rect.bottomRight()),
			distBottomLeft = math::distance(pos, rect.bottomLeft()),
			distTop = std::abs(pos.y() - rect.top()),
			distRight = std::abs(pos.x() - rect.right()),
			distBottom = std::abs(pos.y() - rect.bottom()),
			distLeft = std::abs(pos.x() - rect.left()),
			clearanceRadius = clearance/2;

	if((distTop <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distTopRight <= clearanceRadius)) || (distBottom <= clearanceRadius && !(distBottomLeft <= clearanceRadius) && !(distBottomRight <= clearanceRadius))){
		return QCursor(Qt::SizeVerCursor);
	}else if((distRight <= clearanceRadius && !(distTopRight <= clearanceRadius) && !(distBottomRight <= clearanceRadius)) || (distLeft <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distBottomLeft <= clearanceRadius))){
		return QCursor(Qt::SizeHorCursor);
	}else if((distTopLeft <= clearanceRadius || distBottomRight <= clearanceRadius) && !ignoreCorners){
		return QCursor(Qt::SizeFDiagCursor);
	}else if((distTopRight <= clearanceRadius || distBottomLeft <= clearanceRadius) && !ignoreCorners){
		return QCursor(Qt::SizeBDiagCursor);
	}

	return defCursor;
}
void IsometricRenderer::drawGrid(QPainter *painter, const QRectF &rect,
                                 QColor gridColor) const
{
    const int tileWidth = map()->tileWidth();
    const int tileHeight = map()->tileHeight();

    QRect r = rect.toAlignedRect();
    r.adjust(-tileWidth / 2, -tileHeight / 2,
             tileWidth / 2, tileHeight / 2);

    const int startX = qMax(qreal(0), pixelToTileCoords(r.topLeft()).x());
    const int startY = qMax(qreal(0), pixelToTileCoords(r.topRight()).y());
    const int endX = qMin(qreal(map()->width()),
                          pixelToTileCoords(r.bottomRight()).x());
    const int endY = qMin(qreal(map()->height()),
                          pixelToTileCoords(r.bottomLeft()).y());

    gridColor.setAlpha(128);

    QPen gridPen(gridColor);
    gridPen.setDashPattern(QVector<qreal>() << 2 << 2);
    painter->setPen(gridPen);

    for (int y = startY; y <= endY; ++y) {
        const QPointF start = tileToPixelCoords(startX, y);
        const QPointF end = tileToPixelCoords(endX, y);
        painter->drawLine(start, end);
    }
    for (int x = startX; x <= endX; ++x) {
        const QPointF start = tileToPixelCoords(x, startY);
        const QPointF end = tileToPixelCoords(x, endY);
        painter->drawLine(start, end);
    }
}
void KstGfxPictureMouseHandler::pressMove(KstTopLevelViewPtr view, const QPoint& pos, bool shift, const QRect& geom) {
  if (_cancelled || !_mouseDown) {
    return;
  }

  QRect old = _prevBand;

  _prevBand = KstGfxMouseHandlerUtils::newRect(pos, _mouseOrigin, geom, shift);

  if (old != _prevBand) {
    QPainter p;
    p.begin(view->widget());
    p.setPen(QPen(Qt::black, 0, Qt::SolidLine));
    p.setRasterOp(Qt::NotROP);
    if (old.topLeft() != QPoint(-1, -1)) {
      p.drawRect(old);
      p.drawLine(old.topLeft(), old.bottomRight());
      p.drawLine(old.topRight(), old.bottomLeft());
    } 
    p.drawRect(_prevBand);
    p.drawLine(_prevBand.topRight(), _prevBand.bottomLeft());
    p.drawLine(_prevBand.topLeft(), _prevBand.bottomRight());
    p.end();
  }
}
Пример #7
0
QRect KkrBoardView::getClueRectDown(const QRect &cellRect) const
{
    const QPoint bottomLeft{cellRect.bottomLeft()};
    const int x = bottomLeft.x() + 2;
    const int y = bottomLeft.y() - CLUE_WIDTH - 1;
    return QRect(x, y, CLUE_WIDTH, CLUE_WIDTH);
}
Пример #8
0
core::common::Sides core::common::nearToSide(const QPoint &pos, const QRect &rect, int clearance, bool ignoreCorners)
{
	double
			distTopLeft = math::distance(pos, rect.topLeft()),
			distTopRight = math::distance(pos, rect.topRight()),
			distBottomRight = math::distance(pos, rect.bottomRight()),
			distBottomLeft = math::distance(pos, rect.bottomLeft()),
			distTop = std::abs(pos.y() - rect.top()),
			distRight = std::abs(pos.x() - rect.right()),
			distBottom = std::abs(pos.y() - rect.bottom()),
			distLeft = std::abs(pos.x() - rect.left()),
			clearanceRadius = clearance/2;

	if(distTop <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distTopRight <= clearanceRadius)){
		return Top;
	}else if(distBottom <= clearanceRadius && !(distBottomLeft <= clearanceRadius) && !(distBottomRight <= clearanceRadius)){
		return Bottom;
	}else if(distRight <= clearanceRadius && !(distTopRight <= clearanceRadius) && !(distBottomRight <= clearanceRadius)){
		return Right;
	}else if(distLeft <= clearanceRadius && !(distTopLeft <= clearanceRadius) && !(distBottomLeft <= clearanceRadius)){
		return Left;
	}else if(distTopLeft <= clearanceRadius && !ignoreCorners){
		return TopLeft;
	}else if(distBottomRight <= clearanceRadius && !ignoreCorners){
		return BottomRight;
	}else if(distTopRight <= clearanceRadius && !ignoreCorners){
		return TopRight;
	}else if(distBottomLeft <= clearanceRadius && !ignoreCorners){
		return BottomLeft;
	}else{
		return None;
	}

}
Пример #9
0
RectKey::RectKey(KeyCode keycode, const QRect &textGeometry, const QRect &keyGeometry,
                 const QSize &labelSize,
                 int topLeft, int topRight, int bottomLeft, int bottomRight,
                 const QColor &keyColor, const QColor &textColor, const QColor &secondColor, const QColor &alphaColor,
                 const QString &labelText, const QString &secondText, const QString &alphaText,
                 const QFont &labelFont, const QFont &secondFont, const QFont &alphaFont,
                 Qt::Alignment labelAlign, Qt::Alignment secondAlign, Qt::Alignment alphaAlign)
    : Key{keycode, textGeometry, keyGeometry, keyColor},
      mTextColor{textColor}, mSecondColor{secondColor}, mAlphaColor{alphaColor},
      mLabelAlign{labelAlign}, mSecondAlign{secondAlign}, mAlphaAlign{alphaAlign},
      mLabelFont{labelFont}, mSecondFont{secondFont.resolve(labelFont)},
                              mAlphaFont{alphaFont.resolve(labelFont)},
      mSecondText{secondText}, mAlphaText{alphaText} {
    QRect corner;
    mLabelText = labelText;
    mKeyShape.moveTo(keyGeometry.topLeft() + QPointF{0, topLeft * .5});
    corner.setSize({bottomLeft, bottomLeft});
    corner.moveBottomLeft(keyGeometry.bottomLeft());
    mKeyShape.arcTo(corner, 90 * 2, 90);
    corner.setSize({bottomRight, bottomRight});
    corner.moveBottomRight(keyGeometry.bottomRight());
    mKeyShape.arcTo(corner, 90 * 3, 90);
    corner.setSize({topRight, topRight});
    corner.moveTopRight(keyGeometry.topRight());
    mKeyShape.arcTo(corner, 90 * 0, 90);
    corner.setSize({topLeft, topLeft});
    corner.moveTopLeft(keyGeometry.topLeft());
    mKeyShape.arcTo(corner, 90 * 1, 90);

    mLabelFont.setPixelSize(labelSize.height());
    mLabelFont.setStretch(labelSize.width() * mLabelFont.stretch() /
                           QFontMetricsF(mLabelFont).size(Qt::TextSingleLine, mLabelText).width());
}
Пример #10
0
// Thanks to http://www.qtcentre.org/threads/3205-Toplevel-widget-with-rounded-corners?p=17492#post17492
QRegion QzTools::roundedRect(const QRect &rect, int radius)
{
    QRegion region;

    // middle and borders
    region += rect.adjusted(radius, 0, -radius, 0);
    region += rect.adjusted(0, radius, 0, -radius);

    // top left
    QRect corner(rect.topLeft(), QSize(radius * 2, radius * 2));
    region += QRegion(corner, QRegion::Ellipse);

    // top right
    corner.moveTopRight(rect.topRight());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom left
    corner.moveBottomLeft(rect.bottomLeft());
    region += QRegion(corner, QRegion::Ellipse);

    // bottom right
    corner.moveBottomRight(rect.bottomRight());
    region += QRegion(corner, QRegion::Ellipse);

    return region;
}
Пример #11
0
void MechanicsItemOverlay::slotUpdateResizeHandles()
{
	const PositionInfo absPos = p_mechanicsItem->absolutePosition();
	const QRect sizeRect = p_mechanicsItem->sizeRect();
	
	QPointArray pa(9);
	pa[0] = sizeRect.topLeft();
	pa[2] = sizeRect.topRight();
	pa[1] = (pa[0]+pa[2])/2;
	pa[4] = sizeRect.bottomRight();
	pa[3] = (pa[2]+pa[4])/2;
	pa[6] = sizeRect.bottomLeft();
	pa[5] = (pa[4]+pa[6])/2;
	pa[7] = (pa[6]+pa[0])/2;
	pa[8] = QPoint(0,0);
	
	QWMatrix m;
	m.rotate(absPos.angle() * DPR);
	
	pa = m.map(pa);
	
	m_tl->move( absPos.x()+pa[0].x(), absPos.y()+pa[0].y() );
	m_tm->move( absPos.x()+pa[1].x(), absPos.y()+pa[1].y() );
	m_tr->move( absPos.x()+pa[2].x(), absPos.y()+pa[2].y() );
	m_mr->move( absPos.x()+pa[3].x(), absPos.y()+pa[3].y() );
	m_br->move( absPos.x()+pa[4].x(), absPos.y()+pa[4].y() );
	m_bm->move( absPos.x()+pa[5].x(), absPos.y()+pa[5].y() );
	m_bl->move( absPos.x()+pa[6].x(), absPos.y()+pa[6].y() );
	m_ml->move( absPos.x()+pa[7].x(), absPos.y()+pa[7].y() );
	m_mm->move( absPos.x()+pa[8].x(), absPos.y()+pa[8].y() );
}
Пример #12
0
void CellButton::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QStyleOptionToolButton opt;
    initStyleOption(&opt);
    QPainter p(this);

    QIcon::Mode mode = opt.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled;
    if (mode == QIcon::Normal && (opt.state & QStyle::State_HasFocus || opt.state & QStyle::State_Sunken))
        mode = QIcon::Active;
    QIcon::State state = QIcon::Off;
    if (opt.state & QStyle::State_On)
        state = QIcon::On;

    if (m_pos == Center || m_pos == Right)
    {
        p.setPen(QColor("#F8F8F8"));
        QRect rcBorder = rect();
        p.drawLine(rcBorder.topLeft(), rcBorder.bottomLeft());
    }
    //m_backgroundIcon.paint(&p, opt.rect, Qt::AlignCenter, QIcon::Normal, state);

    QSize size = iconSize();
    QRect rcIcon((opt.rect.width() - size.width()) / 2, (opt.rect.height() - size.height()) / 2, size.width(), size.height());
    if (opt.icon.isNull()) {
        m_iconNomal.paint(&p, rcIcon, Qt::AlignCenter, mode, state);
    } else {
        opt.icon.paint(&p, rcIcon, Qt::AlignCenter, mode, state);
    }
}
void NonPdfCropping::createWidgets(QGraphicsScene &scene)
{
  const double MARGIN_PERCENT = 5.0;
  const int ZERO_WIDTH_IS_ALWAYS_VISIBLE = 0;

  int marginHor = scene.width()  * MARGIN_PERCENT / 100.0;
  int marginVer = scene.height() * MARGIN_PERCENT / 100.0;

  QRect box (scene.sceneRect().left() + marginHor,
             scene.sceneRect().top()  + marginVer,
             scene.sceneRect().width() - 2 * marginHor,
             scene.sceneRect().height() - 2 * marginVer);

  m_handleTL = new NonPdfFrameHandle (scene, m_view, box.topLeft()    , NON_PDF_CROPPING_LEFT   | NON_PDF_CROPPING_TOP    , *this, Z_HANDLE);
  m_handleTR = new NonPdfFrameHandle (scene, m_view, box.topRight()   , NON_PDF_CROPPING_RIGHT  | NON_PDF_CROPPING_TOP    , *this, Z_HANDLE);
  m_handleBR = new NonPdfFrameHandle (scene, m_view, box.bottomRight(), NON_PDF_CROPPING_RIGHT  | NON_PDF_CROPPING_BOTTOM , *this, Z_HANDLE);
  m_handleBL = new NonPdfFrameHandle (scene, m_view, box.bottomLeft() , NON_PDF_CROPPING_LEFT   | NON_PDF_CROPPING_BOTTOM , *this, Z_HANDLE);

  m_box = new QGraphicsRectItem;
  m_box->setZValue (Z_BOX);
  m_box->setPen (QPen (QBrush (Qt::gray), ZERO_WIDTH_IS_ALWAYS_VISIBLE));
  scene.addItem (m_box);

  updateBox ();
}
Пример #14
0
void FreeSpaceBar::DrawBar(QPainter* p, const QRect& r) {
  p->setRenderHint(QPainter::Antialiasing, true);
  p->setRenderHint(QPainter::HighQualityAntialiasing, true);

  QRect bar_rect(r);
  bar_rect.setWidth(float(bar_rect.width()) * (float(total_ - free_) / total_));

  QLinearGradient background_gradient(r.topLeft(), r.bottomLeft());
  background_gradient.setColorAt(0, kColorBg1);
  background_gradient.setColorAt(1, kColorBg2);

  QLinearGradient bar_gradient(bar_rect.topLeft(), bar_rect.bottomLeft());
  bar_gradient.setColorAt(0, kColorBar1);
  bar_gradient.setColorAt(1, kColorBar2);

  // Draw the background
  p->setPen(Qt::NoPen);
  p->setBrush(background_gradient);
  p->drawRoundedRect(r, kBarBorderRadius, kBarBorderRadius);

  // Create a path to use for clipping the bars
  QPainterPath clip_path;
  clip_path.addRoundedRect(r, kBarBorderRadius, kBarBorderRadius);
  p->setClipPath(clip_path);

  // Draw any additional space
  if (additional_) {
    QRect additional_rect(bar_rect);
    additional_rect.setLeft(bar_rect.right());
    additional_rect.setWidth(
        float(r.width()) * (float(qMin(free_, additional_)) / total_) + 1);

    QLinearGradient additional_gradient(additional_rect.topLeft(),
                                        additional_rect.bottomLeft());
    additional_gradient.setColorAt(0, kColorAdd1);
    additional_gradient.setColorAt(1, kColorAdd2);

    p->fillRect(additional_rect, additional_gradient);
  }

  // Draw the bar foreground
  p->fillRect(bar_rect, bar_gradient);

  // Draw a border
  p->setClipping(false);
  p->setPen(kColorBorder);
  p->setBrush(Qt::NoBrush);
  p->drawRoundedRect(r, kBarBorderRadius, kBarBorderRadius);

  // Draw marker lines over the top every few pixels
  p->setOpacity(0.35);
  p->setRenderHint(QPainter::Antialiasing, false);
  p->setPen(QPen(palette().color(QPalette::Light), 1.0));
  for (int x = r.left() + kMarkerSpacing; x < r.right(); x += kMarkerSpacing) {
    p->drawLine(x, r.top() + 2, x, r.bottom() - 2);
  }

  p->setOpacity(1.0);
}
Пример #15
0
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
{
	QStyleOptionTabV2 tab;

	initStyleOption(&tab, tabIndex);
	QRect rect = tab.rect;
	painter->save();

	bool selected = tab.state & QStyle::State_Selected;
	bool hover = tab.state & QStyle::State_MouseOver;

#ifdef Q_WS_MAC
	hover = false;     // Dont hover on Mac
#endif

	QColor hoverColor;

	if (hover)
	{
		hoverColor = QColor(255, 255, 255, m_hoverControl.currentFrame() * 2);
	}

	QColor light = QColor(255, 255, 255, 40);
	QColor dark = QColor(0, 0, 0, 60);

	if (selected)
	{
		painter->fillRect(tab.rect, QColor(0x47, 0x47, 0x47));
		painter->setPen(QPen(light, 0));
		painter->drawLine(rect.topLeft(), rect.topRight());
		painter->setPen(QPen(dark, 0));
		painter->drawLine(rect.bottomLeft(), rect.bottomRight());
	}
	else
	{
		painter->fillRect(tab.rect, StyleHelper::baseColor());
		if (hover)
			painter->fillRect(tab.rect, hoverColor);
	}

	QString tabText(tab.text);
	QRect tabTextRect(tab.rect);
	QRect tabIconRect(tab.rect);
	QFont font(painter->font());
	font.setPointSizeF(StyleHelper::sidebarFontSize());
	font.setBold(false);
	painter->setFont(font);
	painter->setPen(Qt::white);
	int textFlags = Qt::AlignCenter | Qt::AlignCenter | Qt::ElideRight | Qt::TextWordWrap;
	painter->drawText(tabTextRect, textFlags, tabText);
	painter->setPen(selected ? QColor(60, 60, 60) : Qt::white);
	int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
	tabIconRect.adjust(0, 4, 0, -textHeight);
	style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
							tab.icon.pixmap(QSize(64, 64)));
//    painter->translate(0, -1);
//    painter->drawText(tabTextRect, textFlags, tabText);
	painter->restore();
}
Пример #16
0
void SearchBar::doOpenPopupList(bool v)
{
    Q_UNUSED(v);
    QRect rect = m_lineEdit->geometry();
    QPoint widgetPos = mapToGlobal(rect.bottomLeft());
    m_menu->setFixedWidth(m_lineEdit->width());
    m_menu->exec(widgetPos);
}
Пример #17
0
static void menuGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect)
{
    QLinearGradient grad(spanRect.topLeft(), spanRect.bottomLeft());
    QColor menuColor = StyleHelper::mergedColors(StyleHelper::baseColor(), QColor(244, 244, 244), 25);
    grad.setColorAt(0, menuColor.lighter(112));
    grad.setColorAt(1, menuColor);
    p->fillRect(rect, grad);
}
void CSliderMultiPos::drawSpan(QStylePainter* painter, const QRect& rect,int baseElemIndex){
    QStyleOptionSlider opt;
    QColor currentColor;
    QPointF point1,point2;

    // area
    initStyleOption( &opt,baseElemIndex );
    QRect groove = this->style()->subControlRect( QStyle::CC_Slider,&opt,QStyle::SC_SliderGroove,this );

    // Apply color depending on span index
    // Considering the base element index is the interval index
    currentColor = getSpanColor(baseElemIndex);

    if( opt.orientation == Qt::Horizontal ){
        groove.adjust( 0,0,-1,0 );
        point1.setX( groove.center().x() );
        point1.setY( groove.top() );
        point2.setX( groove.center().x() );
        point2.setY( groove.bottom() );
    }
    else{
        groove.adjust( 0,0,0,-1 );
        point1.setX( groove.left() );
        point1.setY( groove.center().y() );
        point2.setX( groove.right() );
        point2.setY( groove.center().y() );
    }
    setupPainter( painter,point1,point2,currentColor );

    // draw groove
    painter->drawRect( rect );//.intersected( groove ) );

    if( displayPosition ){
        QPoint endOfSpan;
        if( this->tickPosition()==TicksBelow ){
            endOfSpan = rect.bottomLeft();
        }
        else{
            endOfSpan = rect.topLeft();
        }
        drawSpanValue( painter,endOfSpan,baseElemIndex );
        if( baseElemIndex==nbValues()-2 ){
            if( this->tickPosition()==TicksBelow ){
                endOfSpan = rect.bottomRight();
            }
            else{
                endOfSpan = rect.topRight();
            }
            drawSpanValue( painter,endOfSpan,baseElemIndex+1 );
        }
    }

    if( displayIntervalLabel ){
        drawSpanLabel( painter,rect,baseElemIndex );
    }

}
Пример #19
0
void TPanelTitleBar::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	QRect rect = this->rect();

	QColor titleColor;
	QColor brushColor;

	TPanel *dw = qobject_cast<TPanel *>(parentWidget());
	Q_ASSERT(dw != 0);
	if (!dw->isFloating()) {
		if (dw->widgetInThisPanelIsFocused()) {
			brushColor = QColor(64, 64, 64);
			titleColor = QColor(Qt::white);
		} else {
			brushColor = QColor(100, 100, 100);
			titleColor = QColor(192, 192, 192);
		}
	} else if (isActiveWindow()) {
		brushColor = QColor(96, 96, 96);
		titleColor = QColor(Qt::white);
	} else {
		brushColor = QColor(128, 128, 128);
		titleColor = QColor(192, 192, 192);
	}
	painter.setBrush(brushColor);
	painter.setPen(Qt::black);
	painter.drawRect(rect.adjusted(0, 0, -1, -1));

	painter.setPen(titleColor);
	painter.drawLine(rect.topLeft(), rect.bottomLeft());
	painter.drawLine(rect.topLeft(), rect.topRight());

	if (dw->getOrientation() == TDockWidget::vertical) {
		QString titleText =
			painter.fontMetrics().elidedText(
				dw->windowTitle(), Qt::ElideRight, rect.width() - 50);

		painter.setBrush(Qt::NoBrush);
		painter.setPen(titleColor);
		painter.drawText(QPointF(10, 15), titleText);
	}

	if (dw->isFloating()) {
		const static QPixmap closeButtonPixmap(":/Resources/close_pane.png");
		const static QPixmap closeButtonPixmapOver(":/Resources/close_pane_rollover.png");

		QRect closeRect(rect.right() - 17, rect.top() + 1, 16, 16);

		if (m_closeButtonHighlighted)
			painter.drawPixmap(closeRect, closeButtonPixmapOver);
		else
			painter.drawPixmap(closeRect, closeButtonPixmap);
	}

	painter.end();
}
Пример #20
0
void StyleHelper::drawListViewItemSeperator(QPainter* p, const QRect& rc)
{
    QRect rcLine = rc;
    rcLine.adjust(5, 0, -5, 0);
    p->save();
    p->setPen(listViewItemSeperator());
    p->drawLine(rcLine.bottomLeft(), rcLine.bottomRight());
    p->restore();
}
Пример #21
0
void
KTreemapTile::drawShape( QPainter & painter )
{
    // kdDebug() << "drawShape() " << _orig << endl;

    QSize size = rect().size();

    if ( size.height() < 1 || size.width() < 1 )
	return;

    if ( _parentView->doCushionShading() )
    {
	if ( _orig->isDir() || _orig->isDotEntry() )
	{
	    QCanvasRectangle::drawShape( painter );
	}
	else
	{
	    if ( _cushion.isNull() )
		_cushion = renderCushion();

	    QRect rect = QCanvasRectangle::rect();

	    if ( ! _cushion.isNull() )
		painter.drawPixmap( rect, _cushion );

	    if ( _parentView->forceCushionGrid() )
	    {
		// Draw a clearly visible boundary

		painter.setPen( QPen( _parentView->cushionGridColor(), 1 ) );

		if ( rect.x() > 0 )
		    painter.drawLine( rect.topLeft(), rect.bottomLeft() + QPoint( 0, 1 ) );

		if ( rect.y() > 0 )
		    painter.drawLine( rect.topLeft(), rect.topRight() + QPoint( 1, 0 ) );
	    }
	}
    }
    else	// No cushion shading, use plain tiles
    {
	painter.setPen( QPen( _parentView->outlineColor(), 1 ) );

	if ( _orig->isDir() || _orig->isDotEntry() )
	    painter.setBrush( _parentView->dirFillColor() );
	else
	{
	    painter.setBrush( _parentView->tileColor( _orig ) );
#if 0
	    painter.setBrush( _parentView->fileFillColor() );
#endif
	}

	QCanvasRectangle::drawShape( painter );
    }
}
Пример #22
0
	void TrayIcon::showMessage(const Data::DlgState& state)
	{
#if defined (_WIN32)
		if (toastSupported())
		{
			ToastManager_->DisplayToastMessage(state.AimId_, state.GetText());
			return;
		}
#elif defined (__APPLE__)
        if (ncSupported())
        {
            NotificationCenterManager_->DisplayNotification(state.AimId_, state.GetText());
            return;
        }
#endif //_WIN32
		MessageAlert_->addAlert(state);

		TrayPosition pos = getTrayPosition();
		QRect availableGeometry = QDesktopWidget().availableGeometry();

		int screenMargin = Utils::scale_value(20) - Ui::get_gui_settings()->get_shadow_width();

		switch (pos)
		{
		case Ui::TOP_RIGHT:
			MessageAlert_->move(availableGeometry.topRight().x() - MessageAlert_->width() - screenMargin, availableGeometry.topRight().y() + screenMargin);
			break;

		case Ui::BOTTOM_LEFT:
			MessageAlert_->move(availableGeometry.bottomLeft().x() + screenMargin, availableGeometry.bottomLeft().y() - MessageAlert_->height() - screenMargin);
			break;

		case Ui::BOTOOM_RIGHT:
			MessageAlert_->move(availableGeometry.bottomRight().x() - MessageAlert_->width() - screenMargin, availableGeometry.bottomRight().y() - MessageAlert_->height() - screenMargin);
			break;

		case Ui::TOP_LEFT:
		default:
            MessageAlert_->move(availableGeometry.topLeft().x() + screenMargin, availableGeometry.topLeft().y() + screenMargin);
			break;
		}

		MessageAlert_->show();
	}
Пример #23
0
void TicTacToe::paintEvent(QPaintEvent * /* event */)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    painter.setPen(QPen(Qt::darkGreen, 1));
    painter.drawLine(cellWidth(), 0, cellWidth(), height());
    painter.drawLine(2 * cellWidth(), 0, 2 * cellWidth(), height());
    painter.drawLine(0, cellHeight(), width(), cellHeight());
    painter.drawLine(0, 2 * cellHeight(), width(), 2 * cellHeight());

    painter.setPen(QPen(Qt::darkBlue, 2));

    for (int position = 0; position < 9; ++position) {
        QRect cell = cellRect(position / 3, position % 3);

        if (myState.at(position) == Cross) {
            painter.drawLine(cell.topLeft(), cell.bottomRight());
            painter.drawLine(cell.topRight(), cell.bottomLeft());
        } else if (myState.at(position) == Nought) {
            painter.drawEllipse(cell);
        }
    }

    painter.setPen(QPen(Qt::yellow, 3));

    for (int position = 0; position < 9; position = position + 3) {
        if (myState.at(position) != Empty
                && myState.at(position + 1) == myState.at(position)
                && myState.at(position + 2) == myState.at(position)) {
            int y = cellRect((position / 3), 0).center().y();
            painter.drawLine(0, y, width(), y);
            turnNumber = 9;
        }
    }

    for (int position = 0; position < 3; ++position) {
        if (myState.at(position) != Empty
                && myState.at(position + 3) == myState.at(position)
                && myState.at(position + 6) == myState.at(position)) {
            int x = cellRect(0, position).center().x();
            painter.drawLine(x, 0, x, height());
            turnNumber = 9;
        }
    }
    if (myState.at(0) != Empty && myState.at(4) == myState.at(0)
            && myState.at(8) == myState.at(0)) {
        painter.drawLine(0, 0, width(), height());
        turnNumber = 9;
    }
    if (myState.at(2) != Empty && myState.at(4) == myState.at(2)
            && myState.at(6) == myState.at(2)) {
        painter.drawLine(0, height(), width(), 0);
        turnNumber = 9;
    }
}
Пример #24
0
void MirrorItem::sourceMoved()
{
    // find out the item's polygon in scene coordinates
    QRectF itemRect = m_source->boundingRect();
    QPolygonF itemScenePolygon = m_source->mapToScene(itemRect);
    QRect itemSceneRect = itemScenePolygon.boundingRect().toRect();

    // reposition
    setPos(itemSceneRect.bottomLeft());
}
void UIGDetailsElement::paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
{
    /* Save painter: */
    pPainter->save();

    /* Prepare variables: */
    int iMargin = data(ElementData_Margin).toInt();
    int iHeaderHeight = 2 * iMargin + m_iMinimumHeaderHeight;
    QRect optionRect = pOption->rect;
    QRect fullRect = !m_fAnimationRunning ? optionRect :
                     QRect(optionRect.topLeft(), QSize(optionRect.width(), iHeaderHeight + m_iAdditionalHeight));
    int iFullHeight = fullRect.height();

    /* Prepare color: */
    QPalette pal = palette();
    QColor headerColor = pal.color(QPalette::Active, QPalette::Button);
    QColor strokeColor = pal.color(QPalette::Active, QPalette::Mid);
    QColor bodyColor = pal.color(QPalette::Active, QPalette::Base);

    /* Add clipping: */
    QPainterPath path;
    path.moveTo(m_iCornerRadius, 0);
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, 0), 90, 90);
    path.lineTo(path.currentPosition().x(), iFullHeight - m_iCornerRadius);
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(0, -m_iCornerRadius), 180, 90);
    path.lineTo(fullRect.width() - m_iCornerRadius, path.currentPosition().y());
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, -2 * m_iCornerRadius), 270, 90);
    path.lineTo(path.currentPosition().x(), m_iCornerRadius);
    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-2 * m_iCornerRadius, -m_iCornerRadius), 0, 90);
    path.closeSubpath();
    pPainter->setClipPath(path);

    /* Calculate top rectangle: */
    QRect tRect = fullRect;
    tRect.setBottom(tRect.top() + iHeaderHeight);
    /* Calculate bottom rectangle: */
    QRect bRect = fullRect;
    bRect.setTop(tRect.bottom());

    /* Prepare top gradient: */
    QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft());
    tGradient.setColorAt(0, headerColor.darker(110));
    tGradient.setColorAt(1, headerColor.darker(animationDarkness()));

    /* Paint all the stuff: */
    pPainter->fillRect(tRect, tGradient);
    pPainter->fillRect(bRect, bodyColor);

    /* Stroke path: */
    pPainter->setClipping(false);
    pPainter->strokePath(path, strokeColor);

    /* Restore painter: */
    pPainter->restore();
}
Пример #26
0
/*!
    Draw an arrow int a bounding rect

    \param p Painter
    \param r Rectangle where to paint the arrow
    \param arrowType Arrow type
*/
void QwtArrowButton::drawArrow(QPainter *p, 
    const QRect &r, Qt::ArrowType arrowType) const 
{
    QwtPointArray pa(3);

    switch(arrowType)
    {
        case Qt::UpArrow:
            pa.setPoint(0, r.bottomLeft());
            pa.setPoint(1, r.bottomRight());
            pa.setPoint(2, r.center().x(), r.top());
            break;
        case Qt::DownArrow:
            pa.setPoint(0, r.topLeft());
            pa.setPoint(1, r.topRight());
            pa.setPoint(2, r.center().x(), r.bottom());
            break;
        case Qt::RightArrow:
            pa.setPoint(0, r.topLeft());
            pa.setPoint(1, r.bottomLeft());
            pa.setPoint(2, r.right(), r.center().y());
            break;
        case Qt::LeftArrow:
            pa.setPoint(0, r.topRight());
            pa.setPoint(1, r.bottomRight());
            pa.setPoint(2, r.left(), r.center().y());
            break;
        default:
            break;
    }

    p->save();
#if QT_VERSION < 0x040000
    p->setPen(colorGroup().buttonText());
    p->setBrush(colorGroup().brush(QColorGroup::ButtonText));
#else
    p->setPen(palette().color(QPalette::ButtonText));
    p->setBrush(palette().brush(QPalette::ButtonText));
#endif
    p->drawPolygon(pa);
    p->restore();
}
Пример #27
0
QPoint eGuiOpPage::_getNearestIntersectionPoint(const QRect &r, const QLine &line) const
{
    // First, calculate intersections with all four
    // rectangle sides.
    const QLineF lines[4] =
    {
        QLineF(r.topLeft(),     r.topRight()),
        QLineF(r.topRight(),    r.bottomRight()),
        QLineF(r.bottomRight(), r.bottomLeft()),
        QLineF(r.bottomLeft(),  r.topLeft())
    };

    QVector<QPoint> ips;
    QPointF ip;

    for (eInt i=0; i<4; i++)
    {
        if (lines[i].intersect(line, &ip) == QLineF::BoundedIntersection)
        {
            ips.append(ip.toPoint());
        }
    }

    eASSERT(ips.size() != eNULL);

    // Second, find nearest intersection point.
    QPoint nip = ips[0];
    eU32 minDist = (nip-line.p2()).manhattanLength();

    for (eInt i=1; i<ips.size(); i++)
    {
        eU32 dist = (ips[i]-line.p2()).manhattanLength();

        if (dist < minDist)
        {
            minDist = dist;
            nip = ips[i];
        }
    }

    return nip;
}
Пример #28
0
/*!
  Reimplement this function to change the contents of the well array.
 */
void WellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r)
{
    if (d) {
        p->fillRect(r, d->brush[row*numCols()+col]);
    } else {
        p->fillRect(r, Qt::white);
        p->setPen(Qt::black);
        p->drawLine(r.topLeft(), r.bottomRight());
        p->drawLine(r.topRight(), r.bottomLeft());
    }
}
Пример #29
0
void TicTacButton::drawButtonLabel( QPainter *p )
{
    QRect r = rect();
    p->setPen( QPen( white,2 ) );		// set fat pen
    if ( t == Circle ) {
	p->drawEllipse( r.left()+4, r.top()+4, r.width()-8, r.height()-8 );
    } else if ( t == Cross ) {			// draw cross
	p->drawLine( r.topLeft()   +QPoint(4,4), r.bottomRight()-QPoint(4,4));
	p->drawLine( r.bottomLeft()+QPoint(4,-4),r.topRight()   -QPoint(4,-4));
    }
}
void UIPopupPane::paintBackground(const QRect &rect, QPainter &painter)
{
    /* Paint background: */
    QColor currentColor(palette().color(QPalette::Window));
    QColor newColor1(currentColor.red(), currentColor.green(), currentColor.blue(), opacity());
    QColor newColor2 = newColor1.darker(115);
    QLinearGradient headerGradient(rect.topLeft(), rect.bottomLeft());
    headerGradient.setColorAt(0, newColor1);
    headerGradient.setColorAt(1, newColor2);
    painter.fillRect(rect, headerGradient);
}