Kstars

ctkrangeslider.h
1/*
2 SPDX-FileCopyrightText: Kitware Inc.
3 SPDX-License-Identifier: Apache-2.0
4*/
5
6#ifndef __ctkRangeSlider_h
7#define __ctkRangeSlider_h
8
9// Qt includes
10#include <QSlider>
11
12// CTK includes
13//#include <ctkPimpl.h>
14
15class QStylePainter;
16class ctkRangeSliderPrivate;
17
18/// \ingroup Widgets
19///
20/// A ctkRangeSlider is a slider that lets you input 2 values instead of one
21/// (see QSlider). These values are typically a lower and upper bound.
22/// Values are comprised between the range of the slider. See setRange(),
23/// minimum() and maximum(). The upper bound can't be smaller than the
24/// lower bound and vice-versa.
25/// When setting new values (setMinimumValue(), setMaximumValue() or
26/// setValues()), make sure they lie between the range (minimum(), maximum())
27/// of the slider, they would be forced otherwised. If it is not the behavior
28/// you desire, you can set the range first (setRange(), setMinimum(),
29/// setMaximum())
30/// TODO: support triggerAction(QAbstractSlider::SliderSingleStepSub) that
31/// moves both values at a time.
32/// \sa ctkDoubleRangeSlider, ctkDoubleSlider, ctkRangeWidget
33class ctkRangeSlider : public QSlider
34{
36 Q_PROPERTY(int minimumValue READ minimumValue WRITE setMinimumValue)
37 Q_PROPERTY(int maximumValue READ maximumValue WRITE setMaximumValue)
38 Q_PROPERTY(int minimumPosition READ minimumPosition WRITE setMinimumPosition)
39 Q_PROPERTY(int maximumPosition READ maximumPosition WRITE setMaximumPosition)
40 Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
41 Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip)
42
43 public:
44 // Superclass typedef
45 typedef QSlider Superclass;
46 /// Constructor, builds a ctkRangeSlider that ranges from 0 to 100 and has
47 /// a lower and upper values of 0 and 100 respectively, other properties
48 /// are set the QSlider default properties.
49 explicit ctkRangeSlider( Qt::Orientation o, QWidget* par = 0 );
50 explicit ctkRangeSlider( QWidget* par = 0 );
51 virtual ~ctkRangeSlider();
52
53 ///
54 /// This property holds the slider's current minimum value.
55 /// The slider silently forces minimumValue to be within the legal range:
56 /// minimum() <= minimumValue() <= maximumValue() <= maximum().
57 /// Changing the minimumValue also changes the minimumPosition.
58 int minimumValue() const;
59
60 ///
61 /// This property holds the slider's current maximum value.
62 /// The slider forces the maximum value to be within the legal range:
63 /// The slider silently forces maximumValue to be within the legal range:
64 /// Changing the maximumValue also changes the maximumPosition.
65 int maximumValue() const;
66
67 ///
68 /// This property holds the current slider minimum position.
69 /// If tracking is enabled (the default), this is identical to minimumValue.
70 int minimumPosition() const;
71 void setMinimumPosition(int min);
72
73 ///
74 /// This property holds the current slider maximum position.
75 /// If tracking is enabled (the default), this is identical to maximumValue.
76 int maximumPosition() const;
77 void setMaximumPosition(int max);
78
79 ///
80 /// Utility function that set the minimum position and
81 /// maximum position at once.
82 void setPositions(int min, int max);
83
84 ///
85 /// When symmetricMoves is true, moving a handle will move the other handle
86 /// symmetrically, otherwise the handles are independent. False by default
87 bool symmetricMoves()const;
88 void setSymmetricMoves(bool symmetry);
89
90 ///
91 /// Controls the text to display for the handle tooltip. It is in addition
92 /// to the widget tooltip.
93 /// "%1" is replaced by the current value of the slider.
94 /// Empty string (by default) means no tooltip.
95 QString handleToolTip()const;
96 void setHandleToolTip(const QString &toolTip);
97
98 /// Returns true if the minimum value handle is down, false if it is up.
99 /// \sa isMaximumSliderDown()
100 bool isMinimumSliderDown()const;
101 /// Returns true if the maximum value handle is down, false if it is up.
102 /// \sa isMinimumSliderDown()
103 bool isMaximumSliderDown()const;
104
105 Q_SIGNALS:
106 ///
107 /// This signal is emitted when the slider minimum value has changed,
108 /// with the new slider value as argument.
109 void minimumValueChanged(int min);
110 ///
111 /// This signal is emitted when the slider maximum value has changed,
112 /// with the new slider value as argument.
113 void maximumValueChanged(int max);
114 ///
115 /// Utility signal that is fired when minimum or maximum values have changed.
116 void valuesChanged(int min, int max);
117
118 ///
119 /// This signal is emitted when sliderDown is true and the slider moves.
120 /// This usually happens when the user is dragging the minimum slider.
121 /// The value is the new slider minimum position.
122 /// This signal is emitted even when tracking is turned off.
124
125 ///
126 /// This signal is emitted when sliderDown is true and the slider moves.
127 /// This usually happens when the user is dragging the maximum slider.
128 /// The value is the new slider maximum position.
129 /// This signal is emitted even when tracking is turned off.
131
132 ///
133 /// Utility signal that is fired when minimum or maximum positions
134 /// have changed.
135 void positionsChanged(int min, int max);
136
137 public Q_SLOTS:
138 ///
139 /// This property holds the slider's current minimum value.
140 /// The slider silently forces min to be within the legal range:
141 /// minimum() <= min <= maximumValue() <= maximum().
142 /// Note: Changing the minimumValue also changes the minimumPosition.
143 /// \sa stMaximumValue, setValues, setMinimum, setMaximum, setRange
144 void setMinimumValue(int min);
145
146 ///
147 /// This property holds the slider's current maximum value.
148 /// The slider silently forces max to be within the legal range:
149 /// minimum() <= minimumValue() <= max <= maximum().
150 /// Note: Changing the maximumValue also changes the maximumPosition.
151 /// \sa stMinimumValue, setValues, setMinimum, setMaximum, setRange
152 void setMaximumValue(int max);
153
154 ///
155 /// Utility function that set the minimum value and maximum value at once.
156 /// The slider silently forces min and max to be within the legal range:
157 /// minimum() <= min <= max <= maximum().
158 /// Note: Changing the minimumValue and maximumValue also changes the
159 /// minimumPosition and maximumPosition.
160 /// \sa setMinimumValue, setMaximumValue, setMinimum, setMaximum, setRange
161 void setValues(int min, int max);
162
163 protected Q_SLOTS:
164 void onRangeChanged(int minimum, int maximum);
165
166 protected:
167 ctkRangeSlider( ctkRangeSliderPrivate* impl, Qt::Orientation o, QWidget* par = 0 );
168 ctkRangeSlider( ctkRangeSliderPrivate* impl, QWidget* par = 0 );
169
170 // Description:
171 // Standard Qt UI events
172 virtual void mousePressEvent(QMouseEvent* ev) override;
173 virtual void mouseMoveEvent(QMouseEvent* ev) override;
174 virtual void mouseReleaseEvent(QMouseEvent* ev) override;
175
176 // Description:
177 // Rendering is done here.
178 virtual void paintEvent(QPaintEvent* ev) override;
179 virtual void initMinimumSliderStyleOption(QStyleOptionSlider* option) const;
180 virtual void initMaximumSliderStyleOption(QStyleOptionSlider* option) const;
181
182 // Description:
183 // Reimplemented for the tooltips
184 virtual bool event(QEvent* event) override;
185
186 protected:
188
189 private:
190 Q_DECLARE_PRIVATE(ctkRangeSlider);
191 Q_DISABLE_COPY(ctkRangeSlider);
192};
193
194#endif
195
A ctkRangeSlider is a slider that lets you input 2 values instead of one (see QSlider).
void setPositions(int min, int max)
Utility function that set the minimum position and maximum position at once.
void minimumPositionChanged(int min)
This signal is emitted when sliderDown is true and the slider moves.
void setMaximumValue(int max)
This property holds the slider's current maximum value.
void minimumValueChanged(int min)
This signal is emitted when the slider minimum value has changed, with the new slider value as argume...
ctkRangeSlider(Qt::Orientation o, QWidget *par=0)
Constructor, builds a ctkRangeSlider that ranges from 0 to 100 and has a lower and upper values of 0 ...
bool isMinimumSliderDown() const
Returns true if the minimum value handle is down, false if it is up.
void maximumValueChanged(int max)
This signal is emitted when the slider maximum value has changed, with the new slider value as argume...
void maximumPositionChanged(int max)
This signal is emitted when sliderDown is true and the slider moves.
void positionsChanged(int min, int max)
Utility signal that is fired when minimum or maximum positions have changed.
void setValues(int min, int max)
Utility function that set the minimum value and maximum value at once.
bool isMaximumSliderDown() const
Returns true if the maximum value handle is down, false if it is up.
void valuesChanged(int min, int max)
Utility signal that is fired when minimum or maximum values have changed.
void setMinimumValue(int min)
This property holds the slider's current minimum value.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
Orientation
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:01 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.