home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
215
/
DDJ9302.ZIP
/
DFPP01.ZIP
/
STATBAR.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-21
|
2KB
|
77 lines
// ------------- statbar.cpp
#include <time.h>
#include <stdlib.h>
#include "statbar.h"
StatusBar::StatusBar(DFWindow *par) : TextBox( par->ClientLeft(),
par->Bottom(),
1,
par->ClientWidth(),
par)
{
windowtype = StatusbarWindow;
SetAttribute(FRAMEWND);
SetColors();
}
StatusBar::~StatusBar()
{
}
// -------- set the fg/bg colors for the window
void StatusBar::SetColors()
{
colors.fg = BLACK;
colors.bg = CYAN;
}
void StatusBar::ParentSized(int xdif, int ydif)
{
Size(Right()+xdif, Top());
Move(Left(), Bottom()+ydif);
}
void StatusBar::ClockTick()
{
static Bool flipflop = False;
time_t t = time(NULL);
struct tm *now = localtime(&t);
int hr = now->tm_hour > 12 ?
now->tm_hour - 12 :
now->tm_hour;
if (hr == 0)
hr = 12;
int mn = now->tm_min;
char hm[3];
itoa(hr, hm, 10);
String timestr(hm);
timestr += ":";
if (mn < 10)
timestr += "0";
itoa(mn, hm, 10);
timestr += hm;
timestr += (now->tm_hour > 11 ? "pm " : "am ");
timestr += " ";
/* ------- blink the : at one-second intervals ----- */
if (flipflop) {
timestr[hr < 10 ? 1 : 2] = ' ';
flipflop = False;
}
else
flipflop = True;
int x = ClientWidth() - 8;
Dequeue();
Enqueue();
WriteClientString(timestr, x, 0, colors.fg, colors.bg);
}
void StatusBar::StatusMessage(String& Msg)
{
int x = (ClientWidth() - Msg.Strlen()) / 2;
WriteClientString(Msg, x, 0, colors.fg, colors.bg);
}