1 /****************************************************************************
2 ** $Id: qt/qdial.h   3.3.8   edited Jan 11 14:46 $
3 **
4 ** Definition of the dial widget
5 **
6 ** Created : 990104
7 **
8 ** Copyright (C) 1999-2007 Trolltech ASA.  All rights reserved.
9 **
10 ** This file is part of the widgets module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech ASA of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 **   information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 
39 #ifndef QDIAL_H
40 #define QDIAL_H
41 
42 #ifndef QT_H
43 #include "qwidget.h"
44 #include "qrangecontrol.h"
45 #endif // QT_H
46 
47 #ifndef QT_NO_DIAL
48 
49 class QDialPrivate;
50 
51 class Q_EXPORT QDial: public QWidget, public QRangeControl
52 {
53     Q_OBJECT
54     Q_PROPERTY( bool tracking READ tracking WRITE setTracking )
55     Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
56     Q_PROPERTY( int notchSize READ notchSize )
57     Q_PROPERTY( double notchTarget READ notchTarget WRITE setNotchTarget )
58     Q_PROPERTY( bool notchesVisible READ notchesVisible WRITE setNotchesVisible )
59     Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
60     Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
61     Q_PROPERTY( int lineStep READ lineStep WRITE setLineStep )
62     Q_PROPERTY( int pageStep READ pageStep WRITE setPageStep )
63     Q_PROPERTY( int value READ value WRITE setValue )
64 
65 public:
66     QDial( QWidget* parent=0, const char* name=0, WFlags f = 0 );
67     QDial( int minValue, int maxValue, int pageStep, int value,
68 	   QWidget* parent=0, const char* name=0 );
69     ~QDial();
70 
71     bool tracking() const;
72 
73     bool wrapping() const;
74 
75     int notchSize() const;
76 
77     virtual void setNotchTarget( double );
78     double notchTarget() const;
79 
80     bool notchesVisible() const;
81 
82     QSize sizeHint() const;
83     QSize minimumSizeHint() const;
84 
85     int	 minValue() const;
86     int	 maxValue() const;
87     void setMinValue( int );
88     void setMaxValue( int );
89     int	 lineStep() const;
90     int	 pageStep() const;
91     void setLineStep( int );
92     void setPageStep( int );
93     int  value() const;
94 
95 public slots:
96     virtual void setValue( int );
97     void addLine();
98     void subtractLine();
99     void addPage();
100     void subtractPage();
101     virtual void setNotchesVisible( bool b );
102     virtual void setWrapping( bool on );
103     virtual void setTracking( bool enable );
104 
105 signals:
106     void valueChanged( int value );
107     void dialPressed();
108     void dialMoved( int value );
109     void dialReleased();
110 
111 protected:
112     void resizeEvent( QResizeEvent * );
113     void paintEvent( QPaintEvent * );
114 
115     void keyPressEvent( QKeyEvent * );
116     void mousePressEvent( QMouseEvent * );
117     void mouseReleaseEvent( QMouseEvent * );
118     void mouseMoveEvent( QMouseEvent * );
119 #ifndef QT_NO_WHEELEVENT
120     void wheelEvent( QWheelEvent * );
121 #endif
122     void focusInEvent( QFocusEvent * );
123     void focusOutEvent( QFocusEvent * );
124 
125     void valueChange();
126     void rangeChange();
127 
128     virtual void repaintScreen( const QRect *cr = 0 );
129 
130 private:
131     QDialPrivate * d;
132 
133     int valueFromPoint( const QPoint & ) const;
134     double angle( const QPoint &, const QPoint & ) const;
135     QPointArray calcArrow( double &a ) const;
136     QRect calcDial() const;
137     int calcBigLineSize() const;
138     void calcLines();
139 
140 private: // Disabled copy constructor and operator=
141 #if defined(Q_DISABLE_COPY)
142     QDial( const QDial & );
143     QDial &operator=( const QDial & );
144 #endif
145 
146 };
147 
148 #endif  // QT_NO_DIAL
149 
150 #endif
151