libkdegames
kgamelcd.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __KGAMELCD_H
00021 #define __KGAMELCD_H
00022
00023 #include <QtCore/QVector>
00024 #include <QtGui/QLCDNumber>
00025 #include <libkdegames_export.h>
00026
00027 class QLabel;
00028 class QTimer;
00029
00030
00042 class KDEGAMES_EXPORT KGameLCD : public QLCDNumber
00043 {
00044 Q_OBJECT
00045 public:
00046 explicit KGameLCD(uint nbDigits, QWidget *parent = 0);
00047
00048 ~KGameLCD();
00049
00053 void setDefaultBackgroundColor(const QColor &color);
00054
00058 void setDefaultColor(const QColor &color);
00059
00063 void setHighlightColor(const QColor &color);
00064
00069 void setLeadingString(const QString &s);
00070
00075 void setHighlightTime(uint time);
00076
00080 void resetColor();
00081
00085 void setColor(const QColor &color);
00086
00087 public Q_SLOTS:
00092 void highlight();
00093
00101 void displayInt(int value);
00102
00103 private Q_SLOTS:
00104 void timeout() { highlight(false); }
00105
00106 private:
00107 QColor _fgColor, _hlColor;
00108 QString _lead;
00109 uint _htime;
00110 QTimer *_timer;
00111
00112 class KGameLCDPrivate;
00113 KGameLCDPrivate *d;
00114
00115 void highlight(bool light);
00116
00117 };
00118
00119
00126 class KDEGAMES_EXPORT KGameLCDClock : public KGameLCD
00127 {
00128 Q_OBJECT
00129 public:
00130 KGameLCDClock(QWidget *parent = 0);
00131
00132 ~KGameLCDClock();
00133
00137 uint seconds() const;
00138
00142 QString pretty() const;
00143
00147 void setTime(uint seconds);
00148
00152 void setTime(const QString &s);
00153
00154 public Q_SLOTS:
00158 virtual void reset();
00159
00163 virtual void stop();
00164
00168 virtual void start();
00169
00170 protected Q_SLOTS:
00171 virtual void timeoutClock();
00172
00173 private:
00174 QTimer *_timerClock;
00175 uint _sec, _min;
00176
00177 class KGameLCDClockPrivate;
00178 KGameLCDClockPrivate *d;
00179
00180 void showTime();
00181 };
00182
00183
00190 class KDEGAMES_EXPORT KGameLCDList : public QWidget
00191 {
00192 Q_OBJECT
00193 public:
00200 explicit KGameLCDList(const QString &title,
00201 QWidget *parent = 0);
00207 KGameLCDList(QWidget *parent = 0);
00208
00209 ~KGameLCDList();
00210
00215 void append(QLCDNumber *lcd);
00216
00221 void append(const QString &leading, QLCDNumber *lcd);
00222
00226 void clear();
00227
00231 QLabel *title() const { return _title; }
00232
00236 QLCDNumber *lcd(uint i) const { return _lcds[i]; }
00237
00241 uint size() const { return _lcds.size(); }
00242
00243 private:
00244 QLabel *_title;
00245 QVector<QLCDNumber *> _lcds;
00246
00247 class KGameLCDListPrivate;
00248 KGameLCDListPrivate *d;
00249
00250 void init(const QString &title);
00251 };
00252
00253 #endif