Sync with trunk r43123
[reactos.git] / rosapps / dflat32 / barchart.c
1 /* ------------ barchart.c ----------- */
2 #include "dflat.h"
3
4 #define BCHEIGHT 12
5 #define BCWIDTH 44
6 #define COLWIDTH 4
7
8 static DFWINDOW Bwnd;
9
10 /* ------- project schedule array ------- */
11 static struct ProjChart {
12 char *prj;
13 int start, stop;
14 } projs[] = {
15 {"Center St", 0,3},
16 {"City Hall", 0,5},
17 {"Rt 395 ", 1,4},
18 {"Sky Condo", 2,3},
19 {"Out Hs ", 0,4},
20 {"Bk Palace", 1,5}
21 };
22
23 static char *Title = " PROJECT SCHEDULE";
24 static char *Months = " Jan Feb Mar Apr May Jun";
25
26 static int BarChartProc(DFWINDOW wnd, DFMESSAGE msg,
27 DF_PARAM p1, DF_PARAM p2)
28 {
29 switch (msg) {
30 case DFM_COMMAND:
31 if ((int)p1 == DF_ID_HELP) {
32 DfDisplayHelp(wnd, "BarChart");
33 return TRUE;
34 }
35 break;
36 case DFM_CLOSE_WINDOW:
37 Bwnd = NULL;
38 break;
39 default:
40 break;
41 }
42 return DfDefaultWndProc(wnd, msg, p1, p2);
43 }
44
45 void BarChart(DFWINDOW pwnd)
46 {
47 int pct = sizeof projs / sizeof(struct ProjChart);
48 int i;
49
50 if (Bwnd == NULL) {
51 Bwnd = DfDfCreateWindow(DF_PICTUREBOX,
52 "BarChart",
53 -1, -1, BCHEIGHT, BCWIDTH,
54 NULL, pwnd, BarChartProc,
55 DF_SHADOW |
56 DF_CONTROLBOX |
57 DF_MOVEABLE |
58 DF_HASBORDER
59 );
60 DfSendMessage(Bwnd, DFM_ADDTEXT, (DF_PARAM) Title, 0);
61 DfSendMessage(Bwnd, DFM_ADDTEXT, (DF_PARAM) "", 0);
62 for (i = 0; i < pct; i++) {
63 DfSendMessage(Bwnd,DFM_ADDTEXT,(DF_PARAM)projs[i].prj,0);
64 DfDrawBar(Bwnd, DF_SOLIDBAR+(i%4),
65 11+projs[i].start*COLWIDTH, 2+i,
66 (1 + projs[i].stop-projs[i].start) * COLWIDTH,
67 TRUE);
68 }
69 DfSendMessage(Bwnd, DFM_ADDTEXT, (DF_PARAM) "", 0);
70 DfSendMessage(Bwnd, DFM_ADDTEXT, (DF_PARAM) Months, 0);
71 DfDrawBox(Bwnd, 10, 1, pct+2, 25);
72 }
73 DfSendMessage(Bwnd, DFM_SETFOCUS, TRUE, 0);
74 }