fix include file case
[reactos.git] / rosapps / lib / dflat32 / radio.c
1 /* -------- radio.c -------- */
2
3 #include "dflat32/dflat.h"
4
5 static CTLWINDOW *rct[MAXRADIOS];
6
7 int RadioButtonProc(DFWINDOW wnd, DFMESSAGE msg, PARAM p1, PARAM p2)
8 {
9 int rtn;
10 DBOX *db = GetParent(wnd)->extension;
11 CTLWINDOW *ct = GetControl(wnd);
12 if (ct != NULL) {
13 switch (msg) {
14 case SETFOCUS:
15 if (!(int)p1)
16 DfSendMessage(NULL, HIDE_CURSOR, 0, 0);
17 case MOVE:
18 rtn = BaseWndProc(RADIOBUTTON,wnd,msg,p1,p2);
19 SetFocusCursor(wnd);
20 return rtn;
21 case PAINT: {
22 char rb[] = "( )";
23 if (ct->setting)
24 rb[1] = 7;
25 DfSendMessage(wnd, CLEARTEXT, 0, 0);
26 DfSendMessage(wnd, ADDTEXT, (PARAM) rb, 0);
27 SetFocusCursor(wnd);
28 break;
29 }
30 case KEYBOARD:
31 if ((int)p1 != ' ')
32 break;
33 case LEFT_BUTTON:
34 SetRadioButton(db, ct);
35 break;
36 default:
37 break;
38 }
39 }
40 return BaseWndProc(RADIOBUTTON, wnd, msg, p1, p2);
41 }
42
43 static BOOL Setting = TRUE;
44
45 void SetRadioButton(DBOX *db, CTLWINDOW *ct)
46 {
47 Setting = FALSE;
48 PushRadioButton(db, ct->command);
49 Setting = TRUE;
50 }
51
52 void PushRadioButton(DBOX *db, enum commands cmd)
53 {
54 CTLWINDOW *ctt = db->ctl;
55 CTLWINDOW *ct = FindCommand(db, cmd, RADIOBUTTON);
56 int i;
57
58 if (ct == NULL)
59 return;
60
61 /* --- clear all the radio buttons
62 in this group on the dialog box --- */
63
64 /* -------- build a table of all radio buttons at the
65 same x vector ---------- */
66 for (i = 0; i < MAXRADIOS; i++)
67 rct[i] = NULL;
68 while (ctt->class) {
69 if (ctt->class == RADIOBUTTON)
70 if (ct->dwnd.x == ctt->dwnd.x)
71 rct[ctt->dwnd.y] = ctt;
72 ctt++;
73 }
74
75 /* ----- find the start of the radiobutton group ---- */
76 i = ct->dwnd.y;
77 while (i >= 0 && rct[i] != NULL)
78 --i;
79 /* ---- ignore everthing before the group ------ */
80 while (i >= 0)
81 rct[i--] = NULL;
82
83 /* ----- find the end of the radiobutton group ---- */
84 i = ct->dwnd.y;
85 while (i < MAXRADIOS && rct[i] != NULL)
86 i++;
87 /* ---- ignore everthing past the group ------ */
88 while (i < MAXRADIOS)
89 rct[i++] = NULL;
90
91 for (i = 0; i < MAXRADIOS; i++) {
92 if (rct[i] != NULL) {
93 int wason = rct[i]->setting;
94 rct[i]->setting = OFF;
95 if (Setting)
96 rct[i]->isetting = OFF;
97 if (wason)
98 DfSendMessage(rct[i]->wnd, PAINT, 0, 0);
99 }
100 }
101 /* ----- set the specified radio button on ----- */
102 ct->setting = ON;
103 if (Setting)
104 ct->isetting = ON;
105 DfSendMessage(ct->wnd, PAINT, 0, 0);
106 }
107
108 BOOL RadioButtonSetting(DBOX *db, enum commands cmd)
109 {
110 CTLWINDOW *ct = FindCommand(db, cmd, RADIOBUTTON);
111 if (ct != NULL)
112 return (ct->setting == ON);
113 return FALSE;
114 }
115
116 /* EOF */