Salome HOME
0020321: EDF : Some windows do not appear depending on the platform (MinimumSizeHint())
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SpinBox.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File   : SMESHGUI_SpinBox.cxx
24 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
25 // SMESH includes
26 //
27 #include "SMESHGUI_SpinBox.h"
28
29 // Qt includes
30 #include <QDoubleValidator>
31 #include <QLineEdit>
32
33 //=================================================================================
34 // class    : SMESHGUI_SpinBox()
35 // purpose  : constructor of specific widget accepting floats in double precision.
36 //=================================================================================
37 SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent )
38   : SalomeApp_DoubleSpinBox( parent )
39 {
40 }
41
42 //=================================================================================
43 // function : ~SMESHGUI_SpinBox()
44 // purpose  : destructor
45 //=================================================================================
46 SMESHGUI_SpinBox::~SMESHGUI_SpinBox()
47 {
48 }
49
50 //=================================================================================
51 // function : SetStep()  [SLOT]
52 // purpose  :
53 //=================================================================================
54 void SMESHGUI_SpinBox::SetStep( double newStep )
55 {
56   setSingleStep( newStep );
57 }
58
59 //=================================================================================
60 // function : SetValue()
61 // purpose  :
62 //=================================================================================
63 void SMESHGUI_SpinBox::SetValue( double v )
64 {
65   setValue(v);
66   editor()->setCursorPosition( 0 );
67 }
68
69 //=================================================================================
70 // function : GetValue()
71 // purpose  : returns a double
72 //=================================================================================
73 double SMESHGUI_SpinBox::GetValue() const
74 {
75   return value();
76 }
77
78 //=================================================================================
79 // function : GetString()
80 // purpose  : returns a QString
81 //=================================================================================
82 QString SMESHGUI_SpinBox::GetString() const
83 {
84   return cleanText();
85 }
86
87 //=================================================================================
88 // function : editor()
89 // purpose  : returns editor
90 //=================================================================================
91 QLineEdit* SMESHGUI_SpinBox::editor() const
92 {
93   return SalomeApp_DoubleSpinBox::lineEdit();
94
95
96 //=================================================================================
97 // function : validator()
98 // purpose  : returns validator
99 //=================================================================================
100 QDoubleValidator* SMESHGUI_SpinBox::validator() const
101 {
102   return (QDoubleValidator*)editor()->validator();
103 }
104
105 //=================================================================================
106 // function : RangeStepAndValidator()
107 // purpose  :
108 //=================================================================================
109 void SMESHGUI_SpinBox::RangeStepAndValidator( double min,
110                                               double max,
111                                               double step,
112                                               unsigned short precision )
113 {
114   setPrecision(precision*(-1)); // PAL8769. Minus is for using 'g' double->string conversion specifier,
115   //                               see QtxDoubleSpinBox::mapValueToText( double v )
116   setDecimals(32);
117   setRange(min, max);
118   setSingleStep( step );
119   setDefaultValue( min );
120 }