14 #include <qstyleoption.h> 16 #include <qapplication.h> 31 QStyleOptionButton option;
33 option.features = QStyleOptionButton::None;
35 option.features |= QStyleOptionButton::Flat;
37 option.features |= QStyleOptionButton::HasMenu;
38 if ( btn->autoDefault() || btn->isDefault() )
39 option.features |= QStyleOptionButton::AutoDefaultButton;
40 if ( btn->isDefault() )
41 option.features |= QStyleOptionButton::DefaultButton;
43 option.state |= QStyle::State_Sunken;
44 if ( !btn->isFlat() && !btn->isDown() )
45 option.state |= QStyle::State_Raised;
56 Qt::ArrowType
arrowType, QWidget *parent ):
63 setAutoRepeat(
true );
64 setAutoDefault(
false );
70 setSizePolicy( QSizePolicy::Expanding,
74 setSizePolicy( QSizePolicy::Fixed,
75 QSizePolicy::Expanding );
110 r.setRect( r.x() + m, r.y() + m,
111 r.width() - 2 * m, r.height() - 2 * m );
115 QStyleOptionButton option =
styleOpt(
this );
116 const int ph = style()->pixelMetric(
117 QStyle::PM_ButtonShiftHorizontal, &option,
this );
118 const int pv = style()->pixelMetric(
119 QStyle::PM_ButtonShiftVertical, &option,
this );
121 r.translate( ph, pv );
133 QPushButton::paintEvent( event );
134 QPainter painter(
this );
152 boundingSize.transpose();
158 QSize( w, boundingSize.height() ) );
166 contentsSize.setWidth(
d_data->
num * arrow.width()
168 contentsSize.setHeight( arrow.height() );
172 contentsSize.setWidth( arrow.width() );
173 contentsSize.setHeight(
d_data->
num * arrow.height()
177 QRect arrowRect( contentsSize );
178 arrowRect.moveCenter( r.center() );
179 arrowRect.setSize( arrow );
194 arrowRect.translate( dx, dy );
200 QStyleOptionFocusRect option;
202 option.backgroundColor = palette().color( QPalette::Window );
204 style()->drawPrimitive( QStyle::PE_FrameFocusRect,
205 &option, painter,
this );
217 const QRect &r, Qt::ArrowType
arrowType )
const 224 pa.setPoint( 0, r.bottomLeft() );
225 pa.setPoint( 1, r.bottomRight() );
226 pa.setPoint( 2, r.center().x(), r.top() );
229 pa.setPoint( 0, r.topLeft() );
230 pa.setPoint( 1, r.topRight() );
231 pa.setPoint( 2, r.center().x(), r.bottom() );
234 pa.setPoint( 0, r.topLeft() );
235 pa.setPoint( 1, r.bottomLeft() );
236 pa.setPoint( 2, r.right(), r.center().y() );
239 pa.setPoint( 0, r.topRight() );
240 pa.setPoint( 1, r.bottomRight() );
241 pa.setPoint( 2, r.left(), r.center().y() );
249 painter->setRenderHint( QPainter::Antialiasing,
true );
250 painter->setPen( Qt::NoPen );
251 painter->setBrush( palette().brush( QPalette::ButtonText ) );
252 painter->drawPolygon( pa );
263 return hint.expandedTo( QApplication::globalStrut() );
271 const QSize asz =
arrowSize( Qt::RightArrow, QSize() );
281 QStyleOption styleOption;
282 styleOption.init(
this );
284 sz = style()->sizeFromContents( QStyle::CT_PushButton,
285 &styleOption, sz,
this );
298 const QSize &boundingSize )
const 300 QSize bs = boundingSize;
301 if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
304 const int MinLen = 2;
305 const QSize sz = bs.expandedTo(
306 QSize( MinLen, 2 * MinLen - 1 ) );
311 if ( h > sz.height() )
317 QSize arrSize( w, h );
318 if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
329 if ( event->isAutoRepeat() &&
event->key() == Qt::Key_Space )
332 QPushButton::keyPressEvent( event );
TFSIMD_FORCE_INLINE const tfScalar & w() const