qwt_slider.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef QWT_SLIDER_H
  10. #define QWT_SLIDER_H
  11. #include "qwt_global.h"
  12. #include "qwt_abstract_slider.h"
  13. class QwtScaleDraw;
  14. /*!
  15. \brief The Slider Widget
  16. QwtSlider is a slider widget which operates on an interval
  17. of type double. Its position is related to a scale showing
  18. the current value.
  19. The slider can be customized by having a through, a groove - or both.
  20. \image html sliders.png
  21. */
  22. class QWT_EXPORT QwtSlider: public QwtAbstractSlider
  23. {
  24. Q_OBJECT
  25. Q_ENUMS( ScalePosition BackgroundStyle )
  26. Q_PROPERTY( Qt::Orientation orientation
  27. READ orientation WRITE setOrientation )
  28. Q_PROPERTY( ScalePosition scalePosition READ scalePosition
  29. WRITE setScalePosition )
  30. Q_PROPERTY( bool trough READ hasTrough WRITE setTrough )
  31. Q_PROPERTY( bool groove READ hasGroove WRITE setGroove )
  32. Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
  33. Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
  34. Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
  35. public:
  36. /*!
  37. Position of the scale
  38. \sa QwtSlider(), setScalePosition(), setOrientation()
  39. */
  40. enum ScalePosition
  41. {
  42. //! The slider has no scale
  43. NoScale,
  44. //! The scale is right of a vertical or below a horizontal slider
  45. LeadingScale,
  46. //! The scale is left of a vertical or above a horizontal slider
  47. TrailingScale
  48. };
  49. explicit QwtSlider( QWidget *parent = NULL );
  50. explicit QwtSlider( Qt::Orientation, QWidget *parent = NULL );
  51. virtual ~QwtSlider();
  52. void setOrientation( Qt::Orientation );
  53. Qt::Orientation orientation() const;
  54. void setScalePosition( ScalePosition );
  55. ScalePosition scalePosition() const;
  56. void setTrough( bool );
  57. bool hasTrough() const;
  58. void setGroove( bool );
  59. bool hasGroove() const;
  60. void setHandleSize( const QSize & );
  61. QSize handleSize() const;
  62. void setBorderWidth( int );
  63. int borderWidth() const;
  64. void setSpacing( int );
  65. int spacing() const;
  66. virtual QSize sizeHint() const;
  67. virtual QSize minimumSizeHint() const;
  68. void setScaleDraw( QwtScaleDraw * );
  69. const QwtScaleDraw *scaleDraw() const;
  70. void setUpdateInterval( int );
  71. int updateInterval() const;
  72. protected:
  73. virtual double scrolledTo( const QPoint & ) const;
  74. virtual bool isScrollPosition( const QPoint & ) const;
  75. virtual void drawSlider ( QPainter *, const QRect & ) const;
  76. virtual void drawHandle( QPainter *, const QRect &, int pos ) const;
  77. virtual void mousePressEvent( QMouseEvent * );
  78. virtual void mouseReleaseEvent( QMouseEvent * );
  79. virtual void resizeEvent( QResizeEvent * );
  80. virtual void paintEvent ( QPaintEvent * );
  81. virtual void changeEvent( QEvent * );
  82. virtual void timerEvent( QTimerEvent * );
  83. virtual void scaleChange();
  84. QRect sliderRect() const;
  85. QRect handleRect() const;
  86. private:
  87. QwtScaleDraw *scaleDraw();
  88. void layoutSlider( bool );
  89. void initSlider( Qt::Orientation );
  90. class PrivateData;
  91. PrivateData *d_data;
  92. };
  93. #endif