]> SALOME platform Git repositories - modules/gui.git/blob - src/Qtx/QtxDblSpinBox.h
Salome HOME
Bug fix for SSPP10924
[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/
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 class QTX_EXPORT QtxDblSpinBox : public QSpinBox
30 {
31   Q_OBJECT
32
33   class Validator;
34
35 public:
36         typedef enum QSpinBox::ButtonSymbols ButtonSymbols;
37
38 public:
39   QtxDblSpinBox( QWidget* = 0, const char* = 0 );
40   QtxDblSpinBox( double, double, double = 1, QWidget* = 0, const char* = 0 );
41   virtual ~QtxDblSpinBox();
42
43   double                   minValue() const;
44   double                   maxValue() const;
45   void               setMinValue( int );
46   void               setMaxValue( int );
47   void               setMinValue( double );
48   void               setMaxValue( double );
49   void               setRange( int, int );
50   virtual void       setRange( double, double );
51
52   double                   lineStep() const;
53   void               setLineStep( int );
54   virtual void       setLineStep( double );
55
56   double             value() const;
57
58   int                precision() const;
59   virtual void       setPrecision( const int );
60   
61   bool               isCleared() const;
62   virtual void       setCleared( const bool );
63   
64   virtual bool       eventFilter( QObject*, QEvent* );
65     
66 signals:
67   void               valueChanged( double );
68   void                     valueChanged( const QString& );
69     
70 public slots:
71   virtual void       stepUp();
72   virtual void       stepDown();
73   virtual void       selectAll();
74   virtual void       setValue( int );
75   virtual void       setValue( double );
76   
77 protected slots:
78   virtual void       onTextChanged( const QString& );
79
80 protected:
81   virtual void       updateDisplay();
82   virtual void       interpretText();
83   
84   virtual void       valueChange();
85   virtual void       rangeChange();
86   
87   QString            currentValueText();
88   virtual QString    mapValueToText( int );
89   virtual QString    mapValueToText( double );
90   virtual double     mapTextToDoubleValue( bool* );
91   
92   virtual void       leaveEvent( QEvent* );
93   virtual void       wheelEvent( QWheelEvent* );
94   
95   double             bound( double );
96
97   QString            removeTrailingZeroes( const QString& ) const;
98
99 private:
100   double             myMin;
101   double             myMax;
102   double             myStep;
103   double             myValue;
104   bool               myCleared;
105   bool               myBlocked;
106   int                myPrecision;
107 };
108
109 #endif