Beispiel #1
0
//! Notify changed scale
void QwtSlider::scaleChange()
{
    QwtAbstractSlider::scaleChange();

    if ( testAttribute( Qt::WA_WState_Polished ) )
        layoutSlider( true );
}
Beispiel #2
0
/*!
  \brief Set the orientation.
  \param o Orientation. Allowed values are Qt::Horizontal and Qt::Vertical.

  If the new orientation and the old scale position are an invalid combination,
  the scale position will be set to QwtSlider::NoScale.
  \sa QwtAbstractSlider::orientation()
*/
void QwtSlider::setOrientation( Qt::Orientation o )
{
    if ( o == orientation() )
        return;

    if ( o == Qt::Horizontal )
    {
        if ( d_data->scalePos == LeftScale 
            || d_data->scalePos == RightScale )
        {
            d_data->scalePos = NoScale;
        }
    }
    else // if (o == Qt::Vertical)
    {
        if ( d_data->scalePos == BottomScale || 
            d_data->scalePos == TopScale )
        {
            d_data->scalePos = NoScale;
        }
    }

    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
    {
        QSizePolicy sp = sizePolicy();
        sp.transpose();
        setSizePolicy( sp );

        setAttribute( Qt::WA_WState_OwnSizePolicy, false );
    }

    QwtAbstractSlider::setOrientation( o );
    layoutSlider( true );
}
Beispiel #3
0
/*!
  \brief Set the slider's handle size
  \param size New size

  \sa handleSize()
*/
void QwtSlider::setHandleSize( const QSize &size )
{
    const QSize handleSize = size.expandedTo( QSize( 8, 4 ) );
    if ( handleSize != d_data->handleSize )
    {
        d_data->handleSize = handleSize;
        layoutSlider( true );
    }
}
Beispiel #4
0
/*!
  En/Disable the trough

  The slider can be cutomized by showing a trough for the
  handle.

  \param on When true, the groove is visible
  \sa hasTrough(), setGroove()
 */
void QwtSlider::setTrough( bool on )
{
    if ( d_data->hasTrough != on )
    {
        d_data->hasTrough = on;

        if ( testAttribute( Qt::WA_WState_Polished ) )
            layoutSlider( true );
    }
}
/*!
  \brief Change the scale position (and slider orientation).

  \param s Position of the scale.

  A valid combination of scale position and orientation is enforced:
  - if the new scale position is Left or Right, the scale orientation will
    become Qt::Vertical;
  - if the new scale position is Bottom or Top the scale orientation will
    become Qt::Horizontal;
  - if the new scale position is QwtSlider::NoScale, the scale 
    orientation will not change.
*/
void QwtSlider::setScalePosition(ScalePos s)
{
    d_data->scalePos = s;
    if ((s == BottomScale) || (s == TopScale))
        setOrientation(Qt::Horizontal);
    else if ((s == LeftScale) || (s == RightScale))
        setOrientation(Qt::Vertical);
    else
        layoutSlider();
}
Beispiel #6
0
/*!
  En/Disable the groove

  The slider can be cutomized by showing a groove for the
  handle.

  \param on When true, the groove is visible
  \sa hasGroove(), setThrough()
 */
