Mercurial > hg > aim92
diff xaim/switch_buttons.c @ 0:5242703e91d3 tip
Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 15:19:45 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xaim/switch_buttons.c Fri May 20 15:19:45 2011 +0100 @@ -0,0 +1,280 @@ +/* + Copyright (c) Applied Psychology Unit, Medical Research Council. 1993 + =========================================================================== + + Permission to use, copy, modify, and distribute this software without fee + is hereby granted for research purposes, provided that this copyright + notice appears in all copies and in all supporting documentation, and that + the software is not redistributed for any fee (except for a nominal + shipping charge). Anyone wanting to incorporate all or part of this + software in a commercial product must obtain a license from the Medical + Research Council. + + The MRC makes no representations about the suitability of this + software for any purpose. It is provided "as is" without express or + implied warranty. + + THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES + OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + SOFTWARE. +*/ + +/* +* switch_buttons.c +* ---------------- +* The 'switch' code for all the Control Window buttons. +* +* M. Akeroyd. July 1993. version 1.10 +* Revisions: MAA: Christmas 1993. +* +*/ + + + +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xos.h> +#include <X11/Xatom.h> +#include <stdio.h> + +#include "xreview.h" + + +/* General ................*/ + +extern char *data_pointer; +extern long location[MAX_FRAMES]; + + +/* X ......................*/ + +extern Display *display; +extern int screen_num; +extern Screen *screen_ptr; + +extern toplevelWindow control; +extern toplevelWindow axes; +extern XImage *reviewimage; + +extern buttonWindow button_quit, button_close; +extern buttonWindow button_animate; +extern buttonWindow button_startf, button_startb, button_stopf, button_stopb; +extern buttonWindow button_skipf, button_skipb, button_faster, button_slower; +extern buttonWindow button_firstframe, button_lastframe, button_middle; +extern buttonWindow button_stepf, button_stepff, button_stepb, button_stepbb; + +extern buttonWindow info_speed, info_start, info_stop, info_skip; +extern buttonWindow info_title, info_frame; +extern buttonWindow info_time, info_freq, info_frstep; + +extern GC button_gc; +extern int button_borderwidth; + +extern XFontStruct *font_info; +extern XEvent report; + + +/* .ctn ......................*/ + +extern int animate_start; +extern int animate_stop; +extern int animate_skip; +extern int frame; +extern int no_frames; +extern long waittime_millisecs; + + + + +/*-------------------------------------------------------------------*/ +/*-------------------------------------------------------------------*/ + + + + +void switch_buttons() +{ + char tempstring[MAX_STRING_LENGTH]; + + /*--------------------------------------------------------*/ + + if (report.xbutton.button != Button1) + return ; + + if (report.xany.window == button_quit.win) { + flashbutton(control, button_quit, &button_gc, "Quit"); + exit_xreview();} + + + if (report.xany.window == button_close.win) { + flashbutton(control, button_close, &button_gc, "Close"); + XUnmapWindow(display, control.win);} + + + if (report.xany.window == button_animate.win){ + flashbutton(control, button_animate, &button_gc, "Animate"); + animate_image(animate_start, animate_stop, animate_skip);} + + + if (report.xany.window == button_startf.win) { + flashbutton(control, button_startf, &button_gc, "+1"); + animate_start++; + if (animate_start == no_frames) + animate_start = no_frames-1; + sprintf(tempstring, "Start: %i", animate_start); + XClearWindow(display, info_start.win); + drawtext(info_start, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_startb.win) { + flashbutton(control, button_startb, &button_gc, "-1"); + animate_start--; + if (animate_start == 0) + animate_start = 1; + sprintf(tempstring, "Start: %i", animate_start); + XClearWindow(display, info_start.win); + drawtext(info_start, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_stopf.win) { + flashbutton(control, button_stopf, &button_gc, "+1"); + animate_stop++; + if (animate_stop == no_frames +1) + animate_stop = no_frames; + sprintf(tempstring, "Stop: %i", animate_stop); + XClearWindow(display, info_stop.win); + drawtext(info_stop, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_stopb.win) { + flashbutton(control, button_stopb, &button_gc, "-1"); + animate_stop--; + if (animate_stop == 1) + animate_stop = 2; + sprintf(tempstring, "Stop: %i", animate_stop); + XClearWindow(display, info_stop.win); + drawtext(info_stop, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_skipf.win) { + flashbutton(control, button_skipf, &button_gc, "+1"); + animate_skip++; + if (animate_skip == no_frames) + animate_start = no_frames-1; + sprintf(tempstring, "Skip: %i", animate_skip); + XClearWindow(display, info_skip.win); + drawtext(info_skip, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_skipb.win) { + flashbutton(control, button_skipb, &button_gc, "-1"); + animate_skip--; + if (animate_skip == 0) + animate_skip = 1; + sprintf(tempstring, "Skip: %i", animate_skip); + XClearWindow(display, info_skip.win); + drawtext(info_skip, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_faster.win) { + flashbutton(control, button_faster, &button_gc, "Fast"); + waittime_millisecs = (long) waittime_millisecs / 2; + if (waittime_millisecs < 1) + waittime_millisecs = 1; + sprintf(tempstring, "Speed: %li", waittime_millisecs); + XClearWindow(display, info_speed.win); + drawtext(info_speed, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_slower.win) { + flashbutton(control, button_slower, &button_gc, "Slow"); + waittime_millisecs = (long) waittime_millisecs * 2; + sprintf(tempstring, "Speed: %li", waittime_millisecs); + XClearWindow(display, info_speed.win); + drawtext(info_speed, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_lastframe.win) { + flashbutton(control, button_lastframe, &button_gc, "Last"); + frame=no_frames; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_firstframe.win) { + flashbutton(control, button_firstframe, &button_gc, "First"); + frame=1; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_middle.win) { + flashbutton(control, button_middle, &button_gc, "Middle"); + frame=no_frames/2; + if (frame == 0) + frame = 1; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_stepf.win) { + flashbutton(control, button_stepf, &button_gc, ">"); + frame++; + if (frame > no_frames) + frame = no_frames; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_stepff.win) { + flashbutton(control, button_stepff, &button_gc, ">>"); + frame+=10; + if (frame > no_frames) + frame = no_frames; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_stepb.win) { + flashbutton(control, button_stepb, &button_gc, "<"); + frame--; + if (frame < 1) + frame = 1; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + + + if (report.xany.window == button_stepbb.win) { + flashbutton(control, button_stepbb, &button_gc, "<<"); + frame-=10; + if (frame < 1) + frame = 1; + drawimage(frame); + XClearWindow(display, info_frame.win); + sprintf(tempstring, "%i of %i", frame, no_frames); + drawtext(info_frame, button_gc, font_info, tempstring);} + +} + + + + +/* The End */ +/*-------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/