/*! \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); } }
/*! \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); }
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 ); }
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); }
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 FakeToolTip::paintEvent(QPaintEvent *) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); }
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 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 TipLabel::paintEvent(QPaintEvent* ev) { QStylePainter p(this); QStyleOptionFrame opt; opt.init(this); p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); p.end(); SqueezeLabelV1::paintEvent(ev); }
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); }
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 }
void Frame::drawFrame(QPainter *p) { QPoint p1, p2; QStyleOptionFrame opt; opt.init(this); if ( hasFocus() ) { opt.state |= QStyle::State_HasFocus; } int frameShape = frameStyle() & QFrame::Shape_Mask; int frameShadow = 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 = lineWidth(); mlw = midLineWidth(); break; default: // most frame styles do not handle customized line and midline widths // (see updateFrameWidth()). lw = 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; } }