#include <tscope.h>
#define BUTTONS 2
struct {
int x1, x2;
int y1, y2;
} knop[BUTTONS];
int main()
{
ts_scrsize(SIZE1);
ts_bgcolor(RED);
ts_font(COURIER, 12, BOLD);
ts_fgcolor(BLUE);
ts_fill(TRUE);
ts_mousepos(0, 0);
ts_mousecolor(WHITE);
knop[0].x1 = -XMAX / 3 - ax(.1);
knop[0].x2 = -XMAX / 3 + ax(.1);
knop[0].y1 = -YMAX / 4 - ay(.1);
knop[0].y2 = -YMAX / 4 + ay(.1);
knop[1].x1 = XMAX / 3 - ax(.1);
knop[1].x2 = XMAX / 3 + ax(.1);
knop[1].y1 = -YMAX / 4 - ay(.1);
knop[1].y2 = -YMAX / 4 + ay(.1);
int i;
for (i = 0; i < BUTTONS; i++) {
ts_rect(knop[i].x1, knop[i].y1, knop[i].x2, knop[i].y2);
int col = ts_fgcolor(RED);
ts_printf_centre((knop[i].x1 + knop[i].x2) / 2,
(knop[i].y1 + knop[i].y2) / 2, "%d", i + 1);
ts_fgcolor(col);
}
ts_drawmouse();
ts_defkey(M1);
ts_defkey(M2);
int resp;
int x, y, waar = 0;
do {
resp = ts_respstatus();
x = ts_xmouse();
y = ts_ymouse();
if (resp)
for (i = 0; i < BUTTONS; i++)
if (x > knop[i].x1 && x < knop[i].x2 && y > knop[i].y1
&& y < knop[i].y2)
waar = i + 1;
} while (!waar);
ts_hidemouse();
ts_printf_centre(0, 2 * YMAX / 3, "screen button %d pressed", waar);
ts_printf_centre(0, YMAX / 3, "with mouse button %d", resp);
ts_button(XMAX - 20, -YMAX + 20);
return 0;
}
END_OF_MAIN();