DoubleSpinBox.h

Go to the documentation of this file.
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     QString textFromValue ( double value ) const;
00054     virtual QValidator::State validate ( QString & input, int & pos ) const;
00055 
00056 signals:
00057     void valueChanged ( double d );
00058 
00059 private slots:
00060     void interpretText();
00061 
00062 protected:
00063     void stepBy ( int steps );
00064     StepEnabled stepEnabled () const;
00065 
00066 private:
00067     const char d_format;
00068     double d_min_val;
00069     double d_max_val;
00070     double d_value;
00071     double d_step;
00072     int d_prec;
00073 };
00074 
00075 class RangeLimitBox : public QWidget
00076 {
00077 public:
00078     enum LimitType{LeftLimit, RightLimit};
00079 
00080     RangeLimitBox(LimitType type, QWidget * parent = 0);    
00081     void setDecimals(int prec){d_spin_box->setDecimals(prec);};
00082     double value();
00083     bool isChecked(){return d_checkbox->isChecked();};
00084 
00085 private:
00086     DoubleSpinBox *d_spin_box;
00087     QCheckBox *d_checkbox;
00088     LimitType d_type;
00089 };
00090 #endif // FITDIALOG_H

Generated on Tue Jun 17 08:36:12 2008 for QtiPlot by  doxygen 1.5.5