Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / Qtx / QtxDblSpinBox.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File:      QtxDblSpinBox.h
20 // Author:    Sergey TELKOV
21
22 #ifndef QTXDBLSPINBOX_H
23 #define QTXDBLSPINBOX_H
24
25 #include "Qtx.h"
26
27 #include <qspinbox.h>
28
29 /*!
30   \class  QtxDblSpinBox
31   Spin box for real numbers.
32 */
33 class QTX_EXPORT QtxDblSpinBox : public QSpinBox
34 {
35   Q_OBJECT
36
37   class Validator;
38
39 public:
40         typedef enum QSpinBox::ButtonSymbols ButtonSymbols;
41
42 public:
43   QtxDblSpinBox( QWidget* = 0, const char* = 0 );
44   QtxDblSpinBox( double, double, double = 1, QWidget* = 0, const char* = 0 );
45   virtual ~QtxDblSpinBox();
46
47   double                   minValue() const;
48   double                   maxValue() const;
49   void               setMinValue( int );
50   void               setMaxValue( int );
51   void               setMinValue( double );
52   void               setMaxValue( double );
53   void               setRange( int, int );
54   virtual void       setRange( double, double );
55
56   double                   lineStep() const;
57   void               setLineStep( int );
58   virtual void       setLineStep( double );
59
60   double             value() const;
61
62   int                precision() const;
63   virtual void       setPrecision( const int );
64   
65   bool               isCleared() const;
66   virtual void       setCleared( const bool );
67   
68   virtual bool       eventFilter( QObject*, QEvent* );
69     
70 signals:
71   void               valueChanged( double );
72   void                     valueChanged( const QString& );
73     
74 public slots:
75   virtual void       stepUp();
76   virtual void       stepDown();
77   virtual void       selectAll();
78   virtual void       setValue( int );
79   virtual void       setValue( double );
80   
81 protected slots:
82   virtual void       onTextChanged( const QString& );
83
84 protected:
85   virtual void       updateDisplay();
86   virtual void       interpretText();
87   
88   virtual void       valueChange();
89   virtual void       rangeChange();
90   
91   QString            currentValueText();
92   virtual QString    mapValueToText( int );
93   virtual QString    mapValueToText( double );
94   virtual double     mapTextToDoubleValue( bool* );
95   
96   virtual void       leaveEvent( QEvent* );
97   virtual void       wheelEvent( QWheelEvent* );
98   
99   double             bound( double );
100
101   QString            removeTrailingZeroes( const QString& ) const;
102
103 private:
104   double             myMin;
105   double             myMax;
106   double             myStep;
107   double             myValue;
108   bool               myCleared;
109   bool               myBlocked;
110   int                myPrecision;
111 };
112
113 #endif