implemented some stubs needed by ClamWin
[reactos.git] / rosapps / dflat32 / radio.c
1 /* -------- radio.c -------- */
2
3 #include "dflat.h"
4
5 static DF_CTLWINDOW *rct[DF_MAXRADIOS];
6
7 int DfRadioButtonProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
8 {
9 int rtn;
10 DF_DBOX *db = DfGetParent(wnd)->extension;
11 DF_CTLWINDOW *ct = DfGetControl(wnd);
12 if (ct != NULL) {
13 switch (msg) {
14 case DFM_SETFOCUS:
15 if (!(int)p1)
16 DfSendMessage(NULL, DFM_HIDE_CURSOR, 0, 0);
17 case DFM_MOVE:
18 rtn = DfBaseWndProc(DF_RADIOBUTTON,wnd,msg,p1,p2);
19 DfSetFocusCursor(wnd);
20 return rtn;
21 case DFM_PAINT: {
22 char rb[] = "( )";
23 if (ct->setting)
24 rb[1] = 7;
25 DfSendMessage(wnd, DFM_CLEARTEXT, 0, 0);
26 DfSendMessage(wnd, DFM_ADDTEXT, (DF_PARAM) rb, 0);
27 DfSetFocusCursor(wnd);
28 break;
29 }
30 case DFM_KEYBOARD:
31 if ((int)p1 != ' ')
32 break;
33 case DFM_LEFT_BUTTON:
34 DfSetRadioButton(db, ct);
35 break;
36 default:
37 break;
38 }
39 }
40 return DfBaseWndProc(DF_RADIOBUTTON, wnd, msg, p1, p2);
41 }
42
43 static BOOL Setting = TRUE;
44
45 void DfSetRadioButton(DF_DBOX *db, DF_CTLWINDOW *ct)
46 {
47 Setting = FALSE;
48 DfPushRadioButton(db, ct->command);
49 Setting = TRUE;
50 }
51
52 void DfPushRadioButton(DF_DBOX *db, enum DfCommands cmd)
53 {
54 DF_CTLWINDOW *ctt = db->ctl;
55 DF_CTLWINDOW *ct = DfFindCommand(db, cmd, DF_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 < DF_MAXRADIOS; i++)
67 rct[i] = NULL;
68 while (ctt->class) {
69 if (ctt->class == DF_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 < DF_MAXRADIOS && rct[i] != NULL)
86 i++;
87 /* ---- ignore everthing past the group ------ */
88 while (i < DF_MAXRADIOS)
89 rct[i++] = NULL;
90
91 for (i = 0; i < DF_MAXRADIOS; i++) {
92 if (rct[i] != NULL) {
93 int wason = rct[i]->setting;
94 rct[i]->setting = DF_OFF;
95 if (Setting)
96 rct[i]->isetting = DF_OFF;
97 if (wason)
98 DfSendMessage(rct[i]->wnd, DFM_PAINT, 0, 0);
99 }
100 }
101 /* ----- set the specified radio button on ----- */
102 ct->setting = DF_ON;
103 if (Setting)
104 ct->isetting = DF_ON;
105 DfSendMessage(ct->wnd, DFM_PAINT, 0, 0);
106 }
107
108 BOOL DfRadioButtonSetting(DF_DBOX *db, enum DfCommands cmd)
109 {
110 DF_CTLWINDOW *ct = DfFindCommand(db, cmd, DF_RADIOBUTTON);
111 if (ct != NULL)
112 return (ct->setting == DF_ON);
113 return FALSE;
114 }
115
116 /* EOF */