]> SALOME platform Git repositories - modules/gui.git/blob - src/SalomeApp/SalomeApp_IntSpinBox.h
Salome HOME
d15fe99c1d811f777e93a1e645366729c124abb1
[modules/gui.git] / src / SalomeApp / SalomeApp_IntSpinBox.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_IntSpinBox.h
20 // Author:    Oleg UVAROV
21
22 #ifndef SALOMEAPP_INTSPINBOX_H
23 #define SALOMEAPP_INTSPINBOX_H
24
25 #include "SalomeApp.h"
26
27 #include <QtxIntSpinBox.h>
28
29 #include <QValidator>
30
31 class SALOMEAPP_EXPORT SalomeApp_IntSpinBox : public QtxIntSpinBox
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_IntSpinBox( QWidget* = 0 );
40   SalomeApp_IntSpinBox( int, int, int = 1, QWidget* = 0 );
41   virtual ~SalomeApp_IntSpinBox();
42
43   virtual int               valueFromText( const QString& ) const;
44   virtual QString           textFromValue( int ) const;
45
46   virtual QValidator::State validate( QString&, int& ) const;
47
48   virtual bool              isValid( QString& msg, bool = false );
49
50   virtual void              setDefaultValue( const int );
51
52   virtual void              setValue( int );
53
54   virtual void              setText(const QString& );
55
56 signals:
57   void                      textChanged( const QString& );
58
59 protected:
60   State                     isValid( const QString&, int& ) const;
61
62   int                       defaultValue() const;
63   bool                      checkRange( const int ) const;
64
65   SearchState               findVariable( const QString&, int& ) const;
66
67 protected:
68   virtual void              keyPressEvent( QKeyEvent* );
69   virtual void              showEvent( QShowEvent* );
70
71 protected slots:
72   void                      onEditingFinished();
73   void                      onTextChanged( const QString& );
74
75 private:
76   void                      connectSignalsAndSlots();
77
78 private:
79   int                       myDefaultValue; 
80
81   QString                   myCorrectValue;
82   QString                   myTextValue;
83 };
84
85 #endif