1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef MODULEBASE_DOUBLESPINBOX_H_
22 #define MODULEBASE_DOUBLESPINBOX_H_
24 #include "ModuleBase.h"
26 #include <QDoubleSpinBox>
35 * An extension and customization of QDoubleSpinBox class
37 class MODULEBASE_EXPORT ModuleBase_DoubleSpinBox : public QDoubleSpinBox
42 explicit ModuleBase_DoubleSpinBox( QWidget* theParent = 0, int thePrecision = -12 );
43 virtual ~ModuleBase_DoubleSpinBox();
45 /// Returns true if the control is clear
46 bool isCleared() const;
49 virtual void setCleared(const bool);
51 /// Returns current precision
52 int getPrecision() const;
55 void setPrecision(const int);
58 virtual void stepBy(int);
60 /// Converts value from string to double
61 virtual double valueFromText(const QString&) const;
63 /// Convert value from double to string
64 virtual QString textFromValue(double) const;
66 /// Validate current value
67 virtual QValidator::State validate(QString&, int&) const;
69 /// Imitation of disable control value. If theEnable is false, the control becomes
70 /// read only and base color is disabled.
71 void setValueEnabled(const bool& theEnable);
74 /// Called on text changed
75 virtual void onTextChanged(const QString&);
78 /// Removes extra trailing zero symbols
79 QString removeTrailingZeroes(const QString&) const;
82 // boolen flag whether the key event is emitted. The default value is false
83 bool myIsEmitKeyPressEvent;
91 /// Cashed color of active base palette
92 QColor myEnabledBaseColor;