aboutsummaryrefslogtreecommitdiff
path: root/externals/vanilla
diff options
context:
space:
mode:
Diffstat (limited to 'externals/vanilla')
-rw-r--r--externals/vanilla/TODO1
-rw-r--r--externals/vanilla/bng.c554
-rw-r--r--externals/vanilla/cnv.c386
-rw-r--r--externals/vanilla/hradio.c736
-rw-r--r--externals/vanilla/hsl.c655
-rw-r--r--externals/vanilla/nbx.c903
-rw-r--r--externals/vanilla/tgl.c474
-rw-r--r--externals/vanilla/vradio.c718
-rw-r--r--externals/vanilla/vslider.c630
-rw-r--r--externals/vanilla/vu.c738
10 files changed, 5776 insertions, 19 deletions
diff --git a/externals/vanilla/TODO b/externals/vanilla/TODO
index d715660b..724c6f1b 100644
--- a/externals/vanilla/TODO
+++ b/externals/vanilla/TODO
@@ -12,3 +12,4 @@
- move relevent help patches from doc/pddp to here
+- fix objects so if instantiated with vanilla/bng they retain the namespace prefix
diff --git a/externals/vanilla/bng.c b/externals/vanilla/bng.c
index e4fc5f28..cc55438e 100644
--- a/externals/vanilla/bng.c
+++ b/externals/vanilla/bng.c
@@ -1,5 +1,555 @@
-#include "../../pd/src/g_bang.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+
+/* --------------- bng gui-bang ------------------------- */
+
+t_widgetbehavior bng_widgetbehavior;
+static t_class *bng_class;
+
+/* widget helper functions */
+
+
+void bng_draw_update(t_bng *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", glist_getcanvas(glist), x,
+ x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ }
+}
+
+void bng_draw_new(t_bng *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n",
+ canvas, xpos, ypos,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create oval %d %d %d %d -fill #%6.6x -tags %lxBUT\n",
+ canvas, xpos+1, ypos+1,
+ xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1,
+ x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx,
+ ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xpos,
+ ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
+ ypos + x->x_gui.x_h, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xpos, ypos,
+ xpos + IOWIDTH, ypos+1, x, 0);
+}
+
+void bng_draw_move(t_bng *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ sys_vgui(".x%lx.c coords %lxBUT %d %d %d %d\n",
+ canvas, x, xpos+1,ypos+1,
+ xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x,
+ x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0, xpos,
+ ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
+ ypos + x->x_gui.x_h);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0, xpos, ypos,
+ xpos + IOWIDTH, ypos+1);
+}
+
+void bng_draw_erase(t_bng* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxBUT\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void bng_draw_config(t_bng* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT -fill #%6.6x\n", canvas, x,
+ x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol);
+}
+
+void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xpos,
+ ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
+ ypos + x->x_gui.x_h, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xpos, ypos,
+ xpos + IOWIDTH, ypos+1, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void bng_draw_select(t_bng* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ }
+}
+
+void bng_draw(t_bng *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ bng_draw_update(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ bng_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ bng_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ bng_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ bng_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ bng_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ bng_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ bng widgetbehaviour----------------------------- */
+
+static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_bng *x = (t_bng *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void bng_save(t_gobj *z, t_binbuf *b)
+{
+ t_bng *x = (t_bng *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiiisssiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ gensym("bng"), x->x_gui.x_w,
+ x->x_flashtime_hold, x->x_flashtime_break,
+ iem_symargstoint(&x->x_gui.x_isa),
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2]);
+ binbuf_addv(b, ";");
+}
+
+void bng_check_minmax(t_bng *x, int ftbreak, int fthold)
+{
+ if(ftbreak > fthold)
+ {
+ int h;
+
+ h = ftbreak;
+ ftbreak = fthold;
+ fthold = h;
+ }
+ if(ftbreak < IEM_BNG_MINBREAKFLASHTIME)
+ ftbreak = IEM_BNG_MINBREAKFLASHTIME;
+ if(fthold < IEM_BNG_MINHOLDFLASHTIME)
+ fthold = IEM_BNG_MINHOLDFLASHTIME;
+ x->x_flashtime_break = ftbreak;
+ x->x_flashtime_hold = fthold;
+}
+
+static void bng_properties(t_gobj *z, t_glist *owner)
+{
+ t_bng *x = (t_bng *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s |bang| \
+ ----------dimensions(pix):----------- %d %d size: 0 0 empty \
+ --------flash-time(ms)(ms):--------- %d intrrpt: %d hold: %d \
+ %d empty empty %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE,
+ x->x_flashtime_break, x->x_flashtime_hold, 2,/*min_max_schedule+clip*/
+ -1, x->x_gui.x_isa.x_loadinit, -1, -1,/*no linlog, no multi*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void bng_set(t_bng *x)
+{
+ if(x->x_flashed)
+ {
+ x->x_flashed = 0;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ clock_delay(x->x_clock_brk, x->x_flashtime_break);
+ x->x_flashed = 1;
+ }
+ else
+ {
+ x->x_flashed = 1;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+ clock_delay(x->x_clock_hld, x->x_flashtime_hold);
+}
+
+static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
+{
+ if(!x->x_gui.x_fsf.x_put_in2out)
+ {
+ x->x_gui.x_isa.x_locked = 1;
+ clock_delay(x->x_clock_lck, 2);
+ }
+ outlet_bang(x->x_gui.x_obj.ob_outlet);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && x->x_gui.x_fsf.x_put_in2out)
+ pd_bang(x->x_gui.x_snd->s_thing);
+}
+
+static void bng_bout2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
+{
+ if(!x->x_gui.x_fsf.x_put_in2out)
+ {
+ x->x_gui.x_isa.x_locked = 1;
+ clock_delay(x->x_clock_lck, 2);
+ }
+ outlet_bang(x->x_gui.x_obj.ob_outlet);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_bang(x->x_gui.x_snd->s_thing);
+}
+
+static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/
+{
+ if(!x->x_gui.x_isa.x_locked)
+ {
+ bng_set(x);
+ bng_bout1(x);
+ }
+}
+
+static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/
+{
+ if(!x->x_gui.x_isa.x_locked)
+ {
+ bng_set(x);
+ bng_bout2(x);
+ }
+}
+
+static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int a = (int)atom_getintarg(0, argc, argv);
+ int fthold = (int)atom_getintarg(2, argc, argv);
+ int ftbreak = (int)atom_getintarg(3, argc, argv);
+ int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ bng_check_minmax(x, ftbreak, fthold);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ bng_set(x);
+ bng_bout2(x);
+}
+
+static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ if(doit)
+ bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ return (1);
+}
+
+static void bng_float(t_bng *x, t_floatarg f)
+{bng_bang2(x);}
+
+static void bng_symbol(t_bng *x, t_symbol *s)
+{bng_bang2(x);}
+
+static void bng_pointer(t_bng *x, t_gpointer *gp)
+{bng_bang2(x);}
+
+static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{
+ bng_bang2(x);
+}
+
+static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv)
+{bng_bang2(x);}
+
+static void bng_loadbang(t_bng *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ {
+ bng_set(x);
+ bng_bout2(x);
+ }
+}
+
+static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void bng_delta(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{
+ bng_check_minmax(x, (int)atom_getintarg(0, ac, av),
+ (int)atom_getintarg(1, ac, av));
+}
+
+static void bng_color(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void bng_send(t_bng *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void bng_receive(t_bng *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void bng_label(t_bng *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void bng_label_pos(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void bng_label_font(t_bng *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void bng_init(t_bng *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void bng_tick_hld(t_bng *x)
+{
+ x->x_flashed = 0;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void bng_tick_brk(t_bng *x)
+{
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void bng_tick_lck(t_bng *x)
+{
+ x->x_gui.x_isa.x_locked = 0;
+}
+
+static void *bng_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_bng *x = (t_bng *)pd_new(bng_class);
+ int bflcol[]={-262144, -1, -1};
+ int a=IEM_GUI_DEFAULTSIZE;
+ int ldx=17, ldy=7;
+ int fs=10;
+ int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME,
+ fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if((argc == 14)&&IS_A_FLOAT(argv,0)
+ &&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
+ &&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
+ &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13))
+ {
+
+ a = (int)atom_getintarg(0, argc, argv);
+ fthold = (int)atom_getintarg(1, argc, argv);
+ ftbreak = (int)atom_getintarg(2, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(3, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 4, argv);
+ ldx = (int)atom_getintarg(7, argc, argv);
+ ldy = (int)atom_getintarg(8, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
+ fs = (int)atom_getintarg(10, argc, argv);
+ bflcol[0] = (int)atom_getintarg(11, argc, argv);
+ bflcol[1] = (int)atom_getintarg(12, argc, argv);
+ bflcol[2] = (int)atom_getintarg(13, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 4, 0);
+
+ x->x_gui.x_draw = (t_iemfunptr)bng_draw;
+
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_flashed = 0;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+
+ if (x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ bng_check_minmax(x, ftbreak, fthold);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ x->x_gui.x_isa.x_locked = 0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ x->x_clock_hld = clock_new(x, (t_method)bng_tick_hld);
+ x->x_clock_brk = clock_new(x, (t_method)bng_tick_brk);
+ x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck);
+ outlet_new(&x->x_gui.x_obj, &s_bang);
+ return (x);
+}
+
+static void bng_ff(t_bng *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ clock_free(x->x_clock_lck);
+ clock_free(x->x_clock_brk);
+ clock_free(x->x_clock_hld);
+ gfxstub_deleteforkey(x);
+}
+
void bng_setup(void)
{
- g_bang_setup();
+ bng_class = class_new(gensym("bng"), (t_newmethod)bng_new,
+ (t_method)bng_ff, sizeof(t_bng), 0, A_GIMME, 0);
+ class_addbang(bng_class, bng_bang);
+ class_addfloat(bng_class, bng_float);
+ class_addsymbol(bng_class, bng_symbol);
+ class_addpointer(bng_class, bng_pointer);
+ class_addlist(bng_class, bng_list);
+ class_addanything(bng_class, bng_anything);
+ class_addmethod(bng_class, (t_method)bng_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(bng_class, (t_method)bng_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0);
+ class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(bng_class, (t_method)bng_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0);
+ bng_widgetbehavior.w_getrectfn = bng_getrect;
+ bng_widgetbehavior.w_displacefn = iemgui_displace;
+ bng_widgetbehavior.w_selectfn = iemgui_select;
+ bng_widgetbehavior.w_activatefn = NULL;
+ bng_widgetbehavior.w_deletefn = iemgui_delete;
+ bng_widgetbehavior.w_visfn = iemgui_vis;
+ bng_widgetbehavior.w_clickfn = bng_newclick;
+ class_setwidget(bng_class, &bng_widgetbehavior);
+ class_sethelpsymbol(bng_class, gensym("bng"));
+ class_setsavefn(bng_class, bng_save);
+ class_setpropertiesfn(bng_class, bng_properties);
}
diff --git a/externals/vanilla/cnv.c b/externals/vanilla/cnv.c
index af815721..8b9f0e70 100644
--- a/externals/vanilla/cnv.c
+++ b/externals/vanilla/cnv.c
@@ -1,5 +1,387 @@
-#include "../../pd/src/g_mycanvas.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ---------- cnv my gui-canvas for a window ---------------- */
+
+t_widgetbehavior my_canvas_widgetbehavior;
+static t_class *my_canvas_class;
+
+/* widget helper functions */
+
+void my_canvas_draw_new(t_my_canvas *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %lxRECT\n",
+ canvas, xpos, ypos,
+ xpos + x->x_vis_w, ypos + x->x_vis_h,
+ x->x_gui.x_bcol, x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -outline #%6.6x -tags %lxBASE\n",
+ canvas, xpos, ypos,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h,
+ x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+}
+
+void my_canvas_draw_move(t_my_canvas *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c coords %lxRECT %d %d %d %d\n",
+ canvas, x, xpos, ypos, xpos + x->x_vis_w,
+ ypos + x->x_vis_h);
+ sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
+ canvas, x, xpos, ypos,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx,
+ ypos+x->x_gui.x_ldy);
+}
+
+void my_canvas_draw_erase(t_my_canvas* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxRECT\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+}
+
+void my_canvas_draw_config(t_my_canvas* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxRECT -fill #%6.6x -outline #%6.6x\n", canvas, x,
+ x->x_gui.x_bcol, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+}
+
+void my_canvas_draw_select(t_my_canvas* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+ }
+}
+
+void my_canvas_draw(t_my_canvas *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ my_canvas_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ my_canvas_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ my_canvas_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ my_canvas_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ my_canvas_draw_config(x, glist);
+}
+
+/* ------------------------ cnv widgetbehaviour----------------------------- */
+
+static void my_canvas_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_my_canvas *x = (t_my_canvas *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void my_canvas_save(t_gobj *z, t_binbuf *b)
+{
+ t_my_canvas *x = (t_my_canvas *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiisssiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ gensym("cnv"), x->x_gui.x_w, x->x_vis_w, x->x_vis_h,
+ srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[2], iem_symargstoint(&x->x_gui.x_isa));
+ binbuf_addv(b, ";");
+}
+
+static void my_canvas_properties(t_gobj *z, t_glist *owner)
+{
+ t_my_canvas *x = (t_my_canvas *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s |cnv| \
+ ------selectable_dimensions(pix):------ %d %d size: 0.0 0.0 empty \
+ ------visible_rectangle(pix)(pix):------ %d width: %d height: %d \
+ %d empty empty %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, 1,
+ x->x_vis_w, x->x_vis_h, 0,/*no_schedule*/
+ -1, -1, -1, -1,/*no linlog, no init, no multi*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, -1/*no frontcolor*/, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void my_canvas_get_pos(t_my_canvas *x)
+{
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ {
+ x->x_at[0].a_w.w_float = text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ x->x_at[1].a_w.w_float = text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+}
+
+static void my_canvas_dialog(t_my_canvas *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int a = (int)atom_getintarg(0, argc, argv);
+ int w = (int)atom_getintarg(2, argc, argv);
+ int h = (int)atom_getintarg(3, argc, argv);
+ int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+
+ x->x_gui.x_isa.x_loadinit = 0;
+ if(a < 1)
+ a = 1;
+ x->x_gui.x_w = a;
+ x->x_gui.x_h = x->x_gui.x_w;
+ if(w < 1)
+ w = 1;
+ x->x_vis_w = w;
+ if(h < 1)
+ h = 1;
+ x->x_vis_h = h;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+}
+
+static void my_canvas_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{
+ int i = (int)atom_getintarg(0, ac, av);
+
+ if(i < 1)
+ i = 1;
+ x->x_gui.x_w = i;
+ x->x_gui.x_h = i;
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void my_canvas_delta(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_canvas_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_canvas_vis_size(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{
+ int i;
+
+ i = (int)atom_getintarg(0, ac, av);
+ if(i < 1)
+ i = 1;
+ x->x_vis_w = i;
+ if(ac > 1)
+ {
+ i = (int)atom_getintarg(1, ac, av);
+ if(i < 1)
+ i = 1;
+ }
+ x->x_vis_h = i;
+ if(glist_isvisible(x->x_gui.x_glist))
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+}
+
+static void my_canvas_color(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_canvas_send(t_my_canvas *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void my_canvas_receive(t_my_canvas *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void my_canvas_label(t_my_canvas *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void my_canvas_label_pos(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_canvas_label_font(t_my_canvas *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void *my_canvas_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_my_canvas *x = (t_my_canvas *)pd_new(my_canvas_class);
+ int bflcol[]={-233017, -1, -66577};
+ int a=IEM_GUI_DEFAULTSIZE, w=100, h=60;
+ int ldx=20, ldy=12, f=2, i=0;
+ int fs=14;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if(((argc >= 10)&&(argc <= 13))
+ &&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2))
+ {
+ a = (int)atom_getintarg(0, argc, argv);
+ w = (int)atom_getintarg(1, argc, argv);
+ h = (int)atom_getintarg(2, argc, argv);
+ }
+ if((argc >= 12)&&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))&&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4)))
+ {
+ i = 2;
+ iemgui_new_getnames(&x->x_gui, 3, argv);
+ }
+ else if((argc == 11)&&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3)))
+ {
+ i = 1;
+ iemgui_new_getnames(&x->x_gui, 3, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 3, 0);
+
+ if(((argc >= 10)&&(argc <= 13))
+ &&(IS_A_SYMBOL(argv,i+3)||IS_A_FLOAT(argv,i+3))&&IS_A_FLOAT(argv,i+4)
+ &&IS_A_FLOAT(argv,i+5)&&IS_A_FLOAT(argv,i+6)
+ &&IS_A_FLOAT(argv,i+7)&&IS_A_FLOAT(argv,i+8)
+ &&IS_A_FLOAT(argv,i+9))
+ {
+ /* disastrously, the "label" sits in a different part of the
+ message. So we have to track its location separately (in
+ the slot x_labelbindex) and initialize it specially here. */
+ iemgui_new_dogetname(&x->x_gui, i+3, argv);
+ x->x_gui.x_labelbindex = i+4;
+ ldx = (int)atom_getintarg(i+4, argc, argv);
+ ldy = (int)atom_getintarg(i+5, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(i+6, argc, argv));
+ fs = (int)atom_getintarg(i+7, argc, argv);
+ bflcol[0] = (int)atom_getintarg(i+8, argc, argv);
+ bflcol[2] = (int)atom_getintarg(i+9, argc, argv);
+ }
+ if((argc == 13)&&IS_A_FLOAT(argv,i+10))
+ {
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(i+10, argc, argv));
+ }
+ x->x_gui.x_draw = (t_iemfunptr)my_canvas_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(a < 1)
+ a = 1;
+ x->x_gui.x_w = a;
+ x->x_gui.x_h = x->x_gui.x_w;
+ if(w < 1)
+ w = 1;
+ x->x_vis_w = w;
+ if(h < 1)
+ h = 1;
+ x->x_vis_h = h;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if (x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ x->x_at[0].a_type = A_FLOAT;
+ x->x_at[1].a_type = A_FLOAT;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ return (x);
+}
+
+static void my_canvas_ff(t_my_canvas *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
void cnv_setup(void)
{
- g_mycanvas_setup();
+ my_canvas_class = class_new(gensym("cnv"), (t_newmethod)my_canvas_new,
+ (t_method)my_canvas_ff, sizeof(t_my_canvas), CLASS_NOINLET, A_GIMME, 0);
+ class_addcreator((t_newmethod)my_canvas_new, gensym("my_canvas"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_dialog, gensym("dialog"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_vis_size, gensym("vis_size"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(my_canvas_class, (t_method)my_canvas_get_pos, gensym("get_pos"), 0);
+
+ my_canvas_widgetbehavior.w_getrectfn = my_canvas_getrect;
+ my_canvas_widgetbehavior.w_displacefn = iemgui_displace;
+ my_canvas_widgetbehavior.w_selectfn = iemgui_select;
+ my_canvas_widgetbehavior.w_activatefn = NULL;
+ my_canvas_widgetbehavior.w_deletefn = iemgui_delete;
+ my_canvas_widgetbehavior.w_visfn = iemgui_vis;
+ my_canvas_widgetbehavior.w_clickfn = NULL;
+ class_setwidget(my_canvas_class, &my_canvas_widgetbehavior);
+ class_sethelpsymbol(my_canvas_class, gensym("my_canvas"));
+ class_setsavefn(my_canvas_class, my_canvas_save);
+ class_setpropertiesfn(my_canvas_class, my_canvas_properties);
}
diff --git a/externals/vanilla/hradio.c b/externals/vanilla/hradio.c
index f1b99d07..8016c6b8 100644
--- a/externals/vanilla/hradio.c
+++ b/externals/vanilla/hradio.c
@@ -1,5 +1,737 @@
-#include "../../pd/src/g_hdial.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+/* name change to hradio by MSP and changed to
+put out a "float" as in sliders, toggles, etc. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ------------- hdl gui-horicontal dial ---------------------- */
+
+t_widgetbehavior hradio_widgetbehavior;
+static t_class *hradio_class, *hradio_old_class;
+
+/* widget helper functions */
+
+void hradio_draw_update(t_gobj *client, t_glist *glist)
+{
+ t_hradio *x = (t_hradio *)client;
+ if(glist_isvisible(glist))
+ {
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n",
+ canvas, x, x->x_drawn,
+ x->x_gui.x_bcol, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n",
+ canvas, x, x->x_on,
+ x->x_gui.x_fcol, x->x_gui.x_fcol);
+ x->x_drawn = x->x_on;
+ }
+}
+
+void hradio_draw_new(t_hradio *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4;
+ int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx;
+ int yy21=yy11+s4, yy22=yy12-s4;
+ int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4;
+ int xx22=xx11b+dx-s4;
+
+
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE%d\n",
+ canvas, xx11, yy11, xx11+dx, yy12,
+ x->x_gui.x_bcol, x, i);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %lxBUT%d\n",
+ canvas, xx21, yy21, xx22, yy22,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, i);
+ xx11 += dx;
+ xx21 += dx;
+ xx22 += dx;
+ x->x_drawn = x->x_on;
+ }
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xx11b, yy12-1, xx11b + IOWIDTH, yy12, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xx11b, yy11, xx11b + IOWIDTH, yy11+1, x, 0);
+
+}
+
+void hradio_draw_move(t_hradio *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i, dx=x->x_gui.x_w, s4=dx/4;
+ int yy11=text_ypix(&x->x_gui.x_obj, glist), yy12=yy11+dx;
+ int yy21=yy11+s4, yy22=yy12-s4;
+ int xx11b=text_xpix(&x->x_gui.x_obj, glist), xx11=xx11b, xx21=xx11b+s4;
+ int xx22=xx11b+dx-s4;
+
+ xx11 = xx11b;
+ xx21=xx11b+s4;
+ xx22=xx11b+dx-s4;
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n",
+ canvas, x, i, xx11, yy11, xx11+dx, yy12);
+ sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n",
+ canvas, x, i, xx21, yy21, xx22, yy22);
+ xx11 += dx;
+ xx21 += dx;
+ xx22 += dx;
+ }
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xx11b+x->x_gui.x_ldx, yy11+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0, xx11b, yy12-1, xx11b + IOWIDTH, yy12);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0, xx11b, yy11, xx11b + IOWIDTH, yy11+1);
+}
+
+void hradio_draw_erase(t_hradio* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i;
+
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c delete %lxBASE%d\n", canvas, x, i);
+ sys_vgui(".x%lx.c delete %lxBUT%d\n", canvas, x, i);
+ }
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void hradio_draw_config(t_hradio* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i;
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE%d -fill #%6.6x\n", canvas, x, i,
+ x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n", canvas, x, i,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ }
+}
+
+void hradio_draw_io(t_hradio* x, t_glist* glist, int old_snd_rcv_flags)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_w-1,
+ xpos + IOWIDTH, ypos + x->x_gui.x_w,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos, ypos,
+ xpos + IOWIDTH, ypos+1, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void hradio_draw_select(t_hradio* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i;
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE%d -outline #%6.6x\n", canvas, x, i,
+ IEM_GUI_COLOR_SELECTED);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE%d -outline #%6.6x\n", canvas, x, i,
+ IEM_GUI_COLOR_NORMAL);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x,
+ x->x_gui.x_lcol);
+ }
+}
+
+void hradio_draw(t_hradio *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ sys_queuegui(x, glist, hradio_draw_update);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ hradio_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ hradio_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ hradio_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ hradio_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ hradio_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ hradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ hdl widgetbehaviour----------------------------- */
+
+static void hradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_hradio *x = (t_hradio *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w*x->x_number;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void hradio_save(t_gobj *z, t_binbuf *b)
+{
+ t_hradio *x = (t_hradio *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class ?
+ gensym("hdl") : gensym("hradio")),
+ x->x_gui.x_w,
+ x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number,
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2], x->x_on);
+ binbuf_addv(b, ";");
+}
+
+static void hradio_properties(t_gobj *z, t_glist *owner)
+{
+ t_hradio *x = (t_hradio *)z;
+ char buf[800];
+ t_symbol *srl[3];
+ int hchange=-1;
+
+ iemgui_properties(&x->x_gui, srl);
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
+ hchange = x->x_change;
+ sprintf(buf, "pdtk_iemgui_dialog %%s |hradio| \
+ ----------dimensions(pix):----------- %d %d size: 0 0 empty \
+ empty 0.0 empty 0.0 empty %d \
+ %d new-only new&old %d %d number: %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE,
+ 0,/*no_schedule*/
+ hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number,
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void hradio_dialog(t_hradio *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int a = (int)atom_getintarg(0, argc, argv);
+ int chg = (int)atom_getintarg(4, argc, argv);
+ int num = (int)atom_getintarg(6, argc, argv);
+ int sr_flags;
+
+ if(chg != 0) chg = 1;
+ x->x_change = chg;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ if(x->x_number != num)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_number = num;
+ if(x->x_on >= x->x_number)
+ {
+ x->x_on = x->x_number - 1;
+ x->x_on_old = x->x_on;
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+ else
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+
+}
+
+static void hradio_set(t_hradio *x, t_floatarg f)
+{
+ int i=(int)f;
+ int old=x->x_on_old;
+
+ if(i < 0)
+ i = 0;
+ if(i >= x->x_number)
+ i = x->x_number-1;
+ if(x->x_on != x->x_on_old)
+ {
+ old = x->x_on_old;
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ x->x_on_old = old;
+ }
+ else
+ {
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+}
+
+static void hradio_bang(t_hradio *x)
+{
+ /* compatibility with earlier "hdial" behavior */
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
+ {
+ if((x->x_change)&&(x->x_on != x->x_on_old))
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on_old);
+ SETFLOAT(x->x_at+1, 0.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ x->x_on_old = x->x_on;
+ SETFLOAT(x->x_at, (t_float)x->x_on);
+ SETFLOAT(x->x_at+1, 1.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ else
+ {
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+}
+
+static void hradio_fout(t_hradio *x, t_floatarg f)
+{
+ int i=(int)f;
+
+ if(i < 0)
+ i = 0;
+ if(i >= x->x_number)
+ i = x->x_number-1;
+
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
+ {
+ if((x->x_change)&&(i != x->x_on_old))
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on_old);
+ SETFLOAT(x->x_at+1, 0.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ if(x->x_on != x->x_on_old)
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ x->x_on_old = x->x_on;
+ SETFLOAT(x->x_at, (t_float)x->x_on);
+ SETFLOAT(x->x_at+1, 1.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ else
+ {
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+}
+
+static void hradio_float(t_hradio *x, t_floatarg f)
+{
+ int i=(int)f;
+
+ if(i < 0)
+ i = 0;
+ if(i >= x->x_number)
+ i = x->x_number-1;
+
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == hradio_old_class)
+ {
+ /* compatibility with earlier "vdial" behavior */
+ if((x->x_change)&&(i != x->x_on_old))
+ {
+ if(x->x_gui.x_fsf.x_put_in2out)
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on_old);
+ SETFLOAT(x->x_at+1, 0.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ }
+ if(x->x_on != x->x_on_old)
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ x->x_on_old = x->x_on;
+ if(x->x_gui.x_fsf.x_put_in2out)
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on);
+ SETFLOAT(x->x_at+1, 1.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ }
+ else
+ {
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ if (x->x_gui.x_fsf.x_put_in2out)
+ {
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+ }
+}
+
+static void hradio_click(t_hradio *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ int xx = (int)xpos - (int)text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist);
+
+ hradio_fout(x, (t_float)(xx / x->x_gui.x_w));
+}
+
+static int hradio_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ if(doit)
+ hradio_click((t_hradio *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ return (1);
+}
+
+static void hradio_loadbang(t_hradio *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ hradio_bang(x);
+}
+
+static void hradio_number(t_hradio *x, t_floatarg num)
+{
+ int n=(int)num;
+
+ if(n < 1)
+ n = 1;
+ if(n > IEM_RADIO_MAX)
+ n = IEM_RADIO_MAX;
+ if(n != x->x_number)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_number = n;
+ if(x->x_on >= x->x_number)
+ x->x_on = x->x_number - 1;
+ x->x_on_old = x->x_on;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void hradio_size(t_hradio *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void hradio_delta(t_hradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void hradio_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void hradio_color(t_hradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void hradio_send(t_hradio *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void hradio_receive(t_hradio *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void hradio_label(t_hradio *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void hradio_label_pos(t_hradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void hradio_label_font(t_hradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void hradio_init(t_hradio *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void hradio_double_change(t_hradio *x)
+{x->x_change = 1;}
+
+static void hradio_single_change(t_hradio *x)
+{x->x_change = 0;}
+
+static void *hradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
+{
+ t_hradio *x = (t_hradio *)pd_new(old? hradio_old_class : hradio_class);
+ int bflcol[]={-262144, -1, -1};
+ int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
+ int ldx=0, ldy=-8, chg=1, num=8;
+ int fs=10;
+ int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
+ &&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
+ &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)&&IS_A_FLOAT(argv,14))
+ {
+ a = (int)atom_getintarg(0, argc, argv);
+ chg = (int)atom_getintarg(1, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
+ num = (int)atom_getintarg(3, argc, argv);
+ iemgui_new_getnames(&x->x_gui, 4, argv);
+ ldx = (int)atom_getintarg(7, argc, argv);
+ ldy = (int)atom_getintarg(8, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
+ fs = (int)atom_getintarg(10, argc, argv);
+ bflcol[0] = (int)atom_getintarg(11, argc, argv);
+ bflcol[1] = (int)atom_getintarg(12, argc, argv);
+ bflcol[2] = (int)atom_getintarg(13, argc, argv);
+ on = (int)atom_getintarg(14, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 4, 0);
+ x->x_gui.x_draw = (t_iemfunptr)hradio_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if(num < 1)
+ num = 1;
+ if(num > IEM_RADIO_MAX)
+ num = IEM_RADIO_MAX;
+ x->x_number = num;
+ if(on < 0)
+ on = 0;
+ if(on >= x->x_number)
+ on = x->x_number - 1;
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_on = on;
+ else
+ x->x_on = 0;
+ x->x_on_old = x->x_on;
+ x->x_change = (chg==0)?0:1;
+ if (x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ return (x);
+}
+
+static void *hradio_new(t_symbol *s, int argc, t_atom *argv)
+{
+ return (hradio_donew(s, argc, argv, 0));
+}
+
+static void *hdial_new(t_symbol *s, int argc, t_atom *argv)
+{
+ return (hradio_donew(s, argc, argv, 1));
+}
+
+static void hradio_ff(t_hradio *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
void hradio_setup(void)
{
- g_hradio_setup();
+ hradio_class = class_new(gensym("hradio"), (t_newmethod)hradio_new,
+ (t_method)hradio_ff, sizeof(t_hradio), 0, A_GIMME, 0);
+ class_addbang(hradio_class, hradio_bang);
+ class_addfloat(hradio_class, hradio_float);
+ class_addmethod(hradio_class, (t_method)hradio_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(hradio_class, (t_method)hradio_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_loadbang,
+ gensym("loadbang"), 0);
+ class_addmethod(hradio_class, (t_method)hradio_set,
+ gensym("set"), A_FLOAT, 0);
+ class_addmethod(hradio_class, (t_method)hradio_size,
+ gensym("size"), A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_color,
+ gensym("color"), A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(hradio_class, (t_method)hradio_receive,
+ gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(hradio_class, (t_method)hradio_label,
+ gensym("label"), A_DEFSYM, 0);
+ class_addmethod(hradio_class, (t_method)hradio_label_pos,
+ gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_label_font,
+ gensym("label_font"), A_GIMME, 0);
+ class_addmethod(hradio_class, (t_method)hradio_init,
+ gensym("init"), A_FLOAT, 0);
+ class_addmethod(hradio_class, (t_method)hradio_number,
+ gensym("number"), A_FLOAT, 0);
+ class_addmethod(hradio_class, (t_method)hradio_single_change,
+ gensym("single_change"), 0);
+ class_addmethod(hradio_class, (t_method)hradio_double_change,
+ gensym("double_change"), 0);
+ hradio_widgetbehavior.w_getrectfn = hradio_getrect;
+ hradio_widgetbehavior.w_displacefn = iemgui_displace;
+ hradio_widgetbehavior.w_selectfn = iemgui_select;
+ hradio_widgetbehavior.w_activatefn = NULL;
+ hradio_widgetbehavior.w_deletefn = iemgui_delete;
+ hradio_widgetbehavior.w_visfn = iemgui_vis;
+ hradio_widgetbehavior.w_clickfn = hradio_newclick;
+ class_setwidget(hradio_class, &hradio_widgetbehavior);
+ class_sethelpsymbol(hradio_class, gensym("hradio"));
+ class_setsavefn(hradio_class, hradio_save);
+ class_setpropertiesfn(hradio_class, hradio_properties);
+
+ /*obsolete version (0.34-0.35) */
+ hradio_old_class = class_new(gensym("hdl"), (t_newmethod)hdial_new,
+ (t_method)hradio_ff, sizeof(t_hradio), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)hradio_new, gensym("rdb"), A_GIMME, 0);
+ class_addcreator((t_newmethod)hradio_new, gensym("radiobut"), A_GIMME, 0);
+ class_addcreator((t_newmethod)hradio_new, gensym("radiobutton"),
+ A_GIMME, 0);
+ class_addbang(hradio_old_class, hradio_bang);
+ class_addfloat(hradio_old_class, hradio_float);
+ class_addmethod(hradio_old_class, (t_method)hradio_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_loadbang,
+ gensym("loadbang"), 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_set,
+ gensym("set"), A_FLOAT, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_size,
+ gensym("size"), A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_color,
+ gensym("color"), A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_receive,
+ gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_label,
+ gensym("label"), A_DEFSYM, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_label_pos,
+ gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_label_font,
+ gensym("label_font"), A_GIMME, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_init,
+ gensym("init"), A_FLOAT, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_number,
+ gensym("number"), A_FLOAT, 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_single_change,
+ gensym("single_change"), 0);
+ class_addmethod(hradio_old_class, (t_method)hradio_double_change,
+ gensym("double_change"), 0);
+ class_setwidget(hradio_old_class, &hradio_widgetbehavior);
+ class_sethelpsymbol(hradio_old_class, gensym("hradio"));
}
diff --git a/externals/vanilla/hsl.c b/externals/vanilla/hsl.c
index 3a1f7b81..05474a23 100644
--- a/externals/vanilla/hsl.c
+++ b/externals/vanilla/hsl.c
@@ -1,5 +1,656 @@
-#include "../../pd/src/g_hslider.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+
+/* ------------ hsl gui-horicontal slider ----------------------- */
+
+t_widgetbehavior hslider_widgetbehavior;
+static t_class *hslider_class;
+
+/* widget helper functions */
+
+static void hslider_draw_update(t_gobj *client, t_glist *glist)
+{
+ t_hslider *x = (t_hslider *)client;
+ t_canvas *canvas=glist_getcanvas(glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ if (glist_isvisible(glist))
+ {
+ int r = text_xpix(&x->x_gui.x_obj, glist) + (x->x_val + 50)/100;
+ sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n",
+ canvas, x, r, ypos+1,
+ r, ypos + x->x_gui.x_h);
+ if(x->x_val == x->x_center)
+ {
+ if(!x->x_thick)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxKNOB -width 7\n", canvas, x);
+ x->x_thick = 1;
+ }
+ }
+ else
+ {
+ if(x->x_thick)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxKNOB -width 3\n", canvas, x);
+ x->x_thick = 0;
+ }
+ }
+ }
+}
+
+static void hslider_draw_new(t_hslider *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int r = xpos + (x->x_val + 50)/100;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n",
+ canvas, xpos-3, ypos,
+ xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h,
+ x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %lxKNOB\n",
+ canvas, r, ypos+1, r,
+ ypos + x->x_gui.x_h, x->x_gui.x_fcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx,
+ ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xpos-3, ypos + x->x_gui.x_h-1,
+ xpos+4, ypos + x->x_gui.x_h, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xpos-3, ypos,
+ xpos+4, ypos+1, x, 0);
+}
+
+static void hslider_draw_move(t_hslider *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int r = xpos + (x->x_val + 50)/100;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
+ canvas, x,
+ xpos-3, ypos,
+ xpos + x->x_gui.x_w+2, ypos + x->x_gui.x_h);
+ sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n",
+ canvas, x, r, ypos+1,
+ r, ypos + x->x_gui.x_h);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos-3, ypos + x->x_gui.x_h-1,
+ xpos+4, ypos + x->x_gui.x_h);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos-3, ypos,
+ xpos+4, ypos+1);
+}
+
+static void hslider_draw_erase(t_hslider* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxKNOB\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+static void hslider_draw_config(t_hslider* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ sys_vgui(".x%lx.c itemconfigure %lxKNOB -fill #%6.6x\n", canvas, x, x->x_gui.x_fcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+}
+
+static void hslider_draw_io(t_hslider* x,t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xpos-3, ypos + x->x_gui.x_h-1,
+ xpos+4, ypos + x->x_gui.x_h, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xpos-3, ypos,
+ xpos+4, ypos+1, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+static void hslider_draw_select(t_hslider* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ }
+}
+
+void hslider_draw(t_hslider *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ sys_queuegui(x, glist, hslider_draw_update);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ hslider_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ hslider_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ hslider_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ hslider_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ hslider_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ hslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ hsl widgetbehaviour----------------------------- */
+
+
+static void hslider_getrect(t_gobj *z, t_glist *glist,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_hslider* x = (t_hslider*)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 3;
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w + 5;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void hslider_save(t_gobj *z, t_binbuf *b)
+{
+ t_hslider *x = (t_hslider *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ gensym("hsl"), x->x_gui.x_w, x->x_gui.x_h,
+ (t_float)x->x_min, (t_float)x->x_max,
+ x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2],
+ x->x_val, x->x_steady);
+ binbuf_addv(b, ";");
+}
+
+void hslider_check_width(t_hslider *x, int w)
+{
+ if(w < IEM_SL_MINSIZE)
+ w = IEM_SL_MINSIZE;
+ x->x_gui.x_w = w;
+ x->x_center = (x->x_gui.x_w-1)*50;
+ if(x->x_val > (x->x_gui.x_w*100 - 100))
+ {
+ x->x_pos = x->x_gui.x_w*100 - 100;
+ x->x_val = x->x_pos;
+ }
+ if(x->x_lin0_log1)
+ x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1);
+ else
+ x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
+}
+
+void hslider_check_minmax(t_hslider *x, double min, double max)
+{
+ if(x->x_lin0_log1)
+ {
+ if((min == 0.0)&&(max == 0.0))
+ max = 1.0;
+ if(max > 0.0)
+ {
+ if(min <= 0.0)
+ min = 0.01*max;
+ }
+ else
+ {
+ if(min > 0.0)
+ max = 0.01*min;
+ }
+ }
+ x->x_min = min;
+ x->x_max = max;
+ if(x->x_min > x->x_max) /* bugfix */
+ x->x_gui.x_isa.x_reverse = 1;
+ else
+ x->x_gui.x_isa.x_reverse = 0;
+ if(x->x_lin0_log1)
+ x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_w - 1);
+ else
+ x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
+}
+
+static void hslider_properties(t_gobj *z, t_glist *owner)
+{
+ t_hslider *x = (t_hslider *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s |hsl| \
+ --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
+ -----------output-range:----------- %g left: %g right: %g \
+ %d lin log %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_SL_MINSIZE, x->x_gui.x_h, IEM_GUI_MINSIZE,
+ x->x_min, x->x_max, 0.0,/*no_schedule*/
+ x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void hslider_set(t_hslider *x, t_floatarg f) /* bugfix */
+{
+ double g;
+
+ if(x->x_gui.x_isa.x_reverse) /* bugfix */
+ {
+ if(f > x->x_min)
+ f = x->x_min;
+ if(f < x->x_max)
+ f = x->x_max;
+ }
+ else
+ {
+ if(f > x->x_max)
+ f = x->x_max;
+ if(f < x->x_min)
+ f = x->x_min;
+ }
+ if(x->x_lin0_log1)
+ g = log(f/x->x_min)/x->x_k;
+ else
+ g = (f - x->x_min) / x->x_k;
+ x->x_val = (int)(100.0*g + 0.49999);
+ x->x_pos = x->x_val;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void hslider_bang(t_hslider *x)
+{
+ double out;
+
+ if(x->x_lin0_log1)
+ out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
+ else
+ out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
+ if((out < 1.0e-10)&&(out > -1.0e-10))
+ out = 0.0;
+ outlet_float(x->x_gui.x_obj.ob_outlet, out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, out);
+}
+
+static void hslider_dialog(t_hslider *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int w = (int)atom_getintarg(0, argc, argv);
+ int h = (int)atom_getintarg(1, argc, argv);
+ double min = (double)atom_getfloatarg(2, argc, argv);
+ double max = (double)atom_getfloatarg(3, argc, argv);
+ int lilo = (int)atom_getintarg(4, argc, argv);
+ int steady = (int)atom_getintarg(17, argc, argv);
+ int sr_flags;
+
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ if(steady)
+ x->x_steady = 1;
+ else
+ x->x_steady = 0;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ x->x_gui.x_h = iemgui_clip_size(h);
+ hslider_check_width(x, w);
+ hslider_check_minmax(x, min, max);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void hslider_motion(t_hslider *x, t_floatarg dx, t_floatarg dy)
+{
+ int old = x->x_val;
+
+ if(x->x_gui.x_fsf.x_finemoved)
+ x->x_pos += (int)dx;
+ else
+ x->x_pos += 100*(int)dx;
+ x->x_val = x->x_pos;
+ if(x->x_val > (100*x->x_gui.x_w - 100))
+ {
+ x->x_val = 100*x->x_gui.x_w - 100;
+ x->x_pos += 50;
+ x->x_pos -= x->x_pos%100;
+ }
+ if(x->x_val < 0)
+ {
+ x->x_val = 0;
+ x->x_pos -= 50;
+ x->x_pos -= x->x_pos%100;
+ }
+ if(old != x->x_val)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ hslider_bang(x);
+ }
+}
+
+static void hslider_click(t_hslider *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ if(!x->x_steady)
+ x->x_val = (int)(100.0 * (xpos - text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)));
+ if(x->x_val > (100*x->x_gui.x_w - 100))
+ x->x_val = 100*x->x_gui.x_w - 100;
+ if(x->x_val < 0)
+ x->x_val = 0;
+ x->x_pos = x->x_val;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ hslider_bang(x);
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g, (t_glistmotionfn)hslider_motion,
+ 0, xpos, ypos);
+}
+
+static int hslider_newclick(t_gobj *z, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_hslider* x = (t_hslider *)z;
+
+ if(doit)
+ {
+ hslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
+ 0, (t_floatarg)alt);
+ if(shift)
+ x->x_gui.x_fsf.x_finemoved = 1;
+ else
+ x->x_gui.x_fsf.x_finemoved = 0;
+ }
+ return (1);
+}
+
+static void hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{
+ hslider_check_width(x, (int)atom_getintarg(0, ac, av));
+ if(ac > 1)
+ x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av));
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void hslider_delta(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void hslider_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void hslider_range(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{
+ hslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
+ (double)atom_getfloatarg(1, ac, av));
+}
+
+static void hslider_color(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void hslider_send(t_hslider *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void hslider_receive(t_hslider *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void hslider_label(t_hslider *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void hslider_label_pos(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void hslider_label_font(t_hslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void hslider_log(t_hslider *x)
+{
+ x->x_lin0_log1 = 1;
+ hslider_check_minmax(x, x->x_min, x->x_max);
+}
+
+static void hslider_lin(t_hslider *x)
+{
+ x->x_lin0_log1 = 0;
+ x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_w - 1);
+}
+
+static void hslider_init(t_hslider *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void hslider_steady(t_hslider *x, t_floatarg f)
+{
+ x->x_steady = (f==0.0)?0:1;
+}
+
+static void hslider_float(t_hslider *x, t_floatarg f)
+{
+ double out;
+
+ hslider_set(x, f);
+ if(x->x_lin0_log1)
+ out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
+ else
+ out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
+ if((out < 1.0e-10)&&(out > -1.0e-10))
+ out = 0.0;
+ if(x->x_gui.x_fsf.x_put_in2out)
+ {
+ outlet_float(x->x_gui.x_obj.ob_outlet, out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, out);
+ }
+}
+
+static void hslider_loadbang(t_hslider *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ hslider_bang(x);
+ }
+}
+
+static void *hslider_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_hslider *x = (t_hslider *)pd_new(hslider_class);
+ int bflcol[]={-262144, -1, -1};
+ int w=IEM_SL_DEFAULTSIZE, h=IEM_GUI_DEFAULTSIZE;
+ int lilo=0, ldx=-2, ldy=-8, f=0, v=0, steady=1;
+ int fs=10;
+ double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
+ &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
+ &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
+ &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ min = (double)atom_getfloatarg(2, argc, argv);
+ max = (double)atom_getfloatarg(3, argc, argv);
+ lilo = (int)atom_getintarg(4, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 6, argv);
+ ldx = (int)atom_getintarg(9, argc, argv);
+ ldy = (int)atom_getintarg(10, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
+ fs = (int)atom_getintarg(12, argc, argv);
+ bflcol[0] = (int)atom_getintarg(13, argc, argv);
+ bflcol[1] = (int)atom_getintarg(14, argc, argv);
+ bflcol[2] = (int)atom_getintarg(15, argc, argv);
+ v = (int)atom_getintarg(16, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 6, 0);
+ if((argc == 18)&&IS_A_FLOAT(argv,17))
+ steady = (int)atom_getintarg(17, argc, argv);
+
+ x->x_gui.x_draw = (t_iemfunptr)hslider_draw;
+
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_val = v;
+ else
+ x->x_val = 0;
+ x->x_pos = x->x_val;
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ if(steady != 0) steady = 1;
+ x->x_steady = steady;
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_h = iemgui_clip_size(h);
+ hslider_check_width(x, w);
+ hslider_check_minmax(x, min, max);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ x->x_thick = 0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_float);
+ return (x);
+}
+
+static void hslider_free(t_hslider *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
void hsl_setup(void)
{
- g_hslider_setup();
+ hslider_class = class_new(gensym("hsl"), (t_newmethod)hslider_new,
+ (t_method)hslider_free, sizeof(t_hslider), 0, A_GIMME, 0);
+#ifndef GGEE_HSLIDER_COMPATIBLE
+ class_addcreator((t_newmethod)hslider_new, gensym("hslider"), A_GIMME, 0);
+#endif
+ class_addbang(hslider_class,hslider_bang);
+ class_addfloat(hslider_class,hslider_float);
+ class_addmethod(hslider_class, (t_method)hslider_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(hslider_class, (t_method)hslider_motion, gensym("motion"),
+ A_FLOAT, A_FLOAT, 0);
+ class_addmethod(hslider_class, (t_method)hslider_dialog, gensym("dialog"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_loadbang, gensym("loadbang"), 0);
+ class_addmethod(hslider_class, (t_method)hslider_set, gensym("set"), A_FLOAT, 0);
+ class_addmethod(hslider_class, (t_method)hslider_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_range, gensym("range"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(hslider_class, (t_method)hslider_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(hslider_class, (t_method)hslider_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(hslider_class, (t_method)hslider_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(hslider_class, (t_method)hslider_log, gensym("log"), 0);
+ class_addmethod(hslider_class, (t_method)hslider_lin, gensym("lin"), 0);
+ class_addmethod(hslider_class, (t_method)hslider_init, gensym("init"), A_FLOAT, 0);
+ class_addmethod(hslider_class, (t_method)hslider_steady, gensym("steady"), A_FLOAT, 0);
+ hslider_widgetbehavior.w_getrectfn = hslider_getrect;
+ hslider_widgetbehavior.w_displacefn = iemgui_displace;
+ hslider_widgetbehavior.w_selectfn = iemgui_select;
+ hslider_widgetbehavior.w_activatefn = NULL;
+ hslider_widgetbehavior.w_deletefn = iemgui_delete;
+ hslider_widgetbehavior.w_visfn = iemgui_vis;
+ hslider_widgetbehavior.w_clickfn = hslider_newclick;
+ class_setwidget(hslider_class, &hslider_widgetbehavior);
+ class_sethelpsymbol(hslider_class, gensym("hslider"));
+ class_setsavefn(hslider_class, hslider_save);
+ class_setpropertiesfn(hslider_class, hslider_properties);
}
diff --git a/externals/vanilla/nbx.c b/externals/vanilla/nbx.c
index e79b5573..badf189b 100644
--- a/externals/vanilla/nbx.c
+++ b/externals/vanilla/nbx.c
@@ -1,5 +1,904 @@
-#include "../../pd/src/g_numbox.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* my_numbox.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/*------------------ global varaibles -------------------------*/
+
+
+/*------------------ global functions -------------------------*/
+
+static void my_numbox_key(void *z, t_floatarg fkey);
+static void my_numbox_draw_update(t_gobj *client, t_glist *glist);
+
+/* ------------ nmx gui-my number box ----------------------- */
+
+t_widgetbehavior my_numbox_widgetbehavior;
+static t_class *my_numbox_class;
+
+/* widget helper functions */
+
+static void my_numbox_tick_reset(t_my_numbox *x)
+{
+ if(x->x_gui.x_fsf.x_change && x->x_gui.x_glist)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+}
+
+static void my_numbox_tick_wait(t_my_numbox *x)
+{
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+}
+
+void my_numbox_clip(t_my_numbox *x)
+{
+ if(x->x_val < x->x_min)
+ x->x_val = x->x_min;
+ if(x->x_val > x->x_max)
+ x->x_val = x->x_max;
+}
+
+void my_numbox_calc_fontwidth(t_my_numbox *x)
+{
+ int w, f=31;
+
+ if(x->x_gui.x_fsf.x_font_style == 1)
+ f = 27;
+ else if(x->x_gui.x_fsf.x_font_style == 2)
+ f = 25;
+
+ w = x->x_gui.x_fontsize * f * x->x_gui.x_w;
+ w /= 36;
+ x->x_numwidth = w + (x->x_gui.x_h / 2) + 4;
+}
+
+void my_numbox_ftoa(t_my_numbox *x)
+{
+ double f=x->x_val;
+ int bufsize, is_exp=0, i, idecimal;
+
+ sprintf(x->x_buf, "%g", f);
+ bufsize = strlen(x->x_buf);
+ if(bufsize >= 5)/* if it is in exponential mode */
+ {
+ i = bufsize - 4;
+ if((x->x_buf[i] == 'e') || (x->x_buf[i] == 'E'))
+ is_exp = 1;
+ }
+ if(bufsize > x->x_gui.x_w)/* if to reduce */
+ {
+ if(is_exp)
+ {
+ if(x->x_gui.x_w <= 5)
+ {
+ x->x_buf[0] = (f < 0.0 ? '-' : '+');
+ x->x_buf[1] = 0;
+ }
+ i = bufsize - 4;
+ for(idecimal=0; idecimal < i; idecimal++)
+ if(x->x_buf[idecimal] == '.')
+ break;
+ if(idecimal > (x->x_gui.x_w - 4))
+ {
+ x->x_buf[0] = (f < 0.0 ? '-' : '+');
+ x->x_buf[1] = 0;
+ }
+ else
+ {
+ int new_exp_index=x->x_gui.x_w-4, old_exp_index=bufsize-4;
+
+ for(i=0; i < 4; i++, new_exp_index++, old_exp_index++)
+ x->x_buf[new_exp_index] = x->x_buf[old_exp_index];
+ x->x_buf[x->x_gui.x_w] = 0;
+ }
+
+ }
+ else
+ {
+ for(idecimal=0; idecimal < bufsize; idecimal++)
+ if(x->x_buf[idecimal] == '.')
+ break;
+ if(idecimal > x->x_gui.x_w)
+ {
+ x->x_buf[0] = (f < 0.0 ? '-' : '+');
+ x->x_buf[1] = 0;
+ }
+ else
+ x->x_buf[x->x_gui.x_w] = 0;
+ }
+ }
+}
+
+static void my_numbox_draw_update(t_gobj *client, t_glist *glist)
+{
+ t_my_numbox *x = (t_my_numbox *)client;
+ if (glist_isvisible(glist))
+ {
+ if(x->x_gui.x_fsf.x_change)
+ {
+ if(x->x_buf[0])
+ {
+ char *cp=x->x_buf;
+ int sl = strlen(x->x_buf);
+
+ x->x_buf[sl] = '>';
+ x->x_buf[sl+1] = 0;
+ if(sl >= x->x_gui.x_w)
+ cp += sl - x->x_gui.x_w + 1;
+ sys_vgui(
+ ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s} \n",
+ glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, cp);
+ x->x_buf[sl] = 0;
+ }
+ else
+ {
+ my_numbox_ftoa(x);
+ sys_vgui(
+ ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s} \n",
+ glist_getcanvas(glist), x, IEM_GUI_COLOR_EDITED, x->x_buf);
+ x->x_buf[0] = 0;
+ }
+ }
+ else
+ {
+ my_numbox_ftoa(x);
+ sys_vgui(
+ ".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x -text {%s} \n",
+ glist_getcanvas(glist), x,
+ x->x_gui.x_fsf.x_selected?
+ IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol,
+ x->x_buf);
+ x->x_buf[0] = 0;
+ }
+ }
+}
+
+static void my_numbox_draw_new(t_my_numbox *x, t_glist *glist)
+{
+ int half=x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(
+".x%lx.c create polygon %d %d %d %d %d %d %d %d %d %d -outline #%6.6x \
+-fill #%6.6x -tags %lxBASE1\n",
+ canvas, xpos, ypos,
+ xpos + x->x_numwidth-4, ypos,
+ xpos + x->x_numwidth, ypos+4,
+ xpos + x->x_numwidth, ypos + x->x_gui.x_h,
+ xpos, ypos + x->x_gui.x_h,
+ IEM_GUI_COLOR_NORMAL, x->x_gui.x_bcol, x);
+ sys_vgui(
+ ".x%lx.c create line %d %d %d %d %d %d -fill #%6.6x -tags %lxBASE2\n",
+ canvas, xpos, ypos,
+ xpos + half, ypos + half,
+ xpos, ypos + x->x_gui.x_h,
+ x->x_gui.x_fcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ my_numbox_ftoa(x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxNUMBER\n",
+ canvas, xpos+half+2, ypos+half+d,
+ x->x_buf, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h,
+ x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1,
+ x, 0);
+}
+
+static void my_numbox_draw_move(t_my_numbox *x, t_glist *glist)
+{
+ int half = x->x_gui.x_h/2, d=1+x->x_gui.x_h/34;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c coords %lxBASE1 %d %d %d %d %d %d %d %d %d %d\n",
+ canvas, x, xpos, ypos,
+ xpos + x->x_numwidth-4, ypos,
+ xpos + x->x_numwidth, ypos+4,
+ xpos + x->x_numwidth, ypos + x->x_gui.x_h,
+ xpos, ypos + x->x_gui.x_h);
+ sys_vgui(".x%lx.c coords %lxBASE2 %d %d %d %d %d %d\n",
+ canvas, x, xpos, ypos,
+ xpos + half, ypos + half,
+ xpos, ypos + x->x_gui.x_h);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
+ sys_vgui(".x%lx.c coords %lxNUMBER %d %d\n",
+ canvas, x, xpos+half+2, ypos+half+d);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos + x->x_gui.x_h-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1);
+}
+
+static void my_numbox_draw_erase(t_my_numbox* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE1\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxBASE2\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxNUMBER\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+static void my_numbox_draw_config(t_my_numbox* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ sys_vgui(".x%lx.c itemconfigure %lxNUMBER -font {{%s} -%d %s} -fill #%6.6x \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE1 -fill #%6.6x\n", canvas,
+ x, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill #%6.6x\n", canvas,
+ x, x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_fcol);
+}
+
+static void my_numbox_draw_io(t_my_numbox* x,t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h-1,
+ xpos+IOWIDTH, ypos + x->x_gui.x_h,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos, ypos,
+ xpos+IOWIDTH, ypos+1,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+static void my_numbox_draw_select(t_my_numbox *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ if(x->x_gui.x_fsf.x_change)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ x->x_buf[0] = 0;
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxBASE1 -outline #%6.6x\n",
+ canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill #%6.6x\n",
+ canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n",
+ canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x\n",
+ canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE1 -outline #%6.6x\n",
+ canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE2 -fill #%6.6x\n",
+ canvas, x, x->x_gui.x_fcol);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n",
+ canvas, x, x->x_gui.x_lcol);
+ sys_vgui(".x%lx.c itemconfigure %lxNUMBER -fill #%6.6x\n",
+ canvas, x, x->x_gui.x_fcol);
+ }
+}
+
+void my_numbox_draw(t_my_numbox *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ sys_queuegui(x, glist, my_numbox_draw_update);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ my_numbox_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ my_numbox_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ my_numbox_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ my_numbox_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ my_numbox_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ my_numbox_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ nbx widgetbehaviour----------------------------- */
+
+
+static void my_numbox_getrect(t_gobj *z, t_glist *glist,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_my_numbox* x = (t_my_numbox*)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_numwidth;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void my_numbox_save(t_gobj *z, t_binbuf *b)
+{
+ t_my_numbox *x = (t_my_numbox *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ if(x->x_gui.x_fsf.x_change)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+ binbuf_addv(b, "ssiisiiffiisssiiiiiiifi", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ gensym("nbx"), x->x_gui.x_w, x->x_gui.x_h,
+ (t_float)x->x_min, (t_float)x->x_max,
+ x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2],
+ x->x_val, x->x_log_height);
+ binbuf_addv(b, ";");
+}
+
+int my_numbox_check_minmax(t_my_numbox *x, double min, double max)
+{
+ int ret=0;
+
+ if(x->x_lin0_log1)
+ {
+ if((min == 0.0)&&(max == 0.0))
+ max = 1.0;
+ if(max > 0.0)
+ {
+ if(min <= 0.0)
+ min = 0.01*max;
+ }
+ else
+ {
+ if(min > 0.0)
+ max = 0.01*min;
+ }
+ }
+ x->x_min = min;
+ x->x_max = max;
+ if(x->x_val < x->x_min)
+ {
+ x->x_val = x->x_min;
+ ret = 1;
+ }
+ if(x->x_val > x->x_max)
+ {
+ x->x_val = x->x_max;
+ ret = 1;
+ }
+ if(x->x_lin0_log1)
+ x->x_k = exp(log(x->x_max/x->x_min)/(double)(x->x_log_height));
+ else
+ x->x_k = 1.0;
+ return(ret);
+}
+
+static void my_numbox_properties(t_gobj *z, t_glist *owner)
+{
+ t_my_numbox *x = (t_my_numbox *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ if(x->x_gui.x_fsf.x_change)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+
+ }
+ sprintf(buf, "pdtk_iemgui_dialog %%s |nbx| \
+ -------dimensions(digits)(pix):------- %d %d width: %d %d height: \
+ -----------output-range:----------- %g min: %g max: %d \
+ %d lin log %d %d log-height: %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, 1, x->x_gui.x_h, 8,
+ x->x_min, x->x_max, 0,/*no_schedule*/
+ x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, -1,
+ x->x_log_height, /*no multi, but iem-characteristic*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol,
+ 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void my_numbox_bang(t_my_numbox *x)
+{
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_val);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_val);
+}
+
+static void my_numbox_dialog(t_my_numbox *x, t_symbol *s, int argc,
+ t_atom *argv)
+{
+ t_symbol *srl[3];
+ int w = (int)atom_getintarg(0, argc, argv);
+ int h = (int)atom_getintarg(1, argc, argv);
+ double min = (double)atom_getfloatarg(2, argc, argv);
+ double max = (double)atom_getfloatarg(3, argc, argv);
+ int lilo = (int)atom_getintarg(4, argc, argv);
+ int log_height = (int)atom_getintarg(6, argc, argv);
+ int sr_flags;
+
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ if(log_height < 10)
+ log_height = 10;
+ x->x_log_height = log_height;
+ my_numbox_calc_fontwidth(x);
+ /*if(my_numbox_check_minmax(x, min, max))
+ my_numbox_bang(x);*/
+ my_numbox_check_minmax(x, min, max);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void my_numbox_motion(t_my_numbox *x, t_floatarg dx, t_floatarg dy)
+{
+ double k2=1.0;
+
+ if(x->x_gui.x_fsf.x_finemoved)
+ k2 = 0.01;
+ if(x->x_lin0_log1)
+ x->x_val *= pow(x->x_k, -k2*dy);
+ else
+ x->x_val -= k2*dy;
+ my_numbox_clip(x);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ my_numbox_bang(x);
+ clock_unset(x->x_clock_reset);
+}
+
+static void my_numbox_click(t_my_numbox *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
+ (t_glistmotionfn)my_numbox_motion, my_numbox_key, xpos, ypos);
+}
+
+static int my_numbox_newclick(t_gobj *z, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_my_numbox* x = (t_my_numbox *)z;
+
+ if(doit)
+ {
+ my_numbox_click( x, (t_floatarg)xpix, (t_floatarg)ypix,
+ (t_floatarg)shift, 0, (t_floatarg)alt);
+ if(shift)
+ x->x_gui.x_fsf.x_finemoved = 1;
+ else
+ x->x_gui.x_fsf.x_finemoved = 0;
+ if(!x->x_gui.x_fsf.x_change)
+ {
+ clock_delay(x->x_clock_wait, 50);
+ x->x_gui.x_fsf.x_change = 1;
+ clock_delay(x->x_clock_reset, 3000);
+
+ x->x_buf[0] = 0;
+ }
+ else
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ x->x_buf[0] = 0;
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+ }
+ return (1);
+}
+
+static void my_numbox_set(t_my_numbox *x, t_floatarg f)
+{
+ x->x_val = f;
+ my_numbox_clip(x);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+}
+
+static void my_numbox_log_height(t_my_numbox *x, t_floatarg lh)
+{
+ if(lh < 10.0)
+ lh = 10.0;
+ x->x_log_height = (int)lh;
+ if(x->x_lin0_log1)
+ x->x_k = exp(log(x->x_max/x->x_min)/(double)(x->x_log_height));
+ else
+ x->x_k = 1.0;
+
+}
+
+static void my_numbox_float(t_my_numbox *x, t_floatarg f)
+{
+ my_numbox_set(x, f);
+ if(x->x_gui.x_fsf.x_put_in2out)
+ my_numbox_bang(x);
+}
+
+static void my_numbox_size(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{
+ int h, w;
+
+ w = (int)atom_getintarg(0, ac, av);
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(ac > 1)
+ {
+ h = (int)atom_getintarg(1, ac, av);
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ }
+ my_numbox_calc_fontwidth(x);
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void my_numbox_delta(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_numbox_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_numbox_range(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{
+ if(my_numbox_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
+ (double)atom_getfloatarg(1, ac, av)))
+ {
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ /*my_numbox_bang(x);*/
+ }
+}
+
+static void my_numbox_color(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_numbox_send(t_my_numbox *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void my_numbox_receive(t_my_numbox *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void my_numbox_label(t_my_numbox *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void my_numbox_label_pos(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void my_numbox_label_font(t_my_numbox *x,
+ t_symbol *s, int ac, t_atom *av)
+{
+ int f = (int)atom_getintarg(1, ac, av);
+
+ if(f < 4)
+ f = 4;
+ x->x_gui.x_fontsize = f;
+ f = (int)atom_getintarg(0, ac, av);
+ if((f < 0) || (f > 2))
+ f = 0;
+ x->x_gui.x_fsf.x_font_style = f;
+ my_numbox_calc_fontwidth(x);
+ iemgui_label_font((void *)x, &x->x_gui, s, ac, av);
+}
+
+static void my_numbox_log(t_my_numbox *x)
+{
+ x->x_lin0_log1 = 1;
+ if(my_numbox_check_minmax(x, x->x_min, x->x_max))
+ {
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ /*my_numbox_bang(x);*/
+ }
+}
+
+static void my_numbox_lin(t_my_numbox *x)
+{
+ x->x_lin0_log1 = 0;
+}
+
+static void my_numbox_init(t_my_numbox *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void my_numbox_loadbang(t_my_numbox *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ {
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ my_numbox_bang(x);
+ }
+}
+
+static void my_numbox_key(void *z, t_floatarg fkey)
+{
+ t_my_numbox *x = z;
+ char c=fkey;
+ char buf[3];
+ buf[1] = 0;
+
+ if (c == 0)
+ {
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ return;
+ }
+ if(((c>='0')&&(c<='9'))||(c=='.')||(c=='-')||
+ (c=='e')||(c=='+')||(c=='E'))
+ {
+ if(strlen(x->x_buf) < (IEMGUI_MAX_NUM_LEN-2))
+ {
+ buf[0] = c;
+ strcat(x->x_buf, buf);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+ }
+ else if((c=='\b')||(c==127))
+ {
+ int sl=strlen(x->x_buf)-1;
+
+ if(sl < 0)
+ sl = 0;
+ x->x_buf[sl] = 0;
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+ else if((c=='\n')||(c==13))
+ {
+ x->x_val = atof(x->x_buf);
+ x->x_buf[0] = 0;
+ x->x_gui.x_fsf.x_change = 0;
+ clock_unset(x->x_clock_reset);
+ my_numbox_clip(x);
+ my_numbox_bang(x);
+ sys_queuegui(x, x->x_gui.x_glist, my_numbox_draw_update);
+ }
+ clock_delay(x->x_clock_reset, 3000);
+}
+
+static void my_numbox_list(t_my_numbox *x, t_symbol *s, int ac, t_atom *av)
+{
+ if (IS_A_FLOAT(av,0))
+ {
+ my_numbox_set(x, atom_getfloatarg(0, ac, av));
+ my_numbox_bang(x);
+ }
+}
+
+static void *my_numbox_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_my_numbox *x = (t_my_numbox *)pd_new(my_numbox_class);
+ int bflcol[]={-262144, -1, -1};
+ int w=5, h=14;
+ int lilo=0, f=0, ldx=0, ldy=-8;
+ int fs=10;
+ int log_height=256;
+ double min=-1.0e+37, max=1.0e+37,v=0.0;
+ char str[144];
+
+ if((argc >= 17)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
+ &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
+ &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
+ &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ min = (double)atom_getfloatarg(2, argc, argv);
+ max = (double)atom_getfloatarg(3, argc, argv);
+ lilo = (int)atom_getintarg(4, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 6, argv);
+ ldx = (int)atom_getintarg(9, argc, argv);
+ ldy = (int)atom_getintarg(10, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
+ fs = (int)atom_getintarg(12, argc, argv);
+ bflcol[0] = (int)atom_getintarg(13, argc, argv);
+ bflcol[1] = (int)atom_getintarg(14, argc, argv);
+ bflcol[2] = (int)atom_getintarg(15, argc, argv);
+ v = atom_getfloatarg(16, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 6, 0);
+ if((argc == 18)&&IS_A_FLOAT(argv,17))
+ {
+ log_height = (int)atom_getintarg(17, argc, argv);
+ }
+ x->x_gui.x_draw = (t_iemfunptr)my_numbox_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_val = v;
+ else
+ x->x_val = 0.0;
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ if(log_height < 10)
+ log_height = 10;
+ x->x_log_height = log_height;
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if (x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ if(w < 1)
+ w = 1;
+ x->x_gui.x_w = w;
+ if(h < 8)
+ h = 8;
+ x->x_gui.x_h = h;
+ x->x_buf[0] = 0;
+ my_numbox_calc_fontwidth(x);
+ my_numbox_check_minmax(x, min, max);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ x->x_clock_reset = clock_new(x, (t_method)my_numbox_tick_reset);
+ x->x_clock_wait = clock_new(x, (t_method)my_numbox_tick_wait);
+ x->x_gui.x_fsf.x_change = 0;
+ outlet_new(&x->x_gui.x_obj, &s_float);
+ return (x);
+}
+
+static void my_numbox_free(t_my_numbox *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ clock_free(x->x_clock_reset);
+ clock_free(x->x_clock_wait);
+ gfxstub_deleteforkey(x);
+}
+
void nbx_setup(void)
{
- g_numbox_setup();
+ my_numbox_class = class_new(gensym("nbx"), (t_newmethod)my_numbox_new,
+ (t_method)my_numbox_free, sizeof(t_my_numbox), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)my_numbox_new, gensym("my_numbox"),
+ A_GIMME, 0);
+ class_addbang(my_numbox_class,my_numbox_bang);
+ class_addfloat(my_numbox_class,my_numbox_float);
+ class_addlist(my_numbox_class, my_numbox_list);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_click,
+ gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_motion,
+ gensym("motion"), A_FLOAT, A_FLOAT, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_dialog,
+ gensym("dialog"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_loadbang,
+ gensym("loadbang"), 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_set,
+ gensym("set"), A_FLOAT, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_size,
+ gensym("size"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_range,
+ gensym("range"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_color,
+ gensym("color"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_receive,
+ gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_label,
+ gensym("label"), A_DEFSYM, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_label_pos,
+ gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_label_font,
+ gensym("label_font"), A_GIMME, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_log,
+ gensym("log"), 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_lin,
+ gensym("lin"), 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_init,
+ gensym("init"), A_FLOAT, 0);
+ class_addmethod(my_numbox_class, (t_method)my_numbox_log_height,
+ gensym("log_height"), A_FLOAT, 0);
+ my_numbox_widgetbehavior.w_getrectfn = my_numbox_getrect;
+ my_numbox_widgetbehavior.w_displacefn = iemgui_displace;
+ my_numbox_widgetbehavior.w_selectfn = iemgui_select;
+ my_numbox_widgetbehavior.w_activatefn = NULL;
+ my_numbox_widgetbehavior.w_deletefn = iemgui_delete;
+ my_numbox_widgetbehavior.w_visfn = iemgui_vis;
+ my_numbox_widgetbehavior.w_clickfn = my_numbox_newclick;
+ class_setwidget(my_numbox_class, &my_numbox_widgetbehavior);
+ class_sethelpsymbol(my_numbox_class, gensym("numbox2"));
+ class_setsavefn(my_numbox_class, my_numbox_save);
+ class_setpropertiesfn(my_numbox_class, my_numbox_properties);
}
diff --git a/externals/vanilla/tgl.c b/externals/vanilla/tgl.c
index 08cf7bdf..541521d6 100644
--- a/externals/vanilla/tgl.c
+++ b/externals/vanilla/tgl.c
@@ -1,5 +1,475 @@
-#include "../../pd/src/g_toggle.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* --------------- tgl gui-toggle ------------------------- */
+
+t_widgetbehavior toggle_widgetbehavior;
+static t_class *toggle_class;
+
+/* widget helper functions */
+
+void toggle_draw_update(t_toggle *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxX1 -fill #%6.6x\n", canvas, x,
+ (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxX2 -fill #%6.6x\n", canvas, x,
+ (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ }
+}
+
+void toggle_draw_new(t_toggle *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist);
+
+ if(x->x_gui.x_w >= 30)
+ w = 2;
+ if(x->x_gui.x_w >= 60)
+ w = 3;
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n",
+ canvas, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h,
+ x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create line %d %d %d %d -width %d -fill #%6.6x -tags %lxX1\n",
+ canvas, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w, w,
+ (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create line %d %d %d %d -width %d -fill #%6.6x -tags %lxX2\n",
+ canvas, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w, w,
+ (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xx+x->x_gui.x_ldx,
+ yy+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xx, yy, xx + IOWIDTH, yy+1, x, 0);
+}
+
+void toggle_draw_move(t_toggle *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist);
+
+ if(x->x_gui.x_w >= 30)
+ w = 2;
+
+ if(x->x_gui.x_w >= 60)
+ w = 3;
+ sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
+ canvas, x, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h);
+ sys_vgui(".x%lx.c itemconfigure %lxX1 -width %d\n", canvas, x, w);
+ sys_vgui(".x%lx.c coords %lxX1 %d %d %d %d\n",
+ canvas, x, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w);
+ sys_vgui(".x%lx.c itemconfigure %lxX2 -width %d\n", canvas, x, w);
+ sys_vgui(".x%lx.c coords %lxX2 %d %d %d %d\n",
+ canvas, x, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0, xx, yy, xx + IOWIDTH, yy+1);
+}
+
+void toggle_draw_erase(t_toggle* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxX1\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxX2\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void toggle_draw_config(t_toggle* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x,
+ x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxX1 -fill #%6.6x\n", canvas, x,
+ x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxX2 -fill #%6.6x\n", canvas, x,
+ x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol);
+}
+
+void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xpos,
+ ypos + x->x_gui.x_h-1, xpos + IOWIDTH,
+ ypos + x->x_gui.x_h, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xpos, ypos,
+ xpos + IOWIDTH, ypos+1, x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void toggle_draw_select(t_toggle* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ }
+}
+
+void toggle_draw(t_toggle *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ toggle_draw_update(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ toggle_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ toggle_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ toggle_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ toggle_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ toggle_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ toggle_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ tgl widgetbehaviour----------------------------- */
+
+static void toggle_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_toggle *x = (t_toggle *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h;
+}
+
+static void toggle_save(t_gobj *z, t_binbuf *b)
+{
+ t_toggle *x = (t_toggle *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiisssiiiiiiiff", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix,
+ (int)x->x_gui.x_obj.te_ypix,
+ gensym("tgl"), x->x_gui.x_w,
+ iem_symargstoint(&x->x_gui.x_isa),
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2], x->x_on, x->x_nonzero);
+ binbuf_addv(b, ";");
+}
+
+static void toggle_properties(t_gobj *z, t_glist *owner)
+{
+ t_toggle *x = (t_toggle *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s |tgl| \
+ ----------dimensions(pix):----------- %d %d size: 0 0 empty \
+ -----------non-zero-value:----------- %g value: 0.0 empty %g \
+ -1 lin log %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE,
+ x->x_nonzero, 1.0,/*non_zero-schedule*/
+ x->x_gui.x_isa.x_loadinit, -1, -1,/*no multi*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void toggle_bang(t_toggle *x)
+{
+ x->x_on = (x->x_on==0.0)?x->x_nonzero:0.0;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+}
+
+static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int a = (int)atom_getintarg(0, argc, argv);
+ t_float nonzero = (t_float)atom_getfloatarg(2, argc, argv);
+ int sr_flags;
+
+ if(nonzero == 0.0)
+ nonzero = 1.0;
+ x->x_nonzero = nonzero;
+ if(x->x_on != 0.0)
+ x->x_on = x->x_nonzero;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{toggle_bang(x);}
+
+static int toggle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ if(doit)
+ toggle_click((t_toggle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt);
+ return (1);
+}
+
+static void toggle_set(t_toggle *x, t_floatarg f)
+{
+ x->x_on = f;
+ if(f != 0.0)
+ x->x_nonzero = f;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void toggle_float(t_toggle *x, t_floatarg f)
+{
+ toggle_set(x, f);
+ if(x->x_gui.x_fsf.x_put_in2out)
+ {
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+}
+
+static void toggle_fout(t_toggle *x, t_floatarg f)
+{
+ toggle_set(x, f);
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+}
+
+static void toggle_loadbang(t_toggle *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ toggle_fout(x, (t_float)x->x_on);
+}
+
+static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void toggle_delta(t_toggle *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void toggle_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void toggle_color(t_toggle *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void toggle_send(t_toggle *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void toggle_receive(t_toggle *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void toggle_label(t_toggle *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void toggle_label_font(t_toggle *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void toggle_label_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void toggle_init(t_toggle *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void toggle_nonzero(t_toggle *x, t_floatarg f)
+{
+ if(f != 0.0)
+ x->x_nonzero = f;
+}
+
+static void *toggle_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_toggle *x = (t_toggle *)pd_new(toggle_class);
+ int bflcol[]={-262144, -1, -1};
+ int a=IEM_GUI_DEFAULTSIZE, f=0;
+ int ldx=17, ldy=7;
+ int fs=10;
+ t_float on=0.0, nonzero=1.0;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if(((argc == 13)||(argc == 14))&&IS_A_FLOAT(argv,0)
+ &&IS_A_FLOAT(argv,1)
+ &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
+ &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,6)
+ &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)
+ &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12))
+ {
+ a = (int)atom_getintarg(0, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 2, argv);
+ ldx = (int)atom_getintarg(5, argc, argv);
+ ldy = (int)atom_getintarg(6, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(7, argc, argv));
+ fs = (int)atom_getintarg(8, argc, argv);
+ bflcol[0] = (int)atom_getintarg(9, argc, argv);
+ bflcol[1] = (int)atom_getintarg(10, argc, argv);
+ bflcol[2] = (int)atom_getintarg(11, argc, argv);
+ on = (t_float)atom_getfloatarg(12, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 2, 0);
+ if((argc == 14)&&IS_A_FLOAT(argv,13))
+ nonzero = (t_float)atom_getfloatarg(13, argc, argv);
+ x->x_gui.x_draw = (t_iemfunptr)toggle_draw;
+
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ x->x_nonzero = (nonzero!=0.0)?nonzero:1.0;
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_on = (on!=0.0)?nonzero:0.0;
+ else
+ x->x_on = 0.0;
+ if (x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_float);
+ return (x);
+}
+
+static void toggle_ff(t_toggle *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
void tgl_setup(void)
{
- g_toggle_setup();
+ toggle_class = class_new(gensym("tgl"), (t_newmethod)toggle_new,
+ (t_method)toggle_ff, sizeof(t_toggle), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)toggle_new, gensym("toggle"), A_GIMME, 0);
+ class_addbang(toggle_class, toggle_bang);
+ class_addfloat(toggle_class, toggle_float);
+ class_addmethod(toggle_class, (t_method)toggle_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(toggle_class, (t_method)toggle_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_loadbang, gensym("loadbang"), 0);
+ class_addmethod(toggle_class, (t_method)toggle_set, gensym("set"), A_FLOAT, 0);
+ class_addmethod(toggle_class, (t_method)toggle_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(toggle_class, (t_method)toggle_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(toggle_class, (t_method)toggle_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(toggle_class, (t_method)toggle_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(toggle_class, (t_method)toggle_init, gensym("init"), A_FLOAT, 0);
+ class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), A_FLOAT, 0);
+ toggle_widgetbehavior.w_getrectfn = toggle_getrect;
+ toggle_widgetbehavior.w_displacefn = iemgui_displace;
+ toggle_widgetbehavior.w_selectfn = iemgui_select;
+ toggle_widgetbehavior.w_activatefn = NULL;
+ toggle_widgetbehavior.w_deletefn = iemgui_delete;
+ toggle_widgetbehavior.w_visfn = iemgui_vis;
+ toggle_widgetbehavior.w_clickfn = toggle_newclick;
+ class_setwidget(toggle_class, &toggle_widgetbehavior);
+ class_sethelpsymbol(toggle_class, gensym("toggle"));
+ class_setsavefn(toggle_class, toggle_save);
+ class_setpropertiesfn(toggle_class, toggle_properties);
}
diff --git a/externals/vanilla/vradio.c b/externals/vanilla/vradio.c
index 9fea1c02..a0a08dbf 100644
--- a/externals/vanilla/vradio.c
+++ b/externals/vanilla/vradio.c
@@ -1,5 +1,719 @@
-#include "../../pd/src/g_vdial.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* vdial.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+
+/* name change to vradio by MSP (it's a radio button really) and changed to
+put out a "float" as in sliders, toggles, etc. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+/*------------------ global variables -------------------------*/
+
+
+/*------------------ global functions -------------------------*/
+
+
+
+
+/* ------------- vdl gui-vertical radio button ---------------------- */
+
+t_widgetbehavior vradio_widgetbehavior;
+static t_class *vradio_class, *vradio_old_class;
+
+/* widget helper functions */
+
+void vradio_draw_update(t_gobj *client, t_glist *glist)
+{
+ t_hradio *x = (t_hradio *)client;
+ if(glist_isvisible(glist))
+ {
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n",
+ canvas, x, x->x_drawn,
+ x->x_gui.x_bcol, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n",
+ canvas, x, x->x_on,
+ x->x_gui.x_fcol, x->x_gui.x_fcol);
+ x->x_drawn = x->x_on;
+ }
+}
+
+void vradio_draw_new(t_vradio *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
+ int yy11b=text_ypix(&x->x_gui.x_obj, glist);
+ int yy11=yy11b, yy12=yy11+dy;
+ int yy21=yy11+s4, yy22=yy12-s4;
+ int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy;
+ int xx21=xx11+s4, xx22=xx12-s4;
+
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE%d\n",
+ canvas, xx11, yy11, xx12, yy12,
+ x->x_gui.x_bcol, x, i);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %lxBUT%d\n",
+ canvas, xx21, yy21, xx22, yy22,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, i);
+ yy11 += dy;
+ yy12 += dy;
+ yy21 += dy;
+ yy22 += dy;
+ x->x_drawn = x->x_on;
+ }
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xx11, yy11-1, xx11 + IOWIDTH, yy11, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, 0);
+}
+
+void vradio_draw_move(t_vradio *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
+ int yy11b=text_ypix(&x->x_gui.x_obj, glist);
+ int yy11=yy11b, yy12=yy11+dy;
+ int yy21=yy11+s4, yy22=yy12-s4;
+ int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy;
+ int xx21=xx11+s4, xx22=xx12-s4;
+
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c coords %lxBASE%d %d %d %d %d\n",
+ canvas, x, i, xx11, yy11, xx12, yy12);
+ sys_vgui(".x%lx.c coords %lxBUT%d %d %d %d %d\n",
+ canvas, x, i, xx21, yy21, xx22, yy22);
+ yy11 += dy;
+ yy12 += dy;
+ yy21 += dy;
+ yy22 += dy;
+ }
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1);
+}
+
+void vradio_draw_erase(t_vradio* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i;
+
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c delete %lxBASE%d\n", canvas, x, i);
+ sys_vgui(".x%lx.c delete %lxBUT%d\n", canvas, x, i);
+ }
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void vradio_draw_config(t_vradio* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i;
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE%d -fill #%6.6x\n", canvas, x, i,
+ x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBUT%d -fill #%6.6x -outline #%6.6x\n", canvas, x, i,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
+ (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
+ }
+}
+
+void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas, xpos,
+ ypos+(x->x_number*x->x_gui.x_h)-1,
+ xpos+ IOWIDTH,
+ ypos+(x->x_number*x->x_gui.x_h), x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas, xpos, ypos,
+ xpos+ IOWIDTH, ypos+1,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+void vradio_draw_select(t_vradio* x, t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+ int n=x->x_number, i;
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE%d -outline #%6.6x\n", canvas, x, i,
+ IEM_GUI_COLOR_SELECTED);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ for(i=0; i<n; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE%d -outline #%6.6x\n", canvas, x, i,
+ IEM_GUI_COLOR_NORMAL);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x,
+ x->x_gui.x_lcol);
+ }
+}
+
+void vradio_draw(t_vradio *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ sys_queuegui(x, glist, vradio_draw_update);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ vradio_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ vradio_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ vradio_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ vradio_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ vradio_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ vradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ vdl widgetbehaviour----------------------------- */
+
+static void vradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_vradio *x = (t_vradio *)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist);
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h*x->x_number;
+}
+
+static void vradio_save(t_gobj *z, t_binbuf *b)
+{
+ t_vradio *x = (t_vradio *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix,
+ (int)x->x_gui.x_obj.te_ypix,
+ (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class ?
+ gensym("vdl") : gensym("vradio")),
+ x->x_gui.x_w,
+ x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number,
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2], x->x_on);
+ binbuf_addv(b, ";");
+}
+
+static void vradio_properties(t_gobj *z, t_glist *owner)
+{
+ t_vradio *x = (t_vradio *)z;
+ char buf[800];
+ t_symbol *srl[3];
+ int hchange=-1;
+
+ iemgui_properties(&x->x_gui, srl);
+ if(pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
+ hchange = x->x_change;
+ sprintf(buf, "pdtk_iemgui_dialog %%s |vradio| \
+ ----------dimensions(pix):----------- %d %d size: 0 0 empty \
+ empty 0.0 empty 0.0 empty %d \
+ %d new-only new&old %d %d number: %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE,
+ 0,/*no_schedule*/
+ hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number,
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int a = (int)atom_getintarg(0, argc, argv);
+ int chg = (int)atom_getintarg(4, argc, argv);
+ int num = (int)atom_getintarg(6, argc, argv);
+ int sr_flags;
+
+ if(chg != 0) chg = 1;
+ x->x_change = chg;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ if(x->x_number != num)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_number = num;
+ if(x->x_on >= x->x_number)
+ {
+ x->x_on = x->x_number - 1;
+ x->x_on_old = x->x_on;
+ }
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+ else
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}
+
+static void vradio_set(t_vradio *x, t_floatarg f)
+{
+ int i=(int)f;
+ int old;
+
+ if(i < 0)
+ i = 0;
+ if(i >= x->x_number)
+ i = x->x_number-1;
+ if(x->x_on != x->x_on_old)
+ {
+ old = x->x_on_old;
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ x->x_on_old = old;
+ }
+ else
+ {
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ }
+}
+
+static void vradio_bang(t_vradio *x)
+{
+ /* compatibility with earlier "vdial" behavior */
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
+ {
+ if((x->x_change)&&(x->x_on != x->x_on_old))
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on_old);
+ SETFLOAT(x->x_at+1, 0.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ x->x_on_old = x->x_on;
+ SETFLOAT(x->x_at, (t_float)x->x_on);
+ SETFLOAT(x->x_at+1, 1.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ else
+ {
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+}
+
+static void vradio_fout(t_vradio *x, t_floatarg f)
+{
+ int i=(int)f;
+
+ if(i < 0)
+ i = 0;
+ if(i >= x->x_number)
+ i = x->x_number-1;
+
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
+ {
+ /* compatibility with earlier "vdial" behavior */
+ if((x->x_change)&&(i != x->x_on_old))
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on_old);
+ SETFLOAT(x->x_at+1, 0.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ if(x->x_on != x->x_on_old)
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ x->x_on_old = x->x_on;
+ SETFLOAT(x->x_at, (t_float)x->x_on);
+ SETFLOAT(x->x_at+1, 1.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ else
+ {
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if (x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+}
+
+static void vradio_float(t_vradio *x, t_floatarg f)
+{
+ int i=(int)f;
+
+ if(i < 0)
+ i = 0;
+ if(i >= x->x_number)
+ i = x->x_number-1;
+
+ if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
+ {
+ /* compatibility with earlier "vdial" behavior */
+ if((x->x_change)&&(i != x->x_on_old))
+ {
+ if(x->x_gui.x_fsf.x_put_in2out)
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on_old);
+ SETFLOAT(x->x_at+1, 0.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ }
+ if(x->x_on != x->x_on_old)
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ x->x_on_old = x->x_on;
+ if(x->x_gui.x_fsf.x_put_in2out)
+ {
+ SETFLOAT(x->x_at, (t_float)x->x_on);
+ SETFLOAT(x->x_at+1, 1.0);
+ outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
+ }
+ }
+ else
+ {
+ x->x_on_old = x->x_on;
+ x->x_on = i;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ if (x->x_gui.x_fsf.x_put_in2out)
+ {
+ outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, x->x_on);
+ }
+ }
+}
+
+static void vradio_click(t_vradio *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ int yy = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
+
+ vradio_fout(x, (t_float)(yy / x->x_gui.x_h));
+}
+
+static int vradio_newclick(t_gobj *z, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ if(doit)
+ vradio_click((t_vradio *)z, (t_floatarg)xpix, (t_floatarg)ypix,
+ (t_floatarg)shift, 0, (t_floatarg)alt);
+ return (1);
+}
+
+static void vradio_loadbang(t_vradio *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ vradio_bang(x);
+}
+
+static void vradio_number(t_vradio *x, t_floatarg num)
+{
+ int n=(int)num;
+
+ if(n < 1)
+ n = 1;
+ if(n > IEM_RADIO_MAX)
+ n = IEM_RADIO_MAX;
+ if(n != x->x_number)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
+ x->x_number = n;
+ if(x->x_on >= x->x_number)
+ x->x_on = x->x_number - 1;
+ x->x_on_old = x->x_on;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
+ }
+}
+
+static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void vradio_delta(t_vradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void vradio_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void vradio_color(t_vradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void vradio_send(t_vradio *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void vradio_receive(t_vradio *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void vradio_label(t_vradio *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void vradio_label_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void vradio_label_font(t_vradio *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void vradio_init(t_vradio *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void vradio_double_change(t_vradio *x)
+{x->x_change = 1;}
+
+static void vradio_single_change(t_vradio *x)
+{x->x_change = 0;}
+
+static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
+{
+ t_vradio *x = (t_vradio *)pd_new(old? vradio_old_class : vradio_class);
+ int bflcol[]={-262144, -1, -1};
+ int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
+ int ldx=0, ldy=-8, chg=1, num=8;
+ int fs=10;
+ int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
+ char str[144];
+
+ if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
+ &&IS_A_FLOAT(argv,3)
+ &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
+ &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
+ &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)&&IS_A_FLOAT(argv,14))
+ {
+ a = (int)atom_getintarg(0, argc, argv);
+ chg = (int)atom_getintarg(1, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
+ num = (int)atom_getintarg(3, argc, argv);
+ iemgui_new_getnames(&x->x_gui, 4, argv);
+ ldx = (int)atom_getintarg(7, argc, argv);
+ ldy = (int)atom_getintarg(8, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
+ fs = (int)atom_getintarg(10, argc, argv);
+ bflcol[0] = (int)atom_getintarg(11, argc, argv);
+ bflcol[1] = (int)atom_getintarg(12, argc, argv);
+ bflcol[2] = (int)atom_getintarg(13, argc, argv);
+ on = (int)atom_getintarg(14, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 4, 0);
+ x->x_gui.x_draw = (t_iemfunptr)vradio_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
+ x->x_gui.x_fsf.x_snd_able = 0;
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if(num < 1)
+ num = 1;
+ if(num > IEM_RADIO_MAX)
+ num = IEM_RADIO_MAX;
+ x->x_number = num;
+ if(on < 0)
+ on = 0;
+ if(on >= x->x_number)
+ on = x->x_number - 1;
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_on = on;
+ else
+ x->x_on = 0;
+ x->x_on_old = x->x_on;
+ x->x_change = (chg==0)?0:1;
+ if (x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_w = iemgui_clip_size(a);
+ x->x_gui.x_h = x->x_gui.x_w;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ outlet_new(&x->x_gui.x_obj, &s_list);
+ return (x);
+}
+
+static void *vradio_new(t_symbol *s, int argc, t_atom *argv)
+{
+ return (vradio_donew(s, argc, argv, 0));
+}
+
+static void *vdial_new(t_symbol *s, int argc, t_atom *argv)
+{
+ return (vradio_donew(s, argc, argv, 1));
+}
+
+static void vradio_ff(t_vradio *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
void vradio_setup(void)
{
- g_vradio_setup();
+ vradio_class = class_new(gensym("vradio"), (t_newmethod)vradio_new,
+ (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0);
+ class_addbang(vradio_class, vradio_bang);
+ class_addfloat(vradio_class, vradio_float);
+ class_addmethod(vradio_class, (t_method)vradio_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(vradio_class, (t_method)vradio_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_loadbang,
+ gensym("loadbang"), 0);
+ class_addmethod(vradio_class, (t_method)vradio_set,
+ gensym("set"), A_FLOAT, 0);
+ class_addmethod(vradio_class, (t_method)vradio_size,
+ gensym("size"), A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_delta,
+ gensym("delta"), A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_pos,
+ gensym("pos"), A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_color,
+ gensym("color"), A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_send,
+ gensym("send"), A_DEFSYM, 0);
+ class_addmethod(vradio_class, (t_method)vradio_receive,
+ gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(vradio_class, (t_method)vradio_label,
+ gensym("label"), A_DEFSYM, 0);
+ class_addmethod(vradio_class, (t_method)vradio_label_pos,
+ gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_label_font,
+ gensym("label_font"), A_GIMME, 0);
+ class_addmethod(vradio_class, (t_method)vradio_init,
+ gensym("init"), A_FLOAT, 0);
+ class_addmethod(vradio_class, (t_method)vradio_number,
+ gensym("number"), A_FLOAT, 0);
+ class_addmethod(vradio_class, (t_method)vradio_single_change,
+ gensym("single_change"), 0);
+ class_addmethod(vradio_class, (t_method)vradio_double_change,
+ gensym("double_change"), 0);
+ vradio_widgetbehavior.w_getrectfn = vradio_getrect;
+ vradio_widgetbehavior.w_displacefn = iemgui_displace;
+ vradio_widgetbehavior.w_selectfn = iemgui_select;
+ vradio_widgetbehavior.w_activatefn = NULL;
+ vradio_widgetbehavior.w_deletefn = iemgui_delete;
+ vradio_widgetbehavior.w_visfn = iemgui_vis;
+ vradio_widgetbehavior.w_clickfn = vradio_newclick;
+ class_setwidget(vradio_class, &vradio_widgetbehavior);
+ class_sethelpsymbol(vradio_class, gensym("vradio"));
+ class_setsavefn(vradio_class, vradio_save);
+ class_setpropertiesfn(vradio_class, vradio_properties);
+
+ /* obsolete version (0.34-0.35) */
+ vradio_old_class = class_new(gensym("vdl"), (t_newmethod)vdial_new,
+ (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0);
+ class_addbang(vradio_old_class, vradio_bang);
+ class_addfloat(vradio_old_class, vradio_float);
+ class_addmethod(vradio_old_class, (t_method)vradio_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_loadbang, gensym("loadbang"), 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_set, gensym("set"), A_FLOAT, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_init, gensym("init"), A_FLOAT, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_number, gensym("number"), A_FLOAT, 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_single_change, gensym("single_change"), 0);
+ class_addmethod(vradio_old_class, (t_method)vradio_double_change, gensym("double_change"), 0);
+ class_setwidget(vradio_old_class, &vradio_widgetbehavior);
+ class_sethelpsymbol(vradio_old_class, gensym("vradio"));
}
diff --git a/externals/vanilla/vslider.c b/externals/vanilla/vslider.c
index e4486c4b..fac5d2e8 100644
--- a/externals/vanilla/vslider.c
+++ b/externals/vanilla/vslider.c
@@ -1,5 +1,629 @@
-#include "../../pd/src/g_vslider.c"
-void vslider_setup(void)
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+
+/* ------------ vsl gui-vertical slider ----------------------- */
+
+t_widgetbehavior vslider_widgetbehavior;
+static t_class *vslider_class;
+
+/* widget helper functions */
+
+static void vslider_draw_update(t_gobj *client, t_glist *glist)
{
- g_vslider_setup();
+ t_vslider *x = (t_vslider *)client;
+ if (glist_isvisible(glist))
+ {
+ int r = text_ypix(&x->x_gui.x_obj, glist) + x->x_gui.x_h - (x->x_val + 50)/100;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+
+ sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n",
+ glist_getcanvas(glist), x, xpos+1, r,
+ xpos + x->x_gui.x_w, r);
+ }
+}
+
+static void vslider_draw_new(t_vslider *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n",
+ canvas, xpos, ypos-2,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3,
+ x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %lxKNOB\n",
+ canvas, xpos+1, r,
+ xpos + x->x_gui.x_w, r, x->x_gui.x_fcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h+2,
+ xpos+7, ypos + x->x_gui.x_h+3,
+ x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos, ypos-2,
+ xpos+7, ypos-1,
+ x, 0);
+}
+
+static void vslider_draw_move(t_vslider *x, t_glist *glist)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
+ canvas, x,
+ xpos, ypos-2,
+ xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3);
+ sys_vgui(".x%lx.c coords %lxKNOB %d %d %d %d\n",
+ canvas, x, xpos+1, r,
+ xpos + x->x_gui.x_w, r);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos + x->x_gui.x_h+2,
+ xpos+7, ypos + x->x_gui.x_h+3);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos, ypos-2,
+ xpos+7, ypos-1);
+}
+
+static void vslider_draw_erase(t_vslider* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxKNOB\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+static void vslider_draw_config(t_vslider* x,t_glist* glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+ sys_vgui(".x%lx.c itemconfigure %lxKNOB -fill #%6.6x\n", canvas,
+ x, x->x_gui.x_fcol);
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas,
+ x, x->x_gui.x_bcol);
+}
+
+static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos, ypos + x->x_gui.x_h+2,
+ xpos+7, ypos + x->x_gui.x_h+3,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos, ypos-2,
+ xpos+7, ypos-1,
+ x, 0);
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+}
+
+static void vslider_draw_select(t_vslider *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ }
+}
+
+void vslider_draw(t_vslider *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_UPDATE)
+ sys_queuegui(x, glist, vslider_draw_update);
+ else if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ vslider_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ vslider_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ vslider_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ vslider_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ vslider_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ vslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ vsl widgetbehaviour----------------------------- */
+
+
+static void vslider_getrect(t_gobj *z, t_glist *glist,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_vslider* x = (t_vslider*)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist);
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
+ *xp2 = *xp1 + x->x_gui.x_w;
+ *yp2 = *yp1 + x->x_gui.x_h + 5;
+}
+
+static void vslider_save(t_gobj *z, t_binbuf *b)
+{
+ t_vslider *x = (t_vslider *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ gensym("vsl"), x->x_gui.x_w, x->x_gui.x_h,
+ (t_float)x->x_min, (t_float)x->x_max,
+ x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
+ srl[0], srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[1], bflcol[2],
+ x->x_val, x->x_steady);
+ binbuf_addv(b, ";");
+}
+
+void vslider_check_height(t_vslider *x, int h)
+{
+ if(h < IEM_SL_MINSIZE)
+ h = IEM_SL_MINSIZE;
+ x->x_gui.x_h = h;
+ if(x->x_val > (x->x_gui.x_h*100 - 100))
+ {
+ x->x_pos = x->x_gui.x_h*100 - 100;
+ x->x_val = x->x_pos;
+ }
+ if(x->x_lin0_log1)
+ x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1);
+ else
+ x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
+}
+
+void vslider_check_minmax(t_vslider *x, double min, double max)
+{
+ if(x->x_lin0_log1)
+ {
+ if((min == 0.0)&&(max == 0.0))
+ max = 1.0;
+ if(max > 0.0)
+ {
+ if(min <= 0.0)
+ min = 0.01*max;
+ }
+ else
+ {
+ if(min > 0.0)
+ max = 0.01*min;
+ }
+ }
+ x->x_min = min;
+ x->x_max = max;
+ if(x->x_min > x->x_max) /* bugfix */
+ x->x_gui.x_isa.x_reverse = 1;
+ else
+ x->x_gui.x_isa.x_reverse = 0;
+ if(x->x_lin0_log1)
+ x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1);
+ else
+ x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
+}
+
+static void vslider_properties(t_gobj *z, t_glist *owner)
+{
+ t_vslider *x = (t_vslider *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+
+ sprintf(buf, "pdtk_iemgui_dialog %%s |vsl| \
+ --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
+ -----------output-range:----------- %g bottom: %g top: %d \
+ %d lin log %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_SL_MINSIZE,
+ x->x_min, x->x_max, 0,/*no_schedule*/
+ x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/
+ srl[0]->s_name, srl[1]->s_name,
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void vslider_bang(t_vslider *x)
+{
+ double out;
+
+ if(x->x_lin0_log1)
+ out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
+ else
+ out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
+ if((out < 1.0e-10)&&(out > -1.0e-10))
+ out = 0.0;
+
+ outlet_float(x->x_gui.x_obj.ob_outlet, out);
+ if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
+ pd_float(x->x_gui.x_snd->s_thing, out);
+}
+
+static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int w = (int)atom_getintarg(0, argc, argv);
+ int h = (int)atom_getintarg(1, argc, argv);
+ double min = (double)atom_getfloatarg(2, argc, argv);
+ double max = (double)atom_getfloatarg(3, argc, argv);
+ int lilo = (int)atom_getintarg(4, argc, argv);
+ int steady = (int)atom_getintarg(17, argc, argv);
+ int sr_flags;
+
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ if(steady)
+ x->x_steady = 1;
+ else
+ x->x_steady = 0;
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ x->x_gui.x_w = iemgui_clip_size(w);
+ vslider_check_height(x, h);
+ vslider_check_minmax(x, min, max);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy)
+{
+ int old = x->x_val;
+
+ if(x->x_gui.x_fsf.x_finemoved)
+ x->x_pos -= (int)dy;
+ else
+ x->x_pos -= 100*(int)dy;
+ x->x_val = x->x_pos;
+ if(x->x_val > (100*x->x_gui.x_h - 100))
+ {
+ x->x_val = 100*x->x_gui.x_h - 100;
+ x->x_pos += 50;
+ x->x_pos -= x->x_pos%100;
+ }
+ if(x->x_val < 0)
+ {
+ x->x_val = 0;
+ x->x_pos -= 50;
+ x->x_pos -= x->x_pos%100;
+ }
+ if(old != x->x_val)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ vslider_bang(x);
+ }
+}
+
+static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos,
+ t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
+{
+ if(!x->x_steady)
+ x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos));
+ if(x->x_val > (100*x->x_gui.x_h - 100))
+ x->x_val = 100*x->x_gui.x_h - 100;
+ if(x->x_val < 0)
+ x->x_val = 0;
+ x->x_pos = x->x_val;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ vslider_bang(x);
+ glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
+ (t_glistmotionfn)vslider_motion, 0, xpos, ypos);
+}
+
+static int vslider_newclick(t_gobj *z, struct _glist *glist,
+ int xpix, int ypix, int shift, int alt, int dbl, int doit)
+{
+ t_vslider* x = (t_vslider *)z;
+
+ if(doit)
+ {
+ vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
+ 0, (t_floatarg)alt);
+ if(shift)
+ x->x_gui.x_fsf.x_finemoved = 1;
+ else
+ x->x_gui.x_fsf.x_finemoved = 0;
+ }
+ return (1);
+}
+
+static void vslider_set(t_vslider *x, t_floatarg f)
+{
+ double g;
+
+ if(x->x_gui.x_isa.x_reverse) /* bugfix */
+ {
+ if(f > x->x_min)
+ f = x->x_min;
+ if(f < x->x_max)
+ f = x->x_max;
+ }
+ else
+ {
+ if(f > x->x_max)
+ f = x->x_max;
+ if(f < x->x_min)
+ f = x->x_min;
+ }
+ if(x->x_lin0_log1)
+ g = log(f/x->x_min)/x->x_k;
+ else
+ g = (f - x->x_min) / x->x_k;
+ x->x_val = (int)(100.0*g + 0.49999);
+ x->x_pos = x->x_val;
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+}
+
+static void vslider_float(t_vslider *x, t_floatarg f)
+{
+ vslider_set(x, f);
+ if(x->x_gui.x_fsf.x_put_in2out)
+ vslider_bang(x);
+}
+
+static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
+ if(ac > 1)
+ vslider_check_height(x, (int)atom_getintarg(1, ac, av));
+ iemgui_size((void *)x, &x->x_gui);
+}
+
+static void vslider_delta(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void vslider_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{
+ vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
+ (double)atom_getfloatarg(1, ac, av));
+}
+
+static void vslider_color(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void vslider_send(t_vslider *x, t_symbol *s)
+{iemgui_send(x, &x->x_gui, s);}
+
+static void vslider_receive(t_vslider *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void vslider_label(t_vslider *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void vslider_label_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void vslider_label_font(t_vslider *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void vslider_log(t_vslider *x)
+{
+ x->x_lin0_log1 = 1;
+ vslider_check_minmax(x, x->x_min, x->x_max);
+}
+
+static void vslider_lin(t_vslider *x)
+{
+ x->x_lin0_log1 = 0;
+ x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
+}
+
+static void vslider_init(t_vslider *x, t_floatarg f)
+{
+ x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
+}
+
+static void vslider_steady(t_vslider *x, t_floatarg f)
+{
+ x->x_steady = (f==0.0)?0:1;
+}
+
+static void vslider_loadbang(t_vslider *x)
+{
+ if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
+ vslider_bang(x);
+ }
+}
+
+static void *vslider_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_vslider *x = (t_vslider *)pd_new(vslider_class);
+ int bflcol[]={-262144, -1, -1};
+ int w=IEM_GUI_DEFAULTSIZE, h=IEM_SL_DEFAULTSIZE;
+ int lilo=0, f=0, ldx=0, ldy=-9;
+ int fs=10, v=0, steady=1;
+ double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
+ &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
+ &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
+ &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
+ &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
+ &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
+ &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ min = (double)atom_getfloatarg(2, argc, argv);
+ max = (double)atom_getfloatarg(3, argc, argv);
+ lilo = (int)atom_getintarg(4, argc, argv);
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
+ iemgui_new_getnames(&x->x_gui, 6, argv);
+ ldx = (int)atom_getintarg(9, argc, argv);
+ ldy = (int)atom_getintarg(10, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
+ fs = (int)atom_getintarg(12, argc, argv);
+ bflcol[0] = (int)atom_getintarg(13, argc, argv);
+ bflcol[1] = (int)atom_getintarg(14, argc, argv);
+ bflcol[2] = (int)atom_getintarg(15, argc, argv);
+ v = (int)atom_getintarg(16, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 6, 0);
+ if((argc == 18)&&IS_A_FLOAT(argv,17))
+ steady = (int)atom_getintarg(17, argc, argv);
+ x->x_gui.x_draw = (t_iemfunptr)vslider_draw;
+ x->x_gui.x_fsf.x_snd_able = 1;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if(x->x_gui.x_isa.x_loadinit)
+ x->x_val = v;
+ else
+ x->x_val = 0;
+ x->x_pos = x->x_val;
+ if(lilo != 0) lilo = 1;
+ x->x_lin0_log1 = lilo;
+ if(steady != 0) steady = 1;
+ x->x_steady = steady;
+ if(!strcmp(x->x_gui.x_snd->s_name, "empty")) x->x_gui.x_fsf.x_snd_able = 0;
+ if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0;
+ if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_w = iemgui_clip_size(w);
+ vslider_check_height(x, h);
+ vslider_check_minmax(x, min, max);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ outlet_new(&x->x_gui.x_obj, &s_float);
+ return (x);
+}
+
+static void vslider_free(t_vslider *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
+void vsl_setup(void)
+{
+ vslider_class = class_new(gensym("vsl"), (t_newmethod)vslider_new,
+ (t_method)vslider_free, sizeof(t_vslider), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)vslider_new, gensym("vslider"), A_GIMME, 0);
+ class_addbang(vslider_class,vslider_bang);
+ class_addfloat(vslider_class,vslider_float);
+ class_addmethod(vslider_class, (t_method)vslider_click, gensym("click"),
+ A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
+ class_addmethod(vslider_class, (t_method)vslider_motion, gensym("motion"),
+ A_FLOAT, A_FLOAT, 0);
+ class_addmethod(vslider_class, (t_method)vslider_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_loadbang, gensym("loadbang"), 0);
+ class_addmethod(vslider_class, (t_method)vslider_set, gensym("set"), A_FLOAT, 0);
+ class_addmethod(vslider_class, (t_method)vslider_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_range, gensym("range"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_send, gensym("send"), A_DEFSYM, 0);
+ class_addmethod(vslider_class, (t_method)vslider_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(vslider_class, (t_method)vslider_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(vslider_class, (t_method)vslider_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_label_font, gensym("label_font"), A_GIMME, 0);
+ class_addmethod(vslider_class, (t_method)vslider_log, gensym("log"), 0);
+ class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0);
+ class_addmethod(vslider_class, (t_method)vslider_init, gensym("init"), A_FLOAT, 0);
+ class_addmethod(vslider_class, (t_method)vslider_steady, gensym("steady"), A_FLOAT, 0);
+ vslider_widgetbehavior.w_getrectfn = vslider_getrect;
+ vslider_widgetbehavior.w_displacefn = iemgui_displace;
+ vslider_widgetbehavior.w_selectfn = iemgui_select;
+ vslider_widgetbehavior.w_activatefn = NULL;
+ vslider_widgetbehavior.w_deletefn = iemgui_delete;
+ vslider_widgetbehavior.w_visfn = iemgui_vis;
+ vslider_widgetbehavior.w_clickfn = vslider_newclick;
+ class_setwidget(vslider_class, &vslider_widgetbehavior);
+ class_sethelpsymbol(vslider_class, gensym("vslider"));
+ class_setsavefn(vslider_class, vslider_save);
+ class_setpropertiesfn(vslider_class, vslider_properties);
}
diff --git a/externals/vanilla/vu.c b/externals/vanilla/vu.c
index e0c31da7..a9afd255 100644
--- a/externals/vanilla/vu.c
+++ b/externals/vanilla/vu.c
@@ -1,5 +1,739 @@
-#include "../../pd/src/g_vumeter.c"
+/* Copyright (c) 1997-1999 Miller Puckette.
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
+
+/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
+/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "m_pd.h"
+#include "g_canvas.h"
+
+#include "g_all_guis.h"
+#include <math.h>
+
+#ifdef MSW
+#include <io.h>
+#else
+#include <unistd.h>
+#endif
+
+/* ----- vu gui-peak- & rms- vu-meter-display ---------- */
+
+t_widgetbehavior vu_widgetbehavior;
+static t_class *vu_class;
+
+/* widget helper functions */
+
+static void vu_update_rms(t_vu *x, t_glist *glist)
+{
+ if(glist_isvisible(glist))
+ {
+ int w4=x->x_gui.x_w/4, off=text_ypix(&x->x_gui.x_obj, glist)-1;
+ int xpos=text_xpix(&x->x_gui.x_obj, glist), quad1=xpos+w4+1, quad3=xpos+x->x_gui.x_w-w4-1;
+
+ sys_vgui(".x%lx.c coords %lxRCOVER %d %d %d %d\n",
+ glist_getcanvas(glist), x, quad1, off, quad3,
+ off + (x->x_led_size+1)*(IEM_VU_STEPS-x->x_rms));
+ }
+}
+
+static void vu_update_peak(t_vu *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(glist_isvisible(glist))
+ {
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+
+ if(x->x_peak)
+ {
+ int i=iemgui_vu_col[x->x_peak];
+ int j=ypos + (x->x_led_size+1)*(IEM_VU_STEPS+1-x->x_peak)
+ - (x->x_led_size+1)/2;
+
+ sys_vgui(".x%lx.c coords %lxPLED %d %d %d %d\n", canvas, x,
+ xpos, j,
+ xpos+x->x_gui.x_w+1, j);
+ sys_vgui(".x%lx.c itemconfigure %lxPLED -fill #%6.6x\n", canvas, x,
+ iemgui_color_hex[i]);
+ }
+ else
+ {
+ int mid=xpos+x->x_gui.x_w/2;
+
+ sys_vgui(".x%lx.c itemconfigure %lxPLED -fill #%6.6x\n",
+ canvas, x, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c coords %lxPLED %d %d %d %d\n",
+ canvas, x, mid, ypos+20,
+ mid, ypos+20);
+ }
+ }
+}
+
+static void vu_draw_update(t_gobj *client, t_glist *glist)
+{
+ t_vu *x = (t_vu *)client;
+ if (x->x_updaterms)
+ {
+ vu_update_rms(x, glist);
+ x->x_updaterms = 0;
+ }
+ if (x->x_updatepeak)
+ {
+ vu_update_peak(x, glist);
+ x->x_updatepeak = 0;
+ }
+}
+
+static void vu_draw_new(t_vu *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int w4=x->x_gui.x_w/4, mid=xpos+x->x_gui.x_w/2,
+ quad1=xpos+w4+1;
+ int quad3=xpos+x->x_gui.x_w-w4,
+ end=xpos+x->x_gui.x_w+4;
+ int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
+ int led_col, yyy, i, k4=ypos-k3;
+
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -tags %lxBASE\n",
+ canvas, xpos-1, ypos-2,
+ xpos+x->x_gui.x_w+1,
+ ypos+x->x_gui.x_h+2, x->x_gui.x_bcol, x);
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ led_col = iemgui_vu_col[i];
+ yyy = k4 + k1*(k2-i);
+ sys_vgui(".x%lx.c create line %d %d %d %d -width %d -fill #%6.6x -tags %lxRLED%d\n",
+ canvas, quad1, yyy, quad3, yyy, x->x_led_size, iemgui_color_hex[led_col], x, i);
+ if(((i+2)&3) && (x->x_scale))
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxSCALE%d\n",
+ canvas, end, yyy+k3, iemgui_vu_scale_str[i],
+ x->x_gui.x_font, x->x_gui.x_fontsize,
+ sys_fontweight, x->x_gui.x_lcol, x, i);
+ }
+ if(x->x_scale)
+ {
+ i=IEM_VU_STEPS+1;
+ yyy = k4 + k1*(k2-i);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxSCALE%d\n",
+ canvas, end, yyy+k3, iemgui_vu_scale_str[i], x->x_gui.x_font,
+ x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x, i);
+ }
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %lxRCOVER\n",
+ canvas, quad1, ypos-1, quad3-1,
+ ypos-1 + k1*IEM_VU_STEPS, x->x_gui.x_bcol, x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create line %d %d %d %d -width %d -fill #%6.6x -tags %lxPLED\n",
+ canvas, mid, ypos+10,
+ mid, ypos+10, x->x_led_size, x->x_gui.x_bcol, x);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxLABEL\n",
+ canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_lcol, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos-1, ypos + x->x_gui.x_h+1,
+ xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
+ x, 0);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
+ xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
+ x, 1);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos-1, ypos-2,
+ xpos + IOWIDTH-1, ypos-1,
+ x, 0);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
+ xpos+x->x_gui.x_w+1, ypos-1,
+ x, 1);
+ }
+ x->x_updaterms = x->x_updatepeak = 1;
+ sys_queuegui(x, x->x_gui.x_glist, vu_draw_update);
+}
+
+
+static void vu_draw_move(t_vu *x, t_glist *glist)
+{
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ int w4=x->x_gui.x_w/4, quad1=xpos+w4+1;
+ int quad3=xpos+x->x_gui.x_w-w4,
+ end=xpos+x->x_gui.x_w+4;
+ int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
+ int yyy, i, k4=ypos-k3;
+
+ sys_vgui(".x%lx.c coords %lxBASE %d %d %d %d\n",
+ canvas, x, xpos-1, ypos-2,
+ xpos+x->x_gui.x_w+1,ypos+x->x_gui.x_h+2);
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ yyy = k4 + k1*(k2-i);
+ sys_vgui(".x%lx.c coords %lxRLED%d %d %d %d %d\n",
+ canvas, x, i, quad1, yyy, quad3, yyy);
+ if(((i+2)&3) && (x->x_scale))
+ sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n",
+ canvas, x, i, end, yyy+k3);
+ }
+ if(x->x_scale)
+ {
+ i=IEM_VU_STEPS+1;
+ yyy = k4 + k1*(k2-i);
+ sys_vgui(".x%lx.c coords %lxSCALE%d %d %d\n",
+ canvas, x, i, end, yyy+k3);
+ }
+ x->x_updaterms = x->x_updatepeak = 1;
+ sys_queuegui(x, glist, vu_draw_update);
+ sys_vgui(".x%lx.c coords %lxLABEL %d %d\n",
+ canvas, x, xpos+x->x_gui.x_ldx,
+ ypos+x->x_gui.x_ldy);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos-1, ypos + x->x_gui.x_h+1,
+ xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2);
+ sys_vgui(".x%lx.c coords %lxOUT%d %d %d %d %d\n",
+ canvas, x, 1,
+ xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
+ xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 0,
+ xpos-1, ypos-2,
+ xpos + IOWIDTH-1, ypos-1);
+ sys_vgui(".x%lx.c coords %lxIN%d %d %d %d %d\n",
+ canvas, x, 1,
+ xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
+ xpos+x->x_gui.x_w+1, ypos-1);
+ }
+}
+
+static void vu_draw_erase(t_vu* x,t_glist* glist)
+{
+ int i;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c delete %lxBASE\n", canvas, x);
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ sys_vgui(".x%lx.c delete %lxRLED%d\n", canvas, x, i);
+ if(((i+2)&3) && (x->x_scale))
+ sys_vgui(".x%lx.c delete %lxSCALE%d\n", canvas, x, i);
+ }
+ if(x->x_scale)
+ {
+ i=IEM_VU_STEPS+1;
+ sys_vgui(".x%lx.c delete %lxSCALE%d\n", canvas, x, i);
+ }
+ sys_vgui(".x%lx.c delete %lxPLED\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxRCOVER\n", canvas, x);
+ sys_vgui(".x%lx.c delete %lxLABEL\n", canvas, x);
+ if(!x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 1);
+ }
+ if(!x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 1);
+ }
+}
+
+static void vu_draw_config(t_vu* x, t_glist* glist)
+{
+ int i;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol);
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxRLED%d -width %d\n", canvas, x, i,
+ x->x_led_size);
+ if(((i+2)&3) && (x->x_scale))
+ sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} -%d %s} -fill #%6.6x\n",
+ canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font,
+ x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
+ }
+ if(x->x_scale)
+ {
+ i=IEM_VU_STEPS+1;
+ sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -text {%s} -font {{%s} -%d %s} -fill #%6.6x\n",
+ canvas, x, i, iemgui_vu_scale_str[i], x->x_gui.x_font,
+ x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -font {{%s} -%d %s} -fill #%6.6x -text {%s} \n",
+ canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
+ strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
+
+ sys_vgui(".x%lx.c itemconfigure %lxRCOVER -fill #%6.6x -outline #%6.6x\n", canvas,
+ x, x->x_gui.x_bcol, x->x_gui.x_bcol);
+ sys_vgui(".x%lx.c itemconfigure %lxPLED -width %d\n", canvas, x,
+ x->x_led_size);
+}
+
+static void vu_draw_io(t_vu* x, t_glist* glist, int old_snd_rcv_flags)
+{
+ int xpos=text_xpix(&x->x_gui.x_obj, glist);
+ int ypos=text_ypix(&x->x_gui.x_obj, glist);
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos-1, ypos + x->x_gui.x_h+1,
+ xpos + IOWIDTH-1, ypos + x->x_gui.x_h+2,
+ x, 0);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxOUT%d\n",
+ canvas,
+ xpos+x->x_gui.x_w+1-IOWIDTH, ypos + x->x_gui.x_h+1,
+ xpos+x->x_gui.x_w+1, ypos + x->x_gui.x_h+2,
+ x, 1);
+ }
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
+ {
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 0);
+ sys_vgui(".x%lx.c delete %lxOUT%d\n", canvas, x, 1);
+ }
+ if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos-1, ypos-2,
+ xpos + IOWIDTH-1, ypos-1,
+ x, 0);
+ sys_vgui(".x%lx.c create rectangle %d %d %d %d -tags %lxIN%d\n",
+ canvas,
+ xpos+x->x_gui.x_w+1-IOWIDTH, ypos-2,
+ xpos+x->x_gui.x_w+1, ypos-1,
+ x, 1);
+ }
+ if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
+ {
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 0);
+ sys_vgui(".x%lx.c delete %lxIN%d\n", canvas, x, 1);
+ }
+}
+
+static void vu_draw_select(t_vu* x,t_glist* glist)
+{
+ int i;
+ t_canvas *canvas=glist_getcanvas(glist);
+
+ if(x->x_gui.x_fsf.x_selected)
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ if(((i+2)&3) && (x->x_scale))
+ sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n",
+ canvas, x, i, IEM_GUI_COLOR_SELECTED);
+ }
+ if(x->x_scale)
+ {
+ i=IEM_VU_STEPS+1;
+ sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n",
+ canvas, x, i, IEM_GUI_COLOR_SELECTED);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
+ }
+ else
+ {
+ sys_vgui(".x%lx.c itemconfigure %lxBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ if(((i+2)&3) && (x->x_scale))
+ sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n",
+ canvas, x, i, x->x_gui.x_lcol);
+ }
+ if(x->x_scale)
+ {
+ i=IEM_VU_STEPS+1;
+ sys_vgui(".x%lx.c itemconfigure %lxSCALE%d -fill #%6.6x\n",
+ canvas, x, i, x->x_gui.x_lcol);
+ }
+ sys_vgui(".x%lx.c itemconfigure %lxLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
+ }
+}
+
+void vu_draw(t_vu *x, t_glist *glist, int mode)
+{
+ if(mode == IEM_GUI_DRAW_MODE_MOVE)
+ vu_draw_move(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_NEW)
+ vu_draw_new(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_SELECT)
+ vu_draw_select(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_ERASE)
+ vu_draw_erase(x, glist);
+ else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
+ vu_draw_config(x, glist);
+ else if(mode >= IEM_GUI_DRAW_MODE_IO)
+ vu_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
+}
+
+/* ------------------------ vu widgetbehaviour----------------------------- */
+
+
+static void vu_getrect(t_gobj *z, t_glist *glist,
+ int *xp1, int *yp1, int *xp2, int *yp2)
+{
+ t_vu* x = (t_vu*)z;
+
+ *xp1 = text_xpix(&x->x_gui.x_obj, glist) - 1;
+ *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
+ *xp2 = *xp1 + x->x_gui.x_w + 2;
+ *yp2 = *yp1 + x->x_gui.x_h + 4;
+}
+
+static void vu_save(t_gobj *z, t_binbuf *b)
+{
+ t_vu *x = (t_vu *)z;
+ int bflcol[3];
+ t_symbol *srl[3];
+
+ iemgui_save(&x->x_gui, srl, bflcol);
+ binbuf_addv(b, "ssiisiissiiiiiiii", gensym("#X"),gensym("obj"),
+ (int)x->x_gui.x_obj.te_xpix, (int)x->x_gui.x_obj.te_ypix,
+ gensym("vu"), x->x_gui.x_w, x->x_gui.x_h,
+ srl[1], srl[2],
+ x->x_gui.x_ldx, x->x_gui.x_ldy,
+ iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
+ bflcol[0], bflcol[2], x->x_scale,
+ iem_symargstoint(&x->x_gui.x_isa));
+ binbuf_addv(b, ";");
+}
+
+void vu_check_height(t_vu *x, int h)
+{
+ int n;
+
+ n = h / IEM_VU_STEPS;
+ if(n < IEM_VU_MINSIZE)
+ n = IEM_VU_MINSIZE;
+ x->x_led_size = n-1;
+ x->x_gui.x_h = IEM_VU_STEPS * n;
+}
+
+static void vu_scale(t_vu *x, t_floatarg fscale)
+{
+ int i, scale = (int)fscale;
+
+ if(scale != 0) scale = 1;
+ if(x->x_scale && !scale)
+ {
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ x->x_scale = (int)scale;
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ if((i+2)&3)
+ sys_vgui(".x%lx.c delete %lxSCALE%d\n", canvas, x, i);
+ }
+ i=IEM_VU_STEPS+1;
+ sys_vgui(".x%lx.c delete %lxSCALE%d\n", canvas, x, i);
+ }
+ }
+ if(!x->x_scale && scale)
+ {
+ int w4=x->x_gui.x_w/4, end=text_xpix(&x->x_gui.x_obj, x->x_gui.x_glist)+x->x_gui.x_w+4;
+ int k1=x->x_led_size+1, k2=IEM_VU_STEPS+1, k3=k1/2;
+ int yyy, k4=text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist)-k3;
+ t_canvas *canvas=glist_getcanvas(x->x_gui.x_glist);
+
+ x->x_scale = (int)scale;
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ for(i=1; i<=IEM_VU_STEPS; i++)
+ {
+ yyy = k4 + k1*(k2-i);
+ if((i+2)&3)
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxSCALE%d\n",
+ canvas, end, yyy+k3, iemgui_vu_scale_str[i],
+ x->x_gui.x_font, x->x_gui.x_fontsize,
+ sys_fontweight, x->x_gui.x_lcol, x, i);
+ }
+ i=IEM_VU_STEPS+1;
+ yyy = k4 + k1*(k2-i);
+ sys_vgui(".x%lx.c create text %d %d -text {%s} -anchor w \
+ -font {{%s} -%d %s} -fill #%6.6x -tags %lxSCALE%d\n",
+ canvas, end, yyy+k3, iemgui_vu_scale_str[i],
+ x->x_gui.x_font, x->x_gui.x_fontsize, sys_fontweight,
+ sys_fontweight, x->x_gui.x_lcol, x, i);
+ }
+ }
+}
+
+static void vu_properties(t_gobj *z, t_glist *owner)
+{
+ t_vu *x = (t_vu *)z;
+ char buf[800];
+ t_symbol *srl[3];
+
+ iemgui_properties(&x->x_gui, srl);
+ sprintf(buf, "pdtk_iemgui_dialog %%s |vu| \
+ --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
+ empty 0.0 empty 0.0 empty %d \
+ %d no_scale scale %d %d empty %d \
+ %s %s \
+ %s %d %d \
+ %d %d \
+ %d %d %d\n",
+ x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_VU_STEPS*IEM_VU_MINSIZE,
+ 0,/*no_schedule*/
+ x->x_scale, -1, -1, -1,/*no linlog, no init, no multi*/
+ "nosndno", srl[1]->s_name,/*no send*/
+ srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
+ x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
+ 0xffffff & x->x_gui.x_bcol, -1/*no front-color*/, 0xffffff & x->x_gui.x_lcol);
+ gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
+}
+
+static void vu_dialog(t_vu *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *srl[3];
+ int w = (int)atom_getintarg(0, argc, argv);
+ int h = (int)atom_getintarg(1, argc, argv);
+ int scale = (int)atom_getintarg(4, argc, argv);
+ int sr_flags;
+
+ srl[0] = gensym("empty");
+ sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
+ x->x_gui.x_fsf.x_snd_able = 0;
+ x->x_gui.x_isa.x_loadinit = 0;
+ x->x_gui.x_w = iemgui_clip_size(w);
+ vu_check_height(x, h);
+ if(scale != 0)
+ scale = 1;
+ vu_scale(x, (t_float)scale);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+}
+
+static void vu_size(t_vu *x, t_symbol *s, int ac, t_atom *av)
+{
+ x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
+ if(ac > 1)
+ vu_check_height(x, (int)atom_getintarg(1, ac, av));
+ if(glist_isvisible(x->x_gui.x_glist))
+ {
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
+ (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
+ canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
+ }
+}
+
+static void vu_delta(t_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
+
+static void vu_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void vu_color(t_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
+
+static void vu_receive(t_vu *x, t_symbol *s)
+{iemgui_receive(x, &x->x_gui, s);}
+
+static void vu_label(t_vu *x, t_symbol *s)
+{iemgui_label((void *)x, &x->x_gui, s);}
+
+static void vu_label_pos(t_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
+
+static void vu_label_font(t_vu *x, t_symbol *s, int ac, t_atom *av)
+{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
+
+static void vu_float(t_vu *x, t_floatarg rms)
+{
+ int i;
+
+ if(rms <= IEM_VU_MINDB)
+ x->x_rms = 0;
+ else if(rms >= IEM_VU_MAXDB)
+ x->x_rms = IEM_VU_STEPS;
+ else
+ {
+ int i = (int)(2.0*(rms + IEM_VU_OFFSET));
+ x->x_rms = iemgui_vu_db2i[i];
+ }
+ i = (int)(100.0*rms + 10000.5);
+ rms = 0.01*(t_float)(i - 10000);
+ x->x_fr = rms;
+ outlet_float(x->x_out_rms, rms);
+ x->x_updaterms = 1;
+ sys_queuegui(x, x->x_gui.x_glist, vu_draw_update);
+}
+
+static void vu_ft1(t_vu *x, t_floatarg peak)
+{
+ int i;
+
+ if(peak <= IEM_VU_MINDB)
+ x->x_peak = 0;
+ else if(peak >= IEM_VU_MAXDB)
+ x->x_peak = IEM_VU_STEPS;
+ else
+ {
+ int i = (int)(2.0*(peak + IEM_VU_OFFSET));
+ x->x_peak = iemgui_vu_db2i[i];
+ }
+ i = (int)(100.0*peak + 10000.5);
+ peak = 0.01*(t_float)(i - 10000);
+ x->x_fp = peak;
+ x->x_updatepeak = 1;
+ sys_queuegui(x, x->x_gui.x_glist, vu_draw_update);
+ outlet_float(x->x_out_peak, peak);
+}
+
+static void vu_bang(t_vu *x)
+{
+ outlet_float(x->x_out_peak, x->x_fp);
+ outlet_float(x->x_out_rms, x->x_fr);
+ x->x_updaterms = x->x_updatepeak = 1;
+ sys_queuegui(x, x->x_gui.x_glist, vu_draw_update);
+}
+
+static void *vu_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_vu *x = (t_vu *)pd_new(vu_class);
+ int bflcol[]={-66577, -1, -1};
+ int w=IEM_GUI_DEFAULTSIZE, h=IEM_VU_STEPS*IEM_VU_DEFAULTSIZE;
+ int ldx=-1, ldy=-8, f=0, fs=10, scale=1;
+ int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
+ char str[144];
+
+ iem_inttosymargs(&x->x_gui.x_isa, 0);
+ iem_inttofstyle(&x->x_gui.x_fsf, 0);
+
+ if((argc >= 11)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
+ &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2))
+ &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3))
+ &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
+ &&IS_A_FLOAT(argv,6)&&IS_A_FLOAT(argv,7)
+ &&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10))
+ {
+ w = (int)atom_getintarg(0, argc, argv);
+ h = (int)atom_getintarg(1, argc, argv);
+ iemgui_new_getnames(&x->x_gui, 1, argv);
+ ldx = (int)atom_getintarg(4, argc, argv);
+ ldy = (int)atom_getintarg(5, argc, argv);
+ iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(6, argc, argv));
+ fs = (int)atom_getintarg(7, argc, argv);
+ bflcol[0] = (int)atom_getintarg(8, argc, argv);
+ bflcol[2] = (int)atom_getintarg(9, argc, argv);
+ scale = (int)atom_getintarg(10, argc, argv);
+ }
+ else iemgui_new_getnames(&x->x_gui, 1, 0);
+ if((argc == 12)&&IS_A_FLOAT(argv,11))
+ iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(11, argc, argv));
+ x->x_gui.x_draw = (t_iemfunptr)vu_draw;
+
+ x->x_gui.x_fsf.x_snd_able = 0;
+ x->x_gui.x_fsf.x_rcv_able = 1;
+ x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
+ if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
+ x->x_gui.x_fsf.x_rcv_able = 0;
+ if (x->x_gui.x_fsf.x_font_style == 1)
+ strcpy(x->x_gui.x_font, "helvetica");
+ else if(x->x_gui.x_fsf.x_font_style == 2)
+ strcpy(x->x_gui.x_font, "times");
+ else { x->x_gui.x_fsf.x_font_style = 0;
+ strcpy(x->x_gui.x_font, sys_font); }
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ x->x_gui.x_ldx = ldx;
+ x->x_gui.x_ldy = ldy;
+
+ if(fs < 4)
+ fs = 4;
+ x->x_gui.x_fontsize = fs;
+ x->x_gui.x_w = iemgui_clip_size(w);
+ vu_check_height(x, h);
+ iemgui_all_colfromload(&x->x_gui, bflcol);
+ if(scale != 0)
+ scale = 1;
+ x->x_scale = scale;
+ x->x_peak = 0;
+ x->x_rms = 0;
+ x->x_fp = -101.0;
+ x->x_fr = -101.0;
+ iemgui_verify_snd_ne_rcv(&x->x_gui);
+ inlet_new(&x->x_gui.x_obj, &x->x_gui.x_obj.ob_pd, &s_float, gensym("ft1"));
+ x->x_out_rms = outlet_new(&x->x_gui.x_obj, &s_float);
+ x->x_out_peak = outlet_new(&x->x_gui.x_obj, &s_float);
+ return (x);
+}
+
+static void vu_free(t_vu *x)
+{
+ if(x->x_gui.x_fsf.x_rcv_able)
+ pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
+ gfxstub_deleteforkey(x);
+}
+
void vu_setup(void)
{
- g_vumeter_setup();
+ vu_class = class_new(gensym("vu"), (t_newmethod)vu_new, (t_method)vu_free,
+ sizeof(t_vu), 0, A_GIMME, 0);
+ class_addbang(vu_class,vu_bang);
+ class_addfloat(vu_class,vu_float);
+ class_addmethod(vu_class, (t_method)vu_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addmethod(vu_class, (t_method)vu_dialog, gensym("dialog"),
+ A_GIMME, 0);
+ class_addmethod(vu_class, (t_method)vu_size, gensym("size"), A_GIMME, 0);
+ class_addmethod(vu_class, (t_method)vu_scale, gensym("scale"), A_DEFFLOAT, 0);
+ class_addmethod(vu_class, (t_method)vu_delta, gensym("delta"), A_GIMME, 0);
+ class_addmethod(vu_class, (t_method)vu_pos, gensym("pos"), A_GIMME, 0);
+ class_addmethod(vu_class, (t_method)vu_color, gensym("color"), A_GIMME, 0);
+ class_addmethod(vu_class, (t_method)vu_receive, gensym("receive"), A_DEFSYM, 0);
+ class_addmethod(vu_class, (t_method)vu_label, gensym("label"), A_DEFSYM, 0);
+ class_addmethod(vu_class, (t_method)vu_label_pos, gensym("label_pos"), A_GIMME, 0);
+ class_addmethod(vu_class, (t_method)vu_label_font, gensym("label_font"), A_GIMME, 0);
+ vu_widgetbehavior.w_getrectfn = vu_getrect;
+ vu_widgetbehavior.w_displacefn = iemgui_displace;
+ vu_widgetbehavior.w_selectfn = iemgui_select;
+ vu_widgetbehavior.w_activatefn = NULL;
+ vu_widgetbehavior.w_deletefn = iemgui_delete;
+ vu_widgetbehavior.w_visfn = iemgui_vis;
+ vu_widgetbehavior.w_clickfn = NULL;
+ class_setwidget(vu_class,&vu_widgetbehavior);
+ class_sethelpsymbol(vu_class, gensym("vu"));
+ class_setsavefn(vu_class, vu_save);
+ class_setpropertiesfn(vu_class, vu_properties);
}