Fairly large overhaul of the JuK codebase to beat out a lot of the Qt 3 stuff.
[kdemultimedia.git] / kmid / klcdnumber.h
blobab873ef9be98d15871c4e97fd58b2e6d54d95af3
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_
27 #include <QWidget>
28 //Added by qt3to4:
29 #include <QMouseEvent>
30 #include <QTimerEvent>
31 #include <QResizeEvent>
32 #include <QPaintEvent>
34 class QPainter;
35 class KTriangleButton;
36 class QColor;
38 class KLCDNumber : public QWidget
40 Q_OBJECT
41 protected:
42 class digit {
43 public:
44 digit()
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) { }
51 bool up;
52 bool nw;
53 bool ne;
54 bool md;
55 bool sw;
56 bool se;
57 bool bt;
61 ---
62 nw| |ne
63 |___|<------ md
64 | |
65 sw|___|se
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}
84 };*/
86 int numDigits;
87 bool setUserChangeValue;
88 bool setUserDefaultValue;
89 bool doubleclicked;
91 QColor backgcolor;
92 QColor LCDcolor;
94 double value;
95 double oldvalue;
96 double defaultValue;
98 double minValue;
99 double maxValue;
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);
107 public:
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();
131 protected:
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;
145 public slots:
147 void decreaseValue();
148 void increaseValue();
149 void decreaseValueFast();
150 void increaseValueFast();
152 signals:
154 void valueChanged(double v);
158 #endif