fw4spl
QRangeSlider.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWGUIQT_WIDGET_QRANGESLIDER_HPP__
8 #define __FWGUIQT_WIDGET_QRANGESLIDER_HPP__
9 
10 #include <QWidget>
11 #include <QPainter>
12 #include <QPointer>
13 #include <QDebug>
14 
15 #include "fwGuiQt/config.hpp"
16 
17 
18 namespace fwGuiQt
19 {
20 
21 namespace widget
22 {
23 
24 class FWGUIQT_CLASS_API QRangeSlider : public QWidget
25 {
26 Q_OBJECT
27 
28 public:
29  class Paintable
30  {
31  public:
32  Paintable(QWidget *w)
33  {
34  m_widget = w;
35  }
36  virtual ~Paintable()
37  {
38  }
39 
40  virtual void draw(QPainter &, bool enabled = true) = 0;
41  virtual bool pick(const QPoint&) const = 0;
42 
43  protected:
44  QSize drawingArea() const
45  {
46  return m_widget->size();
47  }
48  QPointer<QWidget> m_widget;
49  };
50 
51 
52 
53  FWGUIQT_API QRangeSlider(QWidget *parent = NULL);
54  FWGUIQT_API virtual ~QRangeSlider();
55 
56  QSize sizeHint() const
57  {
58  return QSize(100,20);
59  }
60 
61  void setMinimumMinMaxDelta(double d)
62  {
63  m_minimumMinMaxDelta = d;
64  }
65 
66 public Q_SLOTS:
67  FWGUIQT_API void setPos(double _min, double _max);
68 
69 Q_SIGNALS:
70  void sliderRangeChanged ( double min, double max);
71  void sliderRangeEdited ( double min, double max);
72 
73 protected:
74 
75 
76  void move(int delta);
77  bool movedTo(double _min, double _max);
78 
79  virtual void paintEvent ( QPaintEvent * event );
80  virtual void mouseMoveEvent ( QMouseEvent * event );
81  virtual void mousePressEvent ( QMouseEvent * event );
82  virtual void mouseReleaseEvent ( QMouseEvent * event );
83  virtual void wheelEvent ( QWheelEvent * event );
84  virtual void resizeEvent ( QResizeEvent * event );
85 
86  Paintable *m_minHandle;
87  Paintable *m_maxHandle;
88  Paintable *m_window;
89 
90  Paintable *m_current;
91 
92  int m_handleSize;
93 
94  QPoint m_pressPos;
95  int m_pressMin;
96  int m_pressMax;
97 
98  double m_minValue;
99  double m_maxValue;
100 
101  double m_minimumMinMaxDelta;
102  bool m_allowMinGreaterThanMax;
103  bool m_emitRangeChanged;
104 
105 };
106 
107 
108 } // namespace widget
109 } // namespace fwGuiQt
110 
111 #endif // __FWGUIQT_WIDGET_QRANGESLIDER_HPP__
The namespace fwGuiQt contains classes which provide the implementation of the Gui using Qt library...
Definition: WindowLevel.hpp:32