void QwtSlider::setGroove( bool on )
{
    if ( d_data->hasGroove != on )
    {
        d_data->hasGroove = on;
        
        if ( testAttribute( Qt::WA_WState_Polished ) )
            layoutSlider( true );
    }
}
Beispiel #7
0
//! Notify change of range
void QwtSlider::rangeChange()
{
    d_data->map.setScaleInterval(minValue(), maxValue());

    if (autoScale())
        rescale(minValue(), maxValue());

    QwtAbstractSlider::rangeChange();
    layoutSlider();
}
Beispiel #8
0
/*!
  \brief Set the slider's handle size

  When the size is empty the slider handle will be painted with a
  default size depending on its orientation() and backgroundStyle().

  \param size New size

  \sa handleSize()
*/
void QwtSlider::setHandleSize( const QSize &size )
{
    if ( size != d_data->handleSize )
    {
        d_data->handleSize = size;

        if ( testAttribute( Qt::WA_WState_Polished ) )
            layoutSlider( true );
    }
}
Beispiel #9
0
//! Notify changed scale
void QwtSlider::scaleChange()
{
    if (!hasUserScale())
    {
        scaleDraw()->setScale(minValue(), maxValue(), 
            scaleMaxMajor(), scaleMaxMinor(),
            scaleDraw()->scaleDiv().logScale());
    }

    layoutSlider();
}
Beispiel #10
0
/*!
  \brief Change the spacing between pipe and scale

  A spacing of 0 means, that the backbone of the scale is below
  the trough.

  The default setting is 4 pixels.

  \param spacing Number of pixels
  \sa spacing();
*/
void QwtSlider::setSpacing( int spacing )
{
    if ( spacing <= 0 )
        spacing = 0;

    if ( spacing != d_data->spacing  )
    {
        d_data->spacing = spacing;
        layoutSlider( true );
    }
}
Beispiel #11
0
/*!
   Handles QEvent::StyleChange and QEvent::FontChange events
   \param event Change event
*/
void QwtSlider::changeEvent( QEvent *event )
{
    if ( event->type() == QEvent::StyleChange || 
        event->type() == QEvent::FontChange )
    {
        if ( testAttribute( Qt::WA_WState_Polished ) )
            layoutSlider( true );
    }

    QwtAbstractSlider::changeEvent( event );
}
Beispiel #12
0
/*!
  \brief Change the slider's border width
  \param width Border width
*/
void QwtSlider::setBorderWidth( int width )
{
    if ( width < 0 )
        width = 0;

    if ( width != d_data->borderWidth )
    {
        d_data->borderWidth = width;
        layoutSlider( true );
    }
}
Beispiel #13
0
/*!
  \brief Change the width of the thumb
  \param w new width
*/
void QwtSlider::setThumbWidth(int w)
{
    if ( w < 4 )
        w = 4;

    if ( d_data->thumbWidth != w )
    {
        d_data->thumbWidth = w;
        layoutSlider();
    }
}
Beispiel #14
0
/*!
  \brief Set the slider's thumb length
  \param thumbLength new length
*/
void QwtSlider::setThumbLength(int thumbLength)
{
    if ( thumbLength < 8 )
        thumbLength = 8;

    if ( thumbLength != d_data->thumbLength )
    {
        d_data->thumbLength = thumbLength;
        layoutSlider();
    }
}
Beispiel #15
0
/*!
  \brief Change the slider's border width
  \param bd border width
*/
void QwtSlider::setBorderWidth(int bd)
{
    if ( bd < 0 )
        bd = 0;

    if ( bd != d_data->borderWidth )
    {
        d_data->borderWidth = bd;
        layoutSlider();
    }
}
Beispiel #16
0
/*!
  \brief Set a scale draw

  For changing the labels of the scales, it
  is necessary to derive from QwtScaleDraw and
  overload QwtScaleDraw::label().

  \param scaleDraw ScaleDraw object, that has to be created with 
                   new and will be deleted in ~QwtSlider or the next 
                   call of setScaleDraw().
*/
void QwtSlider::setScaleDraw(QwtScaleDraw *scaleDraw)
{
    const QwtScaleDraw *previousScaleDraw = this->scaleDraw();
    if ( scaleDraw == NULL || scaleDraw == previousScaleDraw )
        return;

    if ( previousScaleDraw )
        scaleDraw->setAlignment(previousScaleDraw->alignment());

    setAbstractScaleDraw(scaleDraw);
    layoutSlider();
}
Beispiel #17
0
/*!
  \brief Change the position of the scale
  \param scalePosition Position of the scale.

  \sa ScalePosition, scalePosition()
*/
void QwtSlider::setScalePosition( ScalePosition scalePosition )
{
    if ( d_data->scalePosition == scalePosition )
        return;

    d_data->scalePosition = scalePosition;
    scaleDraw()->setAlignment( 
        qwtScaleDrawAlignment( d_data->orientation, scalePosition ) );

    if ( testAttribute( Qt::WA_WState_Polished ) )
        layoutSlider( true );
}
Beispiel #18
0
//! Qt change event handler
void QwtSlider::changeEvent( QEvent *event )
{
    switch( event->type() )
    {
        case QEvent::StyleChange:
        case QEvent::FontChange:
            layoutSlider( true );
            break;
        default: 
            break;
    }
}
Beispiel #19
0
/*!
  \brief Change the spacing between trough and scale

  A spacing of 0 means, that the backbone of the scale is covered
  by the trough.

  The default setting is 4 pixels.

  \param spacing Number of pixels
  \sa spacing();
*/
void QwtSlider::setSpacing( int spacing )
{
    if ( spacing <= 0 )
        spacing = 0;

    if ( spacing != d_data->spacing  )
    {
        d_data->spacing = spacing;

        if ( testAttribute( Qt::WA_WState_Polished ) )
            layoutSlider( true );
    }
}
Beispiel #20
0
/*!
  \brief Change the slider's border width

  The border width is used for drawing the slider handle and the
  trough.

  \param width Border width
  \sa borderWidth()
*/
void QwtSlider::setBorderWidth( int width )
{
    if ( width < 0 )
        width = 0;

    if ( width != d_data->borderWidth )
    {
        d_data->borderWidth = width;

        if ( testAttribute( Qt::WA_WState_Polished ) )
            layoutSlider( true );
    }
}
Beispiel #21
0
/*!
  \brief Set distances between the widget's border and internals.
  \param xMargin Horizontal margin
  \param yMargin Vertical margin
*/
void QwtSlider::setMargins(int xMargin, int yMargin)
{
    if ( xMargin < 0 )
        xMargin = 0;
    if ( yMargin < 0 )
        yMargin = 0;

    if ( xMargin != d_data->xMargin || yMargin != d_data->yMargin )
    {
        d_data->xMargin = xMargin;
        d_data->yMargin = yMargin;
        layoutSlider();
    }
}
Beispiel #22
0
/*!
  \brief Set a scale draw

  For changing the labels of the scales, it
  is necessary to derive from QwtScaleDraw and
  overload QwtScaleDraw::label().

  \param scaleDraw ScaleDraw object, that has to be created with
                   new and will be deleted in ~QwtSlider() or the next
                   call of setScaleDraw().

  \sa scaleDraw()
*/
void QwtSlider::setScaleDraw( QwtScaleDraw *scaleDraw )
{
    const QwtScaleDraw *previousScaleDraw = this->scaleDraw();
    if ( scaleDraw == NULL || scaleDraw == previousScaleDraw )
        return;

    if ( previousScaleDraw )
        scaleDraw->setAlignment( previousScaleDraw->alignment() );

    setAbstractScaleDraw( scaleDraw );

    if ( testAttribute( Qt::WA_WState_Polished ) )
        layoutSlider( true );
}
Beispiel #23
0
/*!
  \brief Set the orientation.
  \param o Orientation. Allowed values are Qt::Horizontal and Qt::Vertical.
  
  If the new orientation and the old scale position are an invalid combination,
  the scale position will be set to None.
  \sa QwtSliderBase::orientation()
*/
void QwtSlider::setOrientation(Qt::Orientation o) 
{
    if (o == Qt::Horizontal)
    {
        if ((d_scalePos == Left) || (d_scalePos == Right))
            d_scalePos = None;
    }
    else // if (o == Qt::Vertical)
    {
        if ((d_scalePos == Bottom) || (d_scalePos == Top))
            d_scalePos = None;
    }
    QwtSliderBase::setOrientation(o);
    layoutSlider();
}
Beispiel #24
0
/*!
  \brief Change the scale position (and slider orientation).

  \param s Position of the scale.

  A valid combination of scale position and orientation is enforced:
  - if the new scale position is Left or Right, the scale orientation will
    become Qt::Vertical;
  - if the new scale position is Bottom or Top the scale orientation will
    become Qt::Horizontal;
  - if the new scale position is QwtSlider::NoScale, the scale 
    orientation will not change.
*/
void QwtSlider::setScalePosition(ScalePos s)
{
    if ( d_data->scalePos == s )
        return;

    d_data->scalePos = s;

    switch(d_data->scalePos)
    {
        case BottomScale:
        {
            setOrientation(Qt::Horizontal);
            scaleDraw()->setAlignment(QwtScaleDraw::BottomScale);
            break;
        }
        case TopScale:
        {
            setOrientation(Qt::Horizontal);
            scaleDraw()->setAlignment(QwtScaleDraw::TopScale);
            break;
        }
        case LeftScale:
        {
            setOrientation(Qt::Vertical);
            scaleDraw()->setAlignment(QwtScaleDraw::LeftScale);
            break;
        }
        case RightScale:
        {
            setOrientation(Qt::Vertical);
            scaleDraw()->setAlignment(QwtScaleDraw::RightScale);
            break;
        }
        default:
        {
            // nothing
        }
    }

    layoutSlider();
}
Beispiel #25
0
/*!
  \brief Set the orientation.
  \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.

  \sa orientation(), scalePosition()
*/
void QwtSlider::setOrientation( Qt::Orientation orientation )
{
    if ( orientation == d_data->orientation )
        return;

    d_data->orientation = orientation;

    scaleDraw()->setAlignment( 
        qwtScaleDrawAlignment( orientation, d_data->scalePosition ) );

    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
    {
        QSizePolicy sp = sizePolicy();
        sp.transpose();
        setSizePolicy( sp );

        setAttribute( Qt::WA_WState_OwnSizePolicy, false );
    }

    if ( testAttribute( Qt::WA_WState_Polished ) )
        layoutSlider( true );
}
Beispiel #26
0
/*!
  \brief Set the orientation.
  \param o Orientation. Allowed values are Qt::Horizontal and Qt::Vertical.
  
  If the new orientation and the old scale position are an invalid combination,
  the scale position will be set to QwtSlider::NoScale.
  \sa QwtAbstractSlider::orientation()
*/
void QwtSlider::setOrientation(Qt::Orientation o) 
{
    if ( o == orientation() )
        return;

    if (o == Qt::Horizontal)
    {
        if ((d_data->scalePos == LeftScale) || (d_data->scalePos == RightScale))
            d_data->scalePos = NoScale;
    }
    else // if (o == Qt::Vertical)
    {
        if ((d_data->scalePos == BottomScale) || (d_data->scalePos == TopScale))
            d_data->scalePos = NoScale;
    }

#if QT_VERSION >= 0x040000
    if ( !testAttribute(Qt::WA_WState_OwnSizePolicy) )
#else
    if ( !testWState( WState_OwnSizePolicy ) ) 
#endif
    {
        QSizePolicy sp = sizePolicy();
        sp.transpose();
        setSizePolicy(sp);

#if QT_VERSION >= 0x040000
        setAttribute(Qt::WA_WState_OwnSizePolicy, false);
#else
        clearWState( WState_OwnSizePolicy );
#endif
    }

    QwtAbstractSlider::setOrientation(o);
    layoutSlider();
}
Beispiel #27
0
/*!
  Set the background style.
*/
void QwtSlider::setBgStyle(BGSTYLE st) 
{
    d_data->bgStyle = st; 
    layoutSlider();
}
Beispiel #28
0
//! Qt resize event
void QwtSlider::resizeEvent(QResizeEvent *)
{
    layoutSlider( false );
}
Beispiel #29
0
//! Notify change in font
void QwtSlider::fontChange(const QFont &f)
{
    QwtAbstractSlider::fontChange( f );
    layoutSlider();
}
Beispiel #30
0
//! Notify changed scale
void QwtSlider::scaleChange()
{
    layoutSlider();
}