16 #include <qdrawutil.h>
19 #include <qstyleoption.h>
20 #include <qelapsedtimer.h>
97 setFocusPolicy( Qt::StrongFocus );
98 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
99 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
193 double mouseValue =
valueAt( event->pos() );
202 ms = qMax( ms, 5.0 );
246 bool startFlying =
false;
251 if ( ( std::fabs(
m_data->
speed ) > 0.0 ) && ( ms < 50 ) )
287 QWidget::timerEvent( event );
326 #if QT_VERSION < 0x050e00
327 const QPoint wheelPos =
event->pos();
328 const int wheelDelta =
event->delta();
330 const QPoint wheelPos =
event->position().toPoint();
332 const QPoint delta =
event->angleDelta();
333 const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) )
334 ? delta.x() : delta.y();
348 double increment = 0.0;
350 if ( ( event->modifiers() & Qt::ControlModifier ) ||
351 ( event->modifiers() & Qt::ShiftModifier ) )
355 if ( wheelDelta < 0 )
356 increment = -increment;
360 const int numSteps = wheelDelta / 120;
365 increment = -increment;
418 double increment = 0.0;
420 switch ( event->key() )
467 case Qt::Key_PageDown:
488 if ( event->isAccepted() )
491 if ( increment != 0.0 )
553 const int d = qMin( width(), height() ) / 3;
597 return contentsRect().adjusted( bw, bw, -bw, -bw );
644 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
646 QSizePolicy sp = sizePolicy();
650 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
705 dx = rect.top() - pos.y();
710 dx = pos.x() - rect.left();
738 QPainter painter(
this );
739 painter.setClipRegion( event->region() );
743 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
745 qDrawShadePanel( &painter,
762 QPainter* painter,
const QRectF& rect )
766 QPalette pal = palette();
769 QLinearGradient gradient( rect.topLeft(),
770 (
m_data->
orientation == Qt::Horizontal ) ? rect.topRight() : rect.bottomLeft() );
771 gradient.setColorAt( 0.0, pal.color( QPalette::Button ) );
772 gradient.setColorAt( 0.2, pal.color( QPalette::Midlight ) );
773 gradient.setColorAt( 0.7, pal.color( QPalette::Mid ) );
774 gradient.setColorAt( 1.0, pal.color( QPalette::Dark ) );
776 painter->fillRect( rect, gradient );
780 const QPen lightPen( palette().
color( QPalette::Light ),
782 const QPen darkPen( pal.color( QPalette::Dark ),
789 painter->setPen( lightPen );
790 painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ),
791 QPointF( rect.right(), rect.top() + bw2 ) );
793 painter->setPen( darkPen );
794 painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ),
795 QPointF( rect.right(), rect.bottom() - bw2 ) );
799 painter->setPen( lightPen );
800 painter->drawLine( QPointF( rect.left() + bw2, rect.top() ),
801 QPointF( rect.left() + bw2, rect.bottom() ) );
803 painter->setPen( darkPen );
804 painter->drawLine( QPointF( rect.right() - bw2, rect.top() ),
805 QPointF( rect.right() - bw2, rect.bottom() ) );
826 const QPen lightPen( palette().
color( QPalette::Light ),
827 0, Qt::SolidLine, Qt::FlatCap );
828 const QPen darkPen( palette().
color( QPalette::Dark ),
829 0, Qt::SolidLine, Qt::FlatCap );
833 const double loValue =
value() - halfIntv;
834 const double hiValue =
value() + halfIntv;
835 const double tickWidth = 360.0 / double(
m_data->
tickCount ) / cnvFactor;
840 const double radius = rect.width() * 0.5;
852 const double maxpos = rect.right() - 2;
853 const double minpos = rect.left() + 2;
856 for (
double tickValue = std::ceil( loValue / tickWidth ) * tickWidth;
857 tickValue < hiValue; tickValue += tickWidth )
860 const double s = qFastSin( angle * cnvFactor );
862 const double off = radius * ( sinArc +
s ) / sinArc;
866 tickPos = rect.left() + off;
868 tickPos = rect.right() - off;
870 if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
872 painter->setPen( darkPen );
873 painter->drawLine( QPointF( tickPos - 1, l1 ),
874 QPointF( tickPos - 1, l2 ) );
875 painter->setPen( lightPen );
876 painter->drawLine( QPointF( tickPos, l1 ),
877 QPointF( tickPos, l2 ) );
883 const double radius = rect.height() * 0.5;
894 const double maxpos = rect.bottom() - 2;
895 const double minpos = rect.top() + 2;
897 for (
double tickValue = std::ceil( loValue / tickWidth ) * tickWidth;
898 tickValue < hiValue; tickValue += tickWidth )
901 const double s = qFastSin( angle * cnvFactor );
903 const double off = radius * ( sinArc +
s ) / sinArc;
908 tickPos = rect.bottom() - off;
910 tickPos = rect.top() + off;
912 if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
914 painter->setPen( darkPen );
915 painter->drawLine( QPointF( l1, tickPos - 1 ),
916 QPointF( l2, tickPos - 1 ) );
917 painter->setPen( lightPen );
918 painter->drawLine( QPointF( l1, tickPos ),
919 QPointF( l2, tickPos ) );
1262 if ( value < m_data->
minimum )
1283 if ( stepSize > 0.0 )
1288 if ( stepSize > 1e-12 )
1290 if ( qFuzzyCompare(
value + 1.0, 1.0 ) )
1307 #include "moc_qwt_wheel.cpp"