]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_DoubleSpinBox.h
Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/gui.git] / src / SalomeApp / SalomeApp_DoubleSpinBox.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:      SalomeApp_DoubleSpinBox.h
20 // Author:    Oleg UVAROV
21
22 #ifndef SALOMEAPP_DOUBLESPINBOX_H
23 #define SALOMEAPP_DOUBLESPINBOX_H
24
25 #include "SalomeApp.h"
26
27 #include <QtxDoubleSpinBox.h>
28
29 #include <QValidator>
30
31 class SALOMEAPP_EXPORT SalomeApp_DoubleSpinBox : public QtxDoubleSpinBox
32 {
33   Q_OBJECT
34
35   enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
36   enum SearchState { NotFound = 0, IncorrectType, Found };
37
38 public:
39   SalomeApp_DoubleSpinBox( QWidget* = 0 );
40   SalomeApp_DoubleSpinBox( double, double, double = 1, QWidget* = 0 );
41   SalomeApp_DoubleSpinBox( double, double, double, int, int, QWidget* = 0 );
42   virtual ~SalomeApp_DoubleSpinBox();
43
44   virtual double            valueFromText( const QString& ) const;
45   virtual QString           textFromValue( double ) const;
46
47   virtual QValidator::State validate( QString&, int& ) const;
48
49   virtual bool              isValid( QString& msg, bool = false );
50
51   virtual void              setDefaultValue( const double );
52
53   virtual void              setRange( double, double );
54   virtual void              setValue( double );
55
56   virtual void              setText(const QString& );
57
58 signals:
59   void                      textChanged( const QString& );
60
61 protected:
62   State                     isValid( const QString&, double& ) const;
63
64   double                    defaultValue() const;
65   bool                      checkRange( const double ) const;
66
67   SearchState               findVariable( const QString&, double& ) const;
68
69 protected:
70   virtual void              keyPressEvent( QKeyEvent* );
71   virtual void              showEvent( QShowEvent* );
72
73 protected slots:
74   void                      onEditingFinished();
75   void                      onTextChanged( const QString& );
76
77 private:
78   void                      connectSignalsAndSlots();
79
80 private:
81   double                    myDefaultValue; 
82
83   bool                      myIsRangeSet;
84   double                    myMinimum;
85   double                    myMaximum;
86
87   QString                   myCorrectValue;
88   QString                   myTextValue;
89 };
90
91 #endif