Mercurial > hg > aim92
comparison xaim/switch_control.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_control.c | |
28 * ---------------- | |
29 * the 'switch' for the Controls Window. | |
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 char progname[MAX_STRING_LENGTH]; | |
50 | |
51 | |
52 /* X ........................*/ | |
53 | |
54 extern Display *display; | |
55 extern int screen_num; | |
56 extern Screen *screen_ptr; | |
57 | |
58 extern toplevelWindow control; | |
59 extern toplevelWindow axes; | |
60 | |
61 extern buttonWindow button_quit, button_close; | |
62 extern buttonWindow button_animate; | |
63 extern buttonWindow button_startf, button_startb, button_stopf, button_stopb; | |
64 extern buttonWindow button_skipf, button_skipb, button_faster, button_slower; | |
65 extern buttonWindow button_firstframe, button_lastframe, button_middle; | |
66 extern buttonWindow button_stepf, button_stepff, button_stepb, button_stepbb; | |
67 | |
68 extern buttonWindow info_speed, info_start, info_stop, info_skip; | |
69 extern buttonWindow info_title, info_frame; | |
70 extern buttonWindow info_time, info_freq, info_frstep; | |
71 | |
72 extern XFontStruct *font_info; | |
73 extern GC button_gc; | |
74 extern XEvent report; | |
75 | |
76 extern int button_borderwidth; | |
77 | |
78 | |
79 /* .ctn .......................*/ | |
80 | |
81 extern int frame; | |
82 extern int no_frames; | |
83 extern double frstep_aid; | |
84 extern double pwidth; | |
85 extern double nwidth; | |
86 extern int mincf; | |
87 extern int maxcf; | |
88 | |
89 extern int waittime_millisecs; | |
90 extern int animate_start; | |
91 extern int animate_stop; | |
92 extern int animate_skip; | |
93 | |
94 | |
95 /* Command line ...............*/ | |
96 extern double scale; | |
97 | |
98 | |
99 | |
100 | |
101 | |
102 /*-----------------------------------------------------------------------*/ | |
103 /*-----------------------------------------------------------------------*/ | |
104 | |
105 | |
106 | |
107 | |
108 void switch_control() | |
109 { | |
110 char tempstring[MAX_STRING_LENGTH]; | |
111 int whitepixel = WhitePixel(display, screen_num); | |
112 int blackpixel = BlackPixel(display, screen_num); | |
113 | |
114 | |
115 switch(report.type) { | |
116 | |
117 /*----------------------------------*/ | |
118 | |
119 case Expose: | |
120 if (report.xexpose.count != 0) | |
121 break; | |
122 | |
123 if ((control.window_size == TOO_SMALL_X) || | |
124 (control.window_size == TOO_BIG_X)) | |
125 break; | |
126 | |
127 XDrawLine(display, control.win, control.gc, \ | |
128 0, 80*scale, control.width, 80*scale); | |
129 XDrawLine(display, control.win, control.gc, \ | |
130 0, 162*scale, control.width, 162*scale); | |
131 | |
132 XMapWindow(display, button_quit.win); | |
133 XMapWindow(display, button_close.win); | |
134 XMapWindow(display, button_animate.win); | |
135 XMapWindow(display, button_startf.win); | |
136 XMapWindow(display, button_startb.win); | |
137 XMapWindow(display, button_stopf.win); | |
138 XMapWindow(display, button_stopb.win); | |
139 XMapWindow(display, button_skipf.win); | |
140 XMapWindow(display, button_skipb.win); | |
141 XMapWindow(display, button_faster.win); | |
142 XMapWindow(display, button_slower.win); | |
143 XMapWindow(display, button_lastframe.win); | |
144 XMapWindow(display, button_firstframe.win); | |
145 XMapWindow(display, button_middle.win); | |
146 XMapWindow(display, button_stepf.win); | |
147 XMapWindow(display, button_stepff.win); | |
148 XMapWindow(display, button_stepb.win); | |
149 XMapWindow(display, button_stepbb.win); | |
150 | |
151 drawbutton(control, button_quit, &button_gc, "Quit",\ | |
152 whitepixel, blackpixel); | |
153 drawbutton(control, button_close, &button_gc, "Close", \ | |
154 whitepixel, blackpixel); | |
155 | |
156 drawbutton(control, button_animate, &button_gc, "Animate", \ | |
157 whitepixel, blackpixel); | |
158 drawbutton(control, button_startf, &button_gc, "+1", \ | |
159 whitepixel, blackpixel); | |
160 drawbutton(control, button_startb, &button_gc, "-1", \ | |
161 whitepixel, blackpixel); | |
162 drawbutton(control, button_stopf, &button_gc, "+1", \ | |
163 whitepixel, blackpixel); | |
164 drawbutton(control, button_stopb, &button_gc, "-1", \ | |
165 whitepixel, blackpixel); | |
166 drawbutton(control, button_skipf, &button_gc, "+1", \ | |
167 whitepixel, blackpixel); | |
168 drawbutton(control, button_skipb, &button_gc, "-1", \ | |
169 whitepixel, blackpixel); | |
170 drawbutton(control, button_faster, &button_gc, "Fast", \ | |
171 whitepixel, blackpixel); | |
172 drawbutton(control, button_slower, &button_gc, "Slow", \ | |
173 whitepixel, blackpixel); | |
174 | |
175 drawbutton(control, button_lastframe, &button_gc, "Last", \ | |
176 whitepixel, blackpixel); | |
177 drawbutton(control, button_firstframe, &button_gc, "First", \ | |
178 whitepixel, blackpixel); | |
179 drawbutton(control, button_middle, &button_gc, "Middle", \ | |
180 whitepixel, blackpixel); | |
181 drawbutton(control, button_stepf, &button_gc, ">", \ | |
182 whitepixel, blackpixel); | |
183 drawbutton(control, button_stepff, &button_gc, ">>", \ | |
184 whitepixel, blackpixel); | |
185 drawbutton(control, button_stepb, &button_gc, "<", \ | |
186 whitepixel, blackpixel); | |
187 drawbutton(control, button_stepbb, &button_gc, "<<", \ | |
188 whitepixel, blackpixel); | |
189 | |
190 | |
191 | |
192 XMapWindow(display, info_speed.win); | |
193 sprintf(tempstring, "Speed: %i", waittime_millisecs); | |
194 drawtext(info_speed, button_gc, font_info, tempstring); | |
195 | |
196 XMapWindow(display, info_start.win); | |
197 sprintf(tempstring, "Start: %i", animate_start); | |
198 drawtext(info_start, button_gc, font_info, tempstring); | |
199 | |
200 XMapWindow(display, info_stop.win); | |
201 sprintf(tempstring, "Stop: %i", animate_stop); | |
202 drawtext(info_stop, button_gc, font_info, tempstring); | |
203 | |
204 XMapWindow(display, info_skip.win); | |
205 sprintf(tempstring, "Skip: %i", animate_skip); | |
206 drawtext(info_skip, button_gc, font_info, tempstring); | |
207 | |
208 XMapWindow(display, info_frame.win); | |
209 sprintf(tempstring, "%i of %i", frame, no_frames); | |
210 drawtext(info_frame, button_gc, font_info, tempstring); | |
211 | |
212 XMapWindow(display, info_title.win); | |
213 sprintf(tempstring, "%s", axes.window_name); | |
214 drawtext(info_title, button_gc, font_info, tempstring); | |
215 | |
216 XMapWindow(display, info_freq.win); | |
217 sprintf(tempstring, "Freq %i-%iHz", mincf, maxcf); | |
218 drawtext(info_freq, button_gc, font_info, tempstring); | |
219 | |
220 XMapWindow(display, info_time.win); | |
221 sprintf(tempstring, "Interval %.1f...%.1fms", pwidth, nwidth); | |
222 drawtext(info_time, button_gc, font_info, tempstring); | |
223 | |
224 XMapWindow(display, info_frstep.win); | |
225 sprintf(tempstring, "frstep: %.1fms", frstep_aid); | |
226 drawtext(info_frstep, button_gc, font_info, tempstring); | |
227 | |
228 | |
229 break; | |
230 | |
231 | |
232 /*--------------------------------------*/ | |
233 | |
234 | |
235 case ConfigureNotify: | |
236 if (report.xconfigure.window != control.win) | |
237 break; | |
238 | |
239 control.width = report.xconfigure.width; | |
240 control.height = report.xconfigure.height; | |
241 | |
242 control.window_size = BIG_ENOUGH_X; | |
243 if ((control.width < control.size_hints.min_width) || \ | |
244 (control.height < control.size_hints.min_height)) | |
245 control.window_size = TOO_SMALL_X; | |
246 if ((control.width > control.size_hints.max_width) || \ | |
247 (control.height > control.size_hints.max_height)) | |
248 control.window_size = TOO_BIG_X; | |
249 break; | |
250 | |
251 /*--------------------------------------*/ | |
252 | |
253 default: | |
254 break; | |
255 | |
256 } /* switch */ | |
257 | |
258 } | |
259 | |
260 | |
261 | |
262 | |
263 | |
264 | |
265 /* The End */ | |
266 /*-------------------------------------------------------------------------*/ | |
267 /*-------------------------------------------------------------------------*/ |