Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 125

KTD-S0057-I
Page 121 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
xsys.gc = gc;
XSelectInput (disp, win, ButtonPressMask | ButtonReleaseMask | ExposureMask | StructureNotifyMask);
closeatom = XInternAtom (disp, "WM_DELETE_WINDOW", TRUE);
if
(closeatom)
XSetWMProtocols (disp, win, (Atom *) & closeatom, 1);
font1 = XLoadQueryFont (disp, BTN_FONT1);
if (font1 == (XFontStruct *) NULL)
{
fprintf (stderr, "Cannot load text font\n");
free_resources
(xsys);
return
EXIT_FAILURE;
}
xsys.font1 = font1;
font2 = XLoadQueryFont (disp, BTN_FONT2);
if (font2 == (XFontStruct *) NULL)
{
fprintf (stderr, "Cannot load text font\n");
free_resources
(xsys);
return
EXIT_FAILURE;
}
xsys.font2 = font2;
XMapWindow (disp, win);
while (! quit)
{
XNextEvent (disp, &e);
if (e.type == ClientMessage && (Atom) (e.xclient.data.l[0]) == closeatom)
quit = TRUE;
else if (e.type == ButtonPress)
{
xbtn.rc = btn1;
if (! check_button (xsys, xbtn, e.xbutton.x, e.xbutton.y, 0))
curbtn
=
BTN_CANCEL;
xbtn.rc = btn2;
if (! check_button (xsys, xbtn, e.xbutton.x, e.xbutton.y, suppress))
curbtn = BTN_PICTURE;
}
else if (e.type == ButtonRelease)
{
if
(curbtn)
{
switch
(curbtn)
{
case
BTN_CANCEL:
XAllocNamedColor (disp, cmap, BTN_LINECOL, &linecol, &linecol);
XAllocNamedColor (disp, cmap, BTN_GRAYCOL, &backcol, &backcol);
xbtn.rc
= btn1;