00001 /*************************************************************************** 00002 File : DoubleSpinBox.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2007-2008 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : A Double Spin Box 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef DoubleSpinBox_H 00030 #define DoubleSpinBox_H 00031 00032 #include <QAbstractSpinBox> 00033 #include <QCheckBox> 00034 00035 class DoubleSpinBox : public QAbstractSpinBox 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 DoubleSpinBox(const char format = 'g', QWidget * parent = 0); 00041 00042 void setSingleStep(double val); 00043 void setMaximum(double max); 00044 void setMinimum(double min); 00045 void setRange(double min, double max); 00046 00047 int decimals(){return d_prec;}; 00048 void setDecimals(int prec){if (prec >= 0) d_prec = prec;}; 00049 00050 double value(){return d_value;}; 00051 bool setValue(double val); 00052 00053 void setFormat(const char format, int prec = 1){d_format = format; setDecimals(prec);}; 00054 00055 QString textFromValue ( double value ) const; 00056 virtual QValidator::State validate ( QString & input, int & pos ) const; 00057 00058 signals: 00059 void valueChanged ( double d ); 00060 00061 private slots: 00062 void interpretText(); 00063 00064 protected: 00065 void stepBy ( int steps ); 00066 StepEnabled stepEnabled () const; 00067 00068 private: 00069 char d_format; 00070 double d_min_val; 00071 double d_max_val; 00072 double d_value; 00073 double d_step; 00074 int d_prec; 00075 }; 00076 00077 class RangeLimitBox : public QWidget 00078 { 00079 public: 00080 enum LimitType{LeftLimit, RightLimit}; 00081 00082 RangeLimitBox(LimitType type, QWidget * parent = 0); 00083 void setDecimals(int prec){d_spin_box->setDecimals(prec);}; 00084 double value(); 00085 bool isChecked(){return d_checkbox->isChecked();}; 00086 00087 private: 00088 DoubleSpinBox *d_spin_box; 00089 QCheckBox *d_checkbox; 00090 LimitType d_type; 00091 }; 00092 #endif // FITDIALOG_H