Ejemplo n.º 1
0
void QRangeControl::subtractLine()
{
    if ( value() - lineStep() < value() )
	setValue( value() - lineStep() );
    else
	setValue( minValue() );
}
Ejemplo n.º 2
0
void QRangeControl::addLine()
{
    if ( value() + lineStep() > value() )
	setValue( value() + lineStep() );
    else
	setValue( maxValue() );
}
ScrollResultOneDimensional ScrollableArea::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta)
{
    ScrollbarOrientation orientation;
    if (direction == ScrollUp || direction == ScrollDown)
        orientation = VerticalScrollbar;
    else
        orientation = HorizontalScrollbar;

    if (!userInputScrollable(orientation))
        return ScrollResultOneDimensional(false, delta);

    cancelProgrammaticScrollAnimation();

    float step = 0;
    switch (granularity) {
    case ScrollByLine:
        step = lineStep(orientation);
        break;
    case ScrollByPage:
        step = pageStep(orientation);
        break;
    case ScrollByDocument:
        step = documentStep(orientation);
        break;
    case ScrollByPixel:
    case ScrollByPrecisePixel:
        step = pixelStep(orientation);
        break;
    }

    if (direction == ScrollUp || direction == ScrollLeft)
        delta = -delta;

    return scrollAnimator()->userScroll(orientation, granularity, step, delta);
}
Ejemplo n.º 4
0
/*!\reimp
*/
void QSlider::paintEvent( QPaintEvent * )
{

    QPainter p( this );
    const QRect & sliderR = sliderRect();
    const QColorGroup & g = colorGroup();
    int mid = thickness()/2;
    if ( ticks & Above )
	mid += style().sliderLength() / 8;
    if ( ticks & Below )
	mid -= style().sliderLength() / 8;
    if ( orient == Horizontal ) {
	style().drawSliderGroove(&p, 0, tickOffset, width(), thickness(),
				     g, mid, Horizontal );
// 	    p.fillRect( 0, 0, width(), tickOffset, g.background() );
// 	    p.fillRect( 0, tickOffset + thickness(),
// 			width(), height()/*###*/, g.background() );
	erase( 0, 0, width(), tickOffset );
	erase( 0, tickOffset + thickness(), width(), height() );
    }
    else {
	style().drawSliderGroove( &p, tickOffset, 0, thickness(), height(),
				      g, mid, Vertical );
// 	    p.fillRect( 0, 0,  tickOffset, height(), g.background() );
// 	    p.fillRect( tickOffset + thickness(), 0,
// 			width()/*###*/, height(), g.background() );
	erase( 0, 0,  tickOffset, height() );
	erase( tickOffset + thickness(), 0, width()/*###*/, height() );
    }

    int interval = tickInt;
    if ( interval <= 0 ) {
	interval = lineStep();
	if ( positionFromValue( interval ) - positionFromValue( 0 ) < 3 )
	    interval = pageStep();
    }
    if ( ticks & Above )
	drawTicks( &p, g, 0, tickOffset - 2, interval );

    if ( ticks & Below ) {
	int avail = (orient == Horizontal) ? height() : width();
	avail -= tickOffset + thickness();
	drawTicks( &p, g, tickOffset + thickness() + 1, avail - 2, interval );
    }
    if ( hasFocus() ) {
	QRect r;
	if ( orient == Horizontal )
	    r.setRect( 0, tickOffset-1, width(), thickness()+2 );
	else
	    r.setRect( tickOffset-1, 0, thickness()+2, height() );
	r = r.intersect( rect() );
	if (style() == MotifStyle)
	    style().drawFocusRect(&p, QRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2), g);
	else
	    style().drawFocusRect(&p, r, g);
    }
    paintSlider( &p, g, sliderR );

}
Ejemplo n.º 5
0
void KSimBaseIntSpinBox::stepDown()
{
	KSimBaseInt newValue(value());
	int res;
	newValue = newValue.value() - lineStep(); // Base is not changed!

	res = setValueInternal(newValue);
	KSimSpinBox::setValue(res);
}
Ejemplo n.º 6
0
int QDial::notchSize() const
{
    // radius of the arc
    int r = QMIN( width(), height() )/2;
    // length of the whole arc
    int l = (int)(r*(d->wrapping ? 6 : 5)*m_pi/6);
    // length of the arc from minValue() to minValue()+pageStep()
    if ( maxValue() > minValue()+pageStep() )
	l = (int)(0.5 + l * pageStep() / (maxValue()-minValue()));
    // length of a lineStep() arc
    l = l * lineStep() / pageStep();
    if ( l < 1 )
	l = 1;
    // how many times lineStep can be draw in d->target pixels
    l = (int)(0.5 + d->target / l);
    // we want notchSize() to be a non-zero multiple of lineStep()
    if ( !l )
	l = 1;
    return lineStep() * l;
}
Ejemplo n.º 7
0
void AbstractSlider::wheelEvent(QWheelEvent* ev)
      {
      int div = 50;
      if (ev->modifiers() & Qt::ShiftModifier)
            div = 15;
      _value += (ev->delta() * lineStep()) / div;
      if (_value < _minValue)
            _value = _minValue;
      else if (_value > _maxValue)
            _value = _maxValue;
      valueChange();
      }
