DoubleSpinBox.h
Go to the documentation of this file.
/***************************************************************************
File : DoubleSpinBox.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2007-2008 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : A Double Spin Box
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef DoubleSpinBox_H
#define DoubleSpinBox_H
#include <QAbstractSpinBox>
#include <QCheckBox>
class DoubleSpinBox : public QAbstractSpinBox
{
Q_OBJECT
public:
DoubleSpinBox(const char format = 'g', QWidget * parent = 0);
void setSingleStep(double val);
void setMaximum(double max);
void setMinimum(double min);
void setRange(double min, double max);
int decimals(){return d_prec;};
void setDecimals(int prec){if (prec >= 0) d_prec = prec;};
double value(){interpretText(); return d_value;};
bool setValue(double val);
QString prefix() const;
void setPrefix(const QString & prefix){d_prefix = prefix;}
void setFormat(const char format, int prec = 1){d_format = format; setDecimals(prec);};
QString textFromValue ( double value ) const;
virtual QValidator::State validate ( QString & input, int & pos ) const;
signals:
void valueChanged ( double d );
void activated(DoubleSpinBox *);
private slots:
void interpretText();
protected:
void stepBy ( int steps );
StepEnabled stepEnabled () const;
void focusInEvent(QFocusEvent *);
private:
char d_format;
double d_min_val;
double d_max_val;
double d_value;
double d_step;
int d_prec;
QString d_prefix;
};
class RangeLimitBox : public QWidget
{
public:
enum LimitType{LeftLimit, RightLimit};
RangeLimitBox(LimitType type, QWidget * parent = 0);
void setDecimals(int prec){d_spin_box->setDecimals(prec);};
double value();
bool isChecked(){return d_checkbox->isChecked();};
private:
DoubleSpinBox *d_spin_box;
QCheckBox *d_checkbox;
LimitType d_type;
};
#endif // FITDIALOG_H
RangeLimitBox
A checkable DoubleSpinBox that can be used to select the limits of a double interval.
Definition: DoubleSpinBox.h:94
DoubleSpinBox::setRange
void setRange(double min, double max)
Definition: DoubleSpinBox.cpp:78
DoubleSpinBox::prefix
QString prefix() const
Definition: DoubleSpinBox.cpp:137
DoubleSpinBox::d_format
char d_format
Definition: DoubleSpinBox.h:84
DoubleSpinBox::DoubleSpinBox
DoubleSpinBox(const char format='g', QWidget *parent=0)
Constructor.
Definition: DoubleSpinBox.cpp:37
DoubleSpinBox::setPrefix
void setPrefix(const QString &prefix)
Definition: DoubleSpinBox.h:63
DoubleSpinBox::interpretText
void interpretText()
Definition: DoubleSpinBox.cpp:84
DoubleSpinBox::focusInEvent
void focusInEvent(QFocusEvent *)
Definition: DoubleSpinBox.cpp:179
DoubleSpinBox::valueChanged
void valueChanged(double d)
DoubleSpinBox::setValue
bool setValue(double val)
Definition: DoubleSpinBox.cpp:142
DoubleSpinBox
A QDoubleSpinBox allowing to customize numbers display with respect to locale settings.
Definition: DoubleSpinBox.h:39
DoubleSpinBox::setSingleStep
void setSingleStep(double val)
Definition: DoubleSpinBox.cpp:56
min
#define min(a, b)
Definition: ShapiroWilkTest.cpp:36
DoubleSpinBox::validate
virtual QValidator::State validate(QString &input, int &pos) const
Definition: DoubleSpinBox.cpp:174
DoubleSpinBox::d_min_val
double d_min_val
Definition: DoubleSpinBox.h:85
RangeLimitBox::d_checkbox
QCheckBox * d_checkbox
Definition: DoubleSpinBox.h:106
DoubleSpinBox::stepEnabled
StepEnabled stepEnabled() const
Definition: DoubleSpinBox.cpp:124
DoubleSpinBox::decimals
int decimals()
Definition: DoubleSpinBox.h:56
DoubleSpinBox::activated
void activated(DoubleSpinBox *)
Signal emitted when the spin box gains focus.
DoubleSpinBox::d_prec
int d_prec
Definition: DoubleSpinBox.h:89
RangeLimitBox::d_type
LimitType d_type
Definition: DoubleSpinBox.h:107
DoubleSpinBox::d_max_val
double d_max_val
Definition: DoubleSpinBox.h:86
DoubleSpinBox::setMinimum
void setMinimum(double min)
Definition: DoubleSpinBox.cpp:70
DoubleSpinBox::textFromValue
QString textFromValue(double value) const
Definition: DoubleSpinBox.cpp:154
DoubleSpinBox::setFormat
void setFormat(const char format, int prec=1)
Definition: DoubleSpinBox.h:65
DoubleSpinBox::d_value
double d_value
Definition: DoubleSpinBox.h:87
RangeLimitBox::isChecked
bool isChecked()
Definition: DoubleSpinBox.h:102
DoubleSpinBox::d_step
double d_step
Definition: DoubleSpinBox.h:88
DoubleSpinBox::stepBy
void stepBy(int steps)
Definition: DoubleSpinBox.cpp:114
DoubleSpinBox::setDecimals
void setDecimals(int prec)
Definition: DoubleSpinBox.h:57
RangeLimitBox::setDecimals
void setDecimals(int prec)
Definition: DoubleSpinBox.h:100
DoubleSpinBox::setMaximum
void setMaximum(double max)
Definition: DoubleSpinBox.cpp:62
RangeLimitBox::LimitType
LimitType
Definition: DoubleSpinBox.h:97
DoubleSpinBox::value
double value()
Definition: DoubleSpinBox.h:59
DoubleSpinBox::d_prefix
QString d_prefix
Definition: DoubleSpinBox.h:90