SVN_SILENT made messages (.desktop file)
[kdegames.git] / libkdegames / kgamelcd.h
blob97b74401d007208f9189d796267e161e866fab9e
1 /*
2 This file is part of the KDE games library
3 Copyright (C) 2001,2002,2003 Nicolas Hadacek (hadacek@kde.org)
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef __KGAMELCD_H
21 #define __KGAMELCD_H
23 #include <QtCore/QVector>
24 #include <QtGui/QLCDNumber>
25 #include <libkdegames_export.h>
27 class QLabel;
28 class QTimer;
30 //-----------------------------------------------------------------------------
31 /**
32 * \class KGameLCD kgamelcd.h <KGameLCD>
34 * This class is a visually enhanced @ref QLCDNumber :
35 * <ul>
36 * <li> It can show an additional string before the integer being
37 * displayed.</li>
38 * <li> Its foreground and background colors can easily be modified. </li>
39 * <li> It can be highlighted for a short time. </li>
40 * </ul>
42 class KDEGAMES_EXPORT KGameLCD : public QLCDNumber
44 Q_OBJECT
45 public:
46 explicit KGameLCD(uint nbDigits, QWidget *parent = 0);
48 ~KGameLCD();
50 /**
51 * Set the default background color.
53 void setDefaultBackgroundColor(const QColor &color);
55 /**
56 * Set the default foreground color.
58 void setDefaultColor(const QColor &color);
60 /**
61 * Set highlight color.
63 void setHighlightColor(const QColor &color);
65 /**
66 * Set the string that will be displayed before the integer number to be
67 * displayed. By default this string is null.
69 void setLeadingString(const QString &s);
71 /**
72 * Set the highlight duration in milliseconds. The default value is
73 * 800 milliseconds.
75 void setHighlightTime(uint time);
77 /**
78 * Reset the foreground color to the default one.
80 void resetColor();
82 /**
83 * Set the foreground color.
85 void setColor(const QColor &color);
87 public Q_SLOTS:
88 /**
89 * Highlight the LCD with the QColorGourp::HighlightedText color
90 * for a small time (setHighlightTime).
92 void highlight();
94 /**
95 * Display the given integer with the (optional) leading string.
97 * Note: we cannot use display(int) since QLCDNumber::display is
98 * not virtual... And you cannot use QLCDNumber::intValue() to retrieve
99 * the given value.
101 void displayInt(int value);
103 private Q_SLOTS:
104 void timeout() { highlight(false); }
106 private:
107 QColor _fgColor, _hlColor;
108 QString _lead;
109 uint _htime;
110 QTimer *_timer;
112 class KGameLCDPrivate;
113 KGameLCDPrivate *d;
115 void highlight(bool light);
119 //-----------------------------------------------------------------------------
121 * \class KGameLCDClock kgamelcd.h <KGameLCD>
123 * This class is a digital clock widget. It has a maximum duration of
124 * 3599 seconds (one hour) and it gets updated every second.
126 class KDEGAMES_EXPORT KGameLCDClock : public KGameLCD
128 Q_OBJECT
129 public:
130 KGameLCDClock(QWidget *parent = 0);
132 ~KGameLCDClock();
135 * @return the total number of seconds elapsed.
137 uint seconds() const;
140 * @return the time as a string to be displayed: "mm:ss".
142 QString pretty() const;
145 * Set the time.
147 void setTime(uint seconds);
150 * Set the time (format should be "mm:ss").
152 void setTime(const QString &s);
154 public Q_SLOTS:
156 * Stop the clock and reset it to zero.
158 virtual void reset();
161 * Stop the clock but do not reset it to zero.
163 virtual void stop();
166 * Start the clock from the current time.
168 virtual void start();
170 protected Q_SLOTS:
171 virtual void timeoutClock();
173 private:
174 QTimer *_timerClock;
175 uint _sec, _min;
177 class KGameLCDClockPrivate;
178 KGameLCDClockPrivate *d;
180 void showTime();
183 //-----------------------------------------------------------------------------
185 * \class KGameLCDList kgamelcd.h <KGameLCD>
187 * This widget holds a list of @ref QLCDNumber arranged in a vertical layout.
188 * It also shows a label at the top of the list.
190 class KDEGAMES_EXPORT KGameLCDList : public QWidget
192 Q_OBJECT
193 public:
195 * Constructor.
197 * @param title is the content of the top label.
198 * @param parent passed to the QWidget constructor.
200 explicit KGameLCDList(const QString &title,
201 QWidget *parent = 0);
203 * Constructor. Create a KGameLCDList with an empty top label.
205 * @param parent passed to the QWidget constructor.
207 KGameLCDList(QWidget *parent = 0);
209 ~KGameLCDList();
212 * Append a QLCDNumber at the bottom of the list.
213 * The QLCDNumber should have the KGameLCDList as parent.
215 void append(QLCDNumber *lcd);
218 * Append a QLCDNumber at the bottom of the list.
219 * The QLCDNumber should have the KGameLCDList as parent.
221 void append(const QString &leading, QLCDNumber *lcd);
224 * Delete all @ref QLCDNumber and clear the list.
226 void clear();
229 * @return the title label.
231 QLabel *title() const { return _title; }
234 * @return the QLCDNumber at index @param i
236 QLCDNumber *lcd(uint i) const { return _lcds[i]; }
239 * @return the number of QLCDNumber in the list.
241 uint size() const { return _lcds.size(); }
243 private:
244 QLabel *_title;
245 QVector<QLCDNumber *> _lcds;
247 class KGameLCDListPrivate;
248 KGameLCDListPrivate *d;
250 void init(const QString &title);
253 #endif