1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : QtxIntSpinSlider.cxx
23 // Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com)
25 #include "QtxIntSpinSlider.h"
28 * CONSTRUCTOR of spin box
30 QtxIntSpinSlider::QtxIntSpinSlider( QWidget* theParent ) : QtxSlider( theParent )
32 // Get default value of slider
33 int aMin = mySlider->minimum();
34 int aMax = mySlider->maximum();
35 int aStep = mySlider->singleStep();
38 myIntSpinBox = new QtxIntSpinBox( aMin, aMax, aStep, theParent );
39 myIntSpinBox->setFixedWidth( 100 );
41 // Add widget in main layout
42 mainLayout->addWidget( myIntSpinBox );
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 )) );
49 QtxIntSpinSlider::QtxIntSpinSlider( int theMin, int theMax, int theStep, QWidget* theParent )
51 // Set value of slider
52 mySlider->setRange( theMin, theMax );
53 mySlider->setSingleStep( theStep );
56 myIntSpinBox = new QtxIntSpinBox( theMin, theMax, theStep, theParent );
57 myIntSpinBox->setFixedWidth( 100 );
59 // Add widgets in main layout
60 mainLayout->addWidget( myIntSpinBox );
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 )) );
68 * DESTRUCTOR of spin box
70 QtxIntSpinSlider::~QtxIntSpinSlider()
76 SLOT: Called when the value of spin box change
78 void QtxIntSpinSlider::IntSpinHasChanged( int theValue )
80 mySlider->blockSignals( true );
81 mySlider->setValue( theValue );
82 mySlider->blockSignals( false );
83 emit valueChanged( theValue );
87 * Get font of spin box
89 QFont QtxIntSpinSlider::font()
91 return myIntSpinBox->font();
95 * Set font of spin box
97 void QtxIntSpinSlider::setFont( QFont& theFont )
99 myIntSpinBox->setFont( theFont );
103 * Get value of spin box
105 int QtxIntSpinSlider::value()
107 return myIntSpinBox->value();
111 * Set value of spin box
113 void QtxIntSpinSlider::setValue( int theValue )
115 myIntSpinBox->setValue( theValue );
118 void QtxIntSpinSlider::setUnit( QString& theUnit )
120 myIntSpinBox->setSuffix( theUnit );