1 #ifndef SOQT_THUMBWHEEL_H 2 #define SOQT_THUMBWHEEL_H 3 4 /**************************************************************************\ 5 * Copyright (c) Kongsberg Oil & Gas Technologies AS 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * Neither the name of the copyright holder nor the names of its 20 * contributors may be used to endorse or promote products derived from 21 * this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 \**************************************************************************/ 35 36 #include <qwidget.h> 37 38 #include <Inventor/Qt/SoQtBasic.h> 39 40 class QPixmap; 41 class SoAnyThumbWheel; 42 43 // ************************************************************************* 44 45 class SOQT_DLL_API SoQtThumbWheel : public QWidget 46 { 47 Q_OBJECT 48 49 public: 50 enum Orientation { Horizontal, Vertical }; 51 52 SoQtThumbWheel(QWidget * parent = 0, const char * name = 0); 53 SoQtThumbWheel(Orientation, QWidget * parent = 0, const char * name = 0); 54 ~SoQtThumbWheel(void); 55 56 void setOrientation(Orientation); 57 Orientation orientation(void) const; 58 59 void setValue(float value); 60 float value(void) const; 61 62 void setEnabled(bool enable); 63 bool isEnabled(void) const; 64 65 enum boundaryHandling { 66 CLAMP, 67 MODULATE, 68 ACCUMULATE 69 }; 70 void setRangeBoundaryHandling(boundaryHandling handling); 71 boundaryHandling getRangeBoundaryHandling(void) const; 72 73 QSize sizeHint(void) const; 74 75 signals: 76 void wheelPressed(void); 77 void wheelMoved(float value); 78 void wheelReleased(void); 79 80 protected: 81 void paintEvent(QPaintEvent *); 82 83 void mousePressEvent(QMouseEvent *); 84 void mouseReleaseEvent(QMouseEvent *); 85 void mouseMoveEvent(QMouseEvent *); 86 87 private: 88 void constructor(Orientation); 89 90 SoQtThumbWheel(const SoQtThumbWheel & wheel); 91 SoQtThumbWheel & operator = (const SoQtThumbWheel & wheel); 92 93 enum State { Idle, Dragging, Disabled } state; 94 95 Orientation orient; 96 float wheelValue, tempWheelValue; 97 int mouseDownPos, mouseLastPos; 98 99 void initWheel(int diameter, int width); 100 101 SoAnyThumbWheel * wheel; 102 QPixmap ** pixmaps; 103 int numPixmaps; 104 int currentPixmap; 105 106 }; // class SoQtThumbWheel 107 108 // ************************************************************************* 109 110 #endif // ! SOQT_THUMBWHEEL_H 111