Ejemplo n.º 8
0
/*!\reimp
*/
void QSlider::wheelEvent( QWheelEvent * e){
    static float offset = 0;
    static QSlider* offset_owner = 0;
    if (offset_owner != this){
	offset_owner = this;
	offset = 0;
    }
    offset += -e->delta()*QMAX(pageStep(),lineStep())/120;
    if (QABS(offset)<1)
	return;
    setValue( value() + int(offset) );
    offset -= int(offset);
}
Ejemplo n.º 9
0
void AbstractSlider::keyPressEvent(QKeyEvent* ev)
      {
      double oval = _value;

      switch (ev->key()) {
            case Qt::Key_Home:    _value = _minValue; break;
            case Qt::Key_End:     _value = _maxValue; break;
            case Qt::Key_Up:
            case Qt::Key_Left:    _value += lineStep(); break;
            case Qt::Key_Down:
            case Qt::Key_Right:   _value -= lineStep(); break;
            case Qt::Key_PageDown: _value -= pageStep(); break;
            case Qt::Key_PageUp:   _value += pageStep(); break;
            default:
                  break;
            }
      if (_value < _minValue)
            _value = _minValue;
      else if (_value > _maxValue)
            _value = _maxValue;
      if (oval != _value)
            valueChange();
      }
Ejemplo n.º 10
0
/*!

 Reimplementation of QWidget::updateMask(). Draws the mask of the
 slider when transparency is required.

 \sa QWidget::setAutoMask()
*/
void QSlider::updateMask()
{
    QBitmap bm( size() );
    bm.fill( color0 );

    {
	QPainter p( &bm, this );
	QRect sliderR = sliderRect();
	QColorGroup g(color1, color1, color1, color1, color1, color1, color1, color1, color0);
	int mid = tickOffset + thickness()/2;
	if ( ticks & Above )
	    mid += style().sliderLength() / 8;
	if ( ticks & Below )
	    mid -= style().sliderLength() / 8;
	if ( orient == Horizontal ) {
	    style().drawSliderGrooveMask(&p, 0, tickOffset, width(), thickness(),
					 mid, Horizontal );
	}
	else {
	    style().drawSliderGrooveMask( &p, tickOffset, 0, thickness(), height(),
					  mid, Vertical );
	}
	style().drawSliderMask( &p, sliderR.x(), sliderR.y(),
				sliderR.width(), sliderR.height(),
				orient, ticks & Above, ticks & Below );

	int interval = tickInt;
	if ( interval <= 0 ) {
	    interval = lineStep();
	    if ( positionFromValue( interval ) - positionFromValue( 0 ) < 3 )
		interval = pageStep();
	}
	if ( ticks & Above )
	    drawTicks( &p, g, 0, tickOffset - 2, interval );

	if ( ticks & Below ) {
	    int avail = (orient == Horizontal) ? height() : width();
	    avail -= tickOffset + thickness();
	    drawTicks( &p, g, tickOffset + thickness() + 1, avail - 2, interval );
	}

    }
    setMask( bm );
}
Ejemplo n.º 11
0
void QDial::setPageStep( int i )
{
    setSteps( lineStep(), i );
}
Ejemplo n.º 12
0
void QRangeControl::subtractLine()
{
    setValue( value() - lineStep() );
}
Ejemplo n.º 13
0
void QRangeControl::addLine()
{
    setValue( value() + lineStep() );
}
Ejemplo n.º 14
0
/*!
  Sets the page step to \e i.

  Calls the virtual stepChange() function if the new page step is
  different from the previous setting.

  \sa pageStep() QRangeControl::setSteps() setLineStep() setRange()
*/
void QSlider::setPageStep( int i )
{
    setSteps( lineStep(), i );
}