tomwalters@0: /* tomwalters@0: Copyright (c) Applied Psychology Unit, Medical Research Council. 1993 tomwalters@0: =========================================================================== tomwalters@0: tomwalters@0: Permission to use, copy, modify, and distribute this software without fee tomwalters@0: is hereby granted for research purposes, provided that this copyright tomwalters@0: notice appears in all copies and in all supporting documentation, and that tomwalters@0: the software is not redistributed for any fee (except for a nominal tomwalters@0: shipping charge). Anyone wanting to incorporate all or part of this tomwalters@0: software in a commercial product must obtain a license from the Medical tomwalters@0: Research Council. tomwalters@0: tomwalters@0: The MRC makes no representations about the suitability of this tomwalters@0: software for any purpose. It is provided "as is" without express or tomwalters@0: implied warranty. tomwalters@0: tomwalters@0: THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING tomwalters@0: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL tomwalters@0: THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES tomwalters@0: OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, tomwalters@0: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, tomwalters@0: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS tomwalters@0: SOFTWARE. tomwalters@0: */ tomwalters@0: tomwalters@0: /* tomwalters@0: * switch_axes.c tomwalters@0: * ------------- tomwalters@0: * 'switch' code for the axes (=cartoon image) window. tomwalters@0: * tomwalters@0: * M. Akeroyd. July 1993. version 1.10 tomwalters@0: * Revisions: MAA: Christmas 1993. tomwalters@0: */ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include tomwalters@0: tomwalters@0: #include "xreview.h" tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /* General .................*/ tomwalters@0: tomwalters@0: tomwalters@0: /* X ........................*/ tomwalters@0: tomwalters@0: extern Display *display; tomwalters@0: extern int screen_num; tomwalters@0: extern Screen *screen_ptr; tomwalters@0: tomwalters@0: extern toplevelWindow control; tomwalters@0: extern toplevelWindow axes; tomwalters@0: extern buttonWindow info_speed, info_frame; tomwalters@0: extern XFontStruct font_info; tomwalters@0: tomwalters@0: extern XEvent report; tomwalters@0: extern GC button_gc; tomwalters@0: tomwalters@0: tomwalters@0: /* .ctn .....................*/ tomwalters@0: tomwalters@0: extern int frame; tomwalters@0: extern int no_frames; tomwalters@0: tomwalters@0: extern int animate_start; tomwalters@0: extern int animate_stop; tomwalters@0: extern int animate_skip; tomwalters@0: tomwalters@0: extern long waittime_millisecs; tomwalters@0: tomwalters@0: tomwalters@0: /* extras for the pcroy version */ tomwalters@0: extern int animate_start; tomwalters@0: extern int animate_stop; tomwalters@0: extern int animate_skip; tomwalters@0: tomwalters@0: /*--------------------------------------------------------------------*/ tomwalters@0: /*--------------------------------------------------------------------*/ tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: void switch_axes() tomwalters@0: { tomwalters@0: char tempstring[MAX_STRING_LENGTH]; tomwalters@0: char buffer[20]; tomwalters@0: int bufsize = 20; tomwalters@0: int charcount; tomwalters@0: XComposeStatus compose_X; tomwalters@0: KeySym keysym_X; tomwalters@0: tomwalters@0: switch(report.type) { tomwalters@0: tomwalters@0: /*---------------------------------------------*/ tomwalters@0: tomwalters@0: case Expose: tomwalters@0: if (report.xexpose.count != 0) tomwalters@0: break; tomwalters@0: tomwalters@0: if ((axes.window_size == TOO_SMALL_X) || tomwalters@0: (axes.window_size == TOO_BIG_X)) tomwalters@0: break; tomwalters@0: tomwalters@0: drawimage(frame); tomwalters@0: break; tomwalters@0: tomwalters@0: /*---------------------------------------------*/ tomwalters@0: tomwalters@0: case ConfigureNotify: tomwalters@0: axes.width = report.xconfigure.width; tomwalters@0: axes.height = report.xconfigure.height; tomwalters@0: tomwalters@0: /* No resizing allowed */ tomwalters@0: axes.window_size = BIG_ENOUGH_X; tomwalters@0: if ((axes.width < axes.size_hints.min_width) || \ tomwalters@0: (axes.height < axes.size_hints.min_height)) tomwalters@0: axes.window_size = TOO_SMALL_X; tomwalters@0: if ((axes.width > axes.size_hints.max_width) || \ tomwalters@0: (axes.height > axes.size_hints.max_height)) tomwalters@0: axes.window_size = TOO_BIG_X; tomwalters@0: break; tomwalters@0: tomwalters@0: /*---------------------------------------------*/ tomwalters@0: tomwalters@0: case ButtonPress: tomwalters@0: tomwalters@0: /* if button 1, animate */ tomwalters@0: if (report.xbutton.button == Button1) { tomwalters@0: animate_image(animate_start, animate_stop, animate_skip); tomwalters@0: break;} tomwalters@0: tomwalters@0: /* if button 2, map control window */ tomwalters@0: if (report.xbutton.button == Button2) { tomwalters@0: XMapWindow(display, control.win); tomwalters@0: break;} tomwalters@0: tomwalters@0: /* If button 3, quit. */ tomwalters@0: if (report.xbutton.button == Button3) { tomwalters@0: exit_xreview(); tomwalters@0: } tomwalters@0: tomwalters@0: break; tomwalters@0: tomwalters@0: /*---------------------------------------------*/ tomwalters@0: tomwalters@0: case KeyPress: tomwalters@0: tomwalters@0: charcount = XLookupString(&report.xkey, buffer, bufsize, &keysym_X, &compose_X); tomwalters@0: tomwalters@0: if ((keysym_X == XK_space) || (keysym_X == XK_Return)) { tomwalters@0: animate_image(animate_start, animate_stop, animate_skip); tomwalters@0: break;} tomwalters@0: tomwalters@0: if ((keysym_X == XK_N) || (keysym_X == XK_n)) { tomwalters@0: frame++; tomwalters@0: if (frame > no_frames) tomwalters@0: frame = no_frames; tomwalters@0: drawimage(frame); tomwalters@0: XClearWindow(display, info_frame.win); tomwalters@0: sprintf(tempstring, "%i of %i", frame, no_frames); tomwalters@0: drawtext(info_frame, button_gc, font_info, tempstring); tomwalters@0: XFlush(display);} tomwalters@0: tomwalters@0: if ((keysym_X == XK_p) || (keysym_X == XK_p)) { tomwalters@0: frame--; tomwalters@0: if (frame < 1) tomwalters@0: frame = 1; tomwalters@0: drawimage(frame); tomwalters@0: XClearWindow(display, info_frame.win); tomwalters@0: sprintf(tempstring, "%i of %i", frame, no_frames); tomwalters@0: drawtext(info_frame, button_gc, font_info, tempstring); tomwalters@0: XFlush(display);} tomwalters@0: tomwalters@0: if ((keysym_X == XK_F)|| (keysym_X == XK_f)){ tomwalters@0: waittime_millisecs = (long) waittime_millisecs / 2; tomwalters@0: #ifndef HOST_LINUXPC tomwalters@0: if (waittime_millisecs < 1) tomwalters@0: waittime_millisecs = 1; tomwalters@0: #endif tomwalters@0: sprintf(tempstring, "Speed: %li", waittime_millisecs); tomwalters@0: XClearWindow(display, info_speed.win); tomwalters@0: drawtext(info_speed, button_gc, font_info, tempstring); tomwalters@0: XFlush(display); tomwalters@0: break;} tomwalters@0: tomwalters@0: if ((keysym_X == XK_S)|| (keysym_X == XK_s)){ tomwalters@0: #ifndef HOST_LINUXPC tomwalters@0: waittime_millisecs = (long) waittime_millisecs * 2; tomwalters@0: #endif tomwalters@0: sprintf(tempstring, "Speed: %li", waittime_millisecs); tomwalters@0: XClearWindow(display, info_speed.win); tomwalters@0: drawtext(info_speed, button_gc, font_info, tempstring); tomwalters@0: XFlush(display); tomwalters@0: break;} tomwalters@0: tomwalters@0: if ((keysym_X == XK_q) || (keysym_X == XK_Q)) { tomwalters@0: exit_xreview(); } tomwalters@0: tomwalters@0: break; tomwalters@0: tomwalters@0: /*---------------------------------------------*/ tomwalters@0: tomwalters@0: default: tomwalters@0: break; tomwalters@0: tomwalters@0: tomwalters@0: } /* switch */ tomwalters@0: tomwalters@0: } tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: /* The End */ tomwalters@0: /*--------------------------------------------------------------------------*/ tomwalters@0: /*--------------------------------------------------------------------------*/