kgamelcd.h
00001 /* 00002 This file is part of the TDE games library 00003 Copyright (C) 2001,2002,2003 Nicolas Hadacek (hadacek@kde.org) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __KGAMELCD_H 00021 #define __KGAMELCD_H 00022 00023 #include <tqlcdnumber.h> 00024 #include <tqvaluevector.h> 00025 #include <kdemacros.h> 00026 00027 class TQLabel; 00028 class TQTimer; 00029 00030 //----------------------------------------------------------------------------- 00042 class KDE_EXPORT KGameLCD : public TQLCDNumber 00043 { 00044 Q_OBJECT 00045 00046 public: 00047 KGameLCD(uint nbDigits, TQWidget *parent = 0, const char *name = 0); 00048 00049 ~KGameLCD(); 00050 00054 void setDefaultBackgroundColor(const TQColor &color); 00055 00059 void setDefaultColor(const TQColor &color); 00060 00064 void setHighlightColor(const TQColor &color); 00065 00070 void setLeadingString(const TQString &s); 00071 00076 void setHighlightTime(uint time); 00077 00081 void resetColor(); 00082 00086 void setColor(const TQColor &color); 00087 00088 public slots: 00093 void highlight(); 00094 00102 void displayInt(int value); 00103 00104 private slots: 00105 void timeout() { highlight(false); } 00106 00107 private: 00108 TQColor _fgColor, _hlColor; 00109 TQString _lead; 00110 uint _htime; 00111 TQTimer *_timer; 00112 00113 class KGameLCDPrivate; 00114 KGameLCDPrivate *d; 00115 00116 void highlight(bool light); 00117 00118 }; 00119 00120 //----------------------------------------------------------------------------- 00127 class KDE_EXPORT KGameLCDClock : public KGameLCD 00128 { 00129 Q_OBJECT 00130 00131 public: 00132 KGameLCDClock(TQWidget *parent = 0, const char *name = 0); 00133 00134 ~KGameLCDClock(); 00135 00139 uint seconds() const; 00140 00144 TQString pretty() const; 00145 00149 void setTime(uint seconds); 00150 00154 void setTime(const TQString &s); 00155 00156 public slots: 00160 virtual void reset(); 00161 00165 virtual void stop(); 00166 00170 virtual void start(); 00171 00172 protected slots: 00173 virtual void timeoutClock(); 00174 00175 private: 00176 TQTimer *_timerClock; 00177 uint _sec, _min; 00178 00179 class KGameLCDClockPrivate; 00180 KGameLCDClockPrivate *d; 00181 00182 void showTime(); 00183 }; 00184 00185 //----------------------------------------------------------------------------- 00192 class KDE_EXPORT KGameLCDList : public TQWidget 00193 { 00194 Q_OBJECT 00195 00196 public: 00204 KGameLCDList(const TQString &title, 00205 TQWidget *parent = 0, const char *name = 0); 00206 KGameLCDList(TQWidget *parent = 0, const char *name = 0); 00207 00208 ~KGameLCDList(); 00209 00214 void append(TQLCDNumber *lcd); 00215 00220 void append(const TQString &leading, TQLCDNumber *lcd); 00221 00225 void clear(); 00226 00230 TQLabel *title() const { return _title; } 00231 00235 TQLCDNumber *lcd(uint i) const { return _lcds[i]; } 00236 00240 uint size() const { return _lcds.size(); } 00241 00242 private: 00243 TQLabel *_title; 00244 TQValueVector<TQLCDNumber *> _lcds; 00245 00246 class KGameLCDListPrivate; 00247 KGameLCDListPrivate *d; 00248 00249 void init(const TQString &title); 00250 }; 00251 00252 #endif