1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
22 /* some positions in the video tape control window */
23 #define VIDEO_BUTTON_EJECT_XPOS (VIDEO_CONTROL_XPOS + 0 * VIDEO_BUTTON_XSIZE)
24 #define VIDEO_BUTTON_STOP_XPOS (VIDEO_CONTROL_XPOS + 1 * VIDEO_BUTTON_XSIZE)
25 #define VIDEO_BUTTON_PAUSE_XPOS (VIDEO_CONTROL_XPOS + 2 * VIDEO_BUTTON_XSIZE)
26 #define VIDEO_BUTTON_REC_XPOS (VIDEO_CONTROL_XPOS + 3 * VIDEO_BUTTON_XSIZE)
27 #define VIDEO_BUTTON_PLAY_XPOS (VIDEO_CONTROL_XPOS + 4 * VIDEO_BUTTON_XSIZE)
28 #define VIDEO_BUTTON_ANY_YPOS (VIDEO_CONTROL_YPOS)
29 #define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS)
30 #define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS)
31 #define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE)
32 #define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE)
33 #define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS+1)
34 #define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS+14)
35 #define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE)
36 #define VIDEO_DATE_YSIZE 16
37 #define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
38 #define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
39 #define VIDEO_REC_LABEL_XSIZE 20
40 #define VIDEO_REC_LABEL_YSIZE 12
41 #define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+20)
42 #define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
43 #define VIDEO_REC_SYMBOL_XSIZE 16
44 #define VIDEO_REC_SYMBOL_YSIZE 16
45 #define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS+65)
46 #define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS)
47 #define VIDEO_PLAY_LABEL_XSIZE 22
48 #define VIDEO_PLAY_LABEL_YSIZE 12
49 #define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+52)
50 #define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
51 #define VIDEO_PLAY_SYMBOL_XSIZE 11
52 #define VIDEO_PLAY_SYMBOL_YSIZE 13
53 #define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS)
54 #define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS+20)
55 #define VIDEO_PAUSE_LABEL_XSIZE 35
56 #define VIDEO_PAUSE_LABEL_YSIZE 8
57 #define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+35)
58 #define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS)
59 #define VIDEO_PAUSE_SYMBOL_XSIZE 17
60 #define VIDEO_PAUSE_SYMBOL_YSIZE 13
61 #define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS+38)
62 #define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS+14)
63 #define VIDEO_TIME_XSIZE 50
64 #define VIDEO_TIME_YSIZE 16
67 #define VIDEO_PBEND_LABEL_XPOS 6
68 #define VIDEO_PBEND_LABEL_YPOS 220
69 #define VIDEO_PBEND_LABEL_XSIZE 35
70 #define VIDEO_PBEND_LABEL_YSIZE 30
72 #define ON_VIDEO_BUTTON(x,y) ((x)>=(VX+VIDEO_CONTROL_XPOS) && \
73 (x)< (VX+VIDEO_CONTROL_XPOS + \
74 VIDEO_CONTROL_XSIZE) && \
75 (y)>=(VY+VIDEO_CONTROL_YPOS) && \
76 (y)< (VY+VIDEO_CONTROL_YPOS + \
78 #define VIDEO_BUTTON(x) (((x)-(VX+VIDEO_CONTROL_XPOS))/VIDEO_BUTTON_XSIZE)
80 #define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \
81 VIDEO_STATE_REC_OFF | \
82 VIDEO_STATE_PAUSE_OFF | \
83 VIDEO_STATE_FFWD_OFF | \
84 VIDEO_STATE_PBEND_OFF | \
85 VIDEO_STATE_DATE_OFF | \
87 #define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \
88 VIDEO_PRESS_REC_OFF | \
89 VIDEO_PRESS_PAUSE_OFF | \
90 VIDEO_PRESS_STOP_OFF | \
91 VIDEO_PRESS_EJECT_OFF)
92 #define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF)
94 #define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \
95 VIDEO_STATE_REC_ON | \
96 VIDEO_STATE_PAUSE_ON | \
97 VIDEO_STATE_FFWD_ON | \
98 VIDEO_STATE_PBEND_ON | \
99 VIDEO_STATE_DATE_ON | \
101 #define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \
102 VIDEO_PRESS_REC_ON | \
103 VIDEO_PRESS_PAUSE_ON | \
104 VIDEO_PRESS_STOP_ON | \
105 VIDEO_PRESS_EJECT_ON)
106 #define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON)
108 #define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF)
109 #define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF)
110 #define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF)
113 /* some positions in the sound control window */
114 #define SOUND_BUTTON_XSIZE 30
115 #define SOUND_BUTTON_YSIZE 30
116 #define SOUND_CONTROL_XPOS 5
117 #define SOUND_CONTROL_YPOS 245
118 #define SOUND_CONTROL_XSIZE (3*SOUND_BUTTON_XSIZE)
119 #define SOUND_CONTROL_YSIZE (1*SOUND_BUTTON_YSIZE)
120 #define SOUND_BUTTON_MUSIC_XPOS (SOUND_CONTROL_XPOS + 0 * SOUND_BUTTON_XSIZE)
121 #define SOUND_BUTTON_LOOPS_XPOS (SOUND_CONTROL_XPOS + 1 * SOUND_BUTTON_XSIZE)
122 #define SOUND_BUTTON_SIMPLE_XPOS (SOUND_CONTROL_XPOS + 2 * SOUND_BUTTON_XSIZE)
123 #define SOUND_BUTTON_ANY_YPOS (SOUND_CONTROL_YPOS)
125 #define ON_SOUND_BUTTON(x,y) ((x)>=(DX+SOUND_CONTROL_XPOS) && \
126 (x)< (DX+SOUND_CONTROL_XPOS + \
127 SOUND_CONTROL_XSIZE) && \
128 (y)>=(DY+SOUND_CONTROL_YPOS) && \
129 (y)< (DY+SOUND_CONTROL_YPOS + \
130 SOUND_CONTROL_YSIZE))
131 #define SOUND_BUTTON(x) (((x)-(DX+SOUND_CONTROL_XPOS))/SOUND_BUTTON_XSIZE)
133 /* some positions in the game control window */
134 #define GAME_BUTTON_STOP_XPOS (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE)
135 #define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE)
136 #define GAME_BUTTON_PLAY_XPOS (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE)
137 #define GAME_BUTTON_ANY_YPOS (GAME_CONTROL_YPOS)
139 #define ON_GAME_BUTTON(x,y) ((x)>=(DX+GAME_CONTROL_XPOS) && \
140 (x)< (DX+GAME_CONTROL_XPOS + \
141 GAME_CONTROL_XSIZE) && \
142 (y)>=(DY+GAME_CONTROL_YPOS) && \
143 (y)< (DY+GAME_CONTROL_YPOS + \
145 #define GAME_BUTTON(x) (((x)-(DX+GAME_CONTROL_XPOS))/GAME_BUTTON_XSIZE)
147 /* some positions in the asking window */
148 #define OK_BUTTON_XPOS 2
149 #define OK_BUTTON_YPOS 250
150 #define OK_BUTTON_GFX_YPOS 0
151 #define OK_BUTTON_XSIZE 46
152 #define OK_BUTTON_YSIZE 28
153 #define NO_BUTTON_XPOS 52
154 #define NO_BUTTON_YPOS OK_BUTTON_YPOS
155 #define NO_BUTTON_XSIZE OK_BUTTON_XSIZE
156 #define NO_BUTTON_YSIZE OK_BUTTON_YSIZE
157 #define CONFIRM_BUTTON_XPOS 2
158 #define CONFIRM_BUTTON_GFX_YPOS 30
159 #define CONFIRM_BUTTON_YPOS OK_BUTTON_YPOS
160 #define CONFIRM_BUTTON_XSIZE 96
161 #define CONFIRM_BUTTON_YSIZE OK_BUTTON_YSIZE
163 #define ON_YESNO_BUTTON(x,y) (((x)>=(DX+OK_BUTTON_XPOS) && \
164 (x)< (DX+OK_BUTTON_XPOS + \
165 OK_BUTTON_XSIZE) && \
166 (y)>=(DY+OK_BUTTON_YPOS) && \
167 (y)< (DY+OK_BUTTON_YPOS + \
168 OK_BUTTON_YSIZE)) || \
169 ((x)>=(DX+NO_BUTTON_XPOS) && \
170 (x)< (DX+NO_BUTTON_XPOS + \
171 NO_BUTTON_XSIZE) && \
172 (y)>=(DY+NO_BUTTON_YPOS) && \
173 (y)< (DY+NO_BUTTON_YPOS + \
175 #define ON_CONFIRM_BUTTON(x,y) (((x)>=(DX+CONFIRM_BUTTON_XPOS) && \
176 (x)< (DX+CONFIRM_BUTTON_XPOS + \
177 CONFIRM_BUTTON_XSIZE) && \
178 (y)>=(DY+CONFIRM_BUTTON_YPOS) && \
179 (y)< (DY+CONFIRM_BUTTON_YPOS + \
180 CONFIRM_BUTTON_YSIZE)))
181 #define YESNO_BUTTON(x) (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE)
183 /* some positions in the choose player window */
184 #define PLAYER_BUTTON_XSIZE 30
185 #define PLAYER_BUTTON_YSIZE 30
186 #define PLAYER_BUTTON_GFX_XPOS 5
187 #define PLAYER_BUTTON_GFX_YPOS (215-30)
188 #define PLAYER_CONTROL_XPOS (5 + PLAYER_BUTTON_XSIZE/2)
189 #define PLAYER_CONTROL_YPOS (215 - PLAYER_BUTTON_YSIZE/2)
190 #define PLAYER_CONTROL_XSIZE (2*PLAYER_BUTTON_XSIZE)
191 #define PLAYER_CONTROL_YSIZE (2*PLAYER_BUTTON_YSIZE)
192 #define PLAYER_BUTTON_1_XPOS (PLAYER_CONTROL_XPOS + 0 * PLAYER_BUTTON_XSIZE)
193 #define PLAYER_BUTTON_2_XPOS (PLAYER_CONTROL_XPOS + 1 * PLAYER_BUTTON_XSIZE)
194 #define PLAYER_BUTTON_3_XPOS (PLAYER_CONTROL_XPOS + 0 * PLAYER_BUTTON_XSIZE)
195 #define PLAYER_BUTTON_4_XPOS (PLAYER_CONTROL_XPOS + 1 * PLAYER_BUTTON_XSIZE)
196 #define PLAYER_BUTTON_1_YPOS (PLAYER_CONTROL_YPOS + 0 * PLAYER_BUTTON_YSIZE)
197 #define PLAYER_BUTTON_2_YPOS (PLAYER_CONTROL_YPOS + 0 * PLAYER_BUTTON_YSIZE)
198 #define PLAYER_BUTTON_3_YPOS (PLAYER_CONTROL_YPOS + 1 * PLAYER_BUTTON_YSIZE)
199 #define PLAYER_BUTTON_4_YPOS (PLAYER_CONTROL_YPOS + 1 * PLAYER_BUTTON_YSIZE)
201 #define ON_PLAYER_BUTTON(x,y) ((x)>=(DX+PLAYER_CONTROL_XPOS) && \
202 (x)< (DX+PLAYER_CONTROL_XPOS + \
203 PLAYER_CONTROL_XSIZE) && \
204 (y)>=(DY+PLAYER_CONTROL_YPOS) && \
205 (y)< (DY+PLAYER_CONTROL_YPOS + \
206 PLAYER_CONTROL_YSIZE))
207 #define PLAYER_BUTTON(x,y) ((((x)-(DX+PLAYER_CONTROL_XPOS)) / \
208 PLAYER_BUTTON_XSIZE) + 2 * \
209 (((y)-(DY+PLAYER_CONTROL_YPOS)) / \
210 PLAYER_BUTTON_YSIZE))
213 /* some definitions for the editor control window */
215 #define ON_EDIT_BUTTON(x,y) (((x)>=(VX+ED_BUTTON_CTRL_XPOS) && \
216 (x)< (VX+ED_BUTTON_CTRL_XPOS + \
217 ED_BUTTON_CTRL_XSIZE) && \
218 (y)>=(VY+ED_BUTTON_CTRL_YPOS) && \
219 (y)< (VY+ED_BUTTON_CTRL_YPOS + \
220 ED_BUTTON_CTRL_YSIZE + \
221 ED_BUTTON_FILL_YSIZE)) || \
222 ((x)>=(VX+ED_BUTTON_LEFT_XPOS) && \
223 (x)< (VX+ED_BUTTON_LEFT_XPOS + \
224 ED_BUTTON_LEFT_XSIZE + \
225 ED_BUTTON_UP_XSIZE + \
226 ED_BUTTON_RIGHT_XSIZE) && \
227 (y)>=(VY+ED_BUTTON_LEFT_YPOS) && \
228 (y)< (VY+ED_BUTTON_LEFT_YPOS + \
229 ED_BUTTON_LEFT_YSIZE)) || \
230 ((x)>=(VX+ED_BUTTON_UP_XPOS) && \
231 (x)< (VX+ED_BUTTON_UP_XPOS + \
232 ED_BUTTON_UP_XSIZE) && \
233 (y)>=(VY+ED_BUTTON_UP_YPOS) && \
234 (y)< (VY+ED_BUTTON_UP_YPOS + \
235 ED_BUTTON_UP_YSIZE + \
236 ED_BUTTON_DOWN_YSIZE)))
238 #define ON_CTRL_BUTTON(x,y) ((x)>=(VX+ED_BUTTON_EDIT_XPOS) && \
239 (x)< (VX+ED_BUTTON_EDIT_XPOS + \
240 ED_BUTTON_EDIT_XSIZE) && \
241 (y)>=(VY+ED_BUTTON_EDIT_YPOS) && \
242 (y)< (VY+ED_BUTTON_EDIT_YPOS + \
243 ED_BUTTON_EDIT_YSIZE + \
244 ED_BUTTON_CLEAR_YSIZE + \
245 ED_BUTTON_UNDO_YSIZE + \
246 ED_BUTTON_EXIT_YSIZE))
248 #define ON_ELEM_BUTTON(x,y) (((x)>=(DX+ED_BUTTON_EUP_XPOS) && \
249 (x)< (DX+ED_BUTTON_EUP_XPOS + \
250 ED_BUTTON_EUP_XSIZE) && \
251 (y)>=(DY+ED_BUTTON_EUP_YPOS) && \
252 (y)< (DY+ED_BUTTON_EUP_YPOS + \
253 ED_BUTTON_EUP_YSIZE)) || \
254 ((x)>=(DX+ED_BUTTON_EDOWN_XPOS) && \
255 (x)< (DX+ED_BUTTON_EDOWN_XPOS + \
256 ED_BUTTON_EDOWN_XSIZE) && \
257 (y)>=(DY+ED_BUTTON_EDOWN_YPOS) && \
258 (y)< (DY+ED_BUTTON_EDOWN_YPOS + \
259 ED_BUTTON_EDOWN_YSIZE)) || \
260 ((x)>=(DX+ED_BUTTON_ELEM_XPOS) && \
261 (x)< (DX+ED_BUTTON_ELEM_XPOS + \
262 MAX_ELEM_X*ED_BUTTON_ELEM_XSIZE) && \
263 (y)>=(DY+ED_BUTTON_ELEM_YPOS) && \
264 (y)< (DY+ED_BUTTON_ELEM_YPOS + \
265 MAX_ELEM_Y*ED_BUTTON_ELEM_YSIZE)))
267 #define ON_COUNT_BUTTON(x,y) (((((x)>=ED_COUNT_GADGET_XPOS && \
268 (x)<(ED_COUNT_GADGET_XPOS + \
269 ED_BUTTON_MINUS_XSIZE)) || \
270 ((x)>=(ED_COUNT_GADGET_XPOS + \
271 (ED_BUTTON_PLUS_XPOS - \
272 ED_BUTTON_MINUS_XPOS)) && \
273 (x)<(ED_COUNT_GADGET_XPOS + \
274 (ED_BUTTON_PLUS_XPOS - \
275 ED_BUTTON_MINUS_XPOS) + \
276 ED_BUTTON_PLUS_XSIZE))) && \
277 ((y)>=ED_COUNT_GADGET_YPOS && \
278 (y)<(ED_COUNT_GADGET_YPOS + \
279 16*ED_COUNT_GADGET_YSIZE)) && \
280 (((y)-ED_COUNT_GADGET_YPOS) % \
281 ED_COUNT_GADGET_YSIZE) < \
282 ED_BUTTON_MINUS_YSIZE) || \
283 ((((x)>=ED_SIZE_GADGET_XPOS && \
284 (x)<(ED_SIZE_GADGET_XPOS + \
285 ED_BUTTON_MINUS_XSIZE)) || \
286 ((x)>=(ED_SIZE_GADGET_XPOS + \
287 (ED_BUTTON_PLUS_XPOS - \
288 ED_BUTTON_MINUS_XPOS)) && \
289 (x)<(ED_SIZE_GADGET_XPOS + \
290 (ED_BUTTON_PLUS_XPOS - \
291 ED_BUTTON_MINUS_XPOS) + \
292 ED_BUTTON_PLUS_XSIZE))) && \
293 ((y)>=ED_SIZE_GADGET_YPOS && \
294 (y)<(ED_SIZE_GADGET_YPOS + \
295 2*ED_SIZE_GADGET_YSIZE)) && \
296 (((y)-ED_SIZE_GADGET_YPOS) % \
297 ED_SIZE_GADGET_YSIZE) < \
298 ED_BUTTON_MINUS_YSIZE))
300 #define EDIT_BUTTON(x,y) (((y) < (VY + ED_BUTTON_CTRL_YPOS + \
301 ED_BUTTON_CTRL_YSIZE)) ? 0 : \
302 ((y) < (VY + ED_BUTTON_CTRL_YPOS + \
303 ED_BUTTON_CTRL_YSIZE + \
304 ED_BUTTON_FILL_YSIZE)) ? 1 : \
305 ((x) < (VX + ED_BUTTON_LEFT_XPOS + \
306 ED_BUTTON_LEFT_XSIZE) ? 2 : \
307 (x) > (VX + ED_BUTTON_LEFT_XPOS + \
308 ED_BUTTON_LEFT_XSIZE + \
309 ED_BUTTON_UP_XSIZE) ? 5 : \
310 3+(((y)-(VY + ED_BUTTON_CTRL_YPOS + \
311 ED_BUTTON_CTRL_YSIZE + \
312 ED_BUTTON_FILL_YSIZE)) / \
313 ED_BUTTON_UP_YSIZE)))
315 #define CTRL_BUTTON(x,y) (((y) < (VY + ED_BUTTON_EDIT_YPOS + \
316 ED_BUTTON_EDIT_YSIZE)) ? 0 : \
317 1+(((y)-(VY + ED_BUTTON_EDIT_YPOS + \
318 ED_BUTTON_EDIT_YSIZE)) / \
319 ED_BUTTON_CLEAR_YSIZE))
321 #define ELEM_BUTTON(x,y) (((y) < (DY + ED_BUTTON_EUP_YPOS + \
322 ED_BUTTON_EUP_YSIZE)) ? 0 : \
323 ((y) > (DY + ED_BUTTON_EDOWN_YPOS)) ? 1 : \
324 2+(((y) - (DY + ED_BUTTON_ELEM_YPOS)) / \
325 ED_BUTTON_ELEM_YSIZE)*MAX_ELEM_X + \
326 ((x) - (DX + ED_BUTTON_ELEM_XPOS)) / \
327 ED_BUTTON_ELEM_XSIZE)
329 #define COUNT_BUTTON(x,y) ((x) < ED_SIZE_GADGET_XPOS ? \
330 ((((y) - ED_COUNT_GADGET_YPOS) / \
331 ED_COUNT_GADGET_YSIZE)*2 + \
332 ((x) < (ED_COUNT_GADGET_XPOS + \
333 ED_BUTTON_MINUS_XSIZE) ? 0 : 1)) : \
334 32+((((y) - ED_SIZE_GADGET_YPOS) / \
335 ED_SIZE_GADGET_YSIZE)*2 + \
336 ((x) < (ED_SIZE_GADGET_XPOS + \
337 ED_BUTTON_MINUS_XSIZE) ? 0 : 1)))
339 /****************************************************************/
340 /********** drawing buttons and corresponding displays **********/
341 /****************************************************************/
343 void DrawVideoDisplay(unsigned long state, unsigned long value)
346 int part_label = 0, part_symbol = 1;
347 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
348 static char *monatsname[12] =
350 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
351 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
353 static int video_pos[10][2][4] =
355 {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
356 VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
357 { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
358 VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
360 {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
361 VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
362 { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
363 VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
365 {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
366 VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
367 { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
368 VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
370 {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
371 VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
372 { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
373 VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
377 { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
378 VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }},
380 {{ VIDEO_BUTTON_PLAY_XPOS, VIDEO_BUTTON_ANY_YPOS,
381 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
385 {{ VIDEO_BUTTON_REC_XPOS, VIDEO_BUTTON_ANY_YPOS,
386 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
390 {{ VIDEO_BUTTON_PAUSE_XPOS, VIDEO_BUTTON_ANY_YPOS,
391 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
395 {{ VIDEO_BUTTON_STOP_XPOS, VIDEO_BUTTON_ANY_YPOS,
396 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
400 {{ VIDEO_BUTTON_EJECT_XPOS, VIDEO_BUTTON_ANY_YPOS,
401 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
406 if (state & VIDEO_STATE_PBEND_OFF)
408 int cx = DOOR_GFX_PAGEX3, cy = DOOR_GFX_PAGEY2;
410 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
411 cx + VIDEO_REC_LABEL_XPOS,
412 cy + VIDEO_REC_LABEL_YPOS,
413 VIDEO_PBEND_LABEL_XSIZE,
414 VIDEO_PBEND_LABEL_YSIZE,
415 VX + VIDEO_REC_LABEL_XPOS,
416 VY + VIDEO_REC_LABEL_YPOS);
423 int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
425 if (i%2) /* i ungerade => STATE_ON / PRESS_OFF */
426 cx = DOOR_GFX_PAGEX4;
428 cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */
430 if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
431 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
432 cx + video_pos[pos][part_label][xpos],
433 cy + video_pos[pos][part_label][ypos],
434 video_pos[pos][part_label][xsize],
435 video_pos[pos][part_label][ysize],
436 VX + video_pos[pos][part_label][xpos],
437 VY + video_pos[pos][part_label][ypos]);
438 if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
439 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
440 cx + video_pos[pos][part_symbol][xpos],
441 cy + video_pos[pos][part_symbol][ypos],
442 video_pos[pos][part_symbol][xsize],
443 video_pos[pos][part_symbol][ysize],
444 VX + video_pos[pos][part_symbol][xpos],
445 VY + video_pos[pos][part_symbol][ypos]);
449 if (state & VIDEO_STATE_FFWD_ON)
451 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
453 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
454 cx + VIDEO_PLAY_SYMBOL_XPOS,
455 cy + VIDEO_PLAY_SYMBOL_YPOS,
456 VIDEO_PLAY_SYMBOL_XSIZE - 2,
457 VIDEO_PLAY_SYMBOL_YSIZE,
458 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
459 VY + VIDEO_PLAY_SYMBOL_YPOS);
462 if (state & VIDEO_STATE_PBEND_ON)
464 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
466 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
467 cx + VIDEO_PBEND_LABEL_XPOS,
468 cy + VIDEO_PBEND_LABEL_YPOS,
469 VIDEO_PBEND_LABEL_XSIZE,
470 VIDEO_PBEND_LABEL_YSIZE,
471 VX + VIDEO_REC_LABEL_XPOS,
472 VY + VIDEO_REC_LABEL_YPOS);
475 if (state & VIDEO_STATE_DATE_ON)
477 int tag = value % 100;
478 int monat = (value/100) % 100;
479 int jahr = (value/10000);
481 DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
482 int2str(tag,2),FS_SMALL,FC_SPECIAL1);
483 DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
484 monatsname[monat],FS_SMALL,FC_SPECIAL1);
485 DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
486 int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
489 if (state & VIDEO_STATE_TIME_ON)
491 int min = value / 60;
492 int sec = value % 60;
494 DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
495 int2str(min,2),FS_SMALL,FC_SPECIAL1);
496 DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
497 int2str(sec,2),FS_SMALL,FC_SPECIAL1);
500 if (state & VIDEO_STATE_DATE)
501 redraw_mask |= REDRAW_VIDEO_1;
502 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
503 redraw_mask |= REDRAW_VIDEO_2;
504 if (state & VIDEO_PRESS)
505 redraw_mask |= REDRAW_VIDEO_3;
508 void DrawCompleteVideoDisplay()
510 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
511 DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY);
512 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
513 DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS,
514 DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS,
515 VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
516 VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
518 DrawVideoDisplay(VIDEO_ALL_OFF,0);
519 if (tape.date && tape.length)
521 DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
522 DrawVideoDisplay(VIDEO_STATE_TIME_ON,tape.length_seconds);
525 XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc,
526 VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
529 void DrawSoundDisplay(unsigned long state)
531 int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
533 pos = (state & BUTTON_SOUND_MUSIC ? SOUND_BUTTON_MUSIC_XPOS :
534 state & BUTTON_SOUND_LOOPS ? SOUND_BUTTON_LOOPS_XPOS :
535 SOUND_BUTTON_SIMPLE_XPOS);
537 if (state & BUTTON_ON)
538 cy -= SOUND_BUTTON_YSIZE;
540 if (state & BUTTON_PRESSED)
541 cx = DOOR_GFX_PAGEX3;
543 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
544 cx + pos,cy + SOUND_BUTTON_ANY_YPOS,
545 SOUND_BUTTON_XSIZE,SOUND_BUTTON_YSIZE,
546 DX + pos,DY + SOUND_BUTTON_ANY_YPOS);
548 redraw_mask |= REDRAW_DOOR_1;
551 void DrawGameButton(unsigned long state)
553 int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE;
555 pos = (state & BUTTON_GAME_STOP ? GAME_BUTTON_STOP_XPOS :
556 state & BUTTON_GAME_PAUSE ? GAME_BUTTON_PAUSE_XPOS :
557 GAME_BUTTON_PLAY_XPOS);
559 if (state & BUTTON_PRESSED)
560 cx = DOOR_GFX_PAGEX3;
562 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
563 cx + pos,cy + GAME_BUTTON_ANY_YPOS,
564 GAME_BUTTON_XSIZE,GAME_BUTTON_YSIZE,
565 DX + pos,DY + GAME_BUTTON_ANY_YPOS);
567 redraw_mask |= REDRAW_DOOR_1;
570 void DrawYesNoButton(unsigned long state, int mode)
572 Drawable dest_drawto;
573 int dest_xoffset, dest_yoffset;
574 int xpos, cx = DOOR_GFX_PAGEX4;
578 dest_drawto = pix[PIX_DB_DOOR];
579 dest_xoffset = DOOR_GFX_PAGEX1;
584 dest_drawto = drawto;
589 xpos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS);
591 if (state & BUTTON_PRESSED)
592 cx = DOOR_GFX_PAGEX3;
594 XCopyArea(display, pix[PIX_DOOR], dest_drawto, gc,
595 cx + xpos, OK_BUTTON_GFX_YPOS,
596 OK_BUTTON_XSIZE, OK_BUTTON_YSIZE,
597 dest_xoffset + xpos, dest_yoffset + OK_BUTTON_YPOS);
599 redraw_mask |= REDRAW_DOOR_1;
602 void DrawConfirmButton(unsigned long state, int mode)
604 Drawable dest_drawto;
605 int dest_xoffset, dest_yoffset;
606 int cx = DOOR_GFX_PAGEX4;
610 dest_drawto = pix[PIX_DB_DOOR];
611 dest_xoffset = DOOR_GFX_PAGEX1;
616 dest_drawto = drawto;
621 if (state & BUTTON_PRESSED)
622 cx = DOOR_GFX_PAGEX3;
624 XCopyArea(display, pix[PIX_DOOR], dest_drawto, gc,
625 cx + CONFIRM_BUTTON_XPOS, CONFIRM_BUTTON_GFX_YPOS,
626 CONFIRM_BUTTON_XSIZE, CONFIRM_BUTTON_YSIZE,
627 dest_xoffset + CONFIRM_BUTTON_XPOS,
628 dest_yoffset + CONFIRM_BUTTON_YPOS);
630 redraw_mask |= REDRAW_DOOR_1;
633 void DrawPlayerButton(unsigned long state, int mode)
635 Drawable dest_drawto;
636 int dest_xoffset, dest_yoffset;
637 int graphic = GFX_SPIELER1; /* default */
638 int graphic_offset = (PLAYER_BUTTON_XSIZE - TILEX/2)/2;
640 int cx = DOOR_GFX_PAGEX4, cy = 0;
644 dest_drawto = pix[PIX_DB_DOOR];
645 dest_xoffset = DOOR_GFX_PAGEX1;
650 dest_drawto = drawto;
655 if (state & BUTTON_PLAYER_1)
656 graphic = GFX_SPIELER1;
657 else if (state & BUTTON_PLAYER_2)
658 graphic = GFX_SPIELER2;
659 else if (state & BUTTON_PLAYER_3)
660 graphic = GFX_SPIELER3;
661 else if (state & BUTTON_PLAYER_4)
662 graphic = GFX_SPIELER4;
664 xpos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_3 ?
665 PLAYER_BUTTON_1_XPOS : PLAYER_BUTTON_2_XPOS);
666 ypos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_2 ?
667 PLAYER_BUTTON_1_YPOS : PLAYER_BUTTON_3_YPOS);
669 if (state & BUTTON_PRESSED)
671 cx = DOOR_GFX_PAGEX3;
675 XCopyArea(display, pix[PIX_DOOR], dest_drawto, gc,
676 cx + PLAYER_BUTTON_GFX_XPOS, cy + PLAYER_BUTTON_GFX_YPOS,
677 PLAYER_BUTTON_XSIZE, PLAYER_BUTTON_YSIZE,
678 dest_xoffset + xpos, dest_yoffset + ypos);
679 DrawMiniGraphicExt(dest_drawto,gc,
680 dest_xoffset + xpos + graphic_offset,
681 dest_yoffset + ypos + graphic_offset,
684 redraw_mask |= REDRAW_DOOR_1;
687 /* several buttons in the level editor */
689 void DrawEditButton(unsigned long state)
692 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
693 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2;
694 static int edit_pos[6][4] =
696 {ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS,
697 ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE},
699 {ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS,
700 ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE},
702 {ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS,
703 ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE},
705 {ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS,
706 ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE},
708 {ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS,
709 ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE},
711 {ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS,
712 ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE}
715 if (state & ED_BUTTON_PRESSED)
716 cx = DOOR_GFX_PAGEX5;
721 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
722 cx + edit_pos[i][xpos],
723 cy + edit_pos[i][ypos],
726 VX + edit_pos[i][xpos],
727 VY + edit_pos[i][ypos]);
730 redraw_mask |= REDRAW_DOOR_2;
733 void DrawCtrlButton(unsigned long state)
736 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
737 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY1+80;
738 static int edit_pos[4][4] =
740 {ED_BUTTON_EDIT_XPOS,ED_BUTTON_EDIT_YPOS,
741 ED_BUTTON_EDIT_XSIZE,ED_BUTTON_EDIT_YSIZE},
743 {ED_BUTTON_CLEAR_XPOS,ED_BUTTON_CLEAR_YPOS,
744 ED_BUTTON_CLEAR_XSIZE,ED_BUTTON_CLEAR_YSIZE},
746 {ED_BUTTON_UNDO_XPOS,ED_BUTTON_UNDO_YPOS,
747 ED_BUTTON_UNDO_XSIZE,ED_BUTTON_UNDO_YSIZE},
749 {ED_BUTTON_EXIT_XPOS,ED_BUTTON_EXIT_YPOS,
750 ED_BUTTON_EXIT_XSIZE,ED_BUTTON_EXIT_YSIZE}
753 if (state & ED_BUTTON_PRESSED)
754 cx = DOOR_GFX_PAGEX3;
758 if (state & (1<<(i+6)))
759 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
760 cx + edit_pos[i][xpos],
761 cy + edit_pos[i][ypos],
764 VX + edit_pos[i][xpos],
765 VY + edit_pos[i][ypos]);
768 redraw_mask |= REDRAW_DOOR_2;
771 void DrawElemButton(int button_nr, int button_state)
773 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
774 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
775 int from_x, from_y, to_x,to_y, size_x, size_y;
776 static int edit_pos[3][4] =
778 {ED_BUTTON_EUP_XPOS,ED_BUTTON_EUP_YPOS,
779 ED_BUTTON_EUP_XSIZE,ED_BUTTON_EUP_YSIZE},
781 {ED_BUTTON_EDOWN_XPOS,ED_BUTTON_EDOWN_YPOS,
782 ED_BUTTON_EDOWN_XSIZE,ED_BUTTON_EDOWN_YSIZE},
784 {ED_BUTTON_ELEM_XPOS,ED_BUTTON_ELEM_YPOS,
785 ED_BUTTON_ELEM_XSIZE,ED_BUTTON_ELEM_YSIZE}
788 if (button_nr<ED_BUTTON_ELEM)
792 from_x = cx + edit_pos[pos][xpos];
793 from_y = cy + edit_pos[pos][ypos];
794 size_x = edit_pos[pos][xsize];
795 size_y = edit_pos[pos][ysize];
796 to_x = DX + edit_pos[pos][xpos];
797 to_y = DY + edit_pos[pos][ypos];
799 if (button_state & ED_BUTTON_PRESSED)
801 if (button_nr==ED_BUTTON_EUP)
802 from_y = cy + ED_BUTTON_EUP_Y2POS;
804 from_y = cy + ED_BUTTON_EDOWN_Y2POS;
807 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
808 from_x,from_y, size_x,size_y, to_x,to_y);
812 int pos = ED_BUTTON_ELEM;
813 int elem_pos = button_nr-ED_BUTTON_ELEM;
814 int x = elem_pos % MAX_ELEM_X;
815 int y = elem_pos / MAX_ELEM_X;
819 if (elem_pos+element_shift < elements_in_list)
820 graphic = el2gfx(editor_element[elem_pos+element_shift]);
822 graphic = GFX_LEERRAUM;
824 from_x = cx + edit_pos[pos][xpos];
825 from_y = cy + edit_pos[pos][ypos];
826 size_x = edit_pos[pos][xsize];
827 size_y = edit_pos[pos][ysize];
828 to_x = DX + edit_pos[pos][xpos] + x * ED_BUTTON_ELEM_XSIZE;
829 to_y = DY + edit_pos[pos][ypos] + y * ED_BUTTON_ELEM_YSIZE;
831 if (button_state & ED_BUTTON_PRESSED)
833 from_y = ED_BUTTON_ELEM_Y2POS;
837 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
838 from_x,from_y, size_x,size_y, to_x,to_y);
840 DrawMiniGraphicExt(drawto,gc,
841 DX+ED_BUTTON_ELEM_XPOS+3+shift +
842 (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
843 DY+ED_BUTTON_ELEM_YPOS+3+shift +
844 (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
848 redraw_mask |= REDRAW_DOOR_1;
851 void DrawCountButton(int button_nr, int button_state)
853 int from_x, from_y, to_x,to_y, size_x, size_y;
856 DOOR_GFX_PAGEX4+(button_nr%2 ? ED_BUTTON_PLUS_XPOS : ED_BUTTON_MINUS_XPOS);
857 from_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS;
858 size_x = ED_BUTTON_MINUS_XSIZE;
859 size_y = ED_BUTTON_MINUS_YSIZE;
860 to_x = (button_nr<32 ? ED_COUNT_GADGET_XPOS : ED_SIZE_GADGET_XPOS);
862 to_x += (ED_BUTTON_PLUS_XPOS - ED_BUTTON_MINUS_XPOS);
863 to_y = (button_nr<32 ? ED_COUNT_GADGET_YPOS : ED_SIZE_GADGET_YPOS) +
864 ((button_nr<32 ? button_nr : button_nr-32)/2)*ED_COUNT_GADGET_YSIZE;
866 if (button_state & ED_BUTTON_PRESSED)
869 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
870 from_x,from_y, size_x,size_y, to_x,to_y);
871 XCopyArea(display,pix[PIX_DOOR],window,gc,
872 from_x,from_y, size_x,size_y, to_x,to_y);
875 /**********************************************************************/
876 /********** checking buttons (and redrawing them, if needed) **********/
877 /**********************************************************************/
879 int CheckVideoButtons(int mx, int my, int button)
882 static int choice = -1;
883 static boolean pressed = FALSE;
884 static int video_button[5] =
886 VIDEO_PRESS_EJECT_ON,
888 VIDEO_PRESS_PAUSE_ON,
895 if (!motion_status) /* Maustaste neu gedrückt */
897 if (ON_VIDEO_BUTTON(mx,my))
899 choice = VIDEO_BUTTON(mx);
901 DrawVideoDisplay(video_button[choice],0);
904 else /* Mausbewegung bei gedrückter Maustaste */
906 if ((!ON_VIDEO_BUTTON(mx,my) || VIDEO_BUTTON(mx)!=choice) &&
907 choice>=0 && pressed)
910 DrawVideoDisplay(video_button[choice]<<1,0);
912 else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed)
915 DrawVideoDisplay(video_button[choice],0);
919 else /* Maustaste wieder losgelassen */
921 if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed)
923 DrawVideoDisplay(video_button[choice]<<1,0);
924 return_code = choice+1;
939 int CheckSoundButtons(int mx, int my, int button)
942 static int choice = -1;
943 static boolean pressed = FALSE;
946 sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music);
947 sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops);
948 sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple);
952 if (!motion_status) /* Maustaste neu gedrückt */
954 if (ON_SOUND_BUTTON(mx,my))
956 choice = SOUND_BUTTON(mx);
958 DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
961 else /* Mausbewegung bei gedrückter Maustaste */
963 if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) &&
964 choice>=0 && pressed)
967 DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
969 else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed)
972 DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
976 else /* Maustaste wieder losgelassen */
978 if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed)
980 DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
981 return_code = 1<<choice;
996 int CheckGameButtons(int mx, int my, int button)
999 static int choice = -1;
1000 static boolean pressed = FALSE;
1010 if (!motion_status) /* Maustaste neu gedrückt */
1012 if (ON_GAME_BUTTON(mx,my))
1014 choice = GAME_BUTTON(mx);
1016 DrawGameButton(game_state[choice] | BUTTON_PRESSED);
1019 else /* Mausbewegung bei gedrückter Maustaste */
1021 if ((!ON_GAME_BUTTON(mx,my) || GAME_BUTTON(mx)!=choice) &&
1022 choice>=0 && pressed)
1025 DrawGameButton(game_state[choice] | BUTTON_RELEASED);
1027 else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed)
1030 DrawGameButton(game_state[choice] | BUTTON_PRESSED);
1034 else /* Maustaste wieder losgelassen */
1036 if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed)
1038 DrawGameButton(game_state[choice] | BUTTON_RELEASED);
1039 return_code = 1<<choice;
1051 return(return_code);
1054 int CheckYesNoButtons(int mx, int my, int button)
1056 int return_code = 0;
1057 static int choice = -1;
1058 static boolean pressed = FALSE;
1059 static int yesno_button[5] =
1067 if (!motion_status) /* Maustaste neu gedrückt */
1069 if (ON_YESNO_BUTTON(mx,my))
1071 choice = YESNO_BUTTON(mx);
1073 DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED, DB_NORMAL);
1076 else /* Mausbewegung bei gedrückter Maustaste */
1078 if ((!ON_YESNO_BUTTON(mx,my) || YESNO_BUTTON(mx)!=choice) &&
1079 choice>=0 && pressed)
1082 DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED, DB_NORMAL);
1084 else if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && !pressed)
1087 DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED, DB_NORMAL);
1091 else /* Maustaste wieder losgelassen */
1093 if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && pressed)
1095 DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED, DB_NORMAL);
1096 return_code = choice+1;
1108 return(return_code);
1111 int CheckConfirmButton(int mx, int my, int button)
1113 int return_code = 0;
1114 static int choice = -1;
1115 static boolean pressed = FALSE;
1119 if (!motion_status) /* Maustaste neu gedrückt */
1121 if (ON_CONFIRM_BUTTON(mx,my))
1125 DrawConfirmButton(BUTTON_PRESSED, DB_NORMAL);
1128 else /* Mausbewegung bei gedrückter Maustaste */
1130 if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed)
1133 DrawConfirmButton(BUTTON_RELEASED, DB_NORMAL);
1135 else if (ON_CONFIRM_BUTTON(mx,my) && !pressed)
1138 DrawConfirmButton(BUTTON_PRESSED, DB_NORMAL);
1142 else /* Maustaste wieder losgelassen */
1144 if (ON_CONFIRM_BUTTON(mx,my) && pressed)
1146 DrawConfirmButton(BUTTON_RELEASED, DB_NORMAL);
1147 return_code = BUTTON_CONFIRM;
1159 return(return_code);
1162 int CheckPlayerButtons(int mx, int my, int button)
1164 int return_code = 0;
1165 static int choice = -1;
1166 static boolean pressed = FALSE;
1167 int player_state[4] =
1177 if (!motion_status) /* Maustaste neu gedrückt */
1179 if (ON_PLAYER_BUTTON(mx,my))
1181 choice = PLAYER_BUTTON(mx,my);
1183 DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
1186 else /* Mausbewegung bei gedrückter Maustaste */
1188 if ((!ON_PLAYER_BUTTON(mx,my) || PLAYER_BUTTON(mx,my)!=choice) &&
1189 choice>=0 && pressed)
1192 DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
1194 else if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && !pressed)
1197 DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
1201 else /* Maustaste wieder losgelassen */
1203 if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && pressed)
1205 DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
1206 return_code = player_state[choice];
1218 return(return_code);
1221 /* several buttons in the level editor */
1223 int CheckEditButtons(int mx, int my, int button)
1225 int return_code = 0;
1226 static int choice = -1;
1227 static boolean pressed = FALSE;
1228 static int edit_button[6] =
1240 if (!motion_status) /* Maustaste neu gedrückt */
1242 if (ON_EDIT_BUTTON(mx,my))
1244 choice = EDIT_BUTTON(mx,my);
1246 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
1247 if (edit_button[choice]!=ED_BUTTON_CTRL &&
1248 edit_button[choice]!=ED_BUTTON_FILL)
1249 return_code = 1<<choice;
1252 else /* Mausbewegung bei gedrückter Maustaste */
1254 if ((!ON_EDIT_BUTTON(mx,my) || EDIT_BUTTON(mx,my)!=choice) &&
1255 choice>=0 && pressed)
1258 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
1260 else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice)
1263 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
1265 if (edit_button[choice]!=ED_BUTTON_CTRL &&
1266 edit_button[choice]!=ED_BUTTON_FILL)
1267 return_code = 1<<choice;
1271 else /* Maustaste wieder losgelassen */
1273 if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice && pressed)
1275 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
1276 if (edit_button[choice]==ED_BUTTON_CTRL ||
1277 edit_button[choice]==ED_BUTTON_FILL)
1278 return_code = 1<<choice;
1290 return(return_code);
1293 int CheckCtrlButtons(int mx, int my, int button)
1295 int return_code = 0;
1296 static int choice = -1;
1297 static boolean pressed = FALSE;
1298 static int ctrl_button[4] =
1308 if (!motion_status) /* Maustaste neu gedrückt */
1310 if (ON_CTRL_BUTTON(mx,my))
1312 choice = CTRL_BUTTON(mx,my);
1314 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
1317 else /* Mausbewegung bei gedrückter Maustaste */
1319 if ((!ON_CTRL_BUTTON(mx,my) || CTRL_BUTTON(mx,my)!=choice) &&
1320 choice>=0 && pressed)
1323 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
1325 else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed)
1328 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
1332 else /* Maustaste wieder losgelassen */
1334 if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed)
1336 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
1337 return_code = 1<<(choice+6);
1349 return(return_code);
1352 int CheckElemButtons(int mx, int my, int button)
1354 int return_code = -1;
1355 static int choice = -1;
1356 static boolean pressed = FALSE;
1360 if (!motion_status) /* Maustaste neu gedrückt */
1362 if (ON_ELEM_BUTTON(mx,my))
1364 choice = ELEM_BUTTON(mx,my);
1366 DrawElemButton(choice,ED_BUTTON_PRESSED);
1367 if (choice==ED_BUTTON_EUP ||
1368 choice==ED_BUTTON_EDOWN)
1369 return_code = choice;
1372 else /* Mausbewegung bei gedrückter Maustaste */
1374 if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) &&
1375 choice>=0 && pressed)
1378 DrawElemButton(choice,ED_BUTTON_RELEASED);
1380 else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice)
1383 DrawElemButton(choice,ED_BUTTON_PRESSED);
1385 if (choice==ED_BUTTON_EUP ||
1386 choice==ED_BUTTON_EDOWN)
1387 return_code = choice;
1391 else /* Maustaste wieder losgelassen */
1393 if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed)
1395 DrawElemButton(choice,ED_BUTTON_RELEASED);
1396 if (choice!=ED_BUTTON_EUP &&
1397 choice!=ED_BUTTON_EDOWN)
1398 return_code = choice;
1410 return(return_code);
1413 int CheckCountButtons(int mx, int my, int button)
1415 int return_code = -1;
1416 static int choice = -1;
1417 static boolean pressed = FALSE;
1421 if (!motion_status) /* Maustaste neu gedrückt */
1423 if (ON_COUNT_BUTTON(mx,my))
1425 choice = COUNT_BUTTON(mx,my);
1427 DrawCountButton(choice,ED_BUTTON_PRESSED);
1428 return_code = choice;
1431 else /* Mausbewegung bei gedrückter Maustaste */
1433 if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) &&
1434 choice>=0 && pressed)
1437 DrawCountButton(choice,ED_BUTTON_RELEASED);
1439 else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice)
1442 DrawCountButton(choice,ED_BUTTON_PRESSED);
1444 return_code = choice;
1448 else /* Maustaste wieder losgelassen */
1450 if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed)
1452 DrawCountButton(choice,ED_BUTTON_RELEASED);
1464 return(return_code);
1468 /* NEW GADGET STUFF -------------------------------------------------------- */
1471 static struct GadgetInfo *gadget_list_first_entry = NULL;
1472 static struct GadgetInfo *gadget_list_last_entry = NULL;
1473 static int next_free_gadget_id = 1;
1474 static boolean gadget_id_wrapped = FALSE;
1476 static struct GadgetInfo *getGadgetInfoFromGadgetID(int id)
1478 struct GadgetInfo *gi = gadget_list_first_entry;
1480 while (gi && gi->id != id)
1486 static int getNewGadgetID()
1488 int id = next_free_gadget_id++;
1490 if (next_free_gadget_id <= 0) /* counter overrun */
1492 gadget_id_wrapped = TRUE; /* now we must check each ID */
1493 next_free_gadget_id = 0;
1496 if (gadget_id_wrapped)
1498 next_free_gadget_id++;
1499 while (getGadgetInfoFromGadgetID(next_free_gadget_id) != NULL)
1500 next_free_gadget_id++;
1503 if (next_free_gadget_id <= 0) /* cannot get new gadget id */
1504 Error(ERR_EXIT, "too much gadgets -- this should not happen");
1509 static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my)
1511 struct GadgetInfo *gi = gadget_list_first_entry;
1516 mx >= gi->x && mx < gi->x + gi->width &&
1517 my >= gi->y && my < gi->y + gi->height)
1526 static void default_callback_function(void *ptr)
1531 struct GadgetInfo *CreateGadget(int first_tag, ...)
1533 struct GadgetInfo *new_gadget = checked_malloc(sizeof(struct GadgetInfo));
1534 int tag = first_tag;
1537 va_start(ap, first_tag);
1539 /* always start with reliable default values */
1540 memset(new_gadget, 0, sizeof(struct GadgetInfo)); /* zero all fields */
1541 new_gadget->id = getNewGadgetID(); /* new gadget id */
1542 new_gadget->callback = default_callback_function; /* dummy function */
1544 while (tag != GDI_END)
1549 new_gadget->custom_id = va_arg(ap, int);
1553 new_gadget->x = va_arg(ap, int);
1557 new_gadget->y = va_arg(ap, int);
1561 new_gadget->width = va_arg(ap, int);
1565 new_gadget->height = va_arg(ap, int);
1569 new_gadget->type = va_arg(ap, unsigned long);
1573 new_gadget->state = va_arg(ap, unsigned long);
1577 new_gadget->radio_nr = va_arg(ap, unsigned long);
1580 case GDI_RADIO_PRESSED:
1581 new_gadget->radio_pressed = va_arg(ap, boolean);
1584 case GDI_NUMBER_VALUE:
1585 new_gadget->number_value = va_arg(ap, long);
1588 case GDI_TEXT_VALUE:
1590 int max_textsize = MAX_GADGET_TEXTSIZE;
1592 if (new_gadget->text_size)
1593 max_textsize = MIN(new_gadget->text_size, MAX_GADGET_TEXTSIZE - 1);
1595 strncpy(new_gadget->text_value, va_arg(ap, char *), max_textsize);
1596 new_gadget->text_value[max_textsize] = '\0';
1602 int tag_value = va_arg(ap, int);
1603 int max_textsize = MIN(tag_value, MAX_GADGET_TEXTSIZE - 1);
1605 new_gadget->text_size = max_textsize;
1606 new_gadget->text_value[max_textsize] = '\0';
1608 if (new_gadget->width == 0 && new_gadget->height == 0)
1610 new_gadget->width = (new_gadget->text_size + 1) * FONT2_XSIZE + 6;
1611 new_gadget->height = ED_WIN_COUNT_YSIZE;
1616 case GDI_TEXT_BORDER:
1617 new_gadget->text_border = va_arg(ap, int);
1620 case GDI_DESIGN_UNPRESSED:
1621 new_gadget->design[GD_BUTTON_UNPRESSED].pixmap = va_arg(ap, Pixmap);
1622 new_gadget->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
1623 new_gadget->design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int);
1626 case GDI_DESIGN_PRESSED:
1627 new_gadget->design[GD_BUTTON_PRESSED].pixmap = va_arg(ap, Pixmap);
1628 new_gadget->design[GD_BUTTON_PRESSED].x = va_arg(ap, int);
1629 new_gadget->design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
1632 case GDI_ALT_DESIGN_UNPRESSED:
1633 new_gadget->alt_design[GD_BUTTON_UNPRESSED].pixmap= va_arg(ap, Pixmap);
1634 new_gadget->alt_design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int);
1635 new_gadget->alt_design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int);
1638 case GDI_ALT_DESIGN_PRESSED:
1639 new_gadget->alt_design[GD_BUTTON_PRESSED].pixmap = va_arg(ap, Pixmap);
1640 new_gadget->alt_design[GD_BUTTON_PRESSED].x = va_arg(ap, int);
1641 new_gadget->alt_design[GD_BUTTON_PRESSED].y = va_arg(ap, int);
1644 case GDI_EVENT_MASK:
1645 new_gadget->event_mask = va_arg(ap, unsigned long);
1649 new_gadget->drawing.area_xsize = va_arg(ap, int);
1650 new_gadget->drawing.area_ysize = va_arg(ap, int);
1652 /* determine dependent values for drawing area gadget, if needed */
1653 if (new_gadget->width == 0 &&
1654 new_gadget->height == 0 &&
1655 new_gadget->drawing.item_xsize !=0 &&
1656 new_gadget->drawing.item_ysize !=0)
1659 new_gadget->drawing.area_xsize * new_gadget->drawing.item_xsize;
1660 new_gadget->height =
1661 new_gadget->drawing.area_ysize * new_gadget->drawing.item_ysize;
1663 else if (new_gadget->drawing.item_xsize == 0 &&
1664 new_gadget->drawing.item_ysize == 0 &&
1665 new_gadget->width != 0 &&
1666 new_gadget->height != 0)
1668 new_gadget->drawing.item_xsize =
1669 new_gadget->width / new_gadget->drawing.area_xsize;
1670 new_gadget->drawing.item_ysize =
1671 new_gadget->height / new_gadget->drawing.area_ysize;
1676 new_gadget->drawing.item_xsize = va_arg(ap, int);
1677 new_gadget->drawing.item_ysize = va_arg(ap, int);
1679 /* determine dependent values for drawing area gadget, if needed */
1680 if (new_gadget->width == 0 &&
1681 new_gadget->height == 0 &&
1682 new_gadget->drawing.area_xsize !=0 &&
1683 new_gadget->drawing.area_ysize !=0)
1686 new_gadget->drawing.area_xsize * new_gadget->drawing.item_xsize;
1687 new_gadget->height =
1688 new_gadget->drawing.area_ysize * new_gadget->drawing.item_ysize;
1690 else if (new_gadget->drawing.area_xsize == 0 &&
1691 new_gadget->drawing.area_ysize == 0 &&
1692 new_gadget->width != 0 &&
1693 new_gadget->height != 0)
1695 new_gadget->drawing.area_xsize =
1696 new_gadget->width / new_gadget->drawing.item_xsize;
1697 new_gadget->drawing.area_ysize =
1698 new_gadget->height / new_gadget->drawing.item_ysize;
1703 new_gadget->callback = va_arg(ap, gadget_callback_function);
1707 Error(ERR_EXIT, "CreateGadget(): unknown tag %d", tag);
1710 tag = va_arg(ap, int); /* read next tag */
1715 /* check if gadget complete */
1716 if (new_gadget->type != GD_TYPE_DRAWING_AREA &&
1717 (!new_gadget->design[GD_BUTTON_UNPRESSED].pixmap ||
1718 !new_gadget->design[GD_BUTTON_PRESSED].pixmap))
1719 Error(ERR_EXIT, "gadget incomplete (missing Pixmap)");
1721 /* insert new gadget into gloabl gadget list */
1723 if (gadget_list_last_entry)
1725 gadget_list_last_entry->next = new_gadget;
1726 gadget_list_last_entry = gadget_list_last_entry->next;
1730 gadget_list_first_entry = gadget_list_last_entry = new_gadget;
1736 void FreeGadget(struct GadgetInfo *gi)
1738 struct GadgetInfo *gi_previous = gadget_list_first_entry;
1740 while (gi_previous && gi_previous->next != gi)
1741 gi_previous = gi_previous->next;
1743 if (gi == gadget_list_first_entry)
1744 gadget_list_first_entry = gi->next;
1746 if (gi == gadget_list_last_entry)
1747 gadget_list_last_entry = gi_previous;
1749 gi_previous->next = gi->next;
1753 /* values for DrawGadget() */
1754 #define DG_UNPRESSED 0
1755 #define DG_PRESSED 1
1756 #define DG_BUFFERED 0
1759 static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct)
1761 int state = (pressed ? 1 : 0);
1762 struct GadgetDesign *gd = (gi->radio_pressed ?
1763 &gi->alt_design[state] :
1764 &gi->design[state]);
1768 case GD_TYPE_NORMAL_BUTTON:
1769 case GD_TYPE_RADIO_BUTTON:
1770 XCopyArea(display, gd->pixmap, drawto, gc,
1771 gd->x, gd->y, gi->width, gi->height, gi->x, gi->y);
1774 case GD_TYPE_TEXTINPUT:
1778 /* left part of gadget */
1779 XCopyArea(display, gd->pixmap, drawto, gc,
1781 gi->text_border, gi->height,
1784 /* middle part of gadget */
1785 for (i=0; i<=gi->text_size; i++)
1786 XCopyArea(display, gd->pixmap, drawto, gc,
1787 gd->x + gi->text_border, gd->y,
1788 FONT2_XSIZE, gi->height,
1789 gi->x + gi->text_border + i * FONT2_XSIZE, gi->y);
1791 /* right part of gadget */
1792 XCopyArea(display, gd->pixmap, drawto, gc,
1793 gd->x + ED_WIN_COUNT_XSIZE - gi->text_border, gd->y,
1794 gi->text_border, gi->height,
1795 gi->x + gi->width - gi->text_border, gi->y);
1797 /* gadget text value */
1798 DrawText(gi->x + gi->text_border, gi->y + gi->text_border,
1799 gi->text_value, FS_SMALL, (pressed ? FC_GREEN : FC_YELLOW));
1801 /* draw cursor, if active */
1802 DrawText(gi->x + gi->text_border + strlen(gi->text_value)*FONT2_XSIZE,
1803 gi->y + gi->text_border,
1804 (pressed ? "<" : " "),
1814 XCopyArea(display, drawto, window, gc,
1815 gi->x, gi->y, gi->width, gi->height, gi->x, gi->y);
1817 redraw_mask |= REDRAW_ALL;
1820 void ClickOnGadget(struct GadgetInfo *gi)
1822 /* simulate releasing mouse button over last gadget, if still pressed */
1824 HandleGadgets(-1, -1, 0);
1826 /* simulate pressing mouse button over specified gadget */
1827 HandleGadgets(gi->x, gi->y, 1);
1829 /* simulate releasing mouse button over specified gadget */
1830 HandleGadgets(gi->x, gi->y, 0);
1833 void MapGadget(struct GadgetInfo *gi)
1840 DrawGadget(gi, (gi->state == GD_BUTTON_PRESSED), DG_BUFFERED);
1843 void UnmapGadget(struct GadgetInfo *gi)
1851 static struct GadgetInfo *last_gi = NULL;
1853 void HandleGadgets(int mx, int my, int button)
1855 static unsigned long pressed_delay = 0;
1857 struct GadgetInfo *new_gi, *gi;
1858 boolean gadget_pressed;
1859 boolean gadget_pressed_repeated;
1860 boolean gadget_moving;
1861 boolean gadget_moving_off_borders;
1862 boolean gadget_released;
1863 boolean gadget_released_off_borders;
1865 if (gadget_list_first_entry == NULL) /* no gadgets defined */
1868 new_gi = getGadgetInfoFromMousePosition(mx, my);
1870 /* if mouse button pressed outside text input gadget, deactivate it */
1871 if (last_gi && last_gi->type == GD_TYPE_TEXTINPUT &&
1872 button != 0 && new_gi != last_gi && !motion_status)
1874 struct GadgetInfo *gi = last_gi;
1876 DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
1878 if (gi->event_mask & GD_EVENT_TEXT_LEAVING)
1885 (button != 0 && last_gi == NULL && new_gi != NULL && !motion_status);
1886 gadget_pressed_repeated =
1887 (button != 0 && last_gi != NULL && new_gi == last_gi);
1889 (button != 0 && last_gi != NULL && new_gi == last_gi && motion_status);
1890 gadget_moving_off_borders =
1891 (button != 0 && last_gi != NULL && new_gi != last_gi && motion_status);
1893 (button == 0 && last_gi != NULL && new_gi == last_gi);
1894 gadget_released_off_borders =
1895 (button == 0 && last_gi != NULL && new_gi != last_gi);
1897 /* if new gadget pressed, store this gadget */
1901 /* 'gi' is actually handled gadget */
1904 /* if mouse button released, no gadget needs to be handled anymore */
1905 if (button == 0 && last_gi && last_gi->type != GD_TYPE_TEXTINPUT)
1910 gi->event.x = mx - gi->x;
1911 gi->event.y = my - gi->y;
1913 if (gi->type == GD_TYPE_DRAWING_AREA)
1915 gi->event.x /= gi->drawing.item_xsize;
1916 gi->event.y /= gi->drawing.item_ysize;
1922 if (gi->type == GD_TYPE_RADIO_BUTTON)
1924 struct GadgetInfo *rgi = gadget_list_first_entry;
1929 rgi->type == GD_TYPE_RADIO_BUTTON &&
1930 rgi->radio_nr == gi->radio_nr &&
1933 rgi->radio_pressed = FALSE;
1934 DrawGadget(rgi, DG_UNPRESSED, DG_DIRECT);
1940 gi->radio_pressed = TRUE;
1943 DrawGadget(gi, DG_PRESSED, DG_DIRECT);
1945 gi->state = GD_BUTTON_PRESSED;
1946 gi->event.type = GD_EVENT_PRESSED;
1947 gi->event.button = button;
1948 gi->event.off_borders = FALSE;
1950 /* initialize delay counter */
1952 DelayReached(&pressed_delay, GADGET_FRAME_DELAY);
1954 if (gi->event_mask & GD_EVENT_PRESSED)
1958 if (gadget_pressed_repeated)
1960 if (gi->event_mask & GD_EVENT_REPEATED &&
1961 DelayReached(&pressed_delay, GADGET_FRAME_DELAY))
1967 if (gi->state == GD_BUTTON_UNPRESSED)
1968 DrawGadget(gi, DG_PRESSED, DG_DIRECT);
1970 gi->state = GD_BUTTON_PRESSED;
1971 gi->event.type = GD_EVENT_MOVING;
1972 gi->event.off_borders = FALSE;
1973 if (gi->event_mask & GD_EVENT_MOVING)
1977 if (gadget_moving_off_borders)
1979 if (gi->state == GD_BUTTON_PRESSED &&
1980 gi->type != GD_TYPE_TEXTINPUT)
1981 DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
1983 gi->state = GD_BUTTON_UNPRESSED;
1984 gi->event.type = GD_EVENT_MOVING;
1985 gi->event.off_borders = TRUE;
1987 if (gi->event_mask & GD_EVENT_MOVING &&
1988 gi->event_mask & GD_EVENT_OFF_BORDERS)
1992 if (gadget_released)
1994 if (gi->type != GD_TYPE_TEXTINPUT)
1995 DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
1997 gi->state = GD_BUTTON_UNPRESSED;
1998 gi->event.type = GD_EVENT_RELEASED;
2000 if (gi->event_mask & GD_EVENT_RELEASED)
2004 if (gadget_released_off_borders)
2006 gi->event.type = GD_EVENT_RELEASED;
2008 if (gi->event_mask & GD_EVENT_RELEASED &&
2009 gi->event_mask & GD_EVENT_OFF_BORDERS)
2014 void HandleGadgetsKeyInput(KeySym key)
2016 struct GadgetInfo *gi = last_gi;
2020 if (gi == NULL || gi->type != GD_TYPE_TEXTINPUT)
2023 text_length = strlen(gi->text_value);
2024 letter = getCharFromKeySym(key);
2026 if (letter && text_length < gi->text_size)
2028 gi->text_value[text_length] = letter;
2029 gi->text_value[text_length + 1] = '\0';
2030 DrawGadget(gi, DG_PRESSED, DG_DIRECT);
2032 else if ((key == XK_Delete || key == XK_BackSpace) && text_length > 0)
2034 gi->text_value[text_length - 1] = '\0';
2035 DrawGadget(gi, DG_PRESSED, DG_DIRECT);
2037 else if (key == XK_Return)
2039 DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
2041 if (gi->event_mask & GD_EVENT_TEXT_RETURN)