Fix some greedy sed changes in imported code. Also provide a sys/types.h for compatib...
[kugel-rb.git] / apps / plugins / pdbox / PDa / src / g_bang.c
blob5cf726cd88297a0d15957993ca232fc090836789
1 /* Copyright (c) 1997-1999 Miller Puckette.
2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
5 /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
6 /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
8 #ifdef ROCKBOX
9 #include "plugin.h"
10 #include "../../pdbox.h"
11 #include "m_pd.h"
12 #include "g_canvas.h"
13 #include "g_all_guis.h"
14 #else /* ROCKBOX */
15 #include <stdlib.h>
16 #include <string.h>
17 #include <stdio.h>
18 #include <ctype.h>
19 #include "m_pd.h"
20 #include "g_canvas.h"
21 #include "t_tk.h"
22 #include "g_all_guis.h"
23 #include <math.h>
25 #ifdef MSW
26 #include <io.h>
27 #else
28 #include <unistd.h>
29 #endif
30 #endif /* ROCKBOX */
33 /* --------------- bng gui-bang ------------------------- */
35 t_widgetbehavior bng_widgetbehavior;
36 static t_class *bng_class;
38 /* widget helper functions */
41 void bng_draw_update(t_bng *x, t_glist *glist)
43 #ifdef ROCKBOX
44 (void) x;
45 (void) glist;
46 #else /* ROCKBOX */
47 if(glist_isvisible(glist))
49 sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", glist_getcanvas(glist), x,
50 x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
52 #endif /* ROCKBOX */
55 void bng_draw_new(t_bng *x, t_glist *glist)
57 #ifdef ROCKBOX
58 (void) x;
59 (void) glist;
60 #else /* ROCKBOX */
61 int xpos=text_xpix(&x->x_gui.x_obj, glist);
62 int ypos=text_ypix(&x->x_gui.x_obj, glist);
63 t_canvas *canvas=glist_getcanvas(glist);
65 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
66 canvas, xpos, ypos,
67 xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
68 x->x_gui.x_bcol, x);
69 sys_vgui(".x%x.c create oval %d %d %d %d -fill #%6.6x -tags %xBUT\n",
70 canvas, xpos+1, ypos+1,
71 xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1,
72 x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
73 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
74 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
75 canvas, xpos+x->x_gui.x_ldx,
76 ypos+x->x_gui.x_ldy,
77 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
78 x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
79 if(!x->x_gui.x_fsf.x_snd_able)
80 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
81 canvas, xpos,
82 ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
83 ypos + x->x_gui.x_h, x, 0);
84 if(!x->x_gui.x_fsf.x_rcv_able)
85 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
86 canvas, xpos, ypos,
87 xpos + IOWIDTH, ypos+1, x, 0);
88 #endif /* ROCKBOX */
91 void bng_draw_move(t_bng *x, t_glist *glist)
93 #ifdef ROCKBOX
94 (void) x;
95 (void) glist;
96 #else /* ROCKBOX */
97 int xpos=text_xpix(&x->x_gui.x_obj, glist);
98 int ypos=text_ypix(&x->x_gui.x_obj, glist);
99 t_canvas *canvas=glist_getcanvas(glist);
101 sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
102 canvas, x, xpos, ypos,
103 xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
104 sys_vgui(".x%x.c coords %xBUT %d %d %d %d\n",
105 canvas, x, xpos+1,ypos+1,
106 xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1);
107 sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x,
108 x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
109 sys_vgui(".x%x.c coords %xLABEL %d %d\n",
110 canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
111 if(!x->x_gui.x_fsf.x_snd_able)
112 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
113 canvas, x, 0, xpos,
114 ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
115 ypos + x->x_gui.x_h);
116 if(!x->x_gui.x_fsf.x_rcv_able)
117 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
118 canvas, x, 0, xpos, ypos,
119 xpos + IOWIDTH, ypos+1);
120 #endif /* ROCKBOX */
123 void bng_draw_erase(t_bng* x, t_glist* glist)
125 #ifdef ROCKBOX
126 (void) x;
127 (void) glist;
128 #else /* ROCKBOX */
129 t_canvas *canvas=glist_getcanvas(glist);
131 sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
132 sys_vgui(".x%x.c delete %xBUT\n", canvas, x);
133 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
134 if(!x->x_gui.x_fsf.x_snd_able)
135 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
136 if(!x->x_gui.x_fsf.x_rcv_able)
137 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
138 #endif /* ROCKBOX */
141 void bng_draw_config(t_bng* x, t_glist* glist)
143 #ifdef ROCKBOX
144 (void) x;
145 (void) glist;
146 #else /* ROCKBOX */
147 t_canvas *canvas=glist_getcanvas(glist);
149 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
150 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
151 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
152 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
153 sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
154 sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x,
155 x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
156 #endif /* ROCKBOX */
159 void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
161 #ifdef ROCKBOX
162 (void) x;
163 (void) glist;
164 (void) old_snd_rcv_flags;
165 #else /* ROCKBOX */
166 int xpos=text_xpix(&x->x_gui.x_obj, glist);
167 int ypos=text_ypix(&x->x_gui.x_obj, glist);
168 t_canvas *canvas=glist_getcanvas(glist);
170 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
171 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
172 canvas, xpos,
173 ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
174 ypos + x->x_gui.x_h, x, 0);
175 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
176 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
177 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
178 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
179 canvas, xpos, ypos,
180 xpos + IOWIDTH, ypos+1, x, 0);
181 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
182 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
183 #endif /* ROCKBOX */
186 void bng_draw_select(t_bng* x, t_glist* glist)
188 #ifdef ROCKBOX
189 (void) x;
190 (void) glist;
191 #else /* ROCKBOX */
192 t_canvas *canvas=glist_getcanvas(glist);
194 if(x->x_gui.x_fsf.x_selected)
196 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
197 sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
198 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
200 else
202 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
203 sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
204 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
206 #endif /* ROCKBOX */
209 void bng_draw(t_bng *x, t_glist *glist, int mode)
211 if(mode == IEM_GUI_DRAW_MODE_UPDATE)
212 bng_draw_update(x, glist);
213 else if(mode == IEM_GUI_DRAW_MODE_MOVE)
214 bng_draw_move(x, glist);
215 else if(mode == IEM_GUI_DRAW_MODE_NEW)
216 bng_draw_new(x, glist);
217 else if(mode == IEM_GUI_DRAW_MODE_SELECT)
218 bng_draw_select(x, glist);
219 else if(mode == IEM_GUI_DRAW_MODE_ERASE)
220 bng_draw_erase(x, glist);
221 else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
222 bng_draw_config(x, glist);
223 else if(mode >= IEM_GUI_DRAW_MODE_IO)
224 bng_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
227 /* ------------------------ bng widgetbehaviour----------------------------- */
229 static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
231 t_bng *x = (t_bng *)z;
233 *xp1 = text_xpix(&x->x_gui.x_obj, glist);
234 *yp1 = text_ypix(&x->x_gui.x_obj, glist);
235 *xp2 = *xp1 + x->x_gui.x_w;
236 *yp2 = *yp1 + x->x_gui.x_h;
239 static void bng_save(t_gobj *z, t_binbuf *b)
241 t_bng *x = (t_bng *)z;
242 int bflcol[3];
243 t_symbol *srl[3];
245 iemgui_save(&x->x_gui, srl, bflcol);
246 binbuf_addv(b, "ssiisiiiisssiiiiiii", gensym("#X"),gensym("obj"),
247 (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
248 gensym("bng"), x->x_gui.x_w,
249 x->x_flashtime_hold, x->x_flashtime_break,
250 iem_symargstoint(&x->x_gui.x_isa),
251 srl[0], srl[1], srl[2],
252 x->x_gui.x_ldx, x->x_gui.x_ldy,
253 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
254 bflcol[0], bflcol[1], bflcol[2]);
255 binbuf_addv(b, ";");
258 void bng_check_minmax(t_bng *x, int ftbreak, int fthold)
260 if(ftbreak > fthold)
262 int h;
264 h = ftbreak;
265 ftbreak = fthold;
266 fthold = h;
268 if(ftbreak < IEM_BNG_MINBREAKFLASHTIME)
269 ftbreak = IEM_BNG_MINBREAKFLASHTIME;
270 if(fthold < IEM_BNG_MINHOLDFLASHTIME)
271 fthold = IEM_BNG_MINHOLDFLASHTIME;
272 x->x_flashtime_break = ftbreak;
273 x->x_flashtime_hold = fthold;
276 static void bng_properties(t_gobj *z, t_glist *owner)
278 #ifdef ROCKBOX
279 (void) z;
280 (void) owner;
281 #else /* ROCKBOX */
282 t_bng *x = (t_bng *)z;
283 char buf[800];
284 t_symbol *srl[3];
286 iemgui_properties(&x->x_gui, srl);
287 sprintf(buf, "pdtk_iemgui_dialog %%s BANG \
288 ----------dimensions(pix):----------- %d %d size: 0 0 empty \
289 --------flash-time(ms)(ms):--------- %d intrrpt: %d hold: %d \
290 %d empty empty %d %d empty %d \
291 %s %s \
292 %s %d %d \
293 %d %d \
294 %d %d %d\n",
295 x->x_gui.x_w, IEM_GUI_MINSIZE,
296 x->x_flashtime_break, x->x_flashtime_hold, 2,/*min_max_schedule+clip*/
297 -1, x->x_gui.x_isa.x_loadinit, -1, -1,/*no linlog, no multi*/
298 srl[0]->s_name, srl[1]->s_name,
299 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
300 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
301 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
302 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
303 #endif /* ROCKBOX */
306 static void bng_set(t_bng *x)
308 if(x->x_flashed)
310 x->x_flashed = 0;
311 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
312 clock_delay(x->x_clock_brk, x->x_flashtime_break);
313 x->x_flashed = 1;
315 else
317 x->x_flashed = 1;
318 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
320 clock_delay(x->x_clock_hld, x->x_flashtime_hold);
323 static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
325 if(!x->x_gui.x_fsf.x_put_in2out)
327 x->x_gui.x_isa.x_locked = 1;
328 clock_delay(x->x_clock_lck, 2);
330 outlet_bang(x->x_gui.x_obj.ob_outlet);
331 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && x->x_gui.x_fsf.x_put_in2out)
332 pd_bang(x->x_gui.x_snd->s_thing);
335 static void bng_bout2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
337 if(!x->x_gui.x_fsf.x_put_in2out)
339 x->x_gui.x_isa.x_locked = 1;
340 clock_delay(x->x_clock_lck, 2);
342 outlet_bang(x->x_gui.x_obj.ob_outlet);
343 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
344 pd_bang(x->x_gui.x_snd->s_thing);
347 static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
349 if(!x->x_gui.x_isa.x_locked)
351 bng_set(x);
352 bng_bout1(x);
356 static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
358 if(!x->x_gui.x_isa.x_locked)
360 bng_set(x);
361 bng_bout2(x);
365 static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
367 #ifdef ROCKBOX
368 (void) s;
369 #endif
370 t_symbol *srl[3];
371 int a = (int)atom_getintarg(0, argc, argv);
372 int fthold = (int)atom_getintarg(2, argc, argv);
373 int ftbreak = (int)atom_getintarg(3, argc, argv);
374 int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
376 x->x_gui.x_w = iemgui_clip_size(a);
377 x->x_gui.x_h = x->x_gui.x_w;
378 bng_check_minmax(x, ftbreak, fthold);
379 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
380 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
381 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
382 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
385 static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
387 #ifdef ROCKBOX
388 (void) xpos;
389 (void) ypos;
390 (void) shift;
391 (void) ctrl;
392 (void) alt;
393 #endif
394 bng_set(x);
395 bng_bout2(x);
398 static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
400 #ifdef ROCKBOX
401 (void) glist;
402 (void) dbl;
403 #endif
404 if(doit)
405 bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
406 return (1);
409 static void bng_float(t_bng *x, t_floatarg f)
410 #ifdef ROCKBOX
412 (void) f;
414 bng_bang2(x);
416 #else /* ROCKBOX */
417 {bng_bang2(x);}
418 #endif /* ROCKBOX */
420 static void bng_symbol(t_bng *x, t_symbol *s)
421 #ifdef ROCKBOX
423 (void) s;
425 bng_bang2(x);
427 #else /* ROCKBOX */
428 {bng_bang2(x);}
429 #endif /* ROCKBOX */
431 static void bng_pointer(t_bng *x, t_gpointer *gp)
432 #ifdef ROCKBOX
434 (void) gp;
436 bng_bang2(x);
438 #else /* ROCKBOX */
439 {bng_bang2(x);}
440 #endif /* ROCKBOX */
442 static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av)
444 #ifdef ROCKBOX
445 (void) s;
446 (void) ac;
447 (void) av;
448 #endif /* ROCKBOX */
450 bng_bang2(x);
453 static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv)
454 #ifdef ROCKBOX
456 (void) s;
457 (void) argc;
458 (void) argv;
460 bng_bang2(x);
462 #else /* ROCKBOX */
463 {bng_bang2(x);}
464 #endif /* ROCKBOX */
466 static void bng_loadbang(t_bng *x)
468 if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
470 bng_set(x);
471 bng_bout2(x);
475 static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av)
477 #ifdef ROCKBOX
478 (void) s;
479 #endif
480 x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
481 x->x_gui.x_h = x->x_gui.x_w;
482 iemgui_size((void *)x, &x->x_gui);
485 static void bng_delta(t_bng *x, t_symbol *s, int ac, t_atom *av)
486 {iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
488 static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
489 {iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
491 static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av)
493 #ifdef ROCKBOX
494 (void) s;
495 #endif
496 bng_check_minmax(x, (int)atom_getintarg(0, ac, av),
497 (int)atom_getintarg(1, ac, av));
500 static void bng_color(t_bng *x, t_symbol *s, int ac, t_atom *av)
501 {iemgui_color((void *)x, &x->x_gui, s, ac, av);}
503 static void bng_send(t_bng *x, t_symbol *s)
504 {iemgui_send(x, &x->x_gui, s);}
506 static void bng_receive(t_bng *x, t_symbol *s)
507 {iemgui_receive(x, &x->x_gui, s);}
509 static void bng_label(t_bng *x, t_symbol *s)
510 {iemgui_label((void *)x, &x->x_gui, s);}
512 static void bng_label_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
513 {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
515 static void bng_label_font(t_bng *x, t_symbol *s, int ac, t_atom *av)
516 {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
518 static void bng_init(t_bng *x, t_floatarg f)
520 x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
523 static void bng_tick_hld(t_bng *x)
525 x->x_flashed = 0;
526 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
529 static void bng_tick_brk(t_bng *x)
531 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
534 static void bng_tick_lck(t_bng *x)
536 x->x_gui.x_isa.x_locked = 0;
539 static void *bng_new(t_symbol *s, int argc, t_atom *argv)
541 t_bng *x = (t_bng *)pd_new(bng_class);
542 int bflcol[]={-262144, -1, -1};
543 int a=IEM_GUI_DEFAULTSIZE;
544 int ldx=0, ldy=-6;
545 int fs=8;
546 int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME,
547 fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
548 #ifdef ROCKBOX
549 (void) s;
550 #else
551 char str[144];
552 #endif
554 iem_inttosymargs(&x->x_gui.x_isa, 0);
555 iem_inttofstyle(&x->x_gui.x_fsf, 0);
557 if((argc == 14)&&IS_A_FLOAT(argv,0)
558 &&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
559 &&IS_A_FLOAT(argv,3)
560 &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
561 &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
562 &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
563 &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
564 &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
565 &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13))
568 a = (int)atom_getintarg(0, argc, argv);
569 fthold = (int)atom_getintarg(1, argc, argv);
570 ftbreak = (int)atom_getintarg(2, argc, argv);
571 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(3, argc, argv));
572 iemgui_new_getnames(&x->x_gui, 4, argv);
573 ldx = (int)atom_getintarg(7, argc, argv);
574 ldy = (int)atom_getintarg(8, argc, argv);
575 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
576 fs = (int)atom_getintarg(10, argc, argv);
577 bflcol[0] = (int)atom_getintarg(11, argc, argv);
578 bflcol[1] = (int)atom_getintarg(12, argc, argv);
579 bflcol[2] = (int)atom_getintarg(13, argc, argv);
581 else iemgui_new_getnames(&x->x_gui, 4, 0);
583 x->x_gui.x_draw = (t_iemfunptr)bng_draw;
585 x->x_gui.x_fsf.x_snd_able = 1;
586 x->x_gui.x_fsf.x_rcv_able = 1;
587 x->x_flashed = 0;
588 x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
589 if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
590 x->x_gui.x_fsf.x_snd_able = 0;
591 if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
592 x->x_gui.x_fsf.x_rcv_able = 0;
593 if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
594 else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
595 else { x->x_gui.x_fsf.x_font_style = 0;
596 strcpy(x->x_gui.x_font, "courier"); }
598 if (x->x_gui.x_fsf.x_rcv_able)
599 pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
600 x->x_gui.x_ldx = ldx;
601 x->x_gui.x_ldy = ldy;
603 if(fs < 4)
604 fs = 4;
605 x->x_gui.x_fontsize = fs;
606 x->x_gui.x_w = iemgui_clip_size(a);
607 x->x_gui.x_h = x->x_gui.x_w;
608 bng_check_minmax(x, ftbreak, fthold);
609 iemgui_all_colfromload(&x->x_gui, bflcol);
610 x->x_gui.x_isa.x_locked = 0;
611 iemgui_verify_snd_ne_rcv(&x->x_gui);
612 x->x_clock_hld = clock_new(x, (t_method)bng_tick_hld);
613 x->x_clock_brk = clock_new(x, (t_method)bng_tick_brk);
614 x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck);
615 outlet_new(&x->x_gui.x_obj, &s_bang);
616 return (x);
619 static void bng_ff(t_bng *x)
621 if(x->x_gui.x_fsf.x_rcv_able)
622 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
623 clock_free(x->x_clock_lck);
624 clock_free(x->x_clock_brk);
625 clock_free(x->x_clock_hld);
626 #ifndef ROCKBOX
627 gfxstub_deleteforkey(x);
628 #endif
631 void g_bang_setup(void)
633 bng_class = class_new(gensym("bng"), (t_newmethod)bng_new,
634 (t_method)bng_ff, sizeof(t_bng), 0, A_GIMME, 0);
635 class_addbang(bng_class, bng_bang);
636 class_addfloat(bng_class, bng_float);
637 class_addsymbol(bng_class, bng_symbol);
638 class_addpointer(bng_class, bng_pointer);
639 class_addlist(bng_class, bng_list);
640 class_addanything(bng_class, bng_anything);
641 class_addmethod(bng_class, (t_method)bng_click, gensym("click"),
642 A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
643 class_addmethod(bng_class, (t_method)bng_dialog, gensym("dialog"),
644 A_GIMME, 0);
645 class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0);
646 class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0);
647 class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), A_GIMME, 0);
648 class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0);
649 class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0);
650 class_addmethod(bng_class, (t_method)bng_color, gensym("color"), A_GIMME, 0);
651 class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0);
652 class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), A_DEFSYM, 0);
653 class_addmethod(bng_class, (t_method)bng_label, gensym("label"), A_DEFSYM, 0);
654 class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0);
655 class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0);
656 class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0);
657 bng_widgetbehavior.w_getrectfn = bng_getrect;
658 bng_widgetbehavior.w_displacefn = iemgui_displace;
659 bng_widgetbehavior.w_selectfn = iemgui_select;
660 bng_widgetbehavior.w_activatefn = NULL;
661 bng_widgetbehavior.w_deletefn = iemgui_delete;
662 bng_widgetbehavior.w_visfn = iemgui_vis;
663 bng_widgetbehavior.w_clickfn = bng_newclick;
664 class_setwidget(bng_class, &bng_widgetbehavior);
665 class_sethelpsymbol(bng_class, gensym("bng"));
666 class_setsavefn(bng_class, bng_save);
667 class_setpropertiesfn(bng_class, bng_properties);