1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef MODULEBASE_DOUBLESPINBOX_H_
21 #define MODULEBASE_DOUBLESPINBOX_H_
23 #include "ModuleBase.h"
25 #include <QDoubleSpinBox>
34 * An extension and customization of QDoubleSpinBox class
36 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
41 explicit ModuleBase_DoubleSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
42 virtual ~ModuleBase_DoubleSpinBox();
44 /// Returns true if the control is clear
45 bool isCleared() const;
48 virtual void setCleared(const bool);
50 /// Returns current precision
51 int getPrecision() const;
54 void setPrecision(const int);
57 virtual void stepBy(int);
59 /// Converts value from string to double
60 virtual double valueFromText(const QString&) const;
62 /// Convert value from double to string
63 virtual QString textFromValue(double) const;
65 /// Validate current value
66 virtual QValidator::State validate(QString&, int&) const;
68 /// Imitation of disable control value. If theEnable is false, the control becomes
69 /// read only and base color is disabled.
70 void setValueEnabled(const bool& theEnable);
73 /// Called on text changed
74 virtual void onTextChanged(const QString&);
77 /// Removes extra trailing zero symbols
78 QString removeTrailingZeroes(const QString&) const;
81 // boolen flag whether the key event is emitted. The default value is false
82 bool myIsEmitKeyPressEvent;
90 /// Cashed color of active base palette
91 QColor myEnabledBaseColor;