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();
343 if ( m_data->isScrolling )
348 double increment = 0.0;
350 if ( ( event->modifiers() & Qt::ControlModifier ) ||
351 ( event->modifiers() & Qt::ShiftModifier ) )
354 increment = m_data->singleStep * m_data->pageStepCount;
355 if ( wheelDelta < 0 )
356 increment = -increment;
360 const int numSteps = wheelDelta / 120;
361 increment = m_data->singleStep * numSteps;
364 if ( m_data->orientation == Qt::Vertical && m_data->inverted )
365 increment = -increment;
367 double value = boundedValue( m_data->value + increment );
369 if ( m_data->stepAlignment )
372 if (
value != m_data->value )
374 m_data->value =
value;
411 if ( m_data->isScrolling )
417 double value = m_data->value;
418 double increment = 0.0;
420 switch ( event->key() )
424 if ( m_data->orientation == Qt::Vertical && m_data->inverted )
425 increment = m_data->singleStep;
427 increment = -m_data->singleStep;
433 if ( m_data->orientation == Qt::Vertical && m_data->inverted )
434 increment = -m_data->singleStep;
436 increment = m_data->singleStep;
442 if ( m_data->orientation == Qt::Horizontal )
444 if ( m_data->inverted )
445 increment = m_data->singleStep;
447 increment = -m_data->singleStep;
453 if ( m_data->orientation == Qt::Horizontal )
455 if ( m_data->inverted )
456 increment = -m_data->singleStep;
458 increment = m_data->singleStep;
464 increment = m_data->pageStepCount * m_data->singleStep;
467 case Qt::Key_PageDown:
469 increment = -m_data->pageStepCount * m_data->singleStep;
474 value = m_data->minimum;
479 value = m_data->maximum;
488 if ( event->isAccepted() )
491 if ( increment != 0.0 )
493 value = boundedValue( m_data->value + increment );
495 if ( m_data->stepAlignment )
499 if (
value != m_data->value )
501 m_data->value =
value;
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 ),
781 m_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap );
782 const QPen darkPen( pal.color( QPalette::Dark ),
783 m_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap );
785 const double bw2 = 0.5 * m_data->wheelBorderWidth;
787 if ( m_data->orientation == Qt::Horizontal )
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() ) );
819 const double range = m_data->maximum - m_data->minimum;
821 if ( range == 0.0 || m_data->totalAngle == 0.0 )
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 );
831 const double cnvFactor = qAbs( m_data->totalAngle / range );
832 const double halfIntv = 0.5 * m_data->viewAngle / cnvFactor;
833 const double loValue =
value() - halfIntv;
834 const double hiValue =
value() + halfIntv;
835 const double tickWidth = 360.0 / double( m_data->tickCount ) / cnvFactor;
836 const double sinArc = qFastSin( m_data->viewAngle * M_PI / 360.0 );
838 if ( m_data->orientation == Qt::Horizontal )
840 const double radius = rect.width() * 0.5;
842 double l1 = rect.top() + m_data->wheelBorderWidth;
843 double l2 = rect.bottom() - m_data->wheelBorderWidth - 1;
846 if ( m_data->wheelBorderWidth > 1 )
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 )
859 const double angle = qwtRadians( tickValue -
value() );
860 const double s = qFastSin( angle * cnvFactor );
862 const double off = radius * ( sinArc + s ) / sinArc;
865 if ( m_data->inverted )
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;
885 double l1 = rect.left() + m_data->wheelBorderWidth;
886 double l2 = rect.right() - m_data->wheelBorderWidth - 1;
888 if ( m_data->wheelBorderWidth > 1 )
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 )
900 const double angle = qwtRadians( tickValue -
value() );
901 const double s = qFastSin( angle * cnvFactor );
903 const double off = radius * ( sinArc + s ) / sinArc;
907 if ( m_data->inverted )
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 ) );