18 #include <qdrawutil.h>
21 #include <qstyleoption.h>
25 Qt::Orientation orientation,
bool hasTrough )
27 QSize handleSize =
size;
29 if ( handleSize.isEmpty() )
31 const int handleThickness = 16;
32 handleSize.setWidth( 2 * handleThickness );
33 handleSize.setHeight( handleThickness );
36 handleSize.transpose();
38 if ( orientation == Qt::Vertical )
39 handleSize.transpose();
50 if ( orientation == Qt::Vertical )
151 setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
153 setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
155 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
185 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
187 QSizePolicy sp = sizePolicy();
191 setAttribute( Qt::WA_WState_OwnSizePolicy,
false );
194 if ( testAttribute( Qt::WA_WState_Polished ) )
222 if ( testAttribute( Qt::WA_WState_Polished ) )
253 if ( testAttribute( Qt::WA_WState_Polished ) )
287 if ( testAttribute( Qt::WA_WState_Polished ) )
317 if ( testAttribute( Qt::WA_WState_Polished ) )
347 if ( scaleDraw == NULL ||
scaleDraw == previousScaleDraw )
350 if ( previousScaleDraw )
355 if ( testAttribute( Qt::WA_WState_Polished ) )
382 if ( testAttribute( Qt::WA_WState_Polished ) )
416 QPainter* painter,
const QRect& sliderRect )
const
423 innerRect =
sliderRect.adjusted( bw, bw, -bw, -bw );
425 painter->fillRect( innerRect, palette().brush( QPalette::Mid ) );
426 qDrawShadePanel( painter,
sliderRect, palette(),
true, bw, NULL );
434 const int slotExtent = 4;
435 const int slotMargin = 4;
440 int slotOffset = qMax( 1,
handleSize.width() / 2 - slotMargin );
441 int slotHeight = slotExtent + ( innerRect.height() % 2 );
443 slotRect.setWidth( innerRect.width() - 2 * slotOffset );
444 slotRect.setHeight( slotHeight );
448 int slotOffset = qMax( 1,
handleSize.height() / 2 - slotMargin );
449 int slotWidth = slotExtent + ( innerRect.width() % 2 );
451 slotRect.setWidth( slotWidth );
452 slotRect.setHeight( innerRect.height() - 2 * slotOffset );
456 slotRect.moveCenter( innerRect.center() );
458 QBrush brush = palette().brush( QPalette::Dark );
459 qDrawShadePanel( painter, slotRect, palette(),
true, 1, &brush );
474 const QRect& handleRect,
int pos )
const
478 qDrawShadePanel( painter,
480 &palette().brush( QPalette::Button ) );
485 qDrawShadeLine( painter, pos,
handleRect.top() + bw,
486 pos,
handleRect.bottom() - bw, palette(),
true, 1 );
490 qDrawShadeLine( painter,
handleRect.left() + bw, pos,
491 handleRect.right() - bw, pos, palette(),
true, 1 );
507 const double v = (
orientation() == Qt::Horizontal )
538 p = qBound( min, p, max );
555 const QPoint pos =
event->pos();
567 if ( pos.x() < markerPos )
572 if ( pos.y() < markerPos )
579 const double v =
value();
637 QwtAbstractSlider::timerEvent(
event );
648 const double v =
value();
677 QPainter painter(
this );
678 painter.setClipRegion(
event->region() );
682 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter,
this);
703 QwtAbstractSlider::resizeEvent(
event );
714 if (
event->type() == QEvent::PolishRequest )
717 return QwtAbstractSlider::event(
event );
726 if (
event->type() == QEvent::StyleChange ||
727 event->type() == QEvent::FontChange )
729 if ( testAttribute( Qt::WA_WState_Polished ) )
773 scaleMargin = qMax( d1, d2 ) - bw;
776 int scaleX, scaleY, scaleLength;
780 const int handleMargin =
handleSize.width() / 2 - 1;
781 if ( scaleMargin > handleMargin )
783 int off = scaleMargin - handleMargin;
792 int handleMargin =
handleSize.height() / 2 - 1;
793 if ( scaleMargin > handleMargin )
795 int off = scaleMargin - handleMargin;
803 scaleLength -= 2 * bw;
843 if ( update_geometry )
866 if ( testAttribute( Qt::WA_WState_Polished ) )
895 if ( testAttribute( Qt::WA_WState_Polished ) )
934 int sliderLength = 0;
942 const int scaleBorderDist = 2 * ( qMax( d1, d2 ) - bw );
944 int handleBorderDist;
951 if ( handleBorderDist > scaleBorderDist )
954 sliderLength += handleBorderDist - scaleBorderDist;
961 sliderLength = qMax( sliderLength, 84 );
969 h =
handleSize.height() + 2 * bw + scaleExtent;
973 w =
handleSize.width() + 2 * bw + scaleExtent;
978 const QMargins m = contentsMargins();
980 w += m.left() + m.right();
981 h += m.top() + m.bottom();
999 center.setX( markerPos );
1001 center.setY( markerPos );
1006 rect.moveCenter( center );
1020 #include "moc_qwt_slider.cpp"