bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { QStyle* style = 0; QPainter* painter = 0; QWidget* widget = 0; if (!getStylePainterAndWidgetFromPaintInfo(i, style, painter, widget)) return true; QStyleOptionFrameV2 panel; panel.initFrom(widget); panel.rect = r; panel.state |= QStyle::State_Sunken; panel.features = QStyleOptionFrameV2::None; // Get the correct theme data for a button EAppearance appearance = applyTheme(panel, o); Q_ASSERT(appearance == TextFieldAppearance); // Now paint the text field. style->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, painter, widget); style->drawPrimitive(QStyle::PE_FrameLineEdit, &panel, painter, widget); return false; }
void KviThemedLabel::paintEvent(QPaintEvent *e) { #ifdef COMPILE_PSEUDO_TRANSPARENCY QPainter *p = new QPainter(this); #if (QT_VERSION >= 0x050000) // In Qt5 QStyle::drawPrimitive seems to always overwrite the background, no matter what. qDrawShadePanel(p,0,0,width(),height(),palette(),true,1,NULL); QRect r(1,1,width()-1,height()-1); #else QStyleOptionFrameV2 option; option.initFrom(this); style()->drawPrimitive(QStyle::PE_FrameLineEdit, &option, p, this); QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &option, this); #endif 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(r, col); } else if(g_pShadedChildGlobalDesktopBackground) { QPoint pnt = m_pKviWindow->isDocked() ? mapTo(g_pMainWindow, r.topLeft()) : mapTo(m_pKviWindow, r.topLeft()); p->drawTiledPixmap(r,*(g_pShadedChildGlobalDesktopBackground), pnt); } delete p; #endif QLabel::paintEvent(e); }
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(); #if QT_VERSION < 0x050000 QStyleOptionFrameV2 opt; #else QStyleOptionFrame opt; #endif 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(); } }
bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { StylePainter p(i); if (!p.isValid()) return true; QStyleOptionFrameV2 panel; if (p.widget) panel.initFrom(p.widget); panel.rect = r; panel.lineWidth = p.style->pixelMetric(QStyle::PM_DefaultFrameWidth, &panel, p.widget); panel.state |= QStyle::State_Sunken; panel.features = QStyleOptionFrameV2::None; // Get the correct theme data for a text field EAppearance appearance = applyTheme(panel, o); if (appearance != TextFieldAppearance && appearance != SearchFieldAppearance && appearance != TextAreaAppearance && appearance != ListboxAppearance) return true; // Now paint the text field. p.drawPrimitive(QStyle::PE_PanelLineEdit, panel); return false; }
bool RenderThemeQt::paintTextField(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r) { StylePainter p(this, i); if (!p.isValid()) return true; QStyleOptionFrameV2 panel; if (p.widget) panel.initFrom(p.widget); panel.rect = r; panel.lineWidth = findFrameLineWidth(qStyle()); panel.state |= QStyle::State_Sunken; panel.features = QStyleOptionFrameV2::None; // Get the correct theme data for a text field ControlPart appearance = applyTheme(panel, o); if (appearance != TextFieldPart && appearance != SearchFieldPart && appearance != TextAreaPart && appearance != ListboxPart) return true; // Now paint the text field. p.drawPrimitive(QStyle::PE_PanelLineEdit, panel); return false; }
QSize v_singlelineTextEdit::sizeHint() const{ QFontMetrics fm(font()); int h = qMax(fm.height(), 14) + 4; int w = fm.width(QLatin1Char('x')) * 17 + 4; QStyleOptionFrameV2 opt; opt.initFrom(this); return (style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(w, h))); }
QSize CodeLineEdit::sizeHint() const { QFontMetrics fm(font()); int h = qMax(fm.height(), 14) + 4; int w = fm.width(QLatin1Char('x')) * 17 + 4; QStyleOptionFrameV2 opt; opt.initFrom(this); return (style()->sizeFromContents( QStyle::CT_LineEdit, &opt, QSize(w, h).expandedTo(QApplication::globalStrut()), this)); }
/*! \internal Updates the frame widths from the style. */ void Q3GroupBoxPrivate::updateStyledFrameWidths() { QStyleOptionFrameV2 opt; opt.initFrom(q); QRect cr = q->style()->subElementRect(QStyle::SE_FrameContents, &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)); }
void KexiRecordNavigator::paintEvent(QPaintEvent* pe) { QWidget::paintEvent(pe); QPainter p(this); // add frame on top QStyleOptionFrameV2 option; option.initFrom(this); option.features = QStyleOptionFrameV2::Flat; option.rect = QRect(option.rect.left() - 5, option.rect.top(), option.rect.width() + 10, option.rect.height() + 5); // to avoid rounding style()->drawPrimitive(QStyle::PE_Frame, &option, &p, this); }
QSize KviTopicWidget::sizeHint() const { QFontMetrics fm(font()); int h = qMax(fm.height(), 14) + 2 * (KVI_INPUT_MARGIN + KVI_INPUT_XTRAPADDING); int w = fm.width(QLatin1Char('x')) * 17 + 2 * (KVI_INPUT_MARGIN + KVI_INPUT_XTRAPADDING); QStyleOptionFrameV2 option; option.initFrom(this); option.rect = rect(); option.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, this); option.midLineWidth = 0; option.state |= QStyle::State_Sunken; option.features = QStyleOptionFrameV2::None; return (style()->sizeFromContents(QStyle::CT_LineEdit, &option, QSize(w, h).expandedTo(QApplication::globalStrut()), this)); }
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(); QStyleOptionFrameV2 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 = QStyleOptionFrameV2::None; 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->mdiParent() ? mapTo(g_pMainWindow, contentsRect().topLeft() + g_pMainWindow->mdiManager()->scrollBarsOffset()) : mapTo(m_pKviWindow, contentsRect().topLeft()); p->drawTiledPixmap(contentsRect(),*(g_pShadedChildGlobalDesktopBackground), pnt); } delete p; #endif QComboBox::paintEvent(event); }