
Example 6-1. The canvas_input.c program (continued)
} else if (view == newview) {
xv_set(xv_get(canvas, OPENWIN_VERTICAL_SCROLLBAR, view),
SCROLLBAR_VIEW_START, 0,
NULL);
xv_set(xv_get(canvas, OPENWIN_HORIZONTAL_SCROLLBAR, view),
SCROLLBAR_VIEW_START, 0,
NULL);
}
i++;
OPENWIN_END_EACH
sprintf(msg, "Total views: %d", i);
xv_set(frame, FRAME_RIGHT_FOOTER, msg, NULL);
}
/*
* Called when an event is received in an arbitrary paint window.
*/
void
my_event_proc(window, event, arg)
Xv_Window window;
Event *event;
Notify_arg arg;
{
register char *p = msg;
*p = 0;
/* test to see if a function key has been hit */
if (event_is_key_left(event))
sprintf(p, "(L%d) ", event_id(event) – KEY_LEFTFIRST + 1);
else if (event_is_key_top(event))
sprintf(p, "(T%d) ", event_id(event) – KEY_TOPFIRST + 1);
else if (event_is_key_right(event))
sprintf(p, "(R%d) ", event_id(event) – KEY_RIGHTFIRST + 1);
else if (event_id(event) == KEY_BOTTOMLEFT)
strcpy(p, "bottom left ");
else if (event_id(event) == KEY_BOTTOMRIGHT)
strcpy(p, "bottom right ");
p += strlen(p);
if (event_is_ascii(event)) {
/*
* note that shift modifier is reflected in the event code by
* virtue of the char printed is upper/lower case.
*/
sprintf(p, "Keyboard: key ’%c’ (%d) %s at %d,%d",
event_action(event), event_action(event),
event_is_down(event)? "pressed" : "released",
event_x(event), event_y(event));
} else switch (event_action(event)) {
case ACTION_CLOSE :
xv_set(frame, FRAME_CLO ...