- Fix InterlockedBitTestAndReset and InterlockedBitTestAndSet
[reactos.git] / rosapps / dflat32 / button.c
1 /* -------------- button.c -------------- */
2
3 #include "dflat.h"
4
5 void PaintMsg(DFWINDOW wnd, DF_CTLWINDOW *ct, DFRECT *rc)
6 {
7 if (DfIsVisible(wnd))
8 {
9 if (DfTestAttribute(wnd, DF_SHADOW))
10 {
11 /* -------- draw the button's shadow ------- */
12 int x;
13 DfBackground = DfWndBackground(DfGetParent(wnd));
14 DfForeground = BLACK;
15 for (x = 1; x <= DfWindowWidth(wnd); x++)
16 DfWPutch(wnd, (char)223, x, 1);
17 DfWPutch(wnd, (char)220, DfWindowWidth(wnd), 0);
18 }
19 if (ct->itext != NULL)
20 {
21 char *txt;
22 txt = DfCalloc(1, strlen(ct->itext)+10);
23 if (ct->setting == DF_OFF) {
24 txt[0] = DF_CHANGECOLOR;
25 txt[1] = wnd->WindowColors
26 [DF_HILITE_COLOR] [DF_FG] | 0x80;
27 txt[2] = wnd->WindowColors
28 [DF_STD_COLOR] [DF_BG] | 0x80;
29 }
30 DfCopyCommand(txt+strlen(txt),ct->itext,!ct->setting,
31 DfWndBackground(wnd));
32 DfSendMessage(wnd, DFM_CLEARTEXT, 0, 0);
33 DfSendMessage(wnd, DFM_ADDTEXT, (DF_PARAM) txt, 0);
34 free(txt);
35 }
36 /* --------- write the button's text ------- */
37 DfWriteTextLine(wnd, rc, 0, wnd == DfInFocus);
38 }
39 }
40
41 void LeftButtonMsg(DFWINDOW wnd, DFMESSAGE msg, DF_CTLWINDOW *ct)
42 {
43 /* --------- draw a pushed button -------- */
44 int x;
45 DfBackground = DfWndBackground(DfGetParent(wnd));
46 DfForeground = DfWndBackground(wnd);
47 DfWPutch(wnd, ' ', 0, 0);
48 for (x = 0; x < DfWindowWidth(wnd); x++)
49 {
50 DfWPutch(wnd, (char)220, x+1, 0);
51 DfWPutch(wnd, (char)223, x+1, 1);
52 }
53 if (msg == DFM_LEFT_BUTTON)
54 DfSendMessage(NULL, DFM_WAITMOUSE, 0, 0);
55 else
56 DfSendMessage(NULL, DFM_WAITKEYBOARD, 0, 0);
57 DfSendMessage(wnd, DFM_PAINT, 0, 0);
58 if (ct->setting == DF_ON)
59 DfPostMessage(DfGetParent(wnd), DFM_COMMAND, ct->command, 0);
60 else
61 DfBeep();
62 }
63
64 int DfButtonProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
65 {
66 DF_CTLWINDOW *ct = DfGetControl(wnd);
67 if (ct != NULL) {
68 switch (msg) {
69 case DFM_SETFOCUS:
70 DfBaseWndProc(DF_BUTTON, wnd, msg, p1, p2);
71 p1 = 0;
72 /* ------- fall through ------- */
73 case DFM_PAINT:
74 PaintMsg(wnd, ct, (DFRECT*)p1);
75 return TRUE;
76 case DFM_KEYBOARD:
77 if (p1 != '\r')
78 break;
79 /* ---- fall through ---- */
80 case DFM_LEFT_BUTTON:
81 LeftButtonMsg(wnd, msg, ct);
82 return TRUE;
83 case DFM_HORIZSCROLL:
84 return TRUE;
85 default:
86 break;
87 }
88 }
89 return DfBaseWndProc(DF_BUTTON, wnd, msg, p1, p2);
90 }
91
92 /* EOF */