QtiPlot 0.9.7.3
|
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 00036 00039 class DoubleSpinBox : public QAbstractSpinBox 00040 { 00041 Q_OBJECT 00042 00043 public: 00045 00049 DoubleSpinBox(const char format = 'g', QWidget * parent = 0); 00050 00051 void setSingleStep(double val); 00052 void setMaximum(double max); 00053 void setMinimum(double min); 00054 void setRange(double min, double max); 00055 00056 int decimals(){return d_prec;}; 00057 void setDecimals(int prec){if (prec >= 0) d_prec = prec;}; 00058 00059 double value(){interpretText(); return d_value;}; 00060 bool setValue(double val); 00061 00062 void setFormat(const char format, int prec = 1){d_format = format; setDecimals(prec);}; 00063 00064 QString textFromValue ( double value ) const; 00065 virtual QValidator::State validate ( QString & input, int & pos ) const; 00066 00067 signals: 00068 void valueChanged ( double d ); 00070 void activated(DoubleSpinBox *); 00071 00072 private slots: 00073 void interpretText(); 00074 00075 protected: 00076 void stepBy ( int steps ); 00077 StepEnabled stepEnabled () const; 00078 void focusInEvent(QFocusEvent *); 00079 00080 private: 00081 char d_format; 00082 double d_min_val; 00083 double d_max_val; 00084 double d_value; 00085 double d_step; 00086 int d_prec; 00087 }; 00088 00090 class RangeLimitBox : public QWidget 00091 { 00092 public: 00093 enum LimitType{LeftLimit, RightLimit}; 00094 00095 RangeLimitBox(LimitType type, QWidget * parent = 0); 00096 void setDecimals(int prec){d_spin_box->setDecimals(prec);}; 00097 double value(); 00098 bool isChecked(){return d_checkbox->isChecked();}; 00099 00100 private: 00101 DoubleSpinBox *d_spin_box; 00102 QCheckBox *d_checkbox; 00103 LimitType d_type; 00104 }; 00105 #endif // FITDIALOG_H