annotate 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
rev   line source
tomwalters@0 1 /*
tomwalters@0 2 Copyright (c) Applied Psychology Unit, Medical Research Council. 1993
tomwalters@0 3 ===========================================================================
tomwalters@0 4
tomwalters@0 5 Permission to use, copy, modify, and distribute this software without fee
tomwalters@0 6 is hereby granted for research purposes, provided that this copyright
tomwalters@0 7 notice appears in all copies and in all supporting documentation, and that
tomwalters@0 8 the software is not redistributed for any fee (except for a nominal
tomwalters@0 9 shipping charge). Anyone wanting to incorporate all or part of this
tomwalters@0 10 software in a commercial product must obtain a license from the Medical
tomwalters@0 11 Research Council.
tomwalters@0 12
tomwalters@0 13 The MRC makes no representations about the suitability of this
tomwalters@0 14 software for any purpose. It is provided "as is" without express or
tomwalters@0 15 implied warranty.
tomwalters@0 16
tomwalters@0 17 THE MRC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
tomwalters@0 18 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
tomwalters@0 19 THE A.P.U. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
tomwalters@0 20 OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
tomwalters@0 21 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
tomwalters@0 22 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
tomwalters@0 23 SOFTWARE.
tomwalters@0 24 */
tomwalters@0 25
tomwalters@0 26 /*
tomwalters@0 27 * switch_buttons.c
tomwalters@0 28 * ----------------
tomwalters@0 29 * The 'switch' code for all the Control Window buttons.
tomwalters@0 30 *
tomwalters@0 31 * M. Akeroyd. July 1993. version 1.10
tomwalters@0 32 * Revisions: MAA: Christmas 1993.
tomwalters@0 33 *
tomwalters@0 34 */
tomwalters@0 35
tomwalters@0 36
tomwalters@0 37
tomwalters@0 38 #include <X11/Xlib.h>
tomwalters@0 39 #include <X11/Xutil.h>
tomwalters@0 40 #include <X11/Xos.h>
tomwalters@0 41 #include <X11/Xatom.h>
tomwalters@0 42 #include <stdio.h>
tomwalters@0 43
tomwalters@0 44 #include "xreview.h"
tomwalters@0 45
tomwalters@0 46
tomwalters@0 47 /* General ................*/
tomwalters@0 48
tomwalters@0 49 extern char *data_pointer;
tomwalters@0 50 extern long location[MAX_FRAMES];
tomwalters@0 51
tomwalters@0 52
tomwalters@0 53 /* X ......................*/
tomwalters@0 54
tomwalters@0 55 extern Display *display;
tomwalters@0 56 extern int screen_num;
tomwalters@0 57 extern Screen *screen_ptr;
tomwalters@0 58
tomwalters@0 59 extern toplevelWindow control;
tomwalters@0 60 extern toplevelWindow axes;
tomwalters@0 61 extern XImage *reviewimage;
tomwalters@0 62
tomwalters@0 63 extern buttonWindow button_quit, button_close;
tomwalters@0 64 extern buttonWindow button_animate;
tomwalters@0 65 extern buttonWindow button_startf, button_startb, button_stopf, button_stopb;
tomwalters@0 66 extern buttonWindow button_skipf, button_skipb, button_faster, button_slower;
tomwalters@0 67 extern buttonWindow button_firstframe, button_lastframe, button_middle;
tomwalters@0 68 extern buttonWindow button_stepf, button_stepff, button_stepb, button_stepbb;
tomwalters@0 69
tomwalters@0 70 extern buttonWindow info_speed, info_start, info_stop, info_skip;
tomwalters@0 71 extern buttonWindow info_title, info_frame;
tomwalters@0 72 extern buttonWindow info_time, info_freq, info_frstep;
tomwalters@0 73
tomwalters@0 74 extern GC button_gc;
tomwalters@0 75 extern int button_borderwidth;
tomwalters@0 76
tomwalters@0 77 extern XFontStruct *font_info;
tomwalters@0 78 extern XEvent report;
tomwalters@0 79
tomwalters@0 80
tomwalters@0 81 /* .ctn ......................*/
tomwalters@0 82
tomwalters@0 83 extern int animate_start;
tomwalters@0 84 extern int animate_stop;
tomwalters@0 85 extern int animate_skip;
tomwalters@0 86 extern int frame;
tomwalters@0 87 extern int no_frames;
tomwalters@0 88 extern long waittime_millisecs;
tomwalters@0 89
tomwalters@0 90
tomwalters@0 91
tomwalters@0 92
tomwalters@0 93 /*-------------------------------------------------------------------*/
tomwalters@0 94 /*-------------------------------------------------------------------*/
tomwalters@0 95
tomwalters@0 96
tomwalters@0 97
tomwalters@0 98
tomwalters@0 99 void switch_buttons()
tomwalters@0 100 {
tomwalters@0 101 char tempstring[MAX_STRING_LENGTH];
tomwalters@0 102
tomwalters@0 103 /*--------------------------------------------------------*/
tomwalters@0 104
tomwalters@0 105 if (report.xbutton.button != Button1)
tomwalters@0 106 return ;
tomwalters@0 107
tomwalters@0 108 if (report.xany.window == button_quit.win) {
tomwalters@0 109 flashbutton(control, button_quit, &button_gc, "Quit");
tomwalters@0 110 exit_xreview();}
tomwalters@0 111
tomwalters@0 112
tomwalters@0 113 if (report.xany.window == button_close.win) {
tomwalters@0 114 flashbutton(control, button_close, &button_gc, "Close");
tomwalters@0 115 XUnmapWindow(display, control.win);}
tomwalters@0 116
tomwalters@0 117
tomwalters@0 118 if (report.xany.window == button_animate.win){
tomwalters@0 119 flashbutton(control, button_animate, &button_gc, "Animate");
tomwalters@0 120 animate_image(animate_start, animate_stop, animate_skip);}
tomwalters@0 121
tomwalters@0 122
tomwalters@0 123 if (report.xany.window == button_startf.win) {
tomwalters@0 124 flashbutton(control, button_startf, &button_gc, "+1");
tomwalters@0 125 animate_start++;
tomwalters@0 126 if (animate_start == no_frames)
tomwalters@0 127 animate_start = no_frames-1;
tomwalters@0 128 sprintf(tempstring, "Start: %i", animate_start);
tomwalters@0 129 XClearWindow(display, info_start.win);
tomwalters@0 130 drawtext(info_start, button_gc, font_info, tempstring);}
tomwalters@0 131
tomwalters@0 132
tomwalters@0 133 if (report.xany.window == button_startb.win) {
tomwalters@0 134 flashbutton(control, button_startb, &button_gc, "-1");
tomwalters@0 135 animate_start--;
tomwalters@0 136 if (animate_start == 0)
tomwalters@0 137 animate_start = 1;
tomwalters@0 138 sprintf(tempstring, "Start: %i", animate_start);
tomwalters@0 139 XClearWindow(display, info_start.win);
tomwalters@0 140 drawtext(info_start, button_gc, font_info, tempstring);}
tomwalters@0 141
tomwalters@0 142
tomwalters@0 143 if (report.xany.window == button_stopf.win) {
tomwalters@0 144 flashbutton(control, button_stopf, &button_gc, "+1");
tomwalters@0 145 animate_stop++;
tomwalters@0 146 if (animate_stop == no_frames +1)
tomwalters@0 147 animate_stop = no_frames;
tomwalters@0 148 sprintf(tempstring, "Stop: %i", animate_stop);
tomwalters@0 149 XClearWindow(display, info_stop.win);
tomwalters@0 150 drawtext(info_stop, button_gc, font_info, tempstring);}
tomwalters@0 151
tomwalters@0 152
tomwalters@0 153 if (report.xany.window == button_stopb.win) {
tomwalters@0 154 flashbutton(control, button_stopb, &button_gc, "-1");
tomwalters@0 155 animate_stop--;
tomwalters@0 156 if (animate_stop == 1)
tomwalters@0 157 animate_stop = 2;
tomwalters@0 158 sprintf(tempstring, "Stop: %i", animate_stop);
tomwalters@0 159 XClearWindow(display, info_stop.win);
tomwalters@0 160 drawtext(info_stop, button_gc, font_info, tempstring);}
tomwalters@0 161
tomwalters@0 162
tomwalters@0 163 if (report.xany.window == button_skipf.win) {
tomwalters@0 164 flashbutton(control, button_skipf, &button_gc, "+1");
tomwalters@0 165 animate_skip++;
tomwalters@0 166 if (animate_skip == no_frames)
tomwalters@0 167 animate_start = no_frames-1;
tomwalters@0 168 sprintf(tempstring, "Skip: %i", animate_skip);
tomwalters@0 169 XClearWindow(display, info_skip.win);
tomwalters@0 170 drawtext(info_skip, button_gc, font_info, tempstring);}
tomwalters@0 171
tomwalters@0 172
tomwalters@0 173 if (report.xany.window == button_skipb.win) {
tomwalters@0 174 flashbutton(control, button_skipb, &button_gc, "-1");
tomwalters@0 175 animate_skip--;
tomwalters@0 176 if (animate_skip == 0)
tomwalters@0 177 animate_skip = 1;
tomwalters@0 178 sprintf(tempstring, "Skip: %i", animate_skip);
tomwalters@0 179 XClearWindow(display, info_skip.win);
tomwalters@0 180 drawtext(info_skip, button_gc, font_info, tempstring);}
tomwalters@0 181
tomwalters@0 182
tomwalters@0 183 if (report.xany.window == button_faster.win) {
tomwalters@0 184 flashbutton(control, button_faster, &button_gc, "Fast");
tomwalters@0 185 waittime_millisecs = (long) waittime_millisecs / 2;
tomwalters@0 186 if (waittime_millisecs < 1)
tomwalters@0 187 waittime_millisecs = 1;
tomwalters@0 188 sprintf(tempstring, "Speed: %li", waittime_millisecs);
tomwalters@0 189 XClearWindow(display, info_speed.win);
tomwalters@0 190 drawtext(info_speed, button_gc, font_info, tempstring);}
tomwalters@0 191
tomwalters@0 192
tomwalters@0 193 if (report.xany.window == button_slower.win) {
tomwalters@0 194 flashbutton(control, button_slower, &button_gc, "Slow");
tomwalters@0 195 waittime_millisecs = (long) waittime_millisecs * 2;
tomwalters@0 196 sprintf(tempstring, "Speed: %li", waittime_millisecs);
tomwalters@0 197 XClearWindow(display, info_speed.win);
tomwalters@0 198 drawtext(info_speed, button_gc, font_info, tempstring);}
tomwalters@0 199
tomwalters@0 200
tomwalters@0 201 if (report.xany.window == button_lastframe.win) {
tomwalters@0 202 flashbutton(control, button_lastframe, &button_gc, "Last");
tomwalters@0 203 frame=no_frames;
tomwalters@0 204 drawimage(frame);
tomwalters@0 205 XClearWindow(display, info_frame.win);
tomwalters@0 206 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 207 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 208
tomwalters@0 209
tomwalters@0 210 if (report.xany.window == button_firstframe.win) {
tomwalters@0 211 flashbutton(control, button_firstframe, &button_gc, "First");
tomwalters@0 212 frame=1;
tomwalters@0 213 drawimage(frame);
tomwalters@0 214 XClearWindow(display, info_frame.win);
tomwalters@0 215 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 216 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 217
tomwalters@0 218
tomwalters@0 219 if (report.xany.window == button_middle.win) {
tomwalters@0 220 flashbutton(control, button_middle, &button_gc, "Middle");
tomwalters@0 221 frame=no_frames/2;
tomwalters@0 222 if (frame == 0)
tomwalters@0 223 frame = 1;
tomwalters@0 224 drawimage(frame);
tomwalters@0 225 XClearWindow(display, info_frame.win);
tomwalters@0 226 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 227 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 228
tomwalters@0 229
tomwalters@0 230 if (report.xany.window == button_stepf.win) {
tomwalters@0 231 flashbutton(control, button_stepf, &button_gc, ">");
tomwalters@0 232 frame++;
tomwalters@0 233 if (frame > no_frames)
tomwalters@0 234 frame = no_frames;
tomwalters@0 235 drawimage(frame);
tomwalters@0 236 XClearWindow(display, info_frame.win);
tomwalters@0 237 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 238 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 239
tomwalters@0 240
tomwalters@0 241 if (report.xany.window == button_stepff.win) {
tomwalters@0 242 flashbutton(control, button_stepff, &button_gc, ">>");
tomwalters@0 243 frame+=10;
tomwalters@0 244 if (frame > no_frames)
tomwalters@0 245 frame = no_frames;
tomwalters@0 246 drawimage(frame);
tomwalters@0 247 XClearWindow(display, info_frame.win);
tomwalters@0 248 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 249 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 250
tomwalters@0 251
tomwalters@0 252 if (report.xany.window == button_stepb.win) {
tomwalters@0 253 flashbutton(control, button_stepb, &button_gc, "<");
tomwalters@0 254 frame--;
tomwalters@0 255 if (frame < 1)
tomwalters@0 256 frame = 1;
tomwalters@0 257 drawimage(frame);
tomwalters@0 258 XClearWindow(display, info_frame.win);
tomwalters@0 259 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 260 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 261
tomwalters@0 262
tomwalters@0 263 if (report.xany.window == button_stepbb.win) {
tomwalters@0 264 flashbutton(control, button_stepbb, &button_gc, "<<");
tomwalters@0 265 frame-=10;
tomwalters@0 266 if (frame < 1)
tomwalters@0 267 frame = 1;
tomwalters@0 268 drawimage(frame);
tomwalters@0 269 XClearWindow(display, info_frame.win);
tomwalters@0 270 sprintf(tempstring, "%i of %i", frame, no_frames);
tomwalters@0 271 drawtext(info_frame, button_gc, font_info, tempstring);}
tomwalters@0 272
tomwalters@0 273 }
tomwalters@0 274
tomwalters@0 275
tomwalters@0 276
tomwalters@0 277
tomwalters@0 278 /* The End */
tomwalters@0 279 /*-------------------------------------------------------------------------*/
tomwalters@0 280 /*-------------------------------------------------------------------------*/