~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

Viewing changes to rkward/misc/rkspinbox.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2008-04-20 21:30:00 UTC
  • mfrom: (1.2.2 upstream) (3.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080420213000-fs4i8efmfc793bnn
new upstream release
closes: #475175
closes: #463348
closes: #475982

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
                          rkspinbox  -  description
3
3
                             -------------------
4
4
    begin                : Wed Aug 11 2004
5
 
    copyright            : (C) 2004 by Thomas Friedrichsmeier
 
5
    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
6
6
    email                : tfry@users.sourceforge.net
7
7
 ***************************************************************************/
8
8
 
22
22
 
23
23
class QValidator;
24
24
 
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
 
26
 
 
27
After constructing use one of setRealMode or setIntMode to initialize the Spinbox.
 
28
 
26
29
@author Thomas Friedrichsmeier
27
30
*/
28
 
class RKSpinBox : public QSpinBox
29
 
{
30
 
Q_OBJECT
 
31
class RKSpinBox : public QSpinBox {
 
32
        Q_OBJECT
31
33
public:
32
 
    RKSpinBox(QWidget *parent = 0);
 
34
/** constructor. Use on of setIntMode or setRealMode to initialize the Spinbox! */
 
35
        RKSpinBox (QWidget *parent = 0);
 
36
/** dtor */
 
37
        ~RKSpinBox ();
33
38
 
34
 
    ~RKSpinBox();
35
 
        
 
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);
40
57
protected:
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 ();
43
62
private:
44
63
        enum Mode { Integer=0, Real=1 };
45
64
        Mode mode;
46
 
        int divisor;
 
65
        bool updating;
 
66
        bool updating_b;
 
67
        double real_value;
 
68
        double real_min;
 
69
        double real_max;
 
70
        int default_precision;
47
71
        QValidator *validator;
48
72
};
49
73