qwt_wheel.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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_WHEEL_H
  10. #define QWT_WHEEL_H
  11. #include "qwt_global.h"
  12. #include <qwidget.h>
  13. /*!
  14. \brief The Wheel Widget
  15. The wheel widget can be used to change values over a very large range
  16. in very small steps. Using the setMass() member, it can be configured
  17. as a flying wheel.
  18. The default range of the wheel is [0.0, 100.0]
  19. \sa The radio example.
  20. */
  21. class QWT_EXPORT QwtWheel: public QWidget
  22. {
  23. Q_OBJECT
  24. Q_PROPERTY( Qt::Orientation orientation
  25. READ orientation WRITE setOrientation )
  26. Q_PROPERTY( double value READ value WRITE setValue )
  27. Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
  28. Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
  29. Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
  30. Q_PROPERTY( int pageStepCount READ pageStepCount WRITE setPageStepCount )
  31. Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment )
  32. Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
  33. Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
  34. Q_PROPERTY( bool inverted READ isInverted WRITE setInverted )
  35. Q_PROPERTY( double mass READ mass WRITE setMass )
  36. Q_PROPERTY( int updateInterval READ updateInterval WRITE setUpdateInterval )
  37. Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
  38. Q_PROPERTY( double viewAngle READ viewAngle WRITE setViewAngle )
  39. Q_PROPERTY( int tickCount READ tickCount WRITE setTickCount )
  40. Q_PROPERTY( int wheelWidth READ wheelWidth WRITE setWheelWidth )
  41. Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
  42. Q_PROPERTY( int wheelBorderWidth READ wheelBorderWidth WRITE setWheelBorderWidth )
  43. public:
  44. explicit QwtWheel( QWidget *parent = NULL );
  45. virtual ~QwtWheel();
  46. double value() const;
  47. void setOrientation( Qt::Orientation );
  48. Qt::Orientation orientation() const;
  49. double totalAngle() const;
  50. double viewAngle() const;
  51. void setTickCount( int );
  52. int tickCount() const;
  53. void setWheelWidth( int );
  54. int wheelWidth() const;
  55. void setWheelBorderWidth( int );
  56. int wheelBorderWidth() const;
  57. void setBorderWidth( int );
  58. int borderWidth() const;
  59. void setInverted( bool );
  60. bool isInverted() const;
  61. void setWrapping( bool );
  62. bool wrapping() const;
  63. void setSingleStep( double );
  64. double singleStep() const;
  65. void setPageStepCount( int );
  66. int pageStepCount() const;
  67. void setStepAlignment( bool on );
  68. bool stepAlignment() const;
  69. void setRange( double min, double max );
  70. void setMinimum( double );
  71. double minimum() const;
  72. void setMaximum( double );
  73. double maximum() const;
  74. void setUpdateInterval( int );
  75. int updateInterval() const;
  76. void setTracking( bool );
  77. bool isTracking() const;
  78. double mass() const;
  79. public Q_SLOTS:
  80. void setValue( double );
  81. void setTotalAngle ( double );
  82. void setViewAngle( double );
  83. void setMass( double );
  84. Q_SIGNALS:
  85. /*!
  86. \brief Notify a change of value.
  87. When tracking is enabled this signal will be emitted every
  88. time the value changes.
  89. \param value new value
  90. \sa setTracking()
  91. */
  92. void valueChanged( double value );
  93. /*!
  94. This signal is emitted when the user presses the
  95. the wheel with the mouse
  96. */
  97. void wheelPressed();
  98. /*!
  99. This signal is emitted when the user releases the mouse
  100. */
  101. void wheelReleased();
  102. /*!
  103. This signal is emitted when the user moves the
  104. wheel with the mouse.
  105. \param value new value
  106. */
  107. void wheelMoved( double value );
  108. protected:
  109. virtual void paintEvent( QPaintEvent * );
  110. virtual void mousePressEvent( QMouseEvent * );
  111. virtual void mouseReleaseEvent( QMouseEvent * );
  112. virtual void mouseMoveEvent( QMouseEvent * );
  113. virtual void keyPressEvent( QKeyEvent * );
  114. virtual void wheelEvent( QWheelEvent * );
  115. virtual void timerEvent( QTimerEvent * );
  116. void stopFlying();
  117. QRect wheelRect() const;
  118. virtual QSize sizeHint() const;
  119. virtual QSize minimumSizeHint() const;
  120. virtual void drawTicks( QPainter *, const QRectF & );
  121. virtual void drawWheelBackground( QPainter *, const QRectF & );
  122. virtual double valueAt( const QPoint & ) const;
  123. private:
  124. double alignedValue( double ) const;
  125. double boundedValue( double ) const;
  126. class PrivateData;
  127. PrivateData *d_data;
  128. };
  129. #endif