Version: 9.12.0
SalomeApp_DoubleSpinBox.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
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, or (at your option) any later version.
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 
20 // File: SalomeApp_DoubleSpinBox.h
21 // Author: Oleg UVAROV
22 //
23 #ifndef SALOMEAPP_DOUBLESPINBOX_H
24 #define SALOMEAPP_DOUBLESPINBOX_H
25 
26 #include "SalomeApp.h"
27 
28 #include <QtxDoubleSpinBox.h>
29 
30 #include <QValidator>
31 
33 {
34  Q_OBJECT
35 
36  enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
37  enum SearchState { NotFound = 0, IncorrectType, Found };
38 
39 public:
41  SalomeApp_DoubleSpinBox( double, double, double = 1, QWidget* = 0 );
42  SalomeApp_DoubleSpinBox( double, double, double, int, int, QWidget* = 0, bool = true, bool = true );
43  virtual ~SalomeApp_DoubleSpinBox();
44 
45  virtual void stepBy( int );
46 
47  virtual double valueFromText( const QString& ) const;
48  virtual QString textFromValue( double ) const;
49 
50  virtual QValidator::State validate( QString&, int& ) const;
51 
52  virtual bool isValid( QString& msg, bool = false );
53 
54  virtual void setDefaultValue( const double );
55 
56  virtual void setRange( double, double );
57  virtual void setValue( double );
58 
59  virtual void setText(const QString& );
60 
61  void setAcceptNames( const bool );
62  bool isAcceptNames() const;
63 
64  void setShowTipOnValidate( const bool );
65  bool isShowTipOnValidate() const;
66 
67 signals:
68  void textChanged( const QString& );
69 
70 protected:
71  State isValid( const QString&, double& ) const;
72 
73  double defaultValue() const;
74  bool checkRange( const double ) const;
75 
76  SearchState findVariable( const QString&, double& ) const;
77 
78 protected:
79  virtual void keyPressEvent( QKeyEvent* );
80  virtual void showEvent( QShowEvent* );
81 
82 protected slots:
83  void onEditingFinished();
84  void onTextChanged( const QString& );
85 
86 private:
87  void connectSignalsAndSlots();
88 
89 private:
90  double myDefaultValue;
91 
93  double myMinimum;
94  double myMaximum;
95 
96  QString myCorrectValue;
97  QString myTextValue;
98 
100  bool myShowTip;
101 };
102 
103 #endif
bool isValid(const QPolygon *thePoints, const QPoint &theCurrent)
Definition: SVTK_InteractorStyle.cxx:1746
#define SALOMEAPPIMPL_EXPORT
Definition: SalomeApp.h:55
Enhanced version of the Qt's double spin box.
Definition: QtxDoubleSpinBox.h:32
virtual QString textFromValue(double) const
This function is used by the spin box whenever it needs to display the given value.
Definition: QtxDoubleSpinBox.cxx:249
virtual QValidator::State validate(QString &, int &) const
This function is used to determine whether input is valid.
Definition: QtxDoubleSpinBox.cxx:314
virtual double valueFromText(const QString &) const
Interpret text entered by the user as a value.
Definition: QtxDoubleSpinBox.cxx:233
virtual void stepBy(int)
Perform steps increment/decrement steps.
Definition: QtxDoubleSpinBox.cxx:296
virtual void onTextChanged(const QString &)
Called when user enters the text in the spin box.
Definition: QtxDoubleSpinBox.cxx:399
Definition: SalomeApp_DoubleSpinBox.h:33
QString myTextValue
Definition: SalomeApp_DoubleSpinBox.h:97
void textChanged(const QString &)
bool myIsRangeSet
Definition: SalomeApp_DoubleSpinBox.h:92
QString myCorrectValue
Definition: SalomeApp_DoubleSpinBox.h:96
double myMinimum
Definition: SalomeApp_DoubleSpinBox.h:93
double myDefaultValue
Definition: SalomeApp_DoubleSpinBox.h:90
State
Definition: SalomeApp_DoubleSpinBox.h:36
SearchState
Definition: SalomeApp_DoubleSpinBox.h:37
bool myAcceptNames
Definition: SalomeApp_DoubleSpinBox.h:99
bool myShowTip
Definition: SalomeApp_DoubleSpinBox.h:100
double myMaximum
Definition: SalomeApp_DoubleSpinBox.h:94