15 #include <qdrawutil.h> 17 #include <qalgorithms.h> 20 #include <qstyleoption.h> 21 #include <qapplication.h> 24 Qt::Orientation orientation,
bool hasTrough )
26 QSize handleSize = size;
28 if ( handleSize.isEmpty() )
30 const int handleThickness = 16;
31 handleSize.setWidth( 2 * handleThickness );
32 handleSize.setHeight( handleThickness );
35 handleSize.transpose();
37 if ( orientation == Qt::Vertical )
38 handleSize.transpose();
49 if ( orientation == Qt::Vertical )
149 if ( orientation == Qt::Vertical )
150 setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
152 setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
154 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
184 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
186 QSizePolicy sp = sizePolicy();
190 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
193 if ( testAttribute( Qt::WA_WState_Polished ) )
221 if ( testAttribute( Qt::WA_WState_Polished ) )
252 if ( testAttribute( Qt::WA_WState_Polished ) )
286 if ( testAttribute( Qt::WA_WState_Polished ) )
316 if ( testAttribute( Qt::WA_WState_Polished ) )
346 if ( scaleDraw == NULL || scaleDraw == previousScaleDraw )
349 if ( previousScaleDraw )
354 if ( testAttribute( Qt::WA_WState_Polished ) )
381 if ( testAttribute( Qt::WA_WState_Polished ) )
415 QPainter *painter,
const QRect &
sliderRect )
const 417 QRect innerRect( sliderRect );
422 innerRect = sliderRect.adjusted( bw, bw, -bw, -bw );
424 painter->fillRect( innerRect, palette().brush( QPalette::Mid ) );
425 qDrawShadePanel( painter, sliderRect, palette(),
true, bw, NULL );
433 const int slotExtent = 4;
434 const int slotMargin = 4;
439 int slotOffset = qMax( 1, handleSize.width() / 2 - slotMargin );
440 int slotHeight = slotExtent + ( innerRect.height() % 2 );
442 slotRect.setWidth( innerRect.width() - 2 * slotOffset );
443 slotRect.setHeight( slotHeight );
447 int slotOffset = qMax( 1, handleSize.height() / 2 - slotMargin );
448 int slotWidth = slotExtent + ( innerRect.width() % 2 );
450 slotRect.setWidth( slotWidth );
451 slotRect.setHeight( innerRect.height() - 2 * slotOffset );
455 slotRect.moveCenter( innerRect.center() );
457 QBrush brush = palette().brush( QPalette::Dark );
458 qDrawShadePanel( painter, slotRect, palette(),
true, 1 , &brush );
477 qDrawShadePanel( painter,
478 handleRect, palette(),
false, bw,
479 &palette().brush( QPalette::Button ) );
484 qDrawShadeLine( painter, pos, handleRect.top() + bw,
485 pos, handleRect.bottom() - bw, palette(),
true, 1 );
489 qDrawShadeLine( painter, handleRect.left() + bw, pos,
490 handleRect.right() - bw, pos, palette(),
true, 1 );
537 p = qBound( min, p, max );
554 const QPoint pos =
event->pos();
566 if ( pos.x() < markerPos )
571 if ( pos.y() < markerPos )
636 QwtAbstractSlider::timerEvent( event );
676 QPainter painter(
this );
677 painter.setClipRegion( event->region() );
681 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
702 QwtAbstractSlider::resizeEvent( event );
713 if ( event->type() == QEvent::PolishRequest )
716 return QwtAbstractSlider::event( event );
725 if ( event->type() == QEvent::StyleChange ||
726 event->type() == QEvent::FontChange )
728 if ( testAttribute( Qt::WA_WState_Polished ) )
772 scaleMargin = qMax( d1, d2 ) - bw;
775 int scaleX, scaleY, scaleLength;
779 const int handleMargin = handleSize.width() / 2 - 1;
780 if ( scaleMargin > handleMargin )
782 int off = scaleMargin - handleMargin;
783 sliderRect.adjust( off, 0, -off, 0 );
786 scaleX = sliderRect.left() + bw + handleSize.width() / 2 - 1;
787 scaleLength = sliderRect.width() - handleSize.width();
791 int handleMargin = handleSize.height() / 2 - 1;
792 if ( scaleMargin > handleMargin )
794 int off = scaleMargin - handleMargin;
795 sliderRect.adjust( 0, off, 0, -off );
798 scaleY = sliderRect.top() + bw + handleSize.height() / 2 - 1;
799 scaleLength = sliderRect.height() - handleSize.height();
802 scaleLength -= 2 * bw;
808 const int h = handleSize.height() + 2 * bw;
812 sliderRect.setTop( sliderRect.bottom() + 1 - h );
817 sliderRect.setHeight( h );
823 const int w = handleSize.width() + 2 * bw;
827 sliderRect.setWidth( w );
832 sliderRect.setLeft( sliderRect.right() + 1 - w );
842 if ( update_geometry )
865 if ( testAttribute( Qt::WA_WState_Polished ) )
894 if ( testAttribute( Qt::WA_WState_Polished ) )
914 return hint.expandedTo( QApplication::globalStrut() );
933 int sliderLength = 0;
941 const int scaleBorderDist = 2 * ( qMax( d1, d2 ) - bw );
943 int handleBorderDist;
950 if ( handleBorderDist > scaleBorderDist )
953 sliderLength += handleBorderDist - scaleBorderDist;
957 scaleExtent += qCeil(
scaleDraw()->extent( font() ) );
960 sliderLength = qMax( sliderLength, 84 );
968 h =
handleSize.height() + 2 * bw + scaleExtent;
972 w =
handleSize.width() + 2 * bw + scaleExtent;
977 int left, right, top, bottom;
978 getContentsMargins( &left, &top, &right, &bottom );
999 center.setX( markerPos );
1001 center.setY( markerPos );
1006 rect.moveCenter( center );
void setScale(double lowerBound, double upperBound)
Specify a scale.
void initSlider(Qt::Orientation)
void setAlignment(Alignment)
void setLength(double length)
static void drawFocusRect(QPainter *, const QWidget *)
Draw a focus rectangle on a widget using its style.
void setAbstractScaleDraw(QwtAbstractScaleDraw *)
Set a scale draw.
int transform(double) const
Qt::Orientation orientation
void setValue(double val)
void valueChanged(double value)
Notify a change of value.
int updateInterval() const
const QwtScaleMap & scaleMap() const
virtual void mousePressEvent(QMouseEvent *)
virtual void scaleChange()
QwtSlider::ScalePosition scalePosition
void getBorderDistHint(const QFont &, int &start, int &end) const
Determine the minimum border distance.
void sliderMoved(double value)
int minLength(const QFont &) const
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
An abstract base class for slider widgets with a scale.
CONSTEXPR_F fields align(second_tag, fields f) noexcept
void setOrientation(Qt::Orientation)
Set the orientation.
Alignment alignment() const
QwtSlider(QWidget *parent=NULL)
virtual void scaleChange()
Notify changed scale.
virtual double scrolledTo(const QPoint &) const
Determine the value for a new position of the slider handle.
The scale is left of a vertical or above a horizontal slider.
virtual void timerEvent(QTimerEvent *)
Qt::Orientation orientation() const
const QwtAbstractScaleDraw * abstractScaleDraw() const
virtual ~QwtSlider()
Destructor.
double invTransform(double p) const
virtual void drawSlider(QPainter *, const QRect &) const
static QSize qwtHandleSize(const QSize &size, Qt::Orientation orientation, bool hasTrough)
virtual QSize minimumSizeHint() const
virtual void changeEvent(QEvent *)
The scale is right of a vertical or below a horizontal slider.
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual void draw(QPainter *, const QPalette &) const
Draw the scale.
const QwtScaleDraw * scaleDraw() const
double lowerBound() const
void setScalePosition(ScalePosition)
Change the position of the scale.
void setUpdateInterval(int)
Specify the update interval for automatic scrolling.
virtual bool event(QEvent *)
virtual void mouseReleaseEvent(QMouseEvent *)
virtual QSize sizeHint() const
ScalePosition scalePosition() const
virtual void drawHandle(QPainter *, const QRect &, int pos) const
void incrementValue(int numSteps)
A class for drawing scales.
virtual void mousePressEvent(QMouseEvent *)
virtual bool isScrollPosition(const QPoint &) const
Determine what to do when the user presses a mouse button.
virtual void mouseReleaseEvent(QMouseEvent *)
double upperBound() const
void setSpacing(int)
Change the spacing between trough and scale.
virtual void paintEvent(QPaintEvent *)
static QwtScaleDraw::Alignment qwtScaleDrawAlignment(Qt::Orientation orientation, QwtSlider::ScalePosition scalePos)
void setScaleDraw(QwtScaleDraw *)
Set a scale draw.
virtual void changeEvent(QEvent *)
virtual void resizeEvent(QResizeEvent *)
void setBorderWidth(int bw)
Change the slider's border width.
void move(double x, double y)
void setHandleSize(const QSize &)
Set the slider's handle size.