1 // Copyright (C) 2007-2016 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 : QtxSlider.cxx
23 // Author : Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com)
25 #include "QtxSlider.h"
28 * CONSTRUCTOR of slider
30 QtxSlider::QtxSlider( QWidget* theParent ) : QWidget( theParent )
33 mySlider = new QSlider( Qt::Horizontal, theParent );
34 mySlider->setFocusPolicy( Qt::NoFocus );
35 mySlider->setMinimumSize( 250, 0 );
36 mySlider->setTracking( false );
38 // Add widgets in main layout
39 mainLayout = new QHBoxLayout();
40 mainLayout->addWidget( mySlider );
41 mainLayout->setContentsMargins( 0, 0, 0, 0 );
42 this->setLayout( mainLayout );
44 // Signals and slots connections
45 connect( mySlider, SIGNAL(sliderMoved( int )), this, SLOT(SliderHasMoved( int )) );
46 connect( mySlider, SIGNAL(valueChanged( int )), this, SLOT(SliderHasMoved( int )) );
49 QtxSlider::QtxSlider( int theMin, int theMax, int theStep, QWidget* theParent ) : QWidget( theParent )
52 mySlider = new QSlider( Qt::Horizontal, theParent );
53 mySlider->setFocusPolicy( Qt::NoFocus );
54 mySlider->setMinimumSize( 200, 0 );
55 mySlider->setRange( theMin, theMax );
56 mySlider->setSingleStep( theStep );
57 mySlider->setPageStep( 10 );
58 mySlider->setTracking( false );
60 // Add widgets in main layout
61 mainLayout = new QHBoxLayout();
62 mainLayout->addWidget( mySlider );
63 mainLayout->setContentsMargins( 0, 0, 0, 0 );
64 this->setLayout( mainLayout );
66 // Signals and slots connections
67 connect( mySlider, SIGNAL(sliderMoved( int )), this, SLOT(SliderHasMoved( int )) );
68 connect( mySlider, SIGNAL(valueChanged( int )), this, SLOT(SliderHasMoved( int )) );
72 * DESTRUCTOR of slider
74 QtxSlider::~QtxSlider()
80 SLOT: Called when the value of slider change
82 void QtxSlider::SliderHasMoved( int theValue )
84 emit valueUpdated( theValue );
90 int QtxSlider::value()
92 return mySlider->value();
98 void QtxSlider::setValue( int theValue )
100 mySlider->setValue( theValue );
104 * Set range of slider
106 void QtxSlider::setRange( int theMin, int theMax )
108 mySlider->setRange( theMin, theMax );
112 * Set single step of slider
114 void QtxSlider::setSingleStep( int theStep )
116 mySlider->setSingleStep( theStep );