/*! \return the bounding rect for the label */ QRect QwtArrowButton::labelRect() const { const int m = Margin; QRect r = rect(); r.setRect(r.x() + m, r.y() + m, r.width() - 2 * m, r.height() - 2 * m); if ( isDown() ) { int ph, pv; #if QT_VERSION < 0x040000 ph = style().pixelMetric( QStyle::PM_ButtonShiftHorizontal, this); pv = style().pixelMetric( QStyle::PM_ButtonShiftVertical, this); r.moveBy(ph, pv); #else QStyleOptionButton option = styleOpt(this); ph = style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &option, this); pv = style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &option, this); r.translate(ph, pv); #endif } return r; }
/*! \return the bounding rect for the label */ QRect QwtArrowButton::labelRect() const { const int m = Margin; QRect r = rect(); r.setRect( r.x() + m, r.y() + m, r.width() - 2 * m, r.height() - 2 * m ); if ( isDown() ) { QStyleOptionButton option = styleOpt( this ); const int ph = style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &option, this ); const int pv = style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &option, this ); r.translate( ph, pv ); } return r; }
void GtkStyle::drawSelection(const QStyleOptionViewItemV4 &opt, QPainter *painter, double opacity) { static const int constMaxDimension=32; static QCache<QString, QPixmap> cache(30000); if (opt.rect.width()<2 || opt.rect.height()<2) { return; } int width=qMin(constMaxDimension, opt.rect.width()); QString key=QString::number(width)+QChar(':')+QString::number(opt.rect.height()); QPixmap *pix=cache.object(key); if (!pix) { pix=new QPixmap(width, opt.rect.height()); QStyleOptionViewItemV4 styleOpt(opt); pix->fill(Qt::transparent); QPainter p(pix); styleOpt.state=opt.state; styleOpt.state&=~(QStyle::State_Selected|QStyle::State_MouseOver); styleOpt.state|=QStyle::State_Selected|QStyle::State_Enabled|QStyle::State_Active; styleOpt.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; styleOpt.rect=QRect(0, 0, opt.rect.width(), opt.rect.height()); QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &styleOpt, &p, 0); p.end(); cache.insert(key, pix, pix->width()*pix->height()); } double opacityB4=painter->opacity(); painter->setOpacity(opacity); if (opt.rect.width()>pix->width()) { int half=qMin(opt.rect.width()>>1, pix->width()>>1); painter->drawPixmap(opt.rect.x(), opt.rect.y(), pix->copy(0, 0, half, pix->height())); if ((half*2)!=opt.rect.width()) { painter->drawTiledPixmap(opt.rect.x()+half, opt.rect.y(), (opt.rect.width()-((2*half))), opt.rect.height(), pix->copy(half-1, 0, 1, pix->height())); } painter->drawPixmap((opt.rect.x()+opt.rect.width())-half, opt.rect.y(), pix->copy(half, 0, half, pix->height())); } else {