ParaView
ctkRangeSlider.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: pqSpinBox.h
5 
6  Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 /*=========================================================================
33 
34  Library: CTK
35 
36  Copyright (c) Kitware Inc.
37 
38  Licensed under the Apache License, Version 2.0 (the "License");
39  you may not use this file except in compliance with the License.
40  You may obtain a copy of the License at
41 
42  http://www.apache.org/licenses/LICENSE-2.0.txt
43 
44  Unless required by applicable law or agreed to in writing, software
45  distributed under the License is distributed on an "AS IS" BASIS,
46  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
47  See the License for the specific language governing permissions and
48  limitations under the License.
49 
50 =========================================================================*/
51 
52 #ifndef ctkRangeSlider_h
53 #define ctkRangeSlider_h
54 
55 // Qt includes
56 #include <QSlider>
57 
58 // PQ includes
59 #include "pqWidgetsModule.h"
60 
61 class QStylePainter;
62 class ctkRangeSliderPrivate;
63 
81 class PQWIDGETS_EXPORT ctkRangeSlider : public QSlider
82 {
83  Q_OBJECT
84  Q_PROPERTY(int minimumValue READ minimumValue WRITE setMinimumValue)
85  Q_PROPERTY(int maximumValue READ maximumValue WRITE setMaximumValue)
86  Q_PROPERTY(int minimumPosition READ minimumPosition WRITE setMinimumPosition)
87  Q_PROPERTY(int maximumPosition READ maximumPosition WRITE setMaximumPosition)
88  Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
89  Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip)
90 
91 public:
92  // Superclass typedef
93  typedef QSlider Superclass;
99  explicit ctkRangeSlider(Qt::Orientation o, QWidget* par = 0);
100  explicit ctkRangeSlider(QWidget* par = 0);
101  virtual ~ctkRangeSlider();
102 
110  int minimumValue() const;
111 
119  int maximumValue() const;
120 
126  int minimumPosition() const;
127  void setMinimumPosition(int min);
128 
134  int maximumPosition() const;
135  void setMaximumPosition(int max);
136 
142  void setPositions(int min, int max);
143 
149  bool symmetricMoves() const;
150  void setSymmetricMoves(bool symmetry);
151 
159  QString handleToolTip() const;
160  void setHandleToolTip(const QString& toolTip);
161 
162 Q_SIGNALS:
168  void minimumValueChanged(int min);
174  void maximumValueChanged(int max);
179  void valuesChanged(int min, int max);
180 
188  void minimumPositionChanged(int min);
189 
197  void maximumPositionChanged(int max);
198 
204  void positionsChanged(int min, int max);
205 
206 public Q_SLOTS:
215  void setMinimumValue(int min);
216 
225  void setMaximumValue(int max);
226 
236  void setValues(int min, int max);
237 
238 protected Q_SLOTS:
239  void onRangeChanged(int minimum, int maximum);
240 
241 protected:
242  ctkRangeSlider(ctkRangeSliderPrivate* impl, Qt::Orientation o, QWidget* par = 0);
243  ctkRangeSlider(ctkRangeSliderPrivate* impl, QWidget* par = 0);
244 
245  // Description:
246  // Standard Qt UI events
247  virtual void mousePressEvent(QMouseEvent* ev);
248  virtual void mouseMoveEvent(QMouseEvent* ev);
249  virtual void mouseReleaseEvent(QMouseEvent* ev);
250  virtual void mouseDoubleClickEvent(QMouseEvent* ev);
251 
252  bool isMinimumSliderDown() const;
253  bool isMaximumSliderDown() const;
254 
255  // Description:
256  // Rendering is done here.
257  virtual void paintEvent(QPaintEvent* ev);
258  virtual void initMinimumSliderStyleOption(QStyleOptionSlider* option) const;
259  virtual void initMaximumSliderStyleOption(QStyleOptionSlider* option) const;
260 
261  // Description:
262  // Reimplemented for the tooltips
263  virtual bool event(QEvent* event);
264 
265 protected:
266  QScopedPointer<ctkRangeSliderPrivate> d_ptr;
267 
268 private:
269  Q_DECLARE_PRIVATE(ctkRangeSlider);
270  Q_DISABLE_COPY(ctkRangeSlider)
271 };
272 
273 #endif
QSlider Superclass
A ctkRangeSlider is a slider that lets you input 2 values instead of one (see QSlider).