Mercurial > hg > aim92
comparison xaim/switch_axes.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_axes.c | |
28 * ------------- | |
29 * 'switch' code for the axes (=cartoon image) window. | |
30 * | |
31 * M. Akeroyd. July 1993. version 1.10 | |
32 * Revisions: MAA: Christmas 1993. | |
33 */ | |
34 | |
35 | |
36 | |
37 #include <X11/Xlib.h> | |
38 #include <X11/Xutil.h> | |
39 #include <X11/Xos.h> | |
40 #include <X11/Xatom.h> | |
41 #include <stdio.h> | |
42 | |
43 #include "xreview.h" | |
44 | |
45 | |
46 | |
47 /* General .................*/ | |
48 | |
49 | |
50 /* X ........................*/ | |
51 | |
52 extern Display *display; | |
53 extern int screen_num; | |
54 extern Screen *screen_ptr; | |
55 | |
56 extern toplevelWindow control; | |
57 extern toplevelWindow axes; | |
58 extern buttonWindow info_speed, info_frame; | |
59 extern XFontStruct font_info; | |
60 | |
61 extern XEvent report; | |
62 extern GC button_gc; | |
63 | |
64 | |
65 /* .ctn .....................*/ | |
66 | |
67 extern int frame; | |
68 extern int no_frames; | |
69 | |
70 extern int animate_start; | |
71 extern int animate_stop; | |
72 extern int animate_skip; | |
73 | |
74 extern long waittime_millisecs; | |
75 | |
76 | |
77 /* extras for the pcroy version */ | |
78 extern int animate_start; | |
79 extern int animate_stop; | |
80 extern int animate_skip; | |
81 | |
82 /*--------------------------------------------------------------------*/ | |
83 /*--------------------------------------------------------------------*/ | |
84 | |
85 | |
86 | |
87 | |
88 | |
89 void switch_axes() | |
90 { | |
91 char tempstring[MAX_STRING_LENGTH]; | |
92 char buffer[20]; | |
93 int bufsize = 20; | |
94 int charcount; | |
95 XComposeStatus compose_X; | |
96 KeySym keysym_X; | |
97 | |
98 switch(report.type) { | |
99 | |
100 /*---------------------------------------------*/ | |
101 | |
102 case Expose: | |
103 if (report.xexpose.count != 0) | |
104 break; | |
105 | |
106 if ((axes.window_size == TOO_SMALL_X) || | |
107 (axes.window_size == TOO_BIG_X)) | |
108 break; | |
109 | |
110 drawimage(frame); | |
111 break; | |
112 | |
113 /*---------------------------------------------*/ | |
114 | |
115 case ConfigureNotify: | |
116 axes.width = report.xconfigure.width; | |
117 axes.height = report.xconfigure.height; | |
118 | |
119 /* No resizing allowed */ | |
120 axes.window_size = BIG_ENOUGH_X; | |
121 if ((axes.width < axes.size_hints.min_width) || \ | |
122 (axes.height < axes.size_hints.min_height)) | |
123 axes.window_size = TOO_SMALL_X; | |
124 if ((axes.width > axes.size_hints.max_width) || \ | |
125 (axes.height > axes.size_hints.max_height)) | |
126 axes.window_size = TOO_BIG_X; | |
127 break; | |
128 | |
129 /*---------------------------------------------*/ | |
130 | |
131 case ButtonPress: | |
132 | |
133 /* if button 1, animate */ | |
134 if (report.xbutton.button == Button1) { | |
135 animate_image(animate_start, animate_stop, animate_skip); | |
136 break;} | |
137 | |
138 /* if button 2, map control window */ | |
139 if (report.xbutton.button == Button2) { | |
140 XMapWindow(display, control.win); | |
141 break;} | |
142 | |
143 /* If button 3, quit. */ | |
144 if (report.xbutton.button == Button3) { | |
145 exit_xreview(); | |
146 } | |
147 | |
148 break; | |
149 | |
150 /*---------------------------------------------*/ | |
151 | |
152 case KeyPress: | |
153 | |
154 charcount = XLookupString(&report.xkey, buffer, bufsize, &keysym_X, &compose_X); | |
155 | |
156 if ((keysym_X == XK_space) || (keysym_X == XK_Return)) { | |
157 animate_image(animate_start, animate_stop, animate_skip); | |
158 break;} | |
159 | |
160 if ((keysym_X == XK_N) || (keysym_X == XK_n)) { | |
161 frame++; | |
162 if (frame > no_frames) | |
163 frame = no_frames; | |
164 drawimage(frame); | |
165 XClearWindow(display, info_frame.win); | |
166 sprintf(tempstring, "%i of %i", frame, no_frames); | |
167 drawtext(info_frame, button_gc, font_info, tempstring); | |
168 XFlush(display);} | |
169 | |
170 if ((keysym_X == XK_p) || (keysym_X == XK_p)) { | |
171 frame--; | |
172 if (frame < 1) | |
173 frame = 1; | |
174 drawimage(frame); | |
175 XClearWindow(display, info_frame.win); | |
176 sprintf(tempstring, "%i of %i", frame, no_frames); | |
177 drawtext(info_frame, button_gc, font_info, tempstring); | |
178 XFlush(display);} | |
179 | |
180 if ((keysym_X == XK_F)|| (keysym_X == XK_f)){ | |
181 waittime_millisecs = (long) waittime_millisecs / 2; | |
182 #ifndef HOST_LINUXPC | |
183 if (waittime_millisecs < 1) | |
184 waittime_millisecs = 1; | |
185 #endif | |
186 sprintf(tempstring, "Speed: %li", waittime_millisecs); | |
187 XClearWindow(display, info_speed.win); | |
188 drawtext(info_speed, button_gc, font_info, tempstring); | |
189 XFlush(display); | |
190 break;} | |
191 | |
192 if ((keysym_X == XK_S)|| (keysym_X == XK_s)){ | |
193 #ifndef HOST_LINUXPC | |
194 waittime_millisecs = (long) waittime_millisecs * 2; | |
195 #endif | |
196 sprintf(tempstring, "Speed: %li", waittime_millisecs); | |
197 XClearWindow(display, info_speed.win); | |
198 drawtext(info_speed, button_gc, font_info, tempstring); | |
199 XFlush(display); | |
200 break;} | |
201 | |
202 if ((keysym_X == XK_q) || (keysym_X == XK_Q)) { | |
203 exit_xreview(); } | |
204 | |
205 break; | |
206 | |
207 /*---------------------------------------------*/ | |
208 | |
209 default: | |
210 break; | |
211 | |
212 | |
213 } /* switch */ | |
214 | |
215 } | |
216 | |
217 | |
218 | |
219 | |
220 /* The End */ | |
221 /*--------------------------------------------------------------------------*/ | |
222 /*--------------------------------------------------------------------------*/ |