Desktop/pd-0.40-0test07/src/g_bang.c

Go to the documentation of this file.
00001 /* Copyright (c) 1997-1999 Miller Puckette.
00002  * For information on usage and redistribution, and for a DISCLAIMER OF ALL
00003  * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
00004 
00005 /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
00006 /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
00007 
00008 
00009 #include <stdlib.h>
00010 #include <string.h>
00011 #include <stdio.h>
00012 #include <ctype.h>
00013 #include "m_pd.h"
00014 #include "g_canvas.h"
00015 #include "t_tk.h"
00016 #include "g_all_guis.h"
00017 #include <math.h>
00018 
00019 #ifdef MSW
00020 #include <io.h>
00021 #else
00022 #include <unistd.h>
00023 #endif
00024 
00025 
00026 /* --------------- bng     gui-bang ------------------------- */
00027 
00028 t_widgetbehavior bng_widgetbehavior;
00029 static t_class *bng_class;
00030 
00031 /*  widget helper functions  */
00032 
00033 
00034 void bng_draw_update(t_bng *x, t_glist *glist)
00035 {
00036     if(glist_isvisible(glist))
00037     {
00038         sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", glist_getcanvas(glist), x,
00039                  x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
00040     }
00041 }
00042 
00043 void bng_draw_new(t_bng *x, t_glist *glist)
00044 {
00045     int xpos=text_xpix(&x->x_gui.x_obj, glist);
00046     int ypos=text_ypix(&x->x_gui.x_obj, glist);
00047     t_canvas *canvas=glist_getcanvas(glist);
00048 
00049     sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n",
00050              canvas, xpos, ypos,
00051              xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
00052              x->x_gui.x_bcol, x);
00053     sys_vgui(".x%lx.c create oval %d %d %d %d -fill #%6.6x -tags %lxBUT\n",
00054              canvas, xpos+1, ypos+1,
00055              xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1,
00056              x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
00057     sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
00058              -font {%s %d bold} -fill #%6.6x -tags %lxLABEL\n",
00059              canvas, xpos+x->x_gui.x_ldx,
00060              ypos+x->x_gui.x_ldy,
00061              strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
00062              x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
00063     if(!x->x_gui.x_fsf.x_snd_able)
00064         sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
00065              canvas, xpos,
00066              ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
00067              ypos + x->x_gui.x_h, x, 0);
00068     if(!x->x_gui.x_fsf.x_rcv_able)
00069         sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
00070              canvas, xpos, ypos,
00071              xpos + IOWIDTH, ypos+1, x, 0);
00072 }
00073 
00074 void bng_draw_move(t_bng *x, t_glist *glist)
00075 {
00076     int xpos=text_xpix(&x->x_gui.x_obj, glist);
00077     int ypos=text_ypix(&x->x_gui.x_obj, glist);
00078     t_canvas *canvas=glist_getcanvas(glist);
00079 
00080     sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
00081              canvas, x, xpos, ypos,
00082              xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
00083     sys_vgui(".x%lx.c coords %lxBUT %d %d %d %d\n",
00084              canvas, x, xpos+1,ypos+1,
00085              xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1);
00086     sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x,
00087              x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
00088     sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
00089              canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
00090     if(!x->x_gui.x_fsf.x_snd_able)
00091         sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
00092              canvas, x, 0, xpos,
00093              ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
00094              ypos + x->x_gui.x_h);
00095     if(!x->x_gui.x_fsf.x_rcv_able)
00096         sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
00097              canvas, x, 0, xpos, ypos,
00098              xpos + IOWIDTH, ypos+1);
00099 }
00100 
00101 void bng_draw_erase(t_bng* x, t_glist* glist)
00102 {
00103     t_canvas *canvas=glist_getcanvas(glist);
00104 
00105     sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
00106     sys_vgui(".x%lx.c delete %lxBUT\n", canvas, x);
00107     sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
00108     if(!x->x_gui.x_fsf.x_snd_able)
00109         sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
00110     if(!x->x_gui.x_fsf.x_rcv_able)
00111         sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
00112 }
00113 
00114 void bng_draw_config(t_bng* x, t_glist* glist)
00115 {
00116     t_canvas *canvas=glist_getcanvas(glist);
00117 
00118     sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
00119              canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
00120              x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
00121              strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
00122     sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
00123     sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x,
00124              x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
00125 }
00126 
00127 void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
00128 {
00129     int xpos=text_xpix(&x->x_gui.x_obj, glist);
00130     int ypos=text_ypix(&x->x_gui.x_obj, glist);
00131     t_canvas *canvas=glist_getcanvas(glist);
00132 
00133     if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
00134         sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
00135              canvas, xpos,
00136              ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
00137              ypos + x->x_gui.x_h, x, 0);
00138     if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
00139         sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
00140     if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
00141         sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
00142              canvas, xpos, ypos,
00143              xpos + IOWIDTH, ypos+1, x, 0);
00144     if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
00145         sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
00146 }
00147 
00148 void bng_draw_select(t_bng* x, t_glist* glist)
00149 {
00150     t_canvas *canvas=glist_getcanvas(glist);
00151 
00152     if(x->x_gui.x_fsf.x_selected)
00153     {
00154         sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
00155         sys_vgui(".x%lx.c itemconfigure %lxBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
00156         sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
00157     }
00158     else
00159     {
00160         sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
00161         sys_vgui(".x%lx.c itemconfigure %lxBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
00162         sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
00163     }
00164 }
00165 
00166 void bng_draw(t_bng *x, t_glist *glist, int mode)
00167 {
00168     if(mode == IEM_GUI_DRAW_MODE_UPDATE)
00169         bng_draw_update(x, glist);
00170     else if(mode == IEM_GUI_DRAW_MODE_MOVE)
00171         bng_draw_move(x, glist);
00172     else if(mode == IEM_GUI_DRAW_MODE_NEW)
00173         bng_draw_new(x, glist);
00174     else if(mode == IEM_GUI_DRAW_MODE_SELECT)
00175         bng_draw_select(x, glist);
00176     else if(mode == IEM_GUI_DRAW_MODE_ERASE)
00177         bng_draw_erase(x, glist);
00178     else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
00179         bng_draw_config(x, glist);
00180     else if(mode >= IEM_GUI_DRAW_MODE_IO)
00181         bng_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
00182 }
00183 
00184 /* ------------------------ bng widgetbehaviour----------------------------- */
00185 
00186 static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
00187 {
00188     t_bng *x = (t_bng *)z;
00189 
00190     *xp1 = text_xpix(&x->x_gui.x_obj, glist);
00191     *yp1 = text_ypix(&x->x_gui.x_obj, glist);
00192     *xp2 = *xp1 + x->x_gui.x_w;
00193     *yp2 = *yp1 + x->x_gui.x_h;
00194 }
00195 
00196 static void bng_save(t_gobj *z, t_binbuf *b)
00197 {
00198     t_bng *x = (t_bng *)z;
00199     int bflcol[3];
00200     t_symbol *srl[3];
00201 
00202     iemgui_save(&x->x_gui, srl, bflcol);
00203     binbuf_addv(b, "ssiisiiiisssiiiiiii", gensym("#X"),gensym("obj"),
00204                 (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
00205                 gensym("bng"), x->x_gui.x_w,
00206                 x->x_flashtime_hold, x->x_flashtime_break,
00207                 iem_symargstoint(&x->x_gui.x_isa),
00208                 srl[0], srl[1], srl[2],
00209                 x->x_gui.x_ldx, x->x_gui.x_ldy,
00210                 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
00211                 bflcol[0], bflcol[1], bflcol[2]);
00212     binbuf_addv(b, ";");
00213 }
00214 
00215 void bng_check_minmax(t_bng *x, int ftbreak, int fthold)
00216 {
00217     if(ftbreak > fthold)
00218     {
00219         int h;
00220 
00221         h = ftbreak;
00222         ftbreak = fthold;
00223         fthold = h;
00224     }
00225     if(ftbreak < IEM_BNG_MINBREAKFLASHTIME)
00226         ftbreak = IEM_BNG_MINBREAKFLASHTIME;
00227     if(fthold < IEM_BNG_MINHOLDFLASHTIME)
00228         fthold = IEM_BNG_MINHOLDFLASHTIME;
00229     x->x_flashtime_break = ftbreak;
00230     x->x_flashtime_hold = fthold;
00231 }
00232 
00233 static void bng_properties(t_gobj *z, t_glist *owner)
00234 {
00235     t_bng *x = (t_bng *)z;
00236     char buf[800];
00237     t_symbol *srl[3];
00238 
00239     iemgui_properties(&x->x_gui, srl);
00240     sprintf(buf, "pdtk_iemgui_dialog %%s BANG \
00241             ----------dimensions(pix):----------- %d %d size: 0 0 empty \
00242             --------flash-time(ms)(ms):--------- %d intrrpt: %d hold: %d \
00243             %d empty empty %d %d empty %d \
00244             %s %s \
00245             %s %d %d \
00246             %d %d \
00247             %d %d %d\n",
00248             x->x_gui.x_w, IEM_GUI_MINSIZE,
00249             x->x_flashtime_break, x->x_flashtime_hold, 2,/*min_max_schedule+clip*/
00250             -1, x->x_gui.x_isa.x_loadinit, -1, -1,/*no linlog, no multi*/
00251             srl[0]->s_name, srl[1]->s_name,
00252             srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
00253             x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
00254             0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
00255     gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
00256 }
00257 
00258 static void bng_set(t_bng *x)
00259 {
00260     if(x->x_flashed)
00261     {
00262         x->x_flashed = 0;
00263         (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
00264         clock_delay(x->x_clock_brk, x->x_flashtime_break);
00265         x->x_flashed = 1;
00266     }
00267     else
00268     {
00269         x->x_flashed = 1;
00270         (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
00271     }
00272     clock_delay(x->x_clock_hld, x->x_flashtime_hold);
00273 }
00274 
00275 static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
00276 {
00277     if(!x->x_gui.x_fsf.x_put_in2out)
00278     {
00279         x->x_gui.x_isa.x_locked = 1;
00280         clock_delay(x->x_clock_lck, 2);
00281     }
00282     outlet_bang(x->x_gui.x_obj.ob_outlet);
00283     if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && x->x_gui.x_fsf.x_put_in2out)
00284         pd_bang(x->x_gui.x_snd->s_thing);
00285 }
00286 
00287 static void bng_bout2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
00288 {
00289     if(!x->x_gui.x_fsf.x_put_in2out)
00290     {
00291         x->x_gui.x_isa.x_locked = 1;
00292         clock_delay(x->x_clock_lck, 2);
00293     }
00294     outlet_bang(x->x_gui.x_obj.ob_outlet);
00295     if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
00296         pd_bang(x->x_gui.x_snd->s_thing);
00297 }
00298 
00299 static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
00300 {
00301     if(!x->x_gui.x_isa.x_locked)
00302     {
00303         bng_set(x);
00304         bng_bout1(x);
00305     }
00306 }
00307 
00308 static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
00309 {
00310     if(!x->x_gui.x_isa.x_locked)
00311     {
00312         bng_set(x);
00313         bng_bout2(x);
00314     }
00315 }
00316 
00317 static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
00318 {
00319     t_symbol *srl[3];
00320     int a = (int)atom_getintarg(0, argc, argv);
00321     int fthold = (int)atom_getintarg(2, argc, argv);
00322     int ftbreak = (int)atom_getintarg(3, argc, argv);
00323     int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
00324 
00325     x->x_gui.x_w = iemgui_clip_size(a);
00326     x->x_gui.x_h = x->x_gui.x_w;
00327     bng_check_minmax(x, ftbreak, fthold);
00328     (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
00329     (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
00330     (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
00331     canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
00332 }
00333 
00334 static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
00335 {
00336     bng_set(x);
00337     bng_bout2(x);
00338 }
00339 
00340 static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
00341 {
00342     if(doit)
00343         bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
00344     return (1);
00345 }
00346 
00347 static void bng_float(t_bng *x, t_floatarg f)
00348 {bng_bang2(x);}
00349 
00350 static void bng_symbol(t_bng *x, t_symbol *s)
00351 {bng_bang2(x);}
00352 
00353 static void bng_pointer(t_bng *x, t_gpointer *gp)
00354 {bng_bang2(x);}
00355 
00356 static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av)
00357 {
00358     bng_bang2(x);
00359 }
00360 
00361 static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv)
00362 {bng_bang2(x);}
00363 
00364 static void bng_loadbang(t_bng *x)
00365 {
00366     if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
00367     {
00368         bng_set(x);
00369         bng_bout2(x);
00370     }
00371 }
00372 
00373 static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av)
00374 {
00375     x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
00376     x->x_gui.x_h = x->x_gui.x_w;
00377     iemgui_size((void *)x, &x->x_gui);
00378 }
00379 
00380 static void bng_delta(t_bng *x, t_symbol *s, int ac, t_atom *av)
00381 {iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
00382 
00383 static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
00384 {iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
00385 
00386 static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av)
00387 {
00388     bng_check_minmax(x, (int)atom_getintarg(0, ac, av),
00389                      (int)atom_getintarg(1, ac, av));
00390 }
00391 
00392 static void bng_color(t_bng *x, t_symbol *s, int ac, t_atom *av)
00393 {iemgui_color((void *)x, &x->x_gui, s, ac, av);}
00394 
00395 static void bng_send(t_bng *x, t_symbol *s)
00396 {iemgui_send(x, &x->x_gui, s);}
00397 
00398 static void bng_receive(t_bng *x, t_symbol *s)
00399 {iemgui_receive(x, &x->x_gui, s);}
00400 
00401 static void bng_label(t_bng *x, t_symbol *s)
00402 {iemgui_label((void *)x, &x->x_gui, s);}
00403 
00404 static void bng_label_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
00405 {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
00406 
00407 static void bng_label_font(t_bng *x, t_symbol *s, int ac, t_atom *av)
00408 {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
00409 
00410 static void bng_init(t_bng *x, t_floatarg f)
00411 {
00412     x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
00413 }
00414 
00415 static void bng_tick_hld(t_bng *x)
00416 {
00417     x->x_flashed = 0;
00418     (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
00419 }
00420 
00421 static void bng_tick_brk(t_bng *x)
00422 {
00423     (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
00424 }
00425 
00426 static void bng_tick_lck(t_bng *x)
00427 {
00428     x->x_gui.x_isa.x_locked = 0;
00429 }
00430 
00431 static void *bng_new(t_symbol *s, int argc, t_atom *argv)
00432 {
00433     t_bng *x = (t_bng *)pd_new(bng_class);
00434     int bflcol[]={-262144, -1, -1};
00435     int a=IEM_GUI_DEFAULTSIZE;
00436     int ldx=17, ldy=7;
00437     int fs=10;
00438     int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME,
00439         fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
00440     char str[144];
00441 
00442     iem_inttosymargs(&x->x_gui.x_isa, 0);
00443     iem_inttofstyle(&x->x_gui.x_fsf, 0);
00444 
00445     if((argc == 14)&&IS_A_FLOAT(argv,0)
00446        &&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
00447        &&IS_A_FLOAT(argv,3)
00448        &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
00449        &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
00450        &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
00451        &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
00452        &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
00453        &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13))
00454     {
00455 
00456         a = (int)atom_getintarg(0, argc, argv);
00457         fthold = (int)atom_getintarg(1, argc, argv);
00458         ftbreak = (int)atom_getintarg(2, argc, argv);
00459         iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(3, argc, argv));
00460         iemgui_new_getnames(&x->x_gui, 4, argv);
00461         ldx = (int)atom_getintarg(7, argc, argv);
00462         ldy = (int)atom_getintarg(8, argc, argv);
00463         iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
00464         fs = (int)atom_getintarg(10, argc, argv);
00465         bflcol[0] = (int)atom_getintarg(11, argc, argv);
00466         bflcol[1] = (int)atom_getintarg(12, argc, argv);
00467         bflcol[2] = (int)atom_getintarg(13, argc, argv);
00468     }
00469     else iemgui_new_getnames(&x->x_gui, 4, 0);
00470 
00471     x->x_gui.x_draw = (t_iemfunptr)bng_draw;
00472 
00473     x->x_gui.x_fsf.x_snd_able = 1;
00474     x->x_gui.x_fsf.x_rcv_able = 1;
00475     x->x_flashed = 0;
00476     x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
00477     if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
00478         x->x_gui.x_fsf.x_snd_able = 0;
00479     if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
00480         x->x_gui.x_fsf.x_rcv_able = 0;
00481     if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
00482     else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
00483     else { x->x_gui.x_fsf.x_font_style = 0;
00484         strcpy(x->x_gui.x_font, "courier"); }
00485 
00486     if (x->x_gui.x_fsf.x_rcv_able)
00487         pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
00488     x->x_gui.x_ldx = ldx;
00489     x->x_gui.x_ldy = ldy;
00490 
00491     if(fs < 4)
00492         fs = 4;
00493     x->x_gui.x_fontsize = fs;
00494     x->x_gui.x_w = iemgui_clip_size(a);
00495     x->x_gui.x_h = x->x_gui.x_w;
00496     bng_check_minmax(x, ftbreak, fthold);
00497     iemgui_all_colfromload(&x->x_gui, bflcol);
00498     x->x_gui.x_isa.x_locked = 0;
00499     iemgui_verify_snd_ne_rcv(&x->x_gui);
00500     x->x_clock_hld = clock_new(x, (t_method)bng_tick_hld);
00501     x->x_clock_brk = clock_new(x, (t_method)bng_tick_brk);
00502     x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck);
00503     outlet_new(&x->x_gui.x_obj, &s_bang);
00504     return (x);
00505 }
00506 
00507 static void bng_ff(t_bng *x)
00508 {
00509     if(x->x_gui.x_fsf.x_rcv_able)
00510         pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
00511     clock_free(x->x_clock_lck);
00512     clock_free(x->x_clock_brk);
00513     clock_free(x->x_clock_hld);
00514     gfxstub_deleteforkey(x);
00515 }
00516 
00517 void g_bang_setup(void)
00518 {
00519     bng_class = class_new(gensym("bng"), (t_newmethod)bng_new,
00520                           (t_method)bng_ff, sizeof(t_bng), 0, A_GIMME, 0);
00521     class_addbang(bng_class, bng_bang);
00522     class_addfloat(bng_class, bng_float);
00523     class_addsymbol(bng_class, bng_symbol);
00524     class_addpointer(bng_class, bng_pointer);
00525     class_addlist(bng_class, bng_list);
00526     class_addanything(bng_class, bng_anything);
00527     class_addmethod(bng_class, (t_method)bng_click, gensym("click"),
00528                     A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
00529     class_addmethod(bng_class, (t_method)bng_dialog, gensym("dialog"),
00530                     A_GIMME, 0);
00531     class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0);
00532     class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0);
00533     class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), A_GIMME, 0);
00534     class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0);
00535     class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0);
00536     class_addmethod(bng_class, (t_method)bng_color, gensym("color"), A_GIMME, 0);
00537     class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0);
00538     class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), A_DEFSYM, 0);
00539     class_addmethod(bng_class, (t_method)bng_label, gensym("label"), A_DEFSYM, 0);
00540     class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0);
00541     class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0);
00542     class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0);
00543     bng_widgetbehavior.w_getrectfn = bng_getrect;
00544     bng_widgetbehavior.w_displacefn = iemgui_displace;
00545     bng_widgetbehavior.w_selectfn = iemgui_select;
00546     bng_widgetbehavior.w_activatefn = NULL;
00547     bng_widgetbehavior.w_deletefn = iemgui_delete;
00548     bng_widgetbehavior.w_visfn = iemgui_vis;
00549     bng_widgetbehavior.w_clickfn = bng_newclick;
00550     class_setwidget(bng_class, &bng_widgetbehavior);
00551     class_sethelpsymbol(bng_class, gensym("bng"));
00552     class_setsavefn(bng_class, bng_save);
00553     class_setpropertiesfn(bng_class, bng_properties);
00554 }

Generated on Sat Sep 16 02:19:20 2006 for Pure Data by  doxygen 1.4.7