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