forked from alexfru/dflat20
-
Notifications
You must be signed in to change notification settings - Fork 2
/
statbar.c
55 lines (52 loc) · 1.34 KB
/
statbar.c
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
/* ---------------- statbar.c -------------- */
#include "dflat.h"
extern char time_string[];
int StatusBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
{
char *statusbar;
switch (msg) {
case CREATE_WINDOW:
SendMessage(wnd, CAPTURE_CLOCK, 0, 0);
break;
case KEYBOARD:
if ((int)p1 == CTRL_F4)
return TRUE;
break;
case PAINT:
if (!isVisible(wnd))
break;
statusbar = DFcalloc(1, WindowWidth(wnd)+1);
memset(statusbar, ' ', WindowWidth(wnd));
*(statusbar+WindowWidth(wnd)) = '\0';
strncpy(statusbar+1, "F1=Help", 7);
if (wnd->text) {
int len = min(strlen(wnd->text), WindowWidth(wnd)-17);
if (len > 0) {
int off=(WindowWidth(wnd)-len)/2;
strncpy(statusbar+off, wnd->text, len);
}
}
if (wnd->TimePosted)
*(statusbar+WindowWidth(wnd)-8) = '\0';
else
strncpy(statusbar+WindowWidth(wnd)-8, time_string, 9);
SetStandardColor(wnd);
PutWindowLine(wnd, statusbar, 0, 0);
free(statusbar);
return TRUE;
case BORDER:
return TRUE;
case CLOCKTICK:
SetStandardColor(wnd);
PutWindowLine(wnd, (char *)p1, WindowWidth(wnd)-8, 0);
wnd->TimePosted = TRUE;
SendMessage(wnd->PrevClock, msg, p1, p2);
return TRUE;
case CLOSE_WINDOW:
SendMessage(wnd, RELEASE_CLOCK, 0, 0);
break;
default:
break;
}
return BaseWndProc(STATUSBAR, wnd, msg, p1, p2);
}