1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the Qt3Support module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef Q3RANGECONTROL_H
43 #define Q3RANGECONTROL_H
44 
45 #include <QtCore/qglobal.h>
46 #include <QtGui/qwidget.h>
47 
48 QT_BEGIN_HEADER
49 
50 QT_BEGIN_NAMESPACE
51 
QT_MODULE(Qt3SupportLight)52 QT_MODULE(Qt3SupportLight)
53 
54 #ifndef QT_NO_RANGECONTROL
55 
56 class Q3RangeControlPrivate;
57 
58 class Q_COMPAT_EXPORT Q3RangeControl
59 {
60 public:
61     Q3RangeControl();
62     Q3RangeControl(int minValue, int maxValue,
63                    int lineStep, int pageStep, int value);
64     virtual ~Q3RangeControl();
65 
66     int                value()                const;
67     void        setValue(int);
68     void        addPage();
69     void        subtractPage();
70     void        addLine();
71     void        subtractLine();
72 
73     int                minValue()        const;
74     int                maxValue()        const;
75     void        setRange(int minValue, int maxValue);
76     void        setMinValue(int minVal);
77     void        setMaxValue(int minVal);
78 
79     int                lineStep()        const;
80     int                pageStep()        const;
81     void        setSteps(int line, int page);
82 
83     int                bound(int) const;
84 
85 protected:
86     int                positionFromValue(int val, int space) const;
87     int                valueFromPosition(int pos, int space) const;
88     void        directSetValue(int val);
89     int                prevValue()        const;
90 
91     virtual void valueChange();
92     virtual void rangeChange();
93     virtual void stepChange();
94 
95 private:
96     int                minVal, maxVal;
97     int                line, page;
98     int                val, prevVal;
99 
100     Q3RangeControlPrivate * d;
101 
102 private:
103     Q_DISABLE_COPY(Q3RangeControl)
104 };
105 
106 
value()107 inline int Q3RangeControl::value() const
108 { return val; }
109 
prevValue()110 inline int Q3RangeControl::prevValue() const
111 { return prevVal; }
112 
minValue()113 inline int Q3RangeControl::minValue() const
114 { return minVal; }
115 
maxValue()116 inline int Q3RangeControl::maxValue() const
117 { return maxVal; }
118 
lineStep()119 inline int Q3RangeControl::lineStep() const
120 { return line; }
121 
pageStep()122 inline int Q3RangeControl::pageStep() const
123 { return page; }
124 
125 
126 #endif // QT_NO_RANGECONTROL
127 
128 #ifndef QT_NO_SPINWIDGET
129 
130 class Q3SpinWidgetPrivate;
131 class Q_COMPAT_EXPORT Q3SpinWidget : public QWidget
132 {
133     Q_OBJECT
134 public:
135     Q3SpinWidget(QWidget* parent=0, const char* name=0);
136     ~Q3SpinWidget();
137 
138     void         setEditWidget(QWidget * widget);
139     QWidget *         editWidget();
140 
141     QRect upRect() const;
142     QRect downRect() const;
143 
144     void setUpEnabled(bool on);
145     void setDownEnabled(bool on);
146 
147     bool isUpEnabled() const;
148     bool isDownEnabled() const;
149 
150     enum ButtonSymbols { UpDownArrows, PlusMinus };
151     virtual void        setButtonSymbols(ButtonSymbols bs);
152     ButtonSymbols        buttonSymbols() const;
153 
154     void arrange();
155 
156 Q_SIGNALS:
157     void stepUpPressed();
158     void stepDownPressed();
159 
160 public Q_SLOTS:
161     void stepUp();
162     void stepDown();
163 
164 protected:
165     void mousePressEvent(QMouseEvent *e);
166     void resizeEvent(QResizeEvent* ev);
167     void mouseReleaseEvent(QMouseEvent *e);
168     void mouseMoveEvent(QMouseEvent *e);
169 #ifndef QT_NO_WHEELEVENT
170     void wheelEvent(QWheelEvent *);
171 #endif
172     void changeEvent(QEvent *);
173     void paintEvent(QPaintEvent *);
174 
175 private Q_SLOTS:
176     void timerDone();
177     void timerDoneEx();
178 
179 private:
180     Q3SpinWidgetPrivate * d;
181 
182     void updateDisplay();
183 
184 private:
185     Q_DISABLE_COPY(Q3SpinWidget)
186 };
187 
188 #endif // QT_NO_RANGECONTROL
189 
190 QT_END_NAMESPACE
191 
192 QT_END_HEADER
193 
194 #endif // Q3RANGECONTROL_H
195