00001 /****************************************************************************** 00002 * SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3 * 00003 * (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify it * 00006 * under the terms of the GNU General Public License as published by the Free * 00007 * Software Foundation; either version 2 of the License, or (at your option) * 00008 * any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, but WITHOUT * 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * 00013 * more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License along * 00016 * with this program; if not, write to the Free Software Foundation, Inc., 51 * 00017 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00018 ******************************************************************************* 00019 * SOFA :: Applications * 00020 * * 00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,* 00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza, * 00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy * 00024 * * 00025 * Contact information: contact@sofa-framework.org * 00026 ******************************************************************************/ 00027 /* -------------------------------------------------------- */ 00028 #ifndef __WFLOATLINEEDIT__ 00029 #define __WFLOATLINEEDIT__ 00030 /* -------------------------------------------------------- */ 00031 #include <qvalidator.h> 00032 #include <qlineedit.h> 00033 00034 #ifdef SOFA_QT4 00035 #include <QKeyEvent> 00036 #endif 00037 /* -------------------------------------------------------- */ 00038 00039 00040 class WFloatLineEdit : public QLineEdit 00041 { 00042 Q_OBJECT 00043 Q_PROPERTY( float minFloatValue READ minFloatValue WRITE setMinFloatValue ) 00044 Q_PROPERTY( float maxFloatValue READ maxFloatValue WRITE setMaxFloatValue ) 00045 Q_PROPERTY( float floatValue READ floatValue WRITE setFloatValue ) 00046 Q_PROPERTY( int intValue READ intValue WRITE setIntValue ) 00047 00048 protected: 00049 00050 int m_iPercent; 00051 float m_fMinValue; 00052 float m_fMaxValue; 00053 bool m_bFirst; 00054 mutable float m_fValue; 00055 QDoubleValidator *m_DblValid; 00056 double m_bInternal; 00057 00058 void checkValue(); 00059 virtual void keyPressEvent(QKeyEvent *); 00060 public: 00061 00062 WFloatLineEdit(QWidget *parent,const char *name); 00063 00064 float minFloatValue() const { return (m_fMinValue);} 00065 float getMinFloatValue(){ emit(returnPressed()); return minFloatValue();} 00066 void setMinFloatValue(float f) {m_fMinValue=f; m_DblValid->setBottom(m_fMinValue); } 00067 00068 00069 float maxFloatValue() const { return (m_fMaxValue);} 00070 float getMaxFloatValue(){ emit(returnPressed()); return maxFloatValue();} 00071 void setMaxFloatValue(float f) {m_fMaxValue=f; m_DblValid->setTop(m_fMaxValue); } 00072 00073 float floatValue() const { return (m_fValue);} 00074 float getFloatValue(){ emit(returnPressed()); return floatValue();} 00075 void setFloatValue(float f); 00076 00077 int intValue() const { return static_cast<int>(m_fValue);} 00078 int getIntValue(){ emit(returnPressed()); return intValue();} 00079 void setIntValue(int f); 00080 00081 int valuePercent(); 00082 00083 signals: 00084 00085 void floatValueChanged(float); 00086 void valuePercentChanged(int); 00087 00088 protected slots: 00089 00090 void slotCalcFloatValue(const QString&); 00091 void slotCalcFloatValue(float); 00092 void slotReturnPressed(); 00093 00094 public slots: 00095 00096 void setValuePercent(int p); 00097 00098 }; 00099 /* -------------------------------------------------------- */ 00100 #endif 00101 /* -------------------------------------------------------- */ 00102 00103
1.5.7.1