1 /**************************************************************************
3 klcdnumber.h - The KLCDNumber widget (displays a lcd number)
4 Copyright (C) 1998 Antonio Larrosa Jimenez
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 Send comments and bug fixes to larrosa@kde.org
21 or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23 ***************************************************************************/
24 #ifndef _klcdnumber_h_
25 #define _klcdnumber_h_
29 #include <QMouseEvent>
30 #include <QTimerEvent>
31 #include <QResizeEvent>
32 #include <QPaintEvent>
35 class KTriangleButton
;
38 class KLCDNumber
: public QWidget
45 : up(false), nw(false), ne(false), md(false),
46 sw(false), se(false), bt(false) { }
47 digit( bool _up
, bool _nw
, bool _ne
,
48 bool _md
, bool _sw
, bool _se
, bool _bt
)
49 : up(_up
), nw(_nw
), ne(_ne
), md(_md
),
50 sw(_sw
), se(_se
), bt(_bt
) { }
70 KLCDNumber::digit Digit
[11];
73 / 0 / {true,true,true,false,true,true,true},
74 / 1 / {false,false,true,false,false,true,false},
75 / 2 / {true,false,true,true,true,false,true},
76 / 3 / {true,false,true,true,false,true,true},
77 / 4 / {false,true,true,true,false,true,false},
78 / 5 / {true,true,false,true,false,true,true},
79 / 6 / {true,true,false,true,true,true,true},
80 / 7 / {true,false,true,false,false,true,false},
81 / 8 / {true,true,true,true,true,true,true},
82 / 9 / {true,true,true,true,false,true,true},
83 / / {false,false,false,false,false,false,false}
87 bool setUserChangeValue
;
88 bool setUserDefaultValue
;
101 void drawVerticalBar(QPainter
*qpaint
,int x
,int y
,int w
,int h
,int d
);
102 void drawHorizBar(QPainter
*qpaint
,int x
,int y
,int w
,int h
,int d
);
103 void drawDigit(QPainter
*qpaint
,int x
,int y
,int w
,int h
,digit d
);
105 void initDigits(void);
108 KLCDNumber(int _numDigits
,QWidget
*parent
,const char *name
);
109 KLCDNumber(bool _setUserChangeValue
,int _numDigits
,QWidget
*parent
,const char *name
);
111 void setUserSetDefaultValue(bool _userSetDefaultValue
);
112 void setDefaultValue(double v
);
114 void setValue(double v
);
115 double getValue(void) { return value
; }
116 double getOldValue(void) { return oldvalue
; }
118 double getMinValue(void) { return minValue
;}
119 double getMaxValue(void) { return maxValue
;}
120 void setRange(double min
, double max
);
122 void setLCDBackgroundColor (int r
,int g
,int b
);
123 void setLCDColor (int r
,int g
,int b
);
125 void display (int v
);
126 void display (double v
);
128 QSize
sizeHint () const;
129 // QSizePolicy sizePolicy();
133 virtual void paintEvent ( QPaintEvent
*e
);
134 virtual void resizeEvent ( QResizeEvent
*e
);
135 virtual void mouseDoubleClickEvent (QMouseEvent
*e
);
136 virtual void mousePressEvent (QMouseEvent
*e
);
137 virtual void timerEvent(QTimerEvent
*e
);
138 void defaultValueClicked();
140 KTriangleButton
*downBtn
;
141 KTriangleButton
*upBtn
;
147 void decreaseValue();
148 void increaseValue();
149 void decreaseValueFast();
150 void increaseValueFast();
154 void valueChanged(double v
);