25
/** After constructing use one of setRealMode or setIntMode to initialize the Spinbox.
25
/** A Spinbox that can operate in either integer or real number mode. Step-sizes are adjusted automatically according to the current value
27
After constructing use one of setRealMode or setIntMode to initialize the Spinbox.
26
29
@author Thomas Friedrichsmeier
28
class RKSpinBox : public QSpinBox
31
class RKSpinBox : public QSpinBox {
32
RKSpinBox(QWidget *parent = 0);
34
/** constructor. Use on of setIntMode or setRealMode to initialize the Spinbox! */
35
RKSpinBox (QWidget *parent = 0);
39
/** set the spinbox to operate on real numbers. When operating on real numbers, QSpinBox::value () is absolutely meaningless! Use realValue () to retrieve the value in this case
40
@param min minimum acceptable value
41
@param max maximum acceptable value
42
@param initial initial value
43
@param default_precision default precision of steps. E.g. 2 to make the second sub-decimal digit the one that is change by pressing up/down arrows, when the value is 0
44
@param max_precison maximum acceptable precision */
36
45
void setRealMode (double min, double max, double initial, int default_precision, int max_precision);
46
/** set the spinbox to operate on integer numbers (like a regular QSpinBox, but step sizes are adjusted automatically
47
@param min minimum acceptable value
48
@param max maximum acceptable value
49
@param initial initial value */
37
50
void setIntMode (int min, int max, int initial);
38
double realValue () { return ((double) value () / (double) divisor); };
51
/** Only meaningful, when in real mode! Returns the current value
52
@returns the value if in real mode */
53
double realValue () { return real_value; };
54
/** Only meaningful, when in real mode! Sets the new value
55
@param new_value the new value */
39
56
void setRealValue (double new_value);
41
int mapTextToValue (bool *ok);
42
QString mapValueToText (int v);
58
/** reimplemented from QSpinBox to update steps and value whenever the internal value changed */
59
void updateDisplay ();
60
/** reimplemented from QSpinBox to update steps and value whenever the text was changed */
61
void interpretText ();
44
63
enum Mode { Integer=0, Real=1 };
70
int default_precision;
47
71
QValidator *validator;