forked from alexfru/dflat20
-
Notifications
You must be signed in to change notification settings - Fork 2
/
barchart.c
77 lines (69 loc) · 1.99 KB
/
barchart.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ------------ barchart.c ----------- */
#include "dflat.h"
#ifdef INCLUDE_PICTUREBOX
#define BCHEIGHT 12
#define BCWIDTH 44
#define COLWIDTH 4
static WINDOW Bwnd;
/* ------- project schedule array ------- */
static struct ProjChart {
char *prj;
int start, stop;
} projs[] = {
{"Center St", 0,3},
{"City Hall", 0,5},
{"Rt 395 ", 1,4},
{"Sky Condo", 2,3},
{"Out Hs ", 0,4},
{"Bk Palace", 1,5}
};
static char *Title = " PROJECT SCHEDULE";
static char *Months = " Jan Feb Mar Apr May Jun";
static int BarChartProc(WINDOW wnd, MESSAGE msg,
PARAM p1, PARAM p2)
{
switch (msg) {
case COMMAND:
if ((int)p1 == ID_HELP) {
DisplayHelp(wnd, "BarChart");
return TRUE;
}
break;
case CLOSE_WINDOW:
Bwnd = NULL;
break;
default:
break;
}
return DefaultWndProc(wnd, msg, p1, p2);
}
void BarChart(WINDOW pwnd)
{
int pct = sizeof projs / sizeof(struct ProjChart);
int i;
if (Bwnd == NULL) {
Bwnd = CreateWindow(PICTUREBOX,
"BarChart",
-1, -1, BCHEIGHT, BCWIDTH,
NULL, pwnd, BarChartProc,
SHADOW |
CONTROLBOX |
MOVEABLE |
HASBORDER
);
SendMessage(Bwnd, ADDTEXT, (PARAM) Title, 0);
SendMessage(Bwnd, ADDTEXT, (PARAM) "", 0);
for (i = 0; i < pct; i++) {
SendMessage(Bwnd,ADDTEXT,(PARAM)projs[i].prj,0);
DrawBar(Bwnd, SOLIDBAR+(i%4),
11+projs[i].start*COLWIDTH, 2+i,
(1 + projs[i].stop-projs[i].start) * COLWIDTH,
TRUE);
}
SendMessage(Bwnd, ADDTEXT, (PARAM) "", 0);
SendMessage(Bwnd, ADDTEXT, (PARAM) Months, 0);
DrawBox(Bwnd, 10, 1, pct+2, 25);
}
SendMessage(Bwnd, SETFOCUS, TRUE, 0);
}
#endif