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.
23 #include <QtCore/QVector>
24 #include <QtGui/QLCDNumber>
25 #include <libkdegames_export.h>
30 //-----------------------------------------------------------------------------
32 * \class KGameLCD kgamelcd.h <KGameLCD>
34 * This class is a visually enhanced @ref QLCDNumber :
36 * <li> It can show an additional string before the integer being
38 * <li> Its foreground and background colors can easily be modified. </li>
39 * <li> It can be highlighted for a short time. </li>
42 class KDEGAMES_EXPORT KGameLCD
: public QLCDNumber
46 explicit KGameLCD(uint nbDigits
, QWidget
*parent
= 0);
51 * Set the default background color.
53 void setDefaultBackgroundColor(const QColor
&color
);
56 * Set the default foreground color.
58 void setDefaultColor(const QColor
&color
);
61 * Set highlight color.
63 void setHighlightColor(const QColor
&color
);
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
);
72 * Set the highlight duration in milliseconds. The default value is
75 void setHighlightTime(uint time
);
78 * Reset the foreground color to the default one.
83 * Set the foreground color.
85 void setColor(const QColor
&color
);
89 * Highlight the LCD with the QColorGourp::HighlightedText color
90 * for a small time (setHighlightTime).
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
101 void displayInt(int value
);
104 void timeout() { highlight(false); }
107 QColor _fgColor
, _hlColor
;
112 class KGameLCDPrivate
;
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
130 KGameLCDClock(QWidget
*parent
= 0);
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;
147 void setTime(uint seconds
);
150 * Set the time (format should be "mm:ss").
152 void setTime(const QString
&s
);
156 * Stop the clock and reset it to zero.
158 virtual void reset();
161 * Stop the clock but do not reset it to zero.
166 * Start the clock from the current time.
168 virtual void start();
171 virtual void timeoutClock();
177 class KGameLCDClockPrivate
;
178 KGameLCDClockPrivate
*d
;
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
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);
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.
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(); }
245 QVector
<QLCDNumber
*> _lcds
;
247 class KGameLCDListPrivate
;
248 KGameLCDListPrivate
*d
;
250 void init(const QString
&title
);