Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_slider.cpp


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_slider.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1212#include "qwt_scale_draw.h"
    1313#include "qwt_scale_map.h"
     14#include "qwt_math.h"
     15#include "qwt.h"
     16
    1417#include <qevent.h>
    1518#include <qdrawutil.h>
    1619#include <qpainter.h>
    17 #include <qalgorithms.h>
    18 #include <qmath.h>
    1920#include <qstyle.h>
    2021#include <qstyleoption.h>
    21 #include <qapplication.h>
    22 
    23 static QSize qwtHandleSize( const QSize &size,
     22#include <qmargins.h>
     23
     24static QSize qwtHandleSize( const QSize& size,
    2425    Qt::Orientation orientation, bool hasTrough )
    2526{
    … …  
    6970class QwtSlider::PrivateData
    7071{
    71 public:
    72     PrivateData():
    73         repeatTimerId( 0 ),
    74         updateInterval( 150 ),
    75         stepsIncrement( 0 ),
    76         pendingValueChange( false ),
    77         borderWidth( 2 ),
    78         spacing( 4 ),
    79         scalePosition( QwtSlider::TrailingScale ),
    80         hasTrough( true ),
    81         hasGroove( false ),
    82         mouseOffset( 0 )
     72  public:
     73    PrivateData()
     74        : repeatTimerId( 0 )
     75        , updateInterval( 150 )
     76        , stepsIncrement( 0 )
     77        , pendingValueChange( false )
     78        , borderWidth( 2 )
     79        , spacing( 4 )
     80        , scalePosition( QwtSlider::TrailingScale )
     81        , hasTrough( true )
     82        , hasGroove( false )
     83        , mouseOffset( 0 )
    8384    {
    8485    }
    … …  
    107108};
    108109/*!
    109   Construct vertical slider in QwtSlider::Trough style
    110   with a scale to the left.
    111 
    112   The scale is initialized to [0.0, 100.0] and the value set to 0.0.
    113 
    114   \param parent Parent widget
    115 
    116   \sa setOrientation(), setScalePosition(), setBackgroundStyle()
    117 */
    118 QwtSlider::QwtSlider( QWidget *parent ):
    119     QwtAbstractSlider( parent )
     110   Construct vertical slider in QwtSlider::Trough style
     111   with a scale to the left.
     112
     113   The scale is initialized to [0.0, 100.0] and the value set to 0.0.
     114
     115   \param parent Parent widget
     116
     117   \sa setOrientation(), setScalePosition(), setBackgroundStyle()
     118 */
     119QwtSlider::QwtSlider( QWidget* parent )
     120    : QwtAbstractSlider( parent )
    120121{
    121122    initSlider( Qt::Vertical );
    … …  
    123124
    124125/*!
    125   Construct a slider in QwtSlider::Trough style
    126 
    127   When orientation is Qt::Vertical the scale will be aligned to
    128   the left - otherwise at the the top of the slider.
    129 
    130   The scale is initialized to [0.0, 100.0] and the value set to 0.0.
    131 
    132   \param parent Parent widget
    133   \param orientation Orientation of the slider.
    134 */
    135 QwtSlider::QwtSlider( Qt::Orientation orientation, QWidget *parent ):
    136     QwtAbstractSlider( parent )
     126   Construct a slider in QwtSlider::Trough style
     127
     128   When orientation is Qt::Vertical the scale will be aligned to
     129   the left - otherwise at the the top of the slider.
     130
     131   The scale is initialized to [0.0, 100.0] and the value set to 0.0.
     132
     133   \param parent Parent widget
     134   \param orientation Orientation of the slider.
     135 */
     136QwtSlider::QwtSlider( Qt::Orientation orientation, QWidget* parent )
     137    : QwtAbstractSlider( parent )
    137138{
    138139    initSlider( orientation );
    … …  
    142143QwtSlider::~QwtSlider()
    143144{
    144     delete d_data;
     145    delete m_data;
    145146}
    146147
    … …  
    154155    setAttribute( Qt::WA_WState_OwnSizePolicy, false );
    155156
    156     d_data = new QwtSlider::PrivateData;
    157 
    158     d_data->orientation = orientation;
     157    m_data = new QwtSlider::PrivateData;
     158
     159    m_data->orientation = orientation;
    159160
    160161    scaleDraw()->setAlignment(
    161         qwtScaleDrawAlignment( orientation, d_data->scalePosition ) );
     162        qwtScaleDrawAlignment( orientation, m_data->scalePosition ) );
    162163    scaleDraw()->setLength( 100 );
    163164
    … …  
    167168
    168169/*!
    169   \brief Set the orientation.
    170   \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.
    171 
    172   \sa orientation(), scalePosition()
    173 */
     170   \brief Set the orientation.
     171   \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.
     172
     173   \sa orientation(), scalePosition()
     174 */
    174175void QwtSlider::setOrientation( Qt::Orientation orientation )
    175176{
    176     if ( orientation == d_data->orientation )
     177    if ( orientation == m_data->orientation )
    177178        return;
    178179
    179     d_data->orientation = orientation;
     180    m_data->orientation = orientation;
    180181
    181182    scaleDraw()->setAlignment(
    182         qwtScaleDrawAlignment( orientation, d_data->scalePosition ) );
     183        qwtScaleDrawAlignment( orientation, m_data->scalePosition ) );
    183184
    184185    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
    … …  
    196197
    197198/*!
    198   \return Orientation
    199   \sa setOrientation()
    200 */
     199   \return Orientation
     200   \sa setOrientation()
     201 */
    201202Qt::Orientation QwtSlider::orientation() const
    202203{
    203     return d_data->orientation;
    204 }
    205 
    206 /*!
    207   \brief Change the position of the scale
    208   \param scalePosition Position of the scale.
    209 
    210   \sa ScalePosition, scalePosition()
    211 */
     204    return m_data->orientation;
     205}
     206
     207/*!
     208   \brief Change the position of the scale
     209   \param scalePosition Position of the scale.
     210
     211   \sa ScalePosition, scalePosition()
     212 */
    212213void QwtSlider::setScalePosition( ScalePosition scalePosition )
    213214{
    214     if ( d_data->scalePosition == scalePosition )
     215    if ( m_data->scalePosition == scalePosition )
    215216        return;
    216217
    217     d_data->scalePosition = scalePosition;
     218    m_data->scalePosition = scalePosition;
    218219    scaleDraw()->setAlignment(
    219         qwtScaleDrawAlignment( d_data->orientation, scalePosition ) );
     220        qwtScaleDrawAlignment( m_data->orientation, scalePosition ) );
    220221
    221222    if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    224225
    225226/*!
    226   \return Position of the scale
    227   \sa setScalePosition()
     227   \return Position of the scale
     228   \sa setScalePosition()
    228229 */
    229230QwtSlider::ScalePosition QwtSlider::scalePosition() const
    230231{
    231     return d_data->scalePosition;
    232 }
    233 
    234 /*!
    235   \brief Change the slider's border width
    236 
    237   The border width is used for drawing the slider handle and the
    238   trough.
    239 
    240   \param width Border width
    241   \sa borderWidth()
    242 */
     232    return m_data->scalePosition;
     233}
     234
     235/*!
     236   \brief Change the slider's border width
     237
     238   The border width is used for drawing the slider handle and the
     239   trough.
     240
     241   \param width Border width
     242   \sa borderWidth()
     243 */
    243244void QwtSlider::setBorderWidth( int width )
    244245{
    … …  
    246247        width = 0;
    247248
    248     if ( width != d_data->borderWidth )
    249     {
    250         d_data->borderWidth = width;
     249    if ( width != m_data->borderWidth )
     250    {
     251        m_data->borderWidth = width;
    251252
    252253        if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    256257
    257258/*!
    258   \return the border width.
    259   \sa setBorderWidth()
    260 */
     259   \return the border width.
     260   \sa setBorderWidth()
     261 */
    261262int QwtSlider::borderWidth() const
    262263{
    263     return d_data->borderWidth;
    264 }
    265 
    266 /*!
    267   \brief Change the spacing between trough and scale
    268 
    269   A spacing of 0 means, that the backbone of the scale is covered
    270   by the trough.
    271 
    272   The default setting is 4 pixels.
    273 
    274   \param spacing Number of pixels
    275   \sa spacing();
    276 */
     264    return m_data->borderWidth;
     265}
     266
     267/*!
     268   \brief Change the spacing between trough and scale
     269
     270   A spacing of 0 means, that the backbone of the scale is covered
     271   by the trough.
     272
     273   The default setting is 4 pixels.
     274
     275   \param spacing Number of pixels
     276   \sa spacing();
     277 */
    277278void QwtSlider::setSpacing( int spacing )
    278279{
    … …  
    280281        spacing = 0;
    281282
    282     if ( spacing != d_data->spacing  )
    283     {
    284         d_data->spacing = spacing;
     283    if ( spacing != m_data->spacing  )
     284    {
     285        m_data->spacing = spacing;
    285286
    286287        if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    290291
    291292/*!
    292   \return Number of pixels between slider and scale
    293   \sa setSpacing()
    294 */
     293   \return Number of pixels between slider and scale
     294   \sa setSpacing()
     295 */
    295296int QwtSlider::spacing() const
    296297{
    297     return d_data->spacing;
    298 }
    299 
    300 /*!
    301   \brief Set the slider's handle size
    302 
    303   When the size is empty the slider handle will be painted with a
    304   default size depending on its orientation() and backgroundStyle().
    305 
    306   \param size New size
    307 
    308   \sa handleSize()
    309 */
    310 void QwtSlider::setHandleSize( const QSize &size )
    311 {
    312     if ( size != d_data->handleSize )
    313     {
    314         d_data->handleSize = size;
     298    return m_data->spacing;
     299}
     300
     301/*!
     302   \brief Set the slider's handle size
     303
     304   When the size is empty the slider handle will be painted with a
     305   default size depending on its orientation() and backgroundStyle().
     306
     307   \param size New size
     308
     309   \sa handleSize()
     310 */
     311void QwtSlider::setHandleSize( const QSize& size )
     312{
     313    if ( size != m_data->handleSize )
     314    {
     315        m_data->handleSize = size;
    315316
    316317        if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    320321
    321322/*!
    322   \return Size of the handle.
    323   \sa setHandleSize()
    324 */
     323   \return Size of the handle.
     324   \sa setHandleSize()
     325 */
    325326QSize QwtSlider::handleSize() const
    326327{
    327     return d_data->handleSize;
    328 }
    329 
    330 /*!
    331   \brief Set a scale draw
    332 
    333   For changing the labels of the scales, it
    334   is necessary to derive from QwtScaleDraw and
    335   overload QwtScaleDraw::label().
    336 
    337   \param scaleDraw ScaleDraw object, that has to be created with
     328    return m_data->handleSize;
     329}
     330
     331/*!
     332   \brief Set a scale draw
     333
     334   For changing the labels of the scales, it
     335   is necessary to derive from QwtScaleDraw and
     336   overload QwtScaleDraw::label().
     337
     338   \param scaleDraw ScaleDraw object, that has to be created with
    338339                   new and will be deleted in ~QwtSlider() or the next
    339340                   call of setScaleDraw().
    340341
    341   \sa scaleDraw()
    342 */
    343 void QwtSlider::setScaleDraw( QwtScaleDraw *scaleDraw )
    344 {
    345     const QwtScaleDraw *previousScaleDraw = this->scaleDraw();
     342   \sa scaleDraw()
     343 */
     344void QwtSlider::setScaleDraw( QwtScaleDraw* scaleDraw )
     345{
     346    const QwtScaleDraw* previousScaleDraw = this->scaleDraw();
    346347    if ( scaleDraw == NULL || scaleDraw == previousScaleDraw )
    347348        return;
    … …  
    357358
    358359/*!
    359   \return the scale draw of the slider
    360   \sa setScaleDraw()
    361 */
    362 const QwtScaleDraw *QwtSlider::scaleDraw() const
    363 {
    364     return static_cast<const QwtScaleDraw *>( abstractScaleDraw() );
    365 }
    366 
    367 /*!
    368   \return the scale draw of the slider
    369   \sa setScaleDraw()
    370 */
    371 QwtScaleDraw *QwtSlider::scaleDraw()
    372 {
    373     return static_cast<QwtScaleDraw *>( abstractScaleDraw() );
     360   \return the scale draw of the slider
     361   \sa setScaleDraw()
     362 */
     363const QwtScaleDraw* QwtSlider::scaleDraw() const
     364{
     365    return static_cast< const QwtScaleDraw* >( abstractScaleDraw() );
     366}
     367
     368/*!
     369   \return the scale draw of the slider
     370   \sa setScaleDraw()
     371 */
     372QwtScaleDraw* QwtSlider::scaleDraw()
     373{
     374    return static_cast< QwtScaleDraw* >( abstractScaleDraw() );
    374375}
    375376
    … …  
    384385
    385386/*!
    386   \brief Specify the update interval for automatic scrolling
    387 
    388   The minimal accepted value is 50 ms.
    389 
    390   \param interval Update interval in milliseconds
    391 
    392   \sa setUpdateInterval()
    393 */
     387   \brief Specify the update interval for automatic scrolling
     388
     389   The minimal accepted value is 50 ms.
     390
     391   \param interval Update interval in milliseconds
     392
     393   \sa setUpdateInterval()
     394 */
    394395void QwtSlider::setUpdateInterval( int interval )
    395396{
    396     d_data->updateInterval = qMax( interval, 50 );
    397 }
    398 
    399 /*!
    400   \return Update interval in milliseconds for automatic scrolling
    401   \sa setUpdateInterval()
     397    m_data->updateInterval = qMax( interval, 50 );
     398}
     399
     400/*!
     401   \return Update interval in milliseconds for automatic scrolling
     402   \sa setUpdateInterval()
    402403 */
    403404int QwtSlider::updateInterval() const
    404405{
    405     return d_data->updateInterval;
     406    return m_data->updateInterval;
    406407}
    407408
    … …  
    411412   \param painter Painter
    412413   \param sliderRect Bounding rectangle of the slider
    413 */
     414 */
    414415void QwtSlider::drawSlider(
    415     QPainter *painter, const QRect &sliderRect ) const
     416    QPainter* painter, const QRect& sliderRect ) const
    416417{
    417418    QRect innerRect( sliderRect );
    418419
    419     if ( d_data->hasTrough )
    420     {
    421         const int bw = d_data->borderWidth;
     420    if ( m_data->hasTrough )
     421    {
     422        const int bw = m_data->borderWidth;
    422423        innerRect = sliderRect.adjusted( bw, bw, -bw, -bw );
    423424
    … …  
    426427    }
    427428
    428     const QSize handleSize = qwtHandleSize( d_data->handleSize,
    429         d_data->orientation, d_data->hasTrough );
    430 
    431     if ( d_data->hasGroove )
    432     {
     429    if ( m_data->hasGroove )
     430    {
     431        const QSize handleSize = qwtHandleSize( m_data->handleSize,
     432            m_data->orientation, m_data->hasTrough );
     433
    433434        const int slotExtent = 4;
    434435        const int slotMargin = 4;
    … …  
    456457
    457458        QBrush brush = palette().brush( QPalette::Dark );
    458         qDrawShadePanel( painter, slotRect, palette(), true, 1 , &brush );
     459        qDrawShadePanel( painter, slotRect, palette(), true, 1, &brush );
    459460    }
    460461
    … …  
    464465
    465466/*!
    466   Draw the thumb at a position
    467 
    468   \param painter Painter
    469   \param handleRect Bounding rectangle of the handle
    470   \param pos Position of the handle marker in widget coordinates
    471 */
    472 void QwtSlider::drawHandle( QPainter *painter,
    473     const QRect &handleRect, int pos ) const
    474 {
    475     const int bw = d_data->borderWidth;
     467   Draw the thumb at a position
     468
     469   \param painter Painter
     470   \param handleRect Bounding rectangle of the handle
     471   \param pos Position of the handle marker in widget coordinates
     472 */
     473void QwtSlider::drawHandle( QPainter* painter,
     474    const QRect& handleRect, int pos ) const
     475{
     476    const int bw = m_data->borderWidth;
    476477
    477478    qDrawShadePanel( painter,
    … …  
    493494
    494495/*!
    495   \brief Determine what to do when the user presses a mouse button.
    496 
    497   \param pos Mouse position
    498 
    499   \retval True, when handleRect() contains pos
    500   \sa scrolledTo()
    501 */
    502 bool QwtSlider::isScrollPosition( const QPoint &pos ) const
     496   \brief Determine what to do when the user presses a mouse button.
     497
     498   \param pos Mouse position
     499
     500   \retval True, when handleRect() contains pos
     501   \sa scrolledTo()
     502 */
     503bool QwtSlider::isScrollPosition( const QPoint& pos ) const
    503504{
    504505    if ( handleRect().contains( pos ) )
    … …  
    507508            ? pos.x() : pos.y();
    508509
    509         d_data->mouseOffset = v - transform( value() );
     510        m_data->mouseOffset = v - transform( value() );
    510511        return true;
    511512    }
    … …  
    515516
    516517/*!
    517   \brief Determine the value for a new position of the
     518   \brief Determine the value for a new position of the
    518519         slider handle.
    519520
    520   \param pos Mouse position
    521 
    522   \return Value for the mouse position
    523   \sa isScrollPosition()
    524 */
    525 double QwtSlider::scrolledTo( const QPoint &pos ) const
     521   \param pos Mouse position
     522
     523   \return Value for the mouse position
     524   \sa isScrollPosition()
     525 */
     526double QwtSlider::scrolledTo( const QPoint& pos ) const
    526527{
    527528    int p = ( orientation() == Qt::Horizontal )
    528529        ? pos.x() : pos.y();
    529530
    530     p -= d_data->mouseOffset;
     531    p -= m_data->mouseOffset;
    531532
    532533    int min = transform( lowerBound() );
    … …  
    543544   Mouse press event handler
    544545   \param event Mouse event
    545 */
    546 void QwtSlider::mousePressEvent( QMouseEvent *event )
     546 */
     547void QwtSlider::mousePressEvent( QMouseEvent* event )
    547548{
    548549    if ( isReadOnly() )
    … …  
    554555    const QPoint pos = event->pos();
    555556
    556     if ( isValid() && d_data->sliderRect.contains( pos ) )
     557    if ( isValid() && m_data->sliderRect.contains( pos ) )
    557558    {
    558559        if ( !handleRect().contains( pos ) )
    … …  
    560561            const int markerPos = transform( value() );
    561562
    562             d_data->stepsIncrement = pageSteps();
    563 
    564             if ( d_data->orientation == Qt::Horizontal )
     563            m_data->stepsIncrement = pageSteps();
     564
     565            if ( m_data->orientation == Qt::Horizontal )
    565566            {
    566567                if ( pos.x() < markerPos )
    567                     d_data->stepsIncrement = -d_data->stepsIncrement;
     568                    m_data->stepsIncrement = -m_data->stepsIncrement;
    568569            }
    569570            else
    570571            {
    571572                if ( pos.y() < markerPos )
    572                     d_data->stepsIncrement = -d_data->stepsIncrement;
     573                    m_data->stepsIncrement = -m_data->stepsIncrement;
    573574            }
    574575
    575576            if ( isInverted() )
    576                 d_data->stepsIncrement = -d_data->stepsIncrement;
     577                m_data->stepsIncrement = -m_data->stepsIncrement;
    577578
    578579            const double v = value();
    579             incrementValue( d_data->stepsIncrement );
     580            incrementValue( m_data->stepsIncrement );
    580581
    581582            if ( v != value() )
    … …  
    584585                    Q_EMIT valueChanged( value() );
    585586                else
    586                     d_data->pendingValueChange = true;
     587                    m_data->pendingValueChange = true;
    587588
    588589                Q_EMIT sliderMoved( value() );
    589590            }
    590591
    591             d_data->timerTick = false;
    592             d_data->repeatTimerId = startTimer( qMax( 250, 2 * updateInterval() ) );
     592            m_data->timerTick = false;
     593            m_data->repeatTimerId = startTimer( qMax( 250, 2 * updateInterval() ) );
    593594
    594595            return;
    … …  
    602603   Mouse release event handler
    603604   \param event Mouse event
    604 */
    605 void QwtSlider::mouseReleaseEvent( QMouseEvent *event )
    606 {
    607     if ( d_data->repeatTimerId > 0 )
    608     {
    609         killTimer( d_data->repeatTimerId );
    610         d_data->repeatTimerId = 0;
    611         d_data->timerTick = false;
    612         d_data->stepsIncrement = 0;
    613     }
    614 
    615     if ( d_data->pendingValueChange )
    616     {
    617         d_data->pendingValueChange = false;
     605 */
     606void QwtSlider::mouseReleaseEvent( QMouseEvent* event )
     607{
     608    if ( m_data->repeatTimerId > 0 )
     609    {
     610        killTimer( m_data->repeatTimerId );
     611        m_data->repeatTimerId = 0;
     612        m_data->timerTick = false;
     613        m_data->stepsIncrement = 0;
     614    }
     615
     616    if ( m_data->pendingValueChange )
     617    {
     618        m_data->pendingValueChange = false;
    618619        Q_EMIT valueChanged( value() );
    619620    }
    … …  
    629630
    630631   \param event Mouse event
    631 */
    632 void QwtSlider::timerEvent( QTimerEvent *event )
    633 {
    634     if ( event->timerId() != d_data->repeatTimerId )
     632 */
     633void QwtSlider::timerEvent( QTimerEvent* event )
     634{
     635    if ( event->timerId() != m_data->repeatTimerId )
    635636    {
    636637        QwtAbstractSlider::timerEvent( event );
    … …  
    640641    if ( !isValid() )
    641642    {
    642         killTimer( d_data->repeatTimerId );
    643         d_data->repeatTimerId = 0;
     643        killTimer( m_data->repeatTimerId );
     644        m_data->repeatTimerId = 0;
    644645        return;
    645646    }
    646647
    647648    const double v = value();
    648     incrementValue( d_data->stepsIncrement );
     649    incrementValue( m_data->stepsIncrement );
    649650
    650651    if ( v != value() )
    … …  
    653654            Q_EMIT valueChanged( value() );
    654655        else
    655             d_data->pendingValueChange = true;
     656            m_data->pendingValueChange = true;
    656657
    657658        Q_EMIT sliderMoved( value() );
    658659    }
    659660
    660     if ( !d_data->timerTick )
     661    if ( !m_data->timerTick )
    661662    {
    662663        // restart the timer with a shorter interval
    663         killTimer( d_data->repeatTimerId );
    664         d_data->repeatTimerId = startTimer( updateInterval() );
    665 
    666         d_data->timerTick = true;
     664        killTimer( m_data->repeatTimerId );
     665        m_data->repeatTimerId = startTimer( updateInterval() );
     666
     667        m_data->timerTick = true;
    667668    }
    668669}
    … …  
    671672   Qt paint event handler
    672673   \param event Paint event
    673 */
    674 void QwtSlider::paintEvent( QPaintEvent *event )
     674 */
     675void QwtSlider::paintEvent( QPaintEvent* event )
    675676{
    676677    QPainter painter( this );
    … …  
    678679
    679680    QStyleOption opt;
    680     opt.init(this);
     681    opt.initFrom(this);
    681682    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
    682683
    683     if ( d_data->scalePosition != QwtSlider::NoScale )
    684     {
    685         if ( !d_data->sliderRect.contains( event->rect() ) )
     684    if ( m_data->scalePosition != QwtSlider::NoScale )
     685    {
     686        if ( !m_data->sliderRect.contains( event->rect() ) )
    686687            scaleDraw()->draw( &painter, palette() );
    687688    }
    688689
    689     drawSlider( &painter, d_data->sliderRect );
     690    drawSlider( &painter, m_data->sliderRect );
    690691
    691692    if ( hasFocus() )
    692         QwtPainter::drawFocusRect( &painter, this, d_data->sliderRect );
     693        QwtPainter::drawFocusRect( &painter, this, m_data->sliderRect );
    693694}
    694695
    … …  
    696697   Qt resize event handler
    697698   \param event Resize event
    698 */
    699 void QwtSlider::resizeEvent( QResizeEvent *event )
    700 {
    701     Q_UNUSED( event );
    702 
     699 */
     700void QwtSlider::resizeEvent( QResizeEvent* event )
     701{
    703702    layoutSlider( false );
     703    QwtAbstractSlider::resizeEvent( event );
     704}
     705
     706/*!
     707   Qt event handler
     708   \param event Event
     709
     710   \return true, if event was recognized and processed
     711 */
     712bool QwtSlider::event( QEvent* event )
     713{
     714    if ( event->type() == QEvent::PolishRequest )
     715        layoutSlider( false );
     716
     717    return QwtAbstractSlider::event( event );
    704718}
    705719
    … …  
    707721   Handles QEvent::StyleChange and QEvent::FontChange events
    708722   \param event Change event
    709 */
    710 void QwtSlider::changeEvent( QEvent *event )
     723 */
     724void QwtSlider::changeEvent( QEvent* event )
    711725{
    712726    if ( event->type() == QEvent::StyleChange ||
    … …  
    721735
    722736/*!
    723   Recalculate the slider's geometry and layout based on
    724   the current geometry and fonts.
    725 
    726   \param update_geometry  notify the layout system and call update
     737   Recalculate the slider's geometry and layout based on
     738   the current geometry and fonts.
     739
     740   \param update_geometry  notify the layout system and call update
    727741         to redraw the scale
    728 */
     742 */
    729743void QwtSlider::layoutSlider( bool update_geometry )
    730744{
    731745    int bw = 0;
    732     if ( d_data->hasTrough )
    733         bw = d_data->borderWidth;
    734 
    735     const QSize handleSize = qwtHandleSize( d_data->handleSize,
    736         d_data->orientation, d_data->hasTrough );
     746    if ( m_data->hasTrough )
     747        bw = m_data->borderWidth;
     748
     749    const QSize handleSize = qwtHandleSize( m_data->handleSize,
     750        m_data->orientation, m_data->hasTrough );
    737751
    738752    QRect sliderRect = contentsRect();
    … …  
    752766
    753767    int scaleMargin = 0;
    754     if ( d_data->scalePosition != QwtSlider::NoScale )
     768    if ( m_data->scalePosition != QwtSlider::NoScale )
    755769    {
    756770        int d1, d2;
    … …  
    762776    int scaleX, scaleY, scaleLength;
    763777
    764     if ( d_data->orientation == Qt::Horizontal )
     778    if ( m_data->orientation == Qt::Horizontal )
    765779    {
    766780        const int handleMargin = handleSize.width() / 2 - 1;
    … …  
    791805    // now align slider and scale according to the ScalePosition
    792806
    793     if ( d_data->orientation == Qt::Horizontal )
     807    if ( m_data->orientation == Qt::Horizontal )
    794808    {
    795809        const int h = handleSize.height() + 2 * bw;
    796810
    797         if ( d_data->scalePosition == QwtSlider::TrailingScale )
     811        if ( m_data->scalePosition == QwtSlider::TrailingScale )
    798812        {
    799813            sliderRect.setTop( sliderRect.bottom() + 1 - h );
    800             scaleY = sliderRect.top() - d_data->spacing;
     814            scaleY = sliderRect.top() - m_data->spacing;
    801815        }
    802816        else
    803817        {
    804818            sliderRect.setHeight( h );
    805             scaleY = sliderRect.bottom() + 1 + d_data->spacing;
     819            scaleY = sliderRect.bottom() + 1 + m_data->spacing;
    806820        }
    807821    }
    … …  
    810824        const int w = handleSize.width() + 2 * bw;
    811825
    812         if ( d_data->scalePosition == QwtSlider::LeadingScale )
     826        if ( m_data->scalePosition == QwtSlider::LeadingScale )
    813827        {
    814828            sliderRect.setWidth( w );
    815             scaleX = sliderRect.right() + 1 + d_data->spacing;
     829            scaleX = sliderRect.right() + 1 + m_data->spacing;
    816830        }
    817831        else
    818832        {
    819833            sliderRect.setLeft( sliderRect.right() + 1 - w );
    820             scaleX = sliderRect.left() - d_data->spacing;
     834            scaleX = sliderRect.left() - m_data->spacing;
    821835        }
    822836    }
    823837
    824     d_data->sliderRect = sliderRect;
     838    m_data->sliderRect = sliderRect;
    825839
    826840    scaleDraw()->move( scaleX, scaleY );
    … …  
    829843    if ( update_geometry )
    830844    {
    831         d_data->sizeHintCache = QSize(); // invalidate
     845        m_data->sizeHintCache = QSize(); // invalidate
    832846        updateGeometry();
    833847        update();
    … …  
    836850
    837851/*!
    838   En/Disable the trough
    839 
    840   The slider can be cutomized by showing a trough for the
    841   handle.
    842 
    843   \param on When true, the groove is visible
    844   \sa hasTrough(), setGroove()
     852   En/Disable the trough
     853
     854   The slider can be customized by showing a trough for the
     855   handle.
     856
     857   \param on When true, the groove is visible
     858   \sa hasTrough(), setGroove()
    845859 */
    846860void QwtSlider::setTrough( bool on )
    847861{
    848     if ( d_data->hasTrough != on )
    849     {
    850         d_data->hasTrough = on;
     862    if ( m_data->hasTrough != on )
     863    {
     864        m_data->hasTrough = on;
    851865
    852866        if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    856870
    857871/*!
    858   \return True, when the trough is visisble
    859   \sa setTrough(), hasGroove()
     872   \return True, when the trough is visible
     873   \sa setTrough(), hasGroove()
    860874 */
    861875bool QwtSlider::hasTrough() const
    862876{
    863     return d_data->hasTrough;
    864 }
    865 
    866 /*!
    867   En/Disable the groove
    868 
    869   The slider can be cutomized by showing a groove for the
    870   handle.
    871 
    872   \param on When true, the groove is visible
    873   \sa hasGroove(), setThrough()
     877    return m_data->hasTrough;
     878}
     879
     880/*!
     881   En/Disable the groove
     882
     883   The slider can be customized by showing a groove for the
     884   handle.
     885
     886   \param on When true, the groove is visible
     887   \sa hasGroove(), setThrough()
    874888 */
    875889void QwtSlider::setGroove( bool on )
    876890{
    877     if ( d_data->hasGroove != on )
    878     {
    879         d_data->hasGroove = on;
     891    if ( m_data->hasGroove != on )
     892    {
     893        m_data->hasGroove = on;
    880894
    881895        if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    885899
    886900/*!
    887   \return True, when the groove is visisble
    888   \sa setGroove(), hasTrough()
     901   \return True, when the groove is visible
     902   \sa setGroove(), hasTrough()
    889903 */
    890904bool QwtSlider::hasGroove() const
    891905{
    892     return d_data->hasGroove;
    893 }
    894 
    895 /*!
    896   \return minimumSizeHint()
    897 */
     906    return m_data->hasGroove;
     907}
     908
     909/*!
     910   \return minimumSizeHint()
     911 */
    898912QSize QwtSlider::sizeHint() const
    899913{
    900914    const QSize hint = minimumSizeHint();
    901     return hint.expandedTo( QApplication::globalStrut() );
    902 }
    903 
    904 /*!
    905   \return Minimum size hint
    906   \sa sizeHint()
    907 */
     915    return qwtExpandedToGlobalStrut( hint );
     916}
     917
     918/*!
     919   \return Minimum size hint
     920   \sa sizeHint()
     921 */
    908922QSize QwtSlider::minimumSizeHint() const
    909923{
    910     if ( !d_data->sizeHintCache.isEmpty() )
    911         return d_data->sizeHintCache;
    912 
    913     const QSize handleSize = qwtHandleSize( d_data->handleSize,
    914         d_data->orientation, d_data->hasTrough );
     924    if ( !m_data->sizeHintCache.isEmpty() )
     925        return m_data->sizeHintCache;
     926
     927    const QSize handleSize = qwtHandleSize( m_data->handleSize,
     928        m_data->orientation, m_data->hasTrough );
    915929
    916930    int bw = 0;
    917     if ( d_data->hasTrough )
    918         bw = d_data->borderWidth;
     931    if ( m_data->hasTrough )
     932        bw = m_data->borderWidth;
    919933
    920934    int sliderLength = 0;
    921935    int scaleExtent = 0;
    922936
    923     if ( d_data->scalePosition != QwtSlider::NoScale )
     937    if ( m_data->scalePosition != QwtSlider::NoScale )
    924938    {
    925939        int d1, d2;
    … …  
    929943
    930944        int handleBorderDist;
    931         if ( d_data->orientation == Qt::Horizontal )
     945        if ( m_data->orientation == Qt::Horizontal )
    932946            handleBorderDist = handleSize.width();
    933947        else
    … …  
    941955        }
    942956
    943         scaleExtent += d_data->spacing;
    944         scaleExtent += qCeil( scaleDraw()->extent( font() ) );
     957        scaleExtent += m_data->spacing;
     958        scaleExtent += qwtCeil( scaleDraw()->extent( font() ) );
    945959    }
    946960
    … …  
    950964    int h = 0;
    951965
    952     if ( d_data->orientation == Qt::Horizontal )
     966    if ( m_data->orientation == Qt::Horizontal )
    953967    {
    954968        w = sliderLength;
    … …  
    962976
    963977    // finally add margins
    964     int left, right, top, bottom;
    965     getContentsMargins( &left, &top, &right, &bottom );
    966 
    967     w += left + right;
    968     h += top + bottom;
    969 
    970     d_data->sizeHintCache = QSize( w, h );
    971     return d_data->sizeHintCache;
     978    const QMargins m = contentsMargins();
     979
     980    w += m.left() + m.right();
     981    h += m.top() + m.bottom();
     982
     983    m_data->sizeHintCache = QSize( w, h );
     984    return m_data->sizeHintCache;
    972985}
    973986
    … …  
    982995    const int markerPos = transform( value() );
    983996
    984     QPoint center = d_data->sliderRect.center();
    985     if ( d_data->orientation == Qt::Horizontal )
     997    QPoint center = m_data->sliderRect.center();
     998    if ( m_data->orientation == Qt::Horizontal )
    986999        center.setX( markerPos );
    9871000    else
    … …  
    9891002
    9901003    QRect rect;
    991     rect.setSize( qwtHandleSize( d_data->handleSize,
    992         d_data->orientation, d_data->hasTrough ) );
     1004    rect.setSize( qwtHandleSize( m_data->handleSize,
     1005        m_data->orientation, m_data->hasTrough ) );
    9931006    rect.moveCenter( center );
    9941007
    … …  
    9971010
    9981011/*!
    999  \return Bounding rectangle of the slider - without the scale
     1012   \return Bounding rectangle of the slider - without the scale
    10001013 */
    10011014QRect QwtSlider::sliderRect() const
    10021015{
    1003     return d_data->sliderRect;
    1004 }
     1016    return m_data->sliderRect;
     1017}
     1018
     1019#include "moc_qwt_slider.cpp"
Note: See TracChangeset for help on using the changeset viewer.