Mercurial > hg > aim92
comparison xaim/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 * buttons.c | |
27 * --------- | |
28 * Defines the size, position, and input-option-possibilites of the buttons | |
29 * that appear on 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 | |
48 | |
49 /* X .......................*/ | |
50 | |
51 extern Display *display; | |
52 extern int screen_num; | |
53 extern Screen *screen_ptr; | |
54 | |
55 extern toplevelWindow control; | |
56 extern Pixmap stipple_pixmap; | |
57 | |
58 extern buttonWindow button_quit, button_close; | |
59 extern buttonWindow button_animate; | |
60 extern buttonWindow button_startf, button_startb, button_stopf, button_stopb; | |
61 extern buttonWindow button_skipf, button_skipb, button_faster, button_slower; | |
62 extern buttonWindow button_firstframe, button_lastframe, button_middle; | |
63 extern buttonWindow button_stepf, button_stepff, button_stepb, button_stepbb; | |
64 | |
65 extern buttonWindow info_speed, info_start, info_stop, info_skip; | |
66 extern buttonWindow info_title, info_frame; | |
67 extern buttonWindow info_time, info_freq, info_frstep; | |
68 | |
69 extern GC button_gc; | |
70 extern XFontStruct *font_info; | |
71 | |
72 extern int button_borderwidth ; | |
73 | |
74 | |
75 /* Command line .............*/ | |
76 | |
77 extern double scale; /* scale factor of Controls Window size */ | |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 /*-------------------------------------------------------------------------*/ | |
85 /*-------------------------------------------------------------------------*/ | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 Window create_button(int x, int y, int width, int height) | |
92 { | |
93 return (Window) XCreateSimpleWindow(display, control.win, \ | |
94 x, y, width, height, \ | |
95 button_borderwidth, \ | |
96 BlackPixel(display, screen_num),\ | |
97 WhitePixel(display, screen_num)); | |
98 } | |
99 | |
100 | |
101 | |
102 | |
103 | |
104 | |
105 /*-------------------------------------------------------------------------*/ | |
106 /*-------------------------------------------------------------------------*/ | |
107 | |
108 | |
109 | |
110 | |
111 | |
112 void initialise_buttons() | |
113 { | |
114 button_gc = XCreateGC(display, RootWindow(display, screen_num),\ | |
115 control.valuemask, &control.values); | |
116 XSetForeground(display, button_gc, BlackPixel(display, screen_num)); | |
117 XSetFillStyle(display, button_gc, FillSolid); | |
118 XSetFont(display, button_gc, font_info->fid); | |
119 | |
120 /*------------------------------*/ | |
121 /* Button Positions: all relative to top-left Controls corner. | |
122 * All in pixels */ | |
123 | |
124 button_quit.x = 20 * scale; button_quit.y = 10 * scale; | |
125 button_close.x = 20 * scale; button_close.y = 44 * scale; | |
126 | |
127 button_animate.x = 500 * scale; button_animate.y = 90 * scale; | |
128 button_startf.x = 64 * scale; button_startf.y = 124 * scale; | |
129 button_startb.x = 14 * scale; button_startb.y = 124 * scale; | |
130 button_stopf.x = 184 * scale; button_stopf.y = 124 * scale; | |
131 button_stopb.x = 134 * scale; button_stopb.y = 124 * scale; | |
132 button_skipf.x = 304 * scale; button_skipf.y = 124 * scale; | |
133 button_skipb.x = 254 * scale; button_skipb.y = 124 * scale; | |
134 button_faster.x = 372 * scale; button_faster.y = 124 * scale; | |
135 button_slower.x = 422 * scale; button_slower.y = 124 * scale; | |
136 | |
137 button_firstframe.x = 10 * scale; button_firstframe.y = 174 * scale; | |
138 button_stepbb.x = 80 * scale; button_stepbb.y = 174 * scale; | |
139 button_stepb.x = 150 * scale; button_stepb.y = 174 * scale; | |
140 button_middle.x = 220 * scale; button_middle.y = 174 * scale; | |
141 button_stepf.x = 290 * scale; button_stepf.y = 174 * scale; | |
142 button_stepff.x = 360 * scale; button_stepff.y = 174 * scale; | |
143 button_lastframe.x = 430 * scale; button_lastframe.y = 174 * scale; | |
144 | |
145 /* Button sizes: also in pixels */ | |
146 | |
147 button_quit.width = 60 * scale; button_quit.height = 25 * scale; | |
148 button_close.width = 60 * scale; button_close.height = 25 * scale; | |
149 button_animate.width = 100 * scale; button_animate.height = 60 * scale; | |
150 button_startf.width = 40 * scale; button_startf.height = 25 * scale; | |
151 button_startb.width = 40 * scale; button_startb.height = 25 * scale; | |
152 button_stopf.width = 40 * scale; button_stopf.height = 25 * scale; | |
153 button_stopb.width = 40 * scale; button_stopb.height = 25 * scale; | |
154 button_skipf.width = 40 * scale; button_skipf.height = 25 * scale; | |
155 button_skipb.width = 40 * scale; button_skipb.height = 25 * scale; | |
156 button_faster.width = 45 * scale; button_faster.height = 25 * scale; | |
157 button_slower.width = 45 * scale; button_slower.height = 25 * scale; | |
158 button_lastframe.width = 60 * scale; button_lastframe.height = 25 *scale; | |
159 button_firstframe.width = 60 * scale; button_firstframe.height = 25 *scale; | |
160 button_middle.width = 60 * scale; button_middle.height = 25 * scale; | |
161 button_stepf.width = 60 * scale; button_stepf.height = 25 * scale; | |
162 button_stepff.width = 60 * scale; button_stepff.height = 25 * scale; | |
163 button_stepb.width = 60 * scale; button_stepb.height = 25 * scale; | |
164 button_stepbb.width = 60 * scale; button_stepbb.height = 25 * scale; | |
165 | |
166 /*------------------------------*/ | |
167 /* make the things */ | |
168 | |
169 button_quit.win = create_button(button_quit.x, button_quit.y, \ | |
170 button_quit.width, button_quit.height); | |
171 button_close.win = create_button(button_close.x, button_close.y, \ | |
172 button_close.width, button_close.height); | |
173 button_animate.win = create_button(button_animate.x, button_animate.y, \ | |
174 button_animate.width, button_animate.height); | |
175 button_startf.win = create_button(button_startf.x, button_startf.y, \ | |
176 button_startf.width, button_startf.height); | |
177 button_startb.win = create_button(button_startb.x, button_startb.y, \ | |
178 button_startb.width, button_startb.height); | |
179 button_stopf.win = create_button(button_stopf.x, button_stopf.y, \ | |
180 button_stopf.width, button_stopf.height); | |
181 button_stopb.win = create_button(button_stopb.x, button_stopb.y, \ | |
182 button_stopb.width, button_stopb.height); | |
183 button_skipf.win = create_button(button_skipf.x, button_skipf.y, \ | |
184 button_skipf.width, button_skipf.height); | |
185 button_skipb.win = create_button(button_skipb.x, button_skipb.y, \ | |
186 button_skipb.width, button_skipb.height); | |
187 button_faster.win = create_button(button_faster.x, button_faster.y, \ | |
188 button_faster.width, button_faster.height); | |
189 button_slower.win = create_button(button_slower.x, button_slower.y, \ | |
190 button_slower.width, button_slower.height); | |
191 button_lastframe.win =create_button(button_lastframe.x, button_lastframe.y,\ | |
192 button_lastframe.width, button_lastframe.height); | |
193 button_firstframe.win=create_button(button_firstframe.x,button_firstframe.y,\ | |
194 button_firstframe.width, button_firstframe.height); | |
195 button_middle.win =create_button(button_middle.x, button_middle.y, \ | |
196 button_middle.width, button_middle.height); | |
197 button_stepf.win = create_button(button_stepf.x, button_stepf.y, \ | |
198 button_stepf.width, button_stepf.height); | |
199 button_stepff.win = create_button(button_stepff.x, button_stepff.y, \ | |
200 button_stepff.width, button_stepff.height); | |
201 button_stepb.win = create_button(button_stepb.x, button_stepb.y, \ | |
202 button_stepb.width, button_stepb.height); | |
203 button_stepbb.win = create_button(button_stepbb.x, button_stepbb.y, \ | |
204 button_stepbb.width, button_stepbb.height); | |
205 | |
206 /*---------------------------*/ | |
207 /* Info positions and sizes. */ | |
208 | |
209 info_speed.x = 370 * scale; info_speed.y = 94 * scale; | |
210 info_start.x = 10 * scale; info_start.y = 94 * scale; | |
211 info_stop.x = 130 * scale; info_stop.y = 94 * scale; | |
212 info_skip.x = 250 * scale; info_skip.y = 94 * scale; | |
213 info_frame.x = 500 * scale; info_frame.y = 174 * scale; | |
214 info_title.x = 100 * scale; info_title.y = 10 * scale; | |
215 info_freq.x = 100 * scale; info_freq.y = 44 * scale; | |
216 info_time.x = 275 * scale; info_time.y = 44 * scale; | |
217 info_frstep.x = 475 * scale; info_frstep.y = 44 * scale; | |
218 | |
219 info_speed.width = 100 * scale; info_speed.height = 25 * scale; | |
220 info_start.width = 100 * scale; info_start.height = 25 * scale; | |
221 info_stop.width = 100 * scale; info_stop.height = 25 * scale; | |
222 info_skip.width = 100 * scale; info_skip.height = 25 * scale; | |
223 info_frame.width = 100 * scale; info_frame.height = 25 * scale; | |
224 info_title.width = 500 * scale; info_title.height = 25 * scale; | |
225 info_freq.width = 175 * scale; info_freq.height = 25 * scale; | |
226 info_time.width = 175 * scale; info_time.height = 25 * scale; | |
227 info_frstep.width = 115 * scale; info_frstep.height = 25 * scale; | |
228 | |
229 info_speed.win = create_button(info_speed.x, info_speed.y, \ | |
230 info_speed.width, info_speed.height); | |
231 info_start.win = create_button(info_start.x, info_start.y, \ | |
232 info_start.width, info_start.height); | |
233 info_stop.win = create_button(info_stop.x, info_stop.y, \ | |
234 info_stop.width, info_stop.height); | |
235 info_skip.win = create_button(info_skip.x, info_skip.y, \ | |
236 info_skip.width, info_skip.height); | |
237 info_frame.win = create_button(info_frame.x, info_frame.y, \ | |
238 info_frame.width, info_frame.height); | |
239 info_title.win = create_button(info_title.x, info_title.y, \ | |
240 info_title.width, info_title.height); | |
241 info_freq.win = create_button(info_freq.x, info_freq.y, \ | |
242 info_freq.width, info_freq.height); | |
243 info_time.win = create_button(info_time.x, info_time.y, \ | |
244 info_time.width, info_time.height); | |
245 info_frstep.win = create_button(info_frstep.x, info_frstep.y, \ | |
246 info_frstep.width, info_frstep.height); | |
247 | |
248 | |
249 /*------------------------------*/ | |
250 /* Define the allowed inputs to the buttons. | |
251 */ | |
252 XSelectInput(display, button_quit.win, ButtonPressMask ); | |
253 XSelectInput(display, button_close.win, ButtonPressMask ); | |
254 XSelectInput(display, button_animate.win, ButtonPressMask ); | |
255 XSelectInput(display, button_startf.win, ButtonPressMask ); | |
256 XSelectInput(display, button_startb.win, ButtonPressMask ); | |
257 XSelectInput(display, button_stopf.win, ButtonPressMask ); | |
258 XSelectInput(display, button_stopb.win, ButtonPressMask ); | |
259 XSelectInput(display, button_skipf.win, ButtonPressMask ); | |
260 XSelectInput(display, button_skipb.win, ButtonPressMask ); | |
261 XSelectInput(display, button_faster.win, ButtonPressMask ); | |
262 XSelectInput(display, button_slower.win, ButtonPressMask ); | |
263 XSelectInput(display, button_lastframe.win, ButtonPressMask ); | |
264 XSelectInput(display, button_firstframe.win, ButtonPressMask ); | |
265 XSelectInput(display, button_middle.win, ButtonPressMask ); | |
266 XSelectInput(display, button_stepf.win, ButtonPressMask ); | |
267 XSelectInput(display, button_stepff.win, ButtonPressMask ); | |
268 XSelectInput(display, button_stepb.win, ButtonPressMask ); | |
269 XSelectInput(display, button_stepbb.win, ButtonPressMask ); | |
270 | |
271 XSelectInput(display, info_speed.win, ButtonPressMask); | |
272 XSelectInput(display, info_start.win, ButtonPressMask); | |
273 XSelectInput(display, info_stop.win, ButtonPressMask); | |
274 XSelectInput(display, info_skip.win, ButtonPressMask); | |
275 XSelectInput(display, info_frame.win, ButtonPressMask); | |
276 XSelectInput(display, info_title.win, ButtonPressMask); | |
277 XSelectInput(display, info_freq.win, ButtonPressMask); | |
278 XSelectInput(display, info_time.win, ButtonPressMask); | |
279 XSelectInput(display, info_frstep.win, ButtonPressMask); | |
280 | |
281 /* Define the backgrounds. */ | |
282 | |
283 XSetWindowBackgroundPixmap(display, button_quit.win, stipple_pixmap); | |
284 XSetWindowBackgroundPixmap(display, button_close.win, stipple_pixmap); | |
285 XSetWindowBackgroundPixmap(display, button_animate.win, stipple_pixmap); | |
286 XSetWindowBackgroundPixmap(display, button_startf.win, stipple_pixmap); | |
287 XSetWindowBackgroundPixmap(display, button_startb.win, stipple_pixmap); | |
288 XSetWindowBackgroundPixmap(display, button_stopf.win, stipple_pixmap); | |
289 XSetWindowBackgroundPixmap(display, button_stopb.win, stipple_pixmap); | |
290 XSetWindowBackgroundPixmap(display, button_skipf.win, stipple_pixmap); | |
291 XSetWindowBackgroundPixmap(display, button_skipb.win, stipple_pixmap); | |
292 XSetWindowBackgroundPixmap(display, button_faster.win, stipple_pixmap); | |
293 XSetWindowBackgroundPixmap(display, button_slower.win, stipple_pixmap); | |
294 XSetWindowBackgroundPixmap(display, button_lastframe.win, stipple_pixmap); | |
295 XSetWindowBackgroundPixmap(display, button_firstframe.win, stipple_pixmap); | |
296 XSetWindowBackgroundPixmap(display, button_middle.win, stipple_pixmap); | |
297 XSetWindowBackgroundPixmap(display, button_stepf.win, stipple_pixmap); | |
298 XSetWindowBackgroundPixmap(display, button_stepff.win, stipple_pixmap); | |
299 XSetWindowBackgroundPixmap(display, button_stepb.win, stipple_pixmap); | |
300 XSetWindowBackgroundPixmap(display, button_stepbb.win, stipple_pixmap); | |
301 | |
302 XSetWindowBackgroundPixmap(display, info_speed.win, stipple_pixmap); | |
303 XSetWindowBackgroundPixmap(display, info_start.win, stipple_pixmap); | |
304 XSetWindowBackgroundPixmap(display, info_stop.win, stipple_pixmap); | |
305 XSetWindowBackgroundPixmap(display, info_skip.win, stipple_pixmap); | |
306 XSetWindowBackgroundPixmap(display, info_frame.win, stipple_pixmap); | |
307 XSetWindowBackgroundPixmap(display, info_title.win, stipple_pixmap); | |
308 XSetWindowBackgroundPixmap(display, info_freq.win, stipple_pixmap); | |
309 XSetWindowBackgroundPixmap(display, info_time.win, stipple_pixmap); | |
310 XSetWindowBackgroundPixmap(display, info_frstep.win, stipple_pixmap); | |
311 } | |
312 | |
313 | |
314 | |
315 | |
316 /* The End */ | |
317 /*------------------------------------------------------------------------*/ | |
318 /*------------------------------------------------------------------------*/ | |
319 | |
320 | |
321 | |
322 |