Qwt User's Guide  6.1-rc3
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
qwt_slider.h
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 
10 #ifndef QWT_SLIDER_H
11 #define QWT_SLIDER_H
12 
13 #include "qwt_global.h"
14 #include "qwt_abstract_slider.h"
15 
16 class QwtScaleDraw;
17 
30 class QWT_EXPORT QwtSlider: public QwtAbstractSlider
31 {
32  Q_OBJECT
33 
34  Q_ENUMS( ScalePosition BackgroundStyle )
35 
36  Q_PROPERTY( Qt::Orientation orientation
37  READ orientation WRITE setOrientation )
38  Q_PROPERTY( ScalePosition scalePosition READ scalePosition
39  WRITE setScalePosition )
40 
41  Q_PROPERTY( bool trough READ hasTrough WRITE setTrough )
42  Q_PROPERTY( bool groove READ hasGroove WRITE setGroove )
43 
44  Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
45  Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
46  Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
47 
48 public:
49 
56  {
59 
62 
64  TrailingScale
65  };
66 
67  explicit QwtSlider( QWidget *parent = NULL );
68  explicit QwtSlider( Qt::Orientation, QWidget *parent = NULL );
69 
70  virtual ~QwtSlider();
71 
72  void setOrientation( Qt::Orientation );
73  Qt::Orientation orientation() const;
74 
75  void setScalePosition( ScalePosition );
76  ScalePosition scalePosition() const;
77 
78  void setTrough( bool );
79  bool hasTrough() const;
80 
81  void setGroove( bool );
82  bool hasGroove() const;
83 
84  void setHandleSize( const QSize & );
85  QSize handleSize() const;
86 
87  void setBorderWidth( int bw );
88  int borderWidth() const;
89 
90  void setSpacing( int );
91  int spacing() const;
92 
93  virtual QSize sizeHint() const;
94  virtual QSize minimumSizeHint() const;
95 
96  void setScaleDraw( QwtScaleDraw * );
97  const QwtScaleDraw *scaleDraw() const;
98 
99  void setUpdateInterval( int );
100  int updateInterval() const;
101 
102 protected:
103  virtual double scrolledTo( const QPoint & ) const;
104  virtual bool isScrollPosition( const QPoint & ) const;
105 
106  virtual void drawSlider ( QPainter *, const QRect & ) const;
107  virtual void drawHandle( QPainter *, const QRect &, int pos ) const;
108 
109  virtual void mousePressEvent( QMouseEvent * );
110  virtual void mouseReleaseEvent( QMouseEvent * );
111  virtual void resizeEvent( QResizeEvent * );
112  virtual void paintEvent ( QPaintEvent * );
113  virtual void changeEvent( QEvent * );
114  virtual void timerEvent( QTimerEvent * );
115 
116  virtual void scaleChange();
117 
118  QRect sliderRect() const;
119  QRect handleRect() const;
120 
121 private:
122  QwtScaleDraw *scaleDraw();
123 
124  void layoutSlider( bool );
125  void initSlider( Qt::Orientation );
126 
127  class PrivateData;
128  PrivateData *d_data;
129 };
130 
131 #endif