void PanelKMenu::paintEvent(QPaintEvent * e) { if (sidePixmap.isNull()) { PanelServiceMenu::paintEvent(e); return; } QPainter p(this); p.setClipRegion(e->region()); QStyleOptionFrame frOpt; frOpt.init(this); frOpt.lineWidth = frameWidth(); frOpt.midLineWidth = 0; style()->drawPrimitive( QStyle::PE_FrameMenu, &frOpt, &p, this); QRect r = sideImageRect(); r.setBottom( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { p.drawTiledPixmap( r, sideTilePixmap ); } r = sideImageRect(); r.setTop( r.bottom() - sidePixmap.height() ); if ( r.intersects( e->rect() ) ) { QRect drawRect = r.intersect( e->rect() ); QRect pixRect = drawRect; pixRect.translate( -r.left(), -r.top() ); p.drawPixmap( drawRect.topLeft(), sidePixmap, pixRect ); } PanelServiceMenu::paintEvent( e ); }
/*! \reimp */ void QDockWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout()); bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0; bool nativeDeco = layout->nativeWindowDeco(); if (!nativeDeco && !customTitleBar) { QStylePainter p(this); // ### Add PixelMetric to change spacers, so style may show border // when not floating. if (isFloating()) { QStyleOptionFrame framOpt; framOpt.init(this); p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt); } // Title must be painted after the frame, since the areas overlap, and // the title may wish to extend out to all sides (eg. XP style) QStyleOptionDockWidgetV2 titleOpt; initStyleOption(&titleOpt); p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt); } }
void KSelector::paintEvent( QPaintEvent * ) { QPainter painter; int w = style()->pixelMetric( QStyle::PM_DefaultFrameWidth ); int iw = (w < ARROWSIZE) ? ARROWSIZE : w; painter.begin( this ); drawContents( &painter ); QBrush brush; QPoint pos = calcArrowPos( value() ); drawArrow( &painter, pos ); if ( indent() ) { QStyleOptionFrame opt; opt.initFrom( this ); opt.state = QStyle::State_Sunken; if ( orientation() == Qt::Vertical ) opt.rect.adjust( 0, iw - w, -5, w - iw ); else opt.rect.adjust(iw - w, 0, w - iw, -5); style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this ); } painter.end(); }
void PsiTipLabel::paintEvent(QPaintEvent *) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); // stolen from QLabel::paintEvent QPainter painter(this); drawFrame(&painter); QRect cr = contentsRect(); cr.adjust(margin, margin, -margin, -margin); PsiRichText::ensureTextLayouted(doc, width() - 2*margin); QAbstractTextDocumentLayout *layout = doc->documentLayout(); // QRect lr = rect(); QRect lr = cr; QAbstractTextDocumentLayout::PaintContext context; // Adjust the palette context.palette = palette(); if (foregroundRole() != QPalette::Text && isEnabled()) context.palette.setColor(QPalette::Text, context.palette.color(foregroundRole())); painter.save(); painter.translate(lr.x() + 1, lr.y() + 1); painter.setClipRect(lr.translated(-lr.x() - 1, -lr.y() - 1)); layout->draw(&painter, context); painter.restore(); }
void MultiLineEdit::updateSizeHint() { QFontMetrics fm(font()); int minPixelHeight = fm.lineSpacing() * _minHeight; int maxPixelHeight = fm.lineSpacing() * _maxHeight; int scrollBarHeight = horizontalScrollBar()->isVisible() ? horizontalScrollBar()->height() : 0; // use the style to determine a decent size int h = qMin(qMax((int)document()->size().height() + scrollBarHeight, minPixelHeight), maxPixelHeight) + 2 * frameWidth(); QStyleOptionFrame opt; opt.initFrom(this); opt.rect = QRect(0, 0, 100, h); opt.lineWidth = lineWidth(); opt.midLineWidth = midLineWidth(); opt.state |= QStyle::State_Sunken; QWidget* widget = this; #ifdef Q_OS_MAC widget = 0; #endif QSize s = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(100, h).expandedTo(QApplication::globalStrut()), widget); if (s != _sizeHint) { _sizeHint = s; updateGeometry(); } }
void CCONTAINER_draw_border(QPainter *p, char frame, QWidget *wid) { QStyleOptionFrame opt; opt.init(wid); opt.rect = QRect(0, 0, wid->width(), wid->height()); _draw_border(p, frame, wid, opt); }
/*! \internal Used by QLabel and QLCDNumber */ void QFrame::drawFrame(QPainter *p) { Q_D(QFrame); QStyleOptionFrame opt; opt.init(this); int frameShape = d->frameStyle & QFrame::Shape_Mask; int frameShadow = d->frameStyle & QFrame::Shadow_Mask; opt.frameShape = Shape(int(opt.frameShape) | frameShape); opt.rect = frameRect(); switch (frameShape) { case QFrame::Box: case QFrame::HLine: case QFrame::VLine: case QFrame::StyledPanel: case QFrame::Panel: opt.lineWidth = d->lineWidth; opt.midLineWidth = d->midLineWidth; break; default: // most frame styles do not handle customized line and midline widths // (see updateFrameWidth()). opt.lineWidth = d->frameWidth; break; } if (frameShadow == Sunken) opt.state |= QStyle::State_Sunken; else if (frameShadow == Raised) opt.state |= QStyle::State_Raised; style()->drawControl(QStyle::CE_ShapedFrame, &opt, p, this); }
QSize QILineEdit::featTextWidth (const QString &aText) const { QStyleOptionFrame sof; sof.initFrom (this); sof.rect = contentsRect(); sof.lineWidth = hasFrame() ? style()->pixelMetric (QStyle::PM_DefaultFrameWidth) : 0; sof.midLineWidth = 0; sof.state |= QStyle::State_Sunken; /* The margins are based on qlineedit.cpp of Qt. Maybe they where changed * at some time in the future. */ QSize sc (fontMetrics().width (aText) + 2*2, fontMetrics().xHeight() + 2*1); QSize sa = style()->sizeFromContents (QStyle::CT_LineEdit, &sof, sc, this); #if defined (Q_WS_WIN32) /* Vista l&f style has a bug where the last parameter of sizeFromContents * function ('widget' what corresponds to 'this' in our class) is ignored. * Due to it QLineEdit processed as QComboBox and size calculation includes * non-existing combo-box button of 23 pix in width. So fixing it here: */ if (qobject_cast <QWindowsVistaStyle*> (style())) { /* Check if l&f style theme is really active else painting performed by * Windows Classic theme and there is no such shifting error. */ typedef bool (*IsAppThemedFunction)(); IsAppThemedFunction isAppThemed = (IsAppThemedFunction) QLibrary::resolve ("uxtheme", "IsAppThemed"); if (isAppThemed && isAppThemed()) sa -= QSize (23, 0); } #endif return sa; }
void FakeToolTip::paintEvent(QPaintEvent *) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); }
void QxtToolTipPrivate::paintEvent(QPaintEvent* event) { Q_UNUSED(event); QStylePainter painter(this); QStyleOptionFrame opt; opt.initFrom(this); painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt); }
void ColorButton::paintEvent(QPaintEvent *ev) { QPushButton::paintEvent(ev); QPainter p(this); // Get contents rectangle QStyleOptionButton opt; initStyleOption(&opt); QRect cRect; if(isFlat()) { // Fill the entire widget area cRect = rect(); } else { // Only fill the contents area cRect = style()->subElementRect(QStyle::SE_PushButtonContents, &opt, this); } cRect.adjust(1, 1, -1, -1); // A little larger padding please // Colour fill if(m_color.alpha() == 255) p.fillRect(cRect, m_color); else { // Separate left and right rectangles QRect lRect = cRect; lRect.setWidth(lRect.width() / 2 + 1); QRect rRect = cRect; rRect.setLeft(lRect.right()); // Fill the left with the solid colour p.fillRect( lRect, QColor(m_color.red(), m_color.green(), m_color.blue())); // Fill the right with the transparent colour on a checkerboard drawCheckerboard(p, rRect, 5, Qt::white, QColor(0xCC, 0xCC, 0xCC)); p.fillRect(rRect, m_color); } // Sunken frame QStyleOptionFrame fOpt; fOpt.initFrom(this); fOpt.rect = cRect; fOpt.features = QStyleOptionFrame::None; fOpt.frameShape = QFrame::Panel; fOpt.lineWidth = 1; fOpt.midLineWidth = 0; fOpt.state |= QStyle::State_Sunken; style()->drawControl(QStyle::CE_ShapedFrame, &fOpt, &p, this); // Fade out when disabled if(!isEnabled()) { QBrush brush = palette().base(); QColor col = brush.color(); col.setAlpha(127); // 50% transparency brush.setColor(col); p.fillRect(cRect, brush); } }
void ToolTip::paintEvent(QPaintEvent *event) { QStylePainter painter(this); QStyleOptionFrame opt; opt.init(this); painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt); painter.end(); QLabel::paintEvent(event); }
void TabPreview::paintEvent(QPaintEvent* pe) { QStyleOptionFrame opt; opt.init(this); QStylePainter painter(this); painter.setClipRegion(pe->region()); painter.drawPrimitive(QStyle::PE_PanelTipLabel, opt); }
void KToolTipWindow::paintEvent(QPaintEvent* event) { QStylePainter painter(this); painter.setClipRegion(event->region()); QStyleOptionFrame option; option.init(this); painter.drawPrimitive(QStyle::PE_PanelTipLabel, option); painter.end(); }
void QwtPlotAbstractCanvas::drawStyled( QPainter *painter, bool hackStyledBackground ) { fillBackground( painter ); if ( hackStyledBackground ) { // Antialiasing rounded borders is done by // inserting pixels with colors between the // border color and the color on the canvas, // When the border is painted before the plot items // these colors are interpolated for the canvas // and the plot items need to be clipped excluding // the anialiased pixels. In situations, where // the plot items fill the area at the rounded // borders this is noticeable. // The only way to avoid these annoying "artefacts" // is to paint the border on top of the plot items. if ( !d_data->styleSheet.hasBorder || d_data->styleSheet.borderPath.isEmpty() ) { // We have no border with at least one rounded corner hackStyledBackground = false; } } QWidget *w = canvasWidget(); if ( hackStyledBackground ) { painter->save(); // paint background without border painter->setPen( Qt::NoPen ); painter->setBrush( d_data->styleSheet.background.brush ); painter->setBrushOrigin( d_data->styleSheet.background.origin ); painter->setClipPath( d_data->styleSheet.borderPath ); painter->drawRect( w->contentsRect() ); painter->restore(); drawCanvas( painter ); // Now paint the border on top QStyleOptionFrame opt; opt.initFrom( w ); w->style()->drawPrimitive( QStyle::PE_Frame, &opt, painter, w); } else { QStyleOption opt; opt.initFrom( w ); w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w ); drawCanvas( painter ); } }
void QgsGradientStopEditor::paintEvent( QPaintEvent *event ) { Q_UNUSED( event ); QPainter painter( this ); QRect frameRect( rect().x() + MARGIN_X, rect().y(), rect().width() - 2 * MARGIN_X, rect().height() - MARGIN_BOTTOM ); //draw frame QStyleOptionFrame option; option.initFrom( this ); option.state = hasFocus() ? QStyle::State_KeyboardFocusChange : QStyle::State_None; option.rect = frameRect; style()->drawPrimitive( QStyle::PE_Frame, &option, &painter ); if ( hasFocus() ) { //draw focus rect QStyleOptionFocusRect option; option.initFrom( this ); option.state = QStyle::State_KeyboardFocusChange; option.rect = frameRect; style()->drawPrimitive( QStyle::PE_FrameFocusRect, &option, &painter ); } //start with the checkboard pattern QBrush checkBrush = QBrush( transparentBackground() ); painter.setBrush( checkBrush ); painter.setPen( Qt::NoPen ); QRect box( frameRect.x() + FRAME_MARGIN, frameRect.y() + FRAME_MARGIN, frameRect.width() - 2 * FRAME_MARGIN, frameRect.height() - 2 * FRAME_MARGIN ); painter.drawRect( box ); // draw gradient preview on top of checkerboard for ( int i = 0; i < box.width() + 1; ++i ) { QPen pen( mGradient.color( static_cast< double >( i ) / box.width() ) ); painter.setPen( pen ); painter.drawLine( box.left() + i, box.top(), box.left() + i, box.height() + 1 ); } // draw stop markers int markerTop = frameRect.bottom() + 1; drawStopMarker( painter, QPoint( box.left(), markerTop ), mGradient.color1(), mSelectedStop == 0 ); drawStopMarker( painter, QPoint( box.right(), markerTop ), mGradient.color2(), mSelectedStop == mGradient.count() - 1 ); int i = 1; Q_FOREACH ( const QgsGradientStop& stop, mStops ) { int x = stop.offset * box.width() + box.left(); drawStopMarker( painter, QPoint( x, markerTop ), stop.color, mSelectedStop == i ); ++i; }
void TipLabel::paintEvent(QPaintEvent* ev) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); SqueezeLabelV1::paintEvent(ev); }
void FileMetaDataToolTip::paintEvent(QPaintEvent* event) { QStylePainter painter(this); QStyleOptionFrame option; option.init(this); painter.drawPrimitive(QStyle::PE_PanelTipLabel, option); painter.end(); QWidget::paintEvent(event); }
void DCursorTracker::paintEvent(QPaintEvent* e) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); QLabel::paintEvent(e); }
void ComboBox::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); p.fillRect( 2, 2, width()-2, height()-4, *s_background ); QColor shadow = palette().shadow().color(); QColor highlight = palette().highlight().color(); shadow.setAlpha( 124 ); highlight.setAlpha( 124 ); // button-separator p.setPen( shadow ); p.drawLine( width() - CB_ARROW_BTN_WIDTH - 1, 1, width() - CB_ARROW_BTN_WIDTH - 1, height() - 3 ); p.setPen( highlight ); p.drawLine( width() - CB_ARROW_BTN_WIDTH, 1, width() - CB_ARROW_BTN_WIDTH, height() - 3 ); // Border QStyleOptionFrame opt; opt.initFrom( this ); opt.state = 0; style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this ); QPixmap * arrow = m_pressed ? s_arrowSelected : s_arrow; p.drawPixmap( width() - CB_ARROW_BTN_WIDTH + 5, 4, *arrow ); if( model() && model()->size() > 0 ) { p.setFont( font() ); p.setClipRect( QRect( 4, 2, width() - CB_ARROW_BTN_WIDTH - 8, height() - 2 ) ); QPixmap pm = model()->currentData() ? model()->currentData()->pixmap() : QPixmap(); int tx = 5; if( !pm.isNull() ) { if( pm.height() > 16 ) { pm = pm.scaledToHeight( 16, Qt::SmoothTransformation ); } p.drawPixmap( tx, 3, pm ); tx += pm.width() + 3; } const int y = ( height()+p.fontMetrics().height() ) /2; p.setPen( QColor( 64, 64, 64 ) ); p.drawText( tx+1, y-3, model()->currentText() ); p.setPen( QColor( 224, 224, 224 ) ); p.drawText( tx, y-4, model()->currentText() ); } }
void KXYSelector::paintEvent( QPaintEvent * /* ev */ ) { QStyleOptionFrame opt; opt.initFrom(this); QPainter painter; painter.begin( this ); drawContents( &painter ); drawMarker( &painter, d->px, d->py ); style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this ); painter.end(); }
void KviThemedComboBox::paintEvent(QPaintEvent * event) { #ifdef COMPILE_PSEUDO_TRANSPARENCY QPainter * p = new QPainter(this); QLineEdit * le = lineEdit(); if(le) { QRect r = rect(); QPalette pal = palette(); QStyleOptionFrame option; option.initFrom(this); option.rect = contentsRect(); option.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, le); option.midLineWidth = 0; option.state |= QStyle::State_Sunken; if(le->isReadOnly()) option.state |= QStyle::State_ReadOnly; option.features = QStyleOptionFrame::None; style()->drawPrimitive(QStyle::PE_FrameLineEdit, &option, p, this); r = style()->subElementRect(QStyle::SE_LineEditContents, &option, le); int left, right, top, bottom; le->getTextMargins(&left, &top, &right, &bottom); r.setX(r.x() + left); r.setY(r.y() + top); r.setRight(r.right() - right); r.setBottom(r.bottom() - bottom); p->setClipRect(r); } // else not editable if(KVI_OPTION_BOOL(KviOption_boolUseCompositingForTransparency) && g_pApp->supportsCompositing()) { p->setCompositionMode(QPainter::CompositionMode_Source); QColor col = KVI_OPTION_COLOR(KviOption_colorGlobalTransparencyFade); col.setAlphaF((float)((float)KVI_OPTION_UINT(KviOption_uintGlobalTransparencyChildFadeFactor) / (float)100)); p->fillRect(contentsRect(), col); } else if(g_pShadedChildGlobalDesktopBackground) { QPoint pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, contentsRect().topLeft()) : mapTo(m_pKviWindow, contentsRect().topLeft()); p->drawTiledPixmap(contentsRect(), *(g_pShadedChildGlobalDesktopBackground), pnt); } delete p; #endif QComboBox::paintEvent(event); }
void ValueSlider::paintEvent(QPaintEvent *) { QPainter painter(this); drawFrame(&painter); QRect rectangle = contentsRect(); QStyleOptionFrame optionFrame; optionFrame.initFrom(this); if (optionFrame.state & QStyle::State_Enabled) { painter.drawPixmap(rectangle.topLeft(), pixMap); DrawTriangle(&painter, trianglePoint); } else { QIcon icon(pixMap); icon.paint(&painter, rectangle, 0, QIcon::Disabled); } }
/*! \internal Updates the frame widths from the style. */ void QFramePrivate::updateStyledFrameWidths() { Q_Q(const QFrame); QStyleOptionFrame opt; opt.initFrom(q); opt.lineWidth = lineWidth; opt.midLineWidth = midLineWidth; opt.frameShape = QFrame::Shape(frameStyle & QFrame::Shape_Mask); QRect cr = q->style()->subElementRect(QStyle::SE_ShapedFrameContents, &opt, q); leftFrameWidth = cr.left() - opt.rect.left(); topFrameWidth = cr.top() - opt.rect.top(); rightFrameWidth = opt.rect.right() - cr.right(), bottomFrameWidth = opt.rect.bottom() - cr.bottom(); frameWidth = qMax(qMax(leftFrameWidth, rightFrameWidth), qMax(topFrameWidth, bottomFrameWidth)); }
/*! Calculate a mask, that can be used to clip away the border frame \param size Size including the frame */ QBitmap QwtPlotCanvas::borderMask( const QSize &size ) const { const QRect r( 0, 0, size.width(), size.height() ); const QPainterPath path = borderPath( r ); if ( path.isEmpty() ) return QBitmap(); QImage image( size, QImage::Format_ARGB32_Premultiplied ); image.fill( Qt::color0 ); QPainter painter( &image ); painter.setClipPath( path ); painter.fillRect( r, Qt::color1 ); // now erase the frame painter.setCompositionMode( QPainter::CompositionMode_DestinationOut ); if ( testAttribute(Qt::WA_StyledBackground ) ) { QStyleOptionFrame opt; opt.initFrom(this); opt.rect = r; style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this ); } else { if ( d_data->borderRadius > 0 && frameWidth() > 0 ) { painter.setPen( QPen( Qt::color1, frameWidth() ) ); painter.setBrush( Qt::NoBrush ); painter.setRenderHint( QPainter::Antialiasing, true ); painter.drawPath( path ); } } painter.end(); const QImage mask = image.createMaskFromColor( QColor( Qt::color1 ).rgb(), Qt::MaskOutColor ); return QBitmap::fromImage( mask ); }
void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.data().canConvert<QColor>()) { QStyleOptionFrame panel; panel.initFrom(option.widget); if (option.widget->isEnabled()) panel.state = QStyle::State_Enabled; panel.rect = option.rect; panel.lineWidth = 2; panel.midLineWidth = 0; panel.state |= QStyle::State_Sunken; option.widget->style()->drawPrimitive(QStyle::PE_Frame, &panel, painter, nullptr); QRect r = option.widget->style()->subElementRect(QStyle::SE_FrameContents, &panel, nullptr); painter->setClipRect(r); painter->fillRect(option.rect, index.data().value<QColor>()); } }
void TreeIndicator::paintEvent(QPaintEvent*) { QStyleOptionFrame frame; frame.init(this); int frameShape = frameStyle() & QFrame::Shape_Mask; int frameShadow = frameStyle() & QFrame::Shadow_Mask; frame.frameShape = Shape(int(frame.frameShape) | frameShape); frame.rect = frameRect(); switch (frameShape) { case QFrame::Box: case QFrame::HLine: case QFrame::VLine: case QFrame::StyledPanel: case QFrame::Panel: frame.lineWidth = lineWidth(); frame.midLineWidth = midLineWidth(); break; default: frame.lineWidth = frameWidth(); break; } if (frameShadow == Sunken) frame.state |= QStyle::State_Sunken; else if (frameShadow == Raised) frame.state |= QStyle::State_Raised; frame.state |= d.state; if (d.lag > 0 && d.state == QStyle::State_None) { qreal f = qMin(100.0, qSqrt(d.lag)) / 100; QColor color = QColor::fromHsl(120 - f * 120, 96, 152); // TODO setStyleSheet(QString("background-color:%1").arg(color.name())); } else { setStyleSheet(QString()); } QStylePainter painter(this); painter.drawPrimitive(QStyle::PE_Widget, frame); painter.drawControl(QStyle::CE_ShapedFrame, frame); }
/*! * \internal */ void HacLed::paintEvent(QPaintEvent * ) { QPainter p(this); QColor bgColor = palette().background().color(); if (d->shape==Circular) { int sidesize = qMin(width(), height()); p.setRenderHint(QPainter::Antialiasing); int rad = sidesize*0.45; QRect r = rect().adjusted((width()-sidesize)/2, (height()-sidesize)/2, -(width()-sidesize)/2, -(height()-sidesize)/2); QRadialGradient grad(rect().center(), rad, rect().center()-QPoint(sidesize*0.1, sidesize*0.1) ); grad.setColorAt(0.0, palette().color(QPalette::Light)); grad.setColorAt(0.75, isChecked() ? d->color : bgColor); p.setBrush(grad); QPen pe = p.pen(); pe.setWidth(d->width); pe.setColor(palette().color(QPalette::Foreground)); p.setPen(pe); p.drawEllipse(r.adjusted(d->width,d->width,-d->width,-d->width)); } else { /*if (d->shape == Rectangular)*/ QStyleOptionFrame opt; opt.initFrom(this); opt.lineWidth = d->width; opt.midLineWidth = d->width; if (d->shape==RectangularRaised) opt.state |= QStyle::State_Raised; else if (d->shape==RectangularSunken) opt.state |= QStyle::State_Sunken; QBrush br(isChecked() ? d->color : bgColor); if (d->shape==RectangularPlain) qDrawPlainRect(&p, opt.rect, opt.palette.foreground().color(), d->width, &br); else qDrawShadePanel(&p, opt.rect, opt.palette, d->shape==RectangularSunken, d->width, &br); } }
void DItemToolTip::paintEvent(QPaintEvent* e) { { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); } QLabel::paintEvent(e); QPainter p(this); if (d->corner >= 4) { return; } QPixmap& pix = d->corners[d->corner]; switch (d->corner) { case 0: p.drawPixmap( 3, 3, pix ); break; case 1: p.drawPixmap( width() - pix.width() - 3, 3, pix ); break; case 2: p.drawPixmap( 3, height() - pix.height() - 3, pix ); break; case 3: p.drawPixmap( width() - pix.width() - 3, height() - pix.height() - 3, pix ); break; } }
void Q3GroupBox::drawFrame(QPainter *p) { QPoint p1, p2; QStyleOptionFrame opt; opt.init(this); int frameShape = d->frameStyle & QFrame::Shape_Mask; int frameShadow = d->frameStyle & QFrame::Shadow_Mask; int lw = 0; int mlw = 0; opt.rect = frameRect(); switch (frameShape) { case QFrame::Box: case QFrame::HLine: case QFrame::VLine: case QFrame::StyledPanel: lw = d->lineWidth; mlw = d->midLineWidth; break; default: // most frame styles do not handle customized line and midline widths // (see updateFrameWidth()). lw = d->frameWidth; break; } opt.lineWidth = lw; opt.midLineWidth = mlw; if (frameShadow == Sunken) opt.state |= QStyle::State_Sunken; else if (frameShadow == Raised) opt.state |= QStyle::State_Raised; switch (frameShape) { case Box: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawShadeRect(p, opt.rect, opt.palette, frameShadow == Sunken, lw, mlw); break; case StyledPanel: style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this); break; case Panel: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawShadePanel(p, opt.rect, opt.palette, frameShadow == Sunken, lw); break; case WinPanel: if (frameShadow == Plain) qDrawPlainRect(p, opt.rect, opt.palette.foreground().color(), lw); else qDrawWinPanel(p, opt.rect, opt.palette, frameShadow == Sunken); break; case HLine: case VLine: if (frameShape == HLine) { p1 = QPoint(opt.rect.x(), opt.rect.height() / 2); p2 = QPoint(opt.rect.x() + opt.rect.width(), p1.y()); } else { p1 = QPoint(opt.rect.x()+opt.rect.width() / 2, 0); p2 = QPoint(p1.x(), opt.rect.height()); } if (frameShadow == Plain) { QPen oldPen = p->pen(); p->setPen(QPen(opt.palette.foreground().color(), lw)); p->drawLine(p1, p2); p->setPen(oldPen); } else { qDrawShadeLine(p, p1, p2, opt.palette, frameShadow == Sunken, lw, mlw); } break; } #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled() && hasFocus()) { QStyleOptionFocusRect fopt; fopt.init(this); fopt.state |= QStyle::State_KeyboardFocusChange; fopt.rect = frameRect(); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &fopt, p, this); } #endif }