Back to index

salome-gui  6.5.0
SalomeApp_DoubleSpinBox.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File:      SalomeApp_DoubleSpinBox.h
00021 // Author:    Oleg UVAROV
00022 //
00023 #ifndef SALOMEAPP_DOUBLESPINBOX_H
00024 #define SALOMEAPP_DOUBLESPINBOX_H
00025 
00026 #include "SalomeApp.h"
00027 
00028 #include <QtxDoubleSpinBox.h>
00029 
00030 #include <QValidator>
00031 
00032 class SALOMEAPP_EXPORT SalomeApp_DoubleSpinBox : public QtxDoubleSpinBox
00033 {
00034   Q_OBJECT
00035 
00036   enum State { Invalid = 0, NoVariable, Incompatible, Acceptable };
00037   enum SearchState { NotFound = 0, IncorrectType, Found };
00038 
00039 public:
00040   SalomeApp_DoubleSpinBox( QWidget* = 0 );
00041   SalomeApp_DoubleSpinBox( double, double, double = 1, QWidget* = 0 );
00042   SalomeApp_DoubleSpinBox( double, double, double, int, int, QWidget* = 0, bool = true, bool = true );
00043   virtual ~SalomeApp_DoubleSpinBox();
00044 
00045   virtual void              stepBy( int );
00046 
00047   virtual double            valueFromText( const QString& ) const;
00048   virtual QString           textFromValue( double ) const;
00049 
00050   virtual QValidator::State validate( QString&, int& ) const;
00051 
00052   virtual bool              isValid( QString& msg, bool = false );
00053 
00054   virtual void              setDefaultValue( const double );
00055 
00056   virtual void              setRange( double, double );
00057   virtual void              setValue( double );
00058 
00059   virtual void              setText(const QString& );
00060 
00061   void                      setAcceptNames( const bool );
00062   bool                      isAcceptNames() const;
00063 
00064   void                      setShowTipOnValidate( const bool );
00065   bool                      isShowTipOnValidate() const;
00066 
00067 signals:
00068   void                      textChanged( const QString& );
00069 
00070 protected:
00071   State                     isValid( const QString&, double& ) const;
00072 
00073   double                    defaultValue() const;
00074   bool                      checkRange( const double ) const;
00075 
00076   SearchState               findVariable( const QString&, double& ) const;
00077 
00078 protected:
00079   virtual void              keyPressEvent( QKeyEvent* );
00080   virtual void              showEvent( QShowEvent* );
00081 
00082 protected slots:
00083   void                      onEditingFinished();
00084   void                      onTextChanged( const QString& );
00085 
00086 private:
00087   void                      connectSignalsAndSlots();
00088 
00089 private:
00090   double                    myDefaultValue; 
00091 
00092   bool                      myIsRangeSet;
00093   double                    myMinimum;
00094   double                    myMaximum;
00095 
00096   QString                   myCorrectValue;
00097   QString                   myTextValue;
00098 
00099   bool                      myAcceptNames;
00100   bool                      myShowTip;
00101 };
00102 
00103 #endif