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 
79 class PQWIDGETS_EXPORT ctkRangeSlider : public QSlider
80 {
81  Q_OBJECT
82  Q_PROPERTY(int minimumValue READ minimumValue WRITE setMinimumValue)
83  Q_PROPERTY(int maximumValue READ maximumValue WRITE setMaximumValue)
84  Q_PROPERTY(int minimumPosition READ minimumPosition WRITE setMinimumPosition)
85  Q_PROPERTY(int maximumPosition READ maximumPosition WRITE setMaximumPosition)
86  Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
87  Q_PROPERTY(QString handleToolTip READ handleToolTip WRITE setHandleToolTip)
88 
89 public:
90  // Superclass typedef
91  typedef QSlider Superclass;
95  explicit ctkRangeSlider( Qt::Orientation o, QWidget* par= 0 );
96  explicit ctkRangeSlider( QWidget* par = 0 );
97  virtual ~ctkRangeSlider();
98 
104  int minimumValue() const;
105 
111  int maximumValue() const;
112 
116  int minimumPosition() const;
117  void setMinimumPosition(int min);
118 
122  int maximumPosition() const;
123  void setMaximumPosition(int max);
124 
128  void setPositions(int min, int max);
129 
133  bool symmetricMoves()const;
134  void setSymmetricMoves(bool symmetry);
135 
141  QString handleToolTip()const;
142  void setHandleToolTip(const QString& toolTip);
143 
144 Q_SIGNALS:
148  void minimumValueChanged(int min);
152  void maximumValueChanged(int max);
155  void valuesChanged(int min, int max);
156 
162  void minimumPositionChanged(int min);
163 
169  void maximumPositionChanged(int max);
170 
174  void positionsChanged(int min, int max);
175 
176 public Q_SLOTS:
183  void setMinimumValue(int min);
184 
191  void setMaximumValue(int max);
192 
200  void setValues(int min, int max);
201 
202 protected Q_SLOTS:
203  void onRangeChanged(int minimum, int maximum);
204 
205 protected:
206  ctkRangeSlider( ctkRangeSliderPrivate* impl, Qt::Orientation o, QWidget* par= 0 );
207  ctkRangeSlider( ctkRangeSliderPrivate* impl, QWidget* par = 0 );
208 
209  // Description:
210  // Standard Qt UI events
211  virtual void mousePressEvent(QMouseEvent* ev);
212  virtual void mouseMoveEvent(QMouseEvent* ev);
213  virtual void mouseReleaseEvent(QMouseEvent* ev);
214  virtual void mouseDoubleClickEvent(QMouseEvent *ev);
215 
216  bool isMinimumSliderDown()const;
217  bool isMaximumSliderDown()const;
218 
219  // Description:
220  // Rendering is done here.
221  virtual void paintEvent(QPaintEvent* ev);
222  virtual void initMinimumSliderStyleOption(QStyleOptionSlider* option) const;
223  virtual void initMaximumSliderStyleOption(QStyleOptionSlider* option) const;
224 
225  // Description:
226  // Reimplemented for the tooltips
227  virtual bool event(QEvent* event);
228 
229 protected:
230  QScopedPointer<ctkRangeSliderPrivate> d_ptr;
231 
232 private:
233  Q_DECLARE_PRIVATE(ctkRangeSlider);
234  Q_DISABLE_COPY(ctkRangeSlider)
235 };
236 
237 #endif
QSlider Superclass
A ctkRangeSlider is a slider that lets you input 2 values instead of one (see QSlider).