Salome HOME
updated copyright message
[modules/gui.git] / src / Qtx / QtxIntSpinSlider.cxx
1 // Copyright (C) 2007-2023  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, or (at your option) any later version.
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 // File   : QtxIntSpinSlider.cxx
23 // Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com)
24
25 #include "QtxIntSpinSlider.h"
26
27 /*!
28  * CONSTRUCTOR of spin box
29  */
30 QtxIntSpinSlider::QtxIntSpinSlider( QWidget* theParent ) : QtxSlider( theParent )
31 {
32   // Get default value of slider
33   int aMin = mySlider->minimum();
34   int aMax = mySlider->maximum();
35   int aStep = mySlider->singleStep();
36   
37   // Create spin box
38   myIntSpinBox = new QtxIntSpinBox( aMin, aMax, aStep, theParent );
39   myIntSpinBox->setFixedWidth( 100 );
40
41   // Add widget in main layout
42   mainLayout->addWidget( myIntSpinBox );
43
44   // Signals and slots connections
45   connect( myIntSpinBox, SIGNAL(valueChanged( int )), this, SLOT(IntSpinHasChanged( int )) );
46   connect( this, SIGNAL(valueUpdated( int )), this, SLOT(setValue( int )) );
47 }
48
49 QtxIntSpinSlider::QtxIntSpinSlider( int theMin, int theMax, int theStep, QWidget* theParent )
50 {
51   // Set value of slider
52   mySlider->setRange( theMin, theMax );
53   mySlider->setSingleStep( theStep );
54   
55   // Create spin box
56   myIntSpinBox = new QtxIntSpinBox( theMin, theMax, theStep, theParent );
57   myIntSpinBox->setFixedWidth( 100 );
58
59   // Add widgets in main layout
60   mainLayout->addWidget( myIntSpinBox );
61
62   // Signals and slots connections
63   connect( myIntSpinBox, SIGNAL(valueChanged( int )), this, SLOT(IntSpinHasChanged( int )) );
64   connect( this, SIGNAL(valueUpdated( int )), this, SLOT(setValue( int )) );
65 }
66
67 /*!
68  * DESTRUCTOR of spin box
69  */
70 QtxIntSpinSlider::~QtxIntSpinSlider()
71 {
72   // Empty
73 }
74
75 /*!
76   SLOT: Called when the value of spin box change
77 */
78 void QtxIntSpinSlider::IntSpinHasChanged( int theValue )
79 {
80   mySlider->blockSignals( true );
81   mySlider->setValue( theValue );
82   mySlider->blockSignals( false );
83   emit valueChanged( theValue );
84 }
85
86 /*!
87  * Get font of spin box
88 */
89 QFont QtxIntSpinSlider::font()
90 {
91   return myIntSpinBox->font();
92 }
93
94 /*!
95  * Set font of spin box
96 */
97 void QtxIntSpinSlider::setFont( QFont& theFont )
98 {
99   myIntSpinBox->setFont( theFont );
100 }
101
102 /*!
103  * Get value of spin box
104 */
105 int QtxIntSpinSlider::value()
106 {
107   return myIntSpinBox->value();
108 }
109
110 /*!
111  * Set value of spin box
112 */
113 void QtxIntSpinSlider::setValue( int theValue )
114 {
115   myIntSpinBox->setValue( theValue );
116 }
117
118 void QtxIntSpinSlider::setUnit( QString& theUnit )
119 {
120   myIntSpinBox->setSuffix( theUnit );
121 }