21 #include "kgamelcd.moc"
27 #include <tdeglobal.h>
31 KGameLCD::KGameLCD(uint nbDigits, TQWidget *parent,
const char *name)
32 : TQLCDNumber(nbDigits, parent, name), _htime(800)
34 const TQPalette &p = palette();
35 _fgColor = p.color(TQPalette::Active, TQColorGroup::Foreground);
36 _hlColor = p.color(TQPalette::Active, TQColorGroup::HighlightedText);
38 _timer =
new TQTimer(
this);
39 connect(_timer, TQ_SIGNAL(timeout()), TQ_SLOT(timeout()));
41 setFrameStyle(Panel | Plain);
42 setSegmentStyle(Flat);
52 TQPalette p = palette();
53 p.setColor(TQColorGroup::Background, color);
60 TQPalette p = palette();
61 p.setColor(TQColorGroup::Foreground, color);
88 const TQColor &c = (color.isValid() ? color : _fgColor);
89 TQPalette p = palette();
90 p.setColor(TQColorGroup::Foreground, c);
96 int n = numDigits() - _lead.length();
97 display(_lead + TQString::number(v).rightJustify(n));
103 _timer->start(_htime,
true);
113 KGameLCDClock::KGameLCDClock(TQWidget *parent,
const char *name)
116 _timerClock =
new TQTimer(
this);
117 connect(_timerClock, TQ_SIGNAL(timeout()), TQ_SLOT(timeoutClock()));
120 KGameLCDClock::~KGameLCDClock()
123 void KGameLCDClock::timeoutClock()
126 if ( _min==59 && _sec==59 )
return;
137 TQString sec = TQString::number(_sec).rightJustify(2,
'0',
true);
138 TQString min = TQString::number(_min).rightJustify(2,
'0',
true);
139 return min +
':' + sec;
142 void KGameLCDClock::showTime()
157 _timerClock->start(1000);
167 return _min*60 + _sec;
172 Q_ASSERT( sec<3600 );
180 Q_ASSERT( s.length()==5 && s[2]==
':' );
181 uint min = kMin(s.section(
':', 0, 0).toUInt(), uint(59));
182 uint sec = kMin(s.section(
':', 1, 1).toUInt(), uint(59));
188 class KGameLCDList::KGameLCDListPrivate
191 TQValueVector<TQLabel *> _leadings;
196 : TQWidget(parent, name)
202 : TQWidget(parent, name)
207 KGameLCDList::~KGameLCDList()
212 void KGameLCDList::init(
const TQString &title)
214 d =
new KGameLCDListPrivate;
216 TQGridLayout *top =
new TQGridLayout(
this, 1, 2, 5);
217 top->setColStretch(1, 1);
219 _title =
new TQLabel(
title,
this);
220 _title->setAlignment(AlignCenter);
221 top->addMultiCellWidget(_title, 0, 0, 0, 1, AlignCenter);
233 if ( !leading.isEmpty() ) {
234 label =
new TQLabel(leading,
this);
235 static_cast<TQGridLayout *
>(layout())->addWidget(label, i+1, 0);
237 d->_leadings.push_back(label);
238 _lcds.push_back(
lcd);
239 static_cast<TQGridLayout *
>(layout())->addWidget(
lcd, i+1, 1);
244 for (uint i=0; i<_lcds.size(); i++) {
245 delete d->_leadings[i];
248 d->_leadings.clear();
void setTime(uint seconds)
Set the time.
virtual void stop()
Stop the clock but do not reset it to zero.
virtual void start()
Start the clock from the current time.
virtual void reset()
Stop the clock and reset it to zero.
TQLCDNumber * lcd(uint i) const
KGameLCDList(const TQString &title, TQWidget *parent=0, const char *name=0)
Constructor.
void clear()
Delete all TQLCDNumber and clear the list.
void append(TQLCDNumber *lcd)
Append a TQLCDNumber at the bottom of the list.
This class is a visually enhanced TQLCDNumber:
void setHighlightTime(uint time)
Set the highlight duration in milliseconds.
void setDefaultBackgroundColor(const TQColor &color)
Set the default background color.
void setColor(const TQColor &color)
Set the foreground color.
void setDefaultColor(const TQColor &color)
Set the default foreground color.
void setLeadingString(const TQString &s)
Set the string that will be displayed before the integer number to be displayed.
void resetColor()
Reset the foreground color to the default one.
void highlight()
Highlight the LCD with the TQColorGourp::HighlightedText color for a small time (setHighlightTime).
void displayInt(int value)
Display the given integer with the (optionnal) leading string.
void setHighlightColor(const TQColor &color)
Set highlight color.