QGradient SVGPaintServerLinearGradient::setupGradient(QPainter* painter, QPainterPath* painterPath, const RenderObject* object) const { Q_UNUSED(painter); Q_UNUSED(object); //QPainterPath* path(context ? context->currentPath() : 0); //Q_ASSERT(path); double x1, x2, y1, y2; if (boundingBoxMode()) { QRectF bbox = painterPath->boundingRect(); x1 = bbox.x(); y1 = bbox.y(); x2 = bbox.x() + bbox.width(); y2 = bbox.y() + bbox.height(); } else { x1 = gradientStart().x(); y1 = gradientStart().y(); x2 = gradientEnd().x(); y2 = gradientEnd().y(); } QLinearGradient gradient(QPointF(x1, y1), QPointF(x2, y2)); return gradient; }
// 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()); } }
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 WindowTitleBar::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); if(m_Cache != NULL) delete m_Cache; // Remove old cache m_Cache = new QPixmap(size()); // Create a cache with same size as the widget m_Cache->fill(Qt::transparent); // Create a the transparent background QPainter painter(m_Cache); // Start painting the cache QColor lightBlue (150, 150, 150, 255); QColor gradientStart( 0, 0, 0, 0); QColor gradientEnd ( 0, 0, 0, 220); QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, height())); linearGrad.setColorAt(0, gradientStart); linearGrad.setColorAt(1, gradientEnd); /********** Title bar's frame **********/ QPolygon frame; frame << QPoint( 20, 4) << QPoint(width() - 4, 4) << QPoint(width() - 4, 32) << QPoint( 4, 32) << QPoint( 4, 20); painter.setPen (QPen (lightBlue )); painter.setBrush(QBrush(linearGrad)); painter.drawPolygon(frame); /***************************************/ /********** Title bar's buttons area **********/ QPolygon buttons; buttons << QPoint(width() - 80, 4) << QPoint(width() - 4, 4) << QPoint(width() - 4, 32) << QPoint(width() - 88, 32) << QPoint(width() - 88, 12); painter.setPen (QPen (lightBlue)); painter.setBrush(QBrush(lightBlue)); painter.drawPolygon(buttons); /**********************************************/ m_Title.move ( 28, 4); m_Title.resize(width() - 116, 29); m_Minimize.move (width() - 84, 8); m_Minimize.resize( 20, 20); m_Maximize.move (width() - 60, 8); m_Maximize.resize( 20, 20); m_Close.move (width() - 28, 8); m_Close.resize( 20, 20); }