QtiPlot  0.9.8.2
DoubleSpinBox.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : DoubleSpinBox.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2007-2008 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : A Double Spin Box
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef DoubleSpinBox_H
30 #define DoubleSpinBox_H
31 
32 #include <QAbstractSpinBox>
33 #include <QCheckBox>
34 
36 
39 class DoubleSpinBox : public QAbstractSpinBox
40 {
41  Q_OBJECT
42 
43 public:
45 
49  DoubleSpinBox(const char format = 'g', QWidget * parent = 0);
50 
51  void setSingleStep(double val);
52  void setMaximum(double max);
53  void setMinimum(double min);
54  void setRange(double min, double max);
55 
56  int decimals(){return d_prec;};
57  void setDecimals(int prec){if (prec >= 0) d_prec = prec;};
58 
59  double value(){interpretText(); return d_value;};
60  bool setValue(double val);
61 
62  QString prefix() const;
63  void setPrefix(const QString & prefix){d_prefix = prefix;}
64 
65  void setFormat(const char format, int prec = 1){d_format = format; setDecimals(prec);};
66 
67  QString textFromValue ( double value ) const;
68  virtual QValidator::State validate ( QString & input, int & pos ) const;
69 
70 signals:
71  void valueChanged ( double d );
73  void activated(DoubleSpinBox *);
74 
75 private slots:
76  void interpretText();
77 
78 protected:
79  void stepBy ( int steps );
80  StepEnabled stepEnabled () const;
81  void focusInEvent(QFocusEvent *);
82 
83 private:
84  char d_format;
85  double d_min_val;
86  double d_max_val;
87  double d_value;
88  double d_step;
89  int d_prec;
90  QString d_prefix;
91 };
92 
94 class RangeLimitBox : public QWidget
95 {
96 public:
97  enum LimitType{LeftLimit, RightLimit};
98 
99  RangeLimitBox(LimitType type, QWidget * parent = 0);
100  void setDecimals(int prec){d_spin_box->setDecimals(prec);};
101  double value();
102  bool isChecked(){return d_checkbox->isChecked();};
103 
104 private:
105  DoubleSpinBox *d_spin_box;
106  QCheckBox *d_checkbox;
108 };
109 #endif // FITDIALOG_H
StepEnabled stepEnabled() const
Definition: DoubleSpinBox.cpp:124
A checkable DoubleSpinBox that can be used to select the limits of a double interval.
Definition: DoubleSpinBox.h:94
void setRange(double min, double max)
Definition: DoubleSpinBox.cpp:78
char d_format
Definition: DoubleSpinBox.h:84
void setPrefix(const QString &prefix)
Definition: DoubleSpinBox.h:63
void interpretText()
Definition: DoubleSpinBox.cpp:84
void focusInEvent(QFocusEvent *)
Definition: DoubleSpinBox.cpp:179
void valueChanged(double d)
bool setValue(double val)
Definition: DoubleSpinBox.cpp:142
A QDoubleSpinBox allowing to customize numbers display with respect to locale settings.
Definition: DoubleSpinBox.h:39
void setSingleStep(double val)
Definition: DoubleSpinBox.cpp:56
#define min(a, b)
Definition: ShapiroWilkTest.cpp:36
QString prefix() const
Definition: DoubleSpinBox.cpp:137
double d_min_val
Definition: DoubleSpinBox.h:85
QCheckBox * d_checkbox
Definition: DoubleSpinBox.h:106
int decimals()
Definition: DoubleSpinBox.h:56
void activated(DoubleSpinBox *)
Signal emitted when the spin box gains focus.
int d_prec
Definition: DoubleSpinBox.h:89
LimitType d_type
Definition: DoubleSpinBox.h:107
double d_max_val
Definition: DoubleSpinBox.h:86
void setMinimum(double min)
Definition: DoubleSpinBox.cpp:70
void setFormat(const char format, int prec=1)
Definition: DoubleSpinBox.h:65
double d_value
Definition: DoubleSpinBox.h:87
bool isChecked()
Definition: DoubleSpinBox.h:102
double d_step
Definition: DoubleSpinBox.h:88
DoubleSpinBox(const char format= 'g', QWidget *parent=0)
Constructor.
Definition: DoubleSpinBox.cpp:37
void stepBy(int steps)
Definition: DoubleSpinBox.cpp:114
void setDecimals(int prec)
Definition: DoubleSpinBox.h:57
void setDecimals(int prec)
Definition: DoubleSpinBox.h:100
void setMaximum(double max)
Definition: DoubleSpinBox.cpp:62
LimitType
Definition: DoubleSpinBox.h:97
QString textFromValue(double value) const
Definition: DoubleSpinBox.cpp:154
virtual QValidator::State validate(QString &input, int &pos) const
Definition: DoubleSpinBox.cpp:174
double value()
Definition: DoubleSpinBox.h:59
QString d_prefix
Definition: DoubleSpinBox.h:90