1 /* -------------- button.c -------------- */
5 void PaintMsg(DFWINDOW wnd
, DF_CTLWINDOW
*ct
, DFRECT
*rc
)
9 if (DfTestAttribute(wnd
, DF_SHADOW
))
11 /* -------- draw the button's shadow ------- */
13 DfBackground
= DfWndBackground(DfGetParent(wnd
));
15 for (x
= 1; x
<= DfWindowWidth(wnd
); x
++)
16 DfWPutch(wnd
, (char)223, x
, 1);
17 DfWPutch(wnd
, (char)220, DfWindowWidth(wnd
), 0);
19 if (ct
->itext
!= NULL
)
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;
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);
36 /* --------- write the button's text ------- */
37 DfWriteTextLine(wnd
, rc
, 0, wnd
== DfInFocus
);
41 void LeftButtonMsg(DFWINDOW wnd
, DFMESSAGE msg
, DF_CTLWINDOW
*ct
)
43 /* --------- draw a pushed button -------- */
45 DfBackground
= DfWndBackground(DfGetParent(wnd
));
46 DfForeground
= DfWndBackground(wnd
);
47 DfWPutch(wnd
, ' ', 0, 0);
48 for (x
= 0; x
< DfWindowWidth(wnd
); x
++)
50 DfWPutch(wnd
, (char)220, x
+1, 0);
51 DfWPutch(wnd
, (char)223, x
+1, 1);
53 if (msg
== DFM_LEFT_BUTTON
)
54 DfSendMessage(NULL
, DFM_WAITMOUSE
, 0, 0);
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);
64 int DfButtonProc(DFWINDOW wnd
, DFMESSAGE msg
, DF_PARAM p1
, DF_PARAM p2
)
66 DF_CTLWINDOW
*ct
= DfGetControl(wnd
);
70 DfBaseWndProc(DF_BUTTON
, wnd
, msg
, p1
, p2
);
72 /* ------- fall through ------- */
74 PaintMsg(wnd
, ct
, (DFRECT
*)p1
);
79 /* ---- fall through ---- */
81 LeftButtonMsg(wnd
, msg
, ct
);
89 return DfBaseWndProc(DF_BUTTON
, wnd
, msg
, p1
, p2
);