1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/***************************************************************************
cpudisplay.cpp - description
-------------------
begin : Sun Nov 25 2001
copyright : (C) 2001 by Miguel Novas
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "uptimepanel.h"
#include "procinfo.h"
#include "qlcddraw.h"
#include <tqcolor.h>
#include <tqpainter.h>
UpTimePanel::UpTimePanel(TQWidget *parent, const char *name) : Panel(parent,name)
{
lcd= new TQLCDString(this);
lcd->setGeometry(6,25,52,15);
lcd->setShadow(true);
lcd->setForeColor(red);
lcd->setShadowColor(darkRed);
lcd->installEventFilter(this);
updateInfo();
}
UpTimePanel::~UpTimePanel()
{
}
void UpTimePanel::updateInfo()
{
int uptime= getUpTime();
int hours = uptime/ (60*60);
int minutes= (uptime % (60*60)) / 60;
TQString str;
str.sprintf("%02d:%02d",hours,minutes);
lcd->display(str);
update();
}
void UpTimePanel::drawContents(TQPainter *p)
{
int w= width();
int h= height();
int i2= (h * 4) / 5;
int th= h-i2-h/11;
TQLcd::draw(p, 2,h/10,w-4,th,"hh:mm",TQLcd::alignCenter, &getColorTitle());
TQLcd::draw(p, 2,i2+1,w-4,th,"Up Time",TQLcd::alignCenter,&getColorTitle());
}
void UpTimePanel::resizeEvent ( TQResizeEvent *e )
{
int w= width();
int h= height();
int mw= w/10;
lcd->setGeometry(mw,h/3,w-mw*2,(h*2)/5);
}
#include "uptimepanel.moc"
|