aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2002-07-30 19:20:23 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2002-07-30 19:20:23 +0000
commit73644be944820f2a81ed861f7bab1e0559c22838 (patch)
tree403e1dd0da602294f40c7f5c0e02656afb99b959
parentd03163cea16c8056fc8095ead5acfbaacebde7ee (diff)
next step towards gui revival
svn path=/trunk/externals/ggee/; revision=64
-rw-r--r--gui/fatom.c364
-rwxr-xr-xgui/hslider.pd10
-rwxr-xr-xgui/slider.c117
-rwxr-xr-xgui/slider.h439
-rwxr-xr-xgui/slider.pd62
-rwxr-xr-xgui/state.c75
-rwxr-xr-xgui/ticker.c423
-rwxr-xr-xgui/ticker.pd21
8 files changed, 191 insertions, 1320 deletions
diff --git a/gui/fatom.c b/gui/fatom.c
index 4ba205c..e71dd27 100644
--- a/gui/fatom.c
+++ b/gui/fatom.c
@@ -7,376 +7,20 @@
#pragma warning( disable : 4305 )
#endif
-/* ------------------------ fatom ----------------------------- */
+#include "fatom.h"
-#define x_val a_pos.a_w.w_float
static t_class *fatom_class;
-typedef struct _fatom
-{
- t_object x_obj;
- t_atom a_pos;
- t_glist * x_glist;
- int x_width;
- int x_height;
- t_symbol* x_sym;
- t_symbol* x_type;
- int x_widget;
-} t_fatom;
-/* widget helper functions */
-
-
-
-static void draw_inlets(t_fatom *x, t_glist *glist, int firsttime, int nin, int nout)
-{
- int n = nin;
- int nplus, i;
- nplus = (n == 1 ? 1 : n-1);
- post("draw inlet");
- for (i = 0; i < n; i++)
- {
- int onset = text_xpix(&x->x_obj, glist) + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
- glist_getcanvas(glist),
- onset, text_ypix(&x->x_obj, glist) + x->x_height - 1,
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_height,
- x, i);
- else
- sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, text_ypix(&x->x_obj, glist) + x->x_height - 1,
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_height);
- }
- n = nout;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = text_xpix(&x->x_obj, glist) + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
- glist_getcanvas(glist),
- onset, text_ypix(&x->x_obj, glist),
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1,
- x, i);
- else
- sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, text_ypix(&x->x_obj, glist),
- onset + IOWIDTH, text_ypix(&x->x_obj, glist) + 1);
-
- }
- post("draw inlet end");
-}
-
-
-static void create_widget(t_fatom *x, t_glist *glist)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- if (!strcmp(x->x_type->s_name,"vslider")) {
- x->x_width = 32;
- x->x_height = 140;
-
- sys_vgui("scale .x%x.c.s%x \
- -sliderlength 10 \
- -showvalue 0 \
- -length 131 \
- -from 127 -to 0 \
- -command fatom_cb%x\n",canvas,x,x);
- } else if (!strcmp(x->x_type->s_name,"hslider")) {
- x->x_width = 150;
- x->x_height = 28;
- sys_vgui("scale .x%x.c.s%x \
- -sliderlength 10 \
- -showvalue 0 \
- -length 131 \
- -orient horizontal \
- -from 127 -to 0 \
- -command fatom_cb%x\n",canvas,x,x);
- } else if (!strcmp(x->x_type->s_name,"checkbutton")) {
- x->x_width = 40;
- x->x_height = 25;
- sys_vgui("checkbutton .x%x.c.s%x \
- -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x\n",canvas,x,x,x,x);
- } else if (!strcmp(x->x_type->s_name,"hradio")) {
- int i;
- x->x_width = 8*20;
- x->x_height = 25;
- for (i=0;i<8;i++) {
- sys_vgui("radiobutton .x%x.c.s%x%d \
- -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -value %d\n",canvas,x,i,x,x,x,i);
- }
- /* TODO pack them */
- } else if (!strcmp(x->x_type->s_name,"vradio")) {
- int i;
- x->x_width = 30;
- x->x_height = 20*8+5;
- for (i=0;i<8;i++) {
- sys_vgui("radiobutton .x%x.c.s%x%d \
- -command { fatom_cb%x $fatom_val%x} -variable fatom_val%x -value %d\n",canvas,x,i,x,x,x,i);
- }
- /* TODO pack them */
- } else {
- x->x_width = 32;
- x->x_height = 140;
- sys_vgui("scale .x%x.c.s%x \
- -sliderlength 10 \
- -showvalue 0 \
- -length 131 \
- -from 127 -to 0 \
- -command fatom_cb%x\n",canvas,x,x);
- }
-}
-
-void fatom_drawme(t_fatom *x, t_glist *glist, int firsttime)
-{
- t_canvas *canvas=glist_getcanvas(glist);
- post("drawme %d",firsttime);
- if (firsttime) {
- post("glist %x canvas %x",x->x_glist,canvas);
- if (x->x_glist != canvas) {
- create_widget(x,glist);
- x->x_glist = canvas;
- }
- sys_vgui(".x%x.c create window %d %d -anchor nw -window .x%x.c.s%x -tags %xS\n",
- canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2,x->x_glist,x,x);
-
- }
- else {
- sys_vgui(".x%x.c coords %xS \
-%d %d\n",
- canvas, x,
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)+2);
- }
- draw_inlets(x, glist, firsttime, 1,1);
-
-}
-
-
-void fatom_erase(t_fatom* x,t_glist* glist)
-{
- int n;
-
- post("erase");
-// sys_vgui(".x%x.c.s%x delete\n",glist_getcanvas(glist),x);
-
- sys_vgui(".x%x.c delete %xS\n",glist_getcanvas(glist), x);
-
- /* inlets and outlets */
-
- sys_vgui(".x%x.c delete %xi%d\n",glist_getcanvas(glist),x,0);
- sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,0);
-}
-
-
-
-/* ------------------------ fatom widgetbehaviour----------------------------- */
-
-
-static void fatom_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_fatom* s = (t_fatom*)z;
-
- width = s->x_width;
- height = s->x_height;
- *xp1 = text_xpix(&s->x_obj, owner);
- *yp1 = text_ypix(&s->x_obj, owner);
- *xp2 = text_xpix(&s->x_obj, owner) + width;
- *yp2 = text_ypix(&s->x_obj, owner) + height;
-}
-
-static void fatom_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_fatom *x = (t_fatom *)z;
- post("displace");
- x->x_obj.te_xpix += dx;
- x->x_obj.te_ypix += dy;
- if (glist_isvisible(glist))
- {
- sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
- glist_getcanvas(glist), x,
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
- text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height);
-
- fatom_drawme(x, glist, 0);
- canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
- }
- post("displace end");
-}
-
-static void fatom_select(t_gobj *z, t_glist *glist, int state)
-{
- t_fatom *x = (t_fatom *)z;
- if (state) {
- sys_vgui(".x%x.c create rectangle \
-%d %d %d %d -tags %xSEL -outline blue\n",
- glist_getcanvas(glist),
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
- text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height,
- x);
- }
- else {
- sys_vgui(".x%x.c delete %xSEL\n",
- glist_getcanvas(glist), x);
- }
-
-
-
-}
-
-
-static void fatom_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void fatom_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist_getcanvas(glist), x);
-}
-
-
-static void fatom_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_fatom* s = (t_fatom*)z;
- t_rtext *y;
- post("vis: %d",vis);
- if (vis) {
- y = (t_rtext *) rtext_new_without_senditup(glist, (t_text *)z, glist->gl_editor->e_rtext);
- fatom_drawme(s, glist, 1);
- }
- else {
- y = glist_findrtext(glist, (t_text *)z);
- fatom_erase(s,glist);
- rtext_free(y);
- }
-}
-
-/* can we use the normal text save function ?? */
-
-static void fatom_save(t_gobj *z, t_binbuf *b)
-{
-
- t_fatom *x = (t_fatom *)z;
-
- binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"),
- x->x_obj.te_xpix, x->x_obj.te_ypix ,
- gensym("fatom"),x->x_type);
- binbuf_addv(b, ";");
-}
-
-
-t_widgetbehavior fatom_widgetbehavior;
-
-void fatom_size(t_fatom* x,t_floatarg w,t_floatarg h) {
- x->x_width = w;
- x->x_height = h;
-}
-
-void fatom_color(t_fatom* x,t_symbol* col)
-{
-/* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang ..
- so color black does the same as bang, but doesn't forward the bang
-*/
-}
-
-static void fatom_setwidget()
-{
- fatom_widgetbehavior.w_getrectfn = fatom_getrect;
- fatom_widgetbehavior.w_displacefn = fatom_displace;
- fatom_widgetbehavior.w_selectfn = fatom_select;
- fatom_widgetbehavior.w_activatefn = fatom_activate;
- fatom_widgetbehavior.w_deletefn = fatom_delete;
- fatom_widgetbehavior.w_visfn = fatom_vis;
- fatom_widgetbehavior.w_savefn = fatom_save;
- fatom_widgetbehavior.w_clickfn = NULL;
- fatom_widgetbehavior.w_propertiesfn = NULL;
-}
-
-
-
-static void fatom_float(t_fatom* x,t_floatarg f)
-{
- x->x_val = f;
- sys_vgui(".x%x.c.s%x set %f\n",x->x_glist,x,f);
- outlet_float(x->x_obj.ob_outlet,f);
-}
-
-static void fatom_f(t_fatom* x,t_floatarg f)
-{
- x->x_val = f;
- outlet_float(x->x_obj.ob_outlet,f);
-}
-
-static void *fatom_new(t_symbol* type)
-{
- t_fatom *x = (t_fatom *)pd_new(fatom_class);
- char buf[256];
-
- x->x_type = type;
- x->x_widget = 0;
- x->x_glist = (t_glist*)NULL;
-/*
- if (h) x->x_width = h;
- else
-*/
-/*
- if (o) x->x_height = o;
- else
-*/
-
- post("x%x",x);
-
- /* bind to a symbol for fatom callback (later make this based on the
- filepath ??) */
-
- sprintf(buf,"fatom%x",x);
- x->x_sym = gensym(buf);
- pd_bind(&x->x_obj.ob_pd, x->x_sym);
-
-/* pipe startup code to tk */
-
- sys_vgui("proc fatom_cb%x {val} {\n
- pd [concat fatom%x f $val \\;]\n
- }\n",x,x);
-
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-void fatom_setup(void)
-{
+void fatom_setup() {
+ post("fatom setup");
fatom_class = class_new(gensym("fatom"), (t_newmethod)fatom_new, 0,
sizeof(t_fatom),0,A_DEFSYM,0);
- class_addfloat(fatom_class, (t_method)fatom_float);
- class_addmethod(fatom_class, (t_method)fatom_f, gensym("f"),
- A_FLOAT, 0);
-
-/*
- class_addmethod(fatom_class, (t_method)fatom_size, gensym("size"),
- A_FLOAT, A_FLOAT, 0);
-
- class_addmethod(fatom_class, (t_method)fatom_color, gensym("color"),
- A_SYMBOL, 0);
-*/
-/*
- class_addmethod(fatom_class, (t_method)fatom_open, gensym("open"),
- A_SYMBOL, 0);
-*/
- fatom_setwidget();
- class_setwidget(fatom_class,&fatom_widgetbehavior);
-
+ fatom_setup_common(fatom_class);
}
diff --git a/gui/hslider.pd b/gui/hslider.pd
deleted file mode 100755
index dddb288..0000000
--- a/gui/hslider.pd
+++ /dev/null
@@ -1,10 +0,0 @@
-#N canvas 330 157 516 263 12;
-#X floatatom 54 83;
-#X text 203 10 Same as slider;
-#X floatatom 54 131;
-#X obj 54 59 hslider 127 0 15;
-#X obj 54 107 hslider 400 0 15;
-#X text 20 226 (C) 1999 - 2000 Guenter Geiger;
-#X connect 0 0 4 0;
-#X connect 3 0 0 0;
-#X connect 4 0 2 0;
diff --git a/gui/slider.c b/gui/slider.c
index 22b3c69..fdb0613 100755
--- a/gui/slider.c
+++ b/gui/slider.c
@@ -1,62 +1,55 @@
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-/* ------------------------ slider ----------------------------- */
-
-#include "slider.h"
-
-static t_class *slider_class;
-
-
-static void *slider_new(t_floatarg h,t_floatarg o,t_floatarg w,t_floatarg n,t_floatarg horiz)
-{
- t_slider *x = (t_slider *)pd_new(slider_class);
- x->x_glist = (t_glist*) canvas_getcurrent();
-
- if (w) x->x_width = w;
- else x->x_width = 15;
- if (h) x->x_height = h - o;
- else
- x->x_height = 127;
- x->x_offset = o;
- x->x_pos = o;
- x->x_pos2 = o;
- x->a_pos.a_type = A_FLOAT;
- if (n) x->x_num = n;
- else x->x_num = 1;
- outlet_new(&x->x_obj, &s_float);
-
-/* make us think we're an atom .. we are one ... this doesn work,
- because the object resets it .. so we will have to create our own menu entry later */
-/* x->x_obj.te_type = T_ATOM; */
- x->x_horizontal = horiz;
-
- return (x);
-}
-
-
-
-void slider_setup(void)
-{
- slider_class = class_new(gensym("slider"), (t_newmethod)slider_new, 0,
- sizeof(t_slider), 0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
- class_addbang(slider_class,slider_bang);
- class_addfloat(slider_class,slider_float);
-
- class_addmethod(slider_class, (t_method)slider_mark, gensym("mark"),
- A_FLOAT, 0);
-
-
- class_addmethod(slider_class, (t_method)slider_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(slider_class, (t_method)slider_motion, gensym("motion"),
- A_FLOAT, A_FLOAT, 0);
- class_addmethod(slider_class, (t_method)slider_set, gensym("set"),
-A_FLOAT, 0);
- class_addmethod(slider_class, (t_method)slider_type, gensym("type"),A_FLOAT,0);
-
-
- slider_setwidget();
- class_setwidget(slider_class,&slider_widgetbehavior);
-}
-
+#include <m_pd.h>
+#include "g_canvas.h"
+#include <ggee.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "fatom.h"
+
+/* can we use the normal text save function ?? */
+
+static t_class *slider_class;
+
+static void slider_save(t_gobj *z, t_binbuf *b)
+{
+
+ t_fatom *x = (t_fatom *)z;
+
+ binbuf_addv(b, "ssiisiii", gensym("#X"),gensym("obj"),
+ x->x_obj.te_xpix, x->x_obj.te_ypix ,
+ gensym("slider"),x->x_max,x->x_min,x->x_width);
+ binbuf_addv(b, ";");
+}
+
+
+static void *slider_new(t_floatarg max, t_floatarg min, t_floatarg h)
+{
+ t_fatom *x = (t_fatom *)pd_new(slider_class);
+ x->x_type = gensym("vslider");
+ return fatom_new(x,max,min,h);
+}
+
+
+t_widgetbehavior slider_widgetbehavior = {
+ w_getrectfn: fatom_getrect,
+ w_displacefn: fatom_displace,
+ w_selectfn: fatom_select,
+ w_activatefn: fatom_activate,
+ w_deletefn: fatom_delete,
+ w_visfn: fatom_vis,
+ w_savefn: slider_save,
+ w_clickfn: NULL,
+ w_propertiesfn: NULL,
+};
+
+
+void slider_setup() {
+ slider_class = class_new(gensym("slider"), (t_newmethod)slider_new, 0,
+ sizeof(t_fatom),0,A_DEFFLOAT,A_DEFFLOAT,A_DEFFLOAT,0);
+
+ fatom_setup_common(slider_class);
+ class_setwidget(slider_class,&slider_widgetbehavior);
+}
diff --git a/gui/slider.h b/gui/slider.h
deleted file mode 100755
index 69c44dd..0000000
--- a/gui/slider.h
+++ /dev/null
@@ -1,439 +0,0 @@
-#ifndef __SLIDER_H__
-#define __SLIDER_H__
-
-/* changes for setting width by <dieter@rhiz.org>
- set message by <dieter@klingt.org>
-*/
-
-#include "ggee.h"
-#include "m_imp.h"
-#include "g_canvas.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-#define SPOSITIONS
-#define te_xpos te_xpix
-#define te_ypos te_ypix
-
-typedef struct _slider
-{
- t_object x_obj;
- t_atom a_pos;
- t_atom a_pos2;
- t_glist * x_glist;
- int x_width;
- int x_height;
- int x_offset;
- int x_mpos;
- int x_num;
- int x_horizontal;
-} t_slider;
-
-#define x_pos a_pos.a_w.w_float
-#define x_pos2 a_pos2.a_w.w_float
-
-
-/* widget helper functions */
-
-static void draw_inlets(t_slider *x, t_glist *glist, int firsttime, int nin, int nout)
-{
- int n = nin;
- int nplus, i;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x->x_obj.te_xpos + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
- glist_getcanvas(glist),
- onset, x->x_obj.te_ypos + x->x_height - 1,
- onset + IOWIDTH, x->x_obj.te_ypos + x->x_height,
- x, i);
- else
- sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, x->x_obj.te_ypos + x->x_height - 1,
- onset + IOWIDTH, x->x_obj.te_ypos + x->x_height);
- }
- n = nout;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x->x_obj.te_xpos + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
- glist_getcanvas(glist),
- onset, x->x_obj.te_ypos,
- onset + IOWIDTH, x->x_obj.te_ypos + 1,
- x, i);
- else
- sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, x->x_obj.te_ypos,
- onset + IOWIDTH, x->x_obj.te_ypos + 1);
-
- }
-}
-
-
-
-static void slider_update(t_slider *x, t_glist *glist)
-{
- if (glist_isvisible(glist)) {
- if (!x->x_horizontal) {
- sys_vgui(".x%x.c coords %xP \
-%d %d %d %d\n",glist_getcanvas(glist),x,
- x->x_obj.te_xpos,x->x_obj.te_ypos + x->x_height - (int)x->x_pos + x->x_offset,
- x->x_obj.te_xpos + x->x_width,x->x_obj.te_ypos + x->x_height - (int)x->x_pos + x->x_offset);
- sys_vgui(".x%x.c coords %xP2 \
-%d %d %d %d\n",glist_getcanvas(glist),x,
- x->x_obj.te_xpos,x->x_obj.te_ypos + x->x_height - (int)x->x_pos2 + x->x_offset,
- x->x_obj.te_xpos + x->x_width,x->x_obj.te_ypos + x->x_height - (int)x->x_pos2 + x->x_offset);
- }
- else {
- sys_vgui(".x%x.c coords %xP \
-%d %d %d %d\n",glist_getcanvas(glist),x,
- x->x_obj.te_xpos +(int)x->x_pos - x->x_offset ,x->x_obj.te_ypos,
- x->x_obj.te_xpos +(int)x->x_pos - x->x_offset ,x->x_obj.te_ypos + x->x_height);
- sys_vgui(".x%x.c coords %xP2 \
-%d %d %d %d\n",glist_getcanvas(glist),x,
- x->x_obj.te_xpos +(int)x->x_pos2 - x->x_offset ,x->x_obj.te_ypos,
- x->x_obj.te_xpos +(int)x->x_pos2 - x->x_offset ,x->x_obj.te_ypos + x->x_height);
- }
- }
-}
-
-
-static void slider_drawme(t_slider *x, t_glist *glist, int firsttime)
-{
- if (firsttime) {
- sys_vgui(".x%x.c create rectangle \
-%d %d %d %d -tags %xS "BACKGROUND"\n",
- glist_getcanvas(glist),
- x->x_obj.te_xpos, x->x_obj.te_ypos,
- x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos + x->x_height,
- x);
- if (!x->x_horizontal) {
- sys_vgui(".x%x.c create line \
-%d %d %d %d -width 3 -tags %xP\n",glist_getcanvas(glist),
- x->x_obj.te_xpos,x->x_obj.te_ypos + x->x_height - (int)x->x_pos + x->x_offset,
- x->x_obj.te_xpos + x->x_width,
- x->x_obj.te_ypos + x->x_height - (int)x->x_pos + x->x_offset,x);
-
- sys_vgui(".x%x.c create line \
-%d %d %d %d -width 3 -tags %xP2\n",glist_getcanvas(glist),
- x->x_obj.te_xpos,x->x_obj.te_ypos + x->x_height - (int)x->x_pos2 + x->x_offset,
- x->x_obj.te_xpos + x->x_width,
- x->x_obj.te_ypos + x->x_height - (int)x->x_pos2 + x->x_offset,x);
- }
- else {
- sys_vgui(".x%x.c create line \
-%d %d %d %d -width 3 -tags %xP\n",glist_getcanvas(glist),
- x->x_obj.te_xpos + (int)x->x_pos + x->x_offset ,x->x_obj.te_ypos,
- x->x_obj.te_xpos + (int)x->x_pos + x->x_offset,
- x->x_obj.te_ypos + x->x_height,x );
- sys_vgui(".x%x.c create line \
-%d %d %d %d -width 3 -tags %xP2\n",glist_getcanvas(glist),
- x->x_obj.te_xpos + (int)x->x_pos2 + x->x_offset ,x->x_obj.te_ypos,
- x->x_obj.te_xpos + (int)x->x_pos2 + x->x_offset,
- x->x_obj.te_ypos + x->x_height,x );
- }
- }
- else {
- sys_vgui(".x%x.c coords %xS \
-%d %d %d %d\n",
- glist_getcanvas(glist), x,
- x->x_obj.te_xpos, x->x_obj.te_ypos,
- x->x_obj.te_xpos + x->x_width, x->x_obj.te_ypos + x->x_height);
- slider_update(x, glist);
- }
-
- draw_inlets(x, glist, firsttime, 1,1);
-
-}
-
-
-
-
-static void slider_erase(t_slider* x,t_glist* glist)
-{
- int n;
- sys_vgui(".x%x.c delete %xS\n",
- glist_getcanvas(glist), x);
-
- sys_vgui(".x%x.c delete %xP\n",
- glist_getcanvas(glist), x);
-
- sys_vgui(".x%x.c delete %xP2\n",
- glist_getcanvas(glist), x);
-
- n = x->x_num;
-
- while (n--) {
- sys_vgui(".x%x.c delete %xi%d\n",glist_getcanvas(glist),x,n);
- sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,n);
- }
-}
-
-
-
-/* ------------------------ slider widgetbehaviour----------------------------- */
-
-
-static void slider_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_slider* s = (t_slider*)z;
-
-
- width = s->x_width;
- height = s->x_height;
- *xp1 = s->x_obj.te_xpos;
- *yp1 = s->x_obj.te_ypos;
- *xp2 = s->x_obj.te_xpos + width;
- *yp2 = s->x_obj.te_ypos + height;
-}
-
-static void slider_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_slider *x = (t_slider *)z;
- x->x_obj.te_xpos += dx;
- x->x_obj.te_ypos += dy;
- slider_drawme(x, glist, 0);
- canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
-}
-
-static void slider_select(t_gobj *z, t_glist *glist, int state)
-{
- t_slider *x = (t_slider *)z;
- sys_vgui(".x%x.c itemconfigure %xS -fill %s\n", glist,
- x, (state? "blue" : BACKGROUNDCOLOR));
-}
-
-
-static void slider_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void slider_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist_getcanvas(glist), x);
-}
-
-
-static void slider_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_slider* s = (t_slider*)z;
- if (vis)
- slider_drawme(s, glist, 1);
- else
- slider_erase(s,glist);
-}
-
-/* can we use the normal text save function ?? */
-
-static void slider_save(t_gobj *z, t_binbuf *b)
-{
- t_slider *x = (t_slider *)z;
- t_symbol* sname;
- int maxlen,maxwidth;
-
-/* if (!x->x_horizontal) {*/
- sname = gensym("slider");
- maxlen = x->x_height + x->x_offset;
- maxwidth = x->x_width;
-/* }*/
-
- /* forget hsliders ...
- else {
- sname = gensym("hslider");
- maxlen = x->x_width + x->x_offset;
- maxwidth = x->x_height;
- }
-*/
-
-
- binbuf_addv(b, "ssiisiiii", gensym("#X"),gensym("obj"),
- (t_int)x->x_obj.te_xpos, (t_int)x->x_obj.te_ypos, sname,maxlen,
- x->x_offset,maxwidth,x->x_num,x->x_horizontal);
-/* binbuf_addbinbuf(b, x->te_binbuf); */
- binbuf_addv(b, ";");
-}
-
-
-t_widgetbehavior slider_widgetbehavior;
-
-
-static void slider_motion(t_slider *x, t_floatarg dx, t_floatarg dy)
-{
- int max;
-
- if (!x->x_horizontal) {
- x->x_mpos -= dy;
- max = (x->x_offset + x->x_height);
- }
- else {
- x->x_mpos += dx;
- max = (x->x_offset + x->x_width);
- }
-
- if (x->x_mpos < x->x_offset)
- x->x_pos = x->x_offset;
- else if (x->x_mpos > (max))
- x->x_pos = (max);
- else
- x->x_pos = x->x_mpos;
-
-
- slider_update(x, x->x_glist);
- outlet_float(x->x_obj.ob_outlet, x->x_pos);
-
-}
-
-
-static void slider_click(t_slider *x,
- t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
- t_floatarg alt)
-{
-
- if (!x->x_horizontal)
- x->x_mpos = x->x_pos = x->x_obj.te_ypos + x->x_height + x->x_offset - ypos;
- else
- x->x_mpos = x->x_pos = xpos - x->x_obj.te_xpos + x->x_offset;
-
- slider_update(x, x->x_glist);
- outlet_float(x->x_obj.ob_outlet, x->x_pos);
-#if (PD_VERSION_MINOR > 31)
- glist_grab(x->x_glist, &x->x_obj.te_g, slider_motion, 0,xpos, ypos);
-#else
- glist_grab(x->x_glist, &x->x_obj.te_g, xpos, ypos);
-#endif
-}
-
-
-#if (PD_VERSION_MINOR > 31)
-static int slider_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- t_slider* x = (t_slider *)z;
- if (doit)
- slider_click( x, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
-}
-#endif
-
-static void slider_setwidget()
-{
- slider_widgetbehavior.w_getrectfn = slider_getrect;
- slider_widgetbehavior.w_displacefn = slider_displace;
- slider_widgetbehavior.w_selectfn = slider_select;
- slider_widgetbehavior.w_activatefn = slider_activate;
- slider_widgetbehavior.w_deletefn = slider_delete;
- slider_widgetbehavior.w_visfn = slider_vis;
-#if (PD_VERSION_MINOR > 31)
- slider_widgetbehavior.w_clickfn = slider_newclick;
- slider_widgetbehavior.w_propertiesfn = NULL;
-#endif
- slider_widgetbehavior.w_savefn = slider_save;
-}
-
-
-
-static void slider_float(t_slider *x,t_floatarg f)
-{
- if (!x->x_horizontal) {
- if (f >= x->x_offset && f <= (x->x_offset + x->x_height))
- x->x_pos = (int)f;
- }
- else
- if (f >= x->x_offset && f <= (x->x_offset + x->x_width))
- x->x_pos = (int)f;
-
-
- slider_update(x, x->x_glist);
- outlet_float(x->x_obj.ob_outlet, x->x_pos);
-
-}
-
-
-static void slider_mark(t_slider *x,t_floatarg val)
-{
- if (!x->x_horizontal) {
- if (val >= x->x_offset && val <= (x->x_offset + x->x_height))
- x->x_pos2 = (int)val;
- }
- else
- if (val >= x->x_offset && val <= (x->x_offset + x->x_width))
- x->x_pos2 = (int)val;
-
- slider_update(x, x->x_glist);
-}
-
-
-static void slider_type(t_slider *x,t_floatarg val)
-{
- x->x_horizontal=val;
- slider_vis((struct _gobj*)x,x->x_glist,0);
- slider_vis((struct _gobj*)x,x->x_glist,1);
-}
-
-static void slider_list(t_slider *x,t_symbol* s,t_int argc, t_atom* argv)
-{
- t_float num;
- t_float val;
-
- if (argc != 2) return;
-
- num = atom_getfloat(argv++);
- val = atom_getfloat(argv);
- if (!x->x_horizontal) {
- if (val >= x->x_offset && val <= (x->x_offset + x->x_height))
- if (num)
- x->x_pos2 = (int)val;
- else
- x->x_pos = (int)val;
- }
- else
- if (val >= x->x_offset && val <= (x->x_offset + x->x_width))
- if (num)
- x->x_pos2 = (int)val;
- else
- x->x_pos = (int)val;
-
- slider_update(x, x->x_glist);
- outlet_float(x->x_obj.ob_outlet, x->x_pos);
-
-}
-
-
-
-static void slider_bang(t_slider *x)
-{
- outlet_float(x->x_obj.ob_outlet, x->x_pos);
-}
-
-
-static void slider_set(t_slider *x,t_floatarg f)
-{
- if (!x->x_horizontal) {
- if (f >= x->x_offset && f <= (x->x_offset + x->x_height))
- x->x_pos = (int)f;
- }
- else{
- if (f >= x->x_offset && f <= (x->x_offset + x->x_width))
- x->x_pos = (int)f;
- }
-
- slider_update(x, x->x_glist);
-}
-
-#endif
diff --git a/gui/slider.pd b/gui/slider.pd
index 23af752..892b372 100755
--- a/gui/slider.pd
+++ b/gui/slider.pd
@@ -1,32 +1,30 @@
-#N canvas 552 205 602 446 12;
-#X obj 14 121 slider 127 0 15 1;
-#X floatatom 12 42 0 0 0;
-#X floatatom 14 319 0 0 0;
-#X obj 12 64 metro 200;
-#X floatatom 121 253 0 0 0;
-#X text 11 23 Alt-Click on number box to toggle between 0 and non-0
-state;
-#X obj 118 142 slider 200 100 15 1;
-#X text 141 139 This was instantiated with "slider 200 100";
-#X obj 14 85 random 127;
-#X obj 304 257 state sl;
-#X msg 304 197 save;
-#X msg 356 197 1;
-#X obj 191 239 slider 100 0 30 1;
-#X text 118 49 Instantiate a new slider with Put->Object and type slider
-into the object. The slider takes up to 3 parameters \, the first is
-the maximum value \, the second is the minimum. The third is the width
-of the slider (contributed by Dieter <dieter@rhiz.org>. Currently only
-integer values are supported.;
-#X msg 178 192 mark 120;
-#X msg 257 285 type 1;
-#X obj 257 315 slider 127 0 15 1;
-#X connect 0 0 2 0;
-#X connect 1 0 3 0;
-#X connect 3 0 8 0;
-#X connect 6 0 4 0;
-#X connect 8 0 0 0;
-#X connect 10 0 9 0;
-#X connect 11 0 9 0;
-#X connect 14 0 6 0;
-#X connect 15 0 16 0;
+#N canvas 465 157 666 446 12;
+#X obj 14 121 slider 127 0 15;
+#X floatatom 12 42 0 0 0;
+#X floatatom 14 319 0 0 0;
+#X obj 12 64 metro 200;
+#X text 139 188 This was instantiated with "slider 200 100";
+#X obj 14 85 random 127;
+#X obj 468 343 state sl;
+#X msg 468 283 save;
+#X msg 520 283 1;
+#X obj 98 167 slider 200 100 15;
+#X floatatom 98 296 0 0 0;
+#X obj 186 252 slider 127 0 40;
+#X text 184 231 This was instantiated with "slider 127 0 40";
+#X obj 274 333 sliderh 127 0 30;
+#X text 273 307 Same with sliderh;
+#X floatatom 274 384 5 0 0;
+#X text 126 11 Instantiate a new slider with Put->Object and type slider
+into the object. The slider takes up to 3 parameters \, the first is
+the maximum value \, the second is the minimum. The third is the width
+of the slider (contributed by Dieter <dieter@rhiz.org>. Click on the
+through to move in 0.01. Middle button jumps.;
+#X connect 0 0 2 0;
+#X connect 1 0 3 0;
+#X connect 3 0 5 0;
+#X connect 5 0 0 0;
+#X connect 7 0 6 0;
+#X connect 8 0 6 0;
+#X connect 9 0 10 0;
+#X connect 13 0 15 0;
diff --git a/gui/state.c b/gui/state.c
index 22abdd2..40d3501 100755
--- a/gui/state.c
+++ b/gui/state.c
@@ -10,68 +10,6 @@
#endif
-/*
- * The iem stuff doesn't work yet !!!
-*/
-
-typedef struct _iem_fstyle_flags
-{
- unsigned int x_font_style:6;
- unsigned int x_rcv_able:1;
- unsigned int x_snd_able:1;
- unsigned int x_lab_is_unique:1;
- unsigned int x_rcv_is_unique:1;
- unsigned int x_snd_is_unique:1;
- unsigned int x_lab_arg_tail_len:6;
- unsigned int x_lab_is_arg_num:6;
- unsigned int x_shiftdown:1;
- unsigned int x_selected:1;
- unsigned int x_finemoved:1;
- unsigned int x_put_in2out:1;
- unsigned int x_change:1;
- unsigned int x_thick:1;
- unsigned int x_lin0_log1:1;
- unsigned int x_steady:1;
- unsigned int dummy:1;
-} t_iem_fstyle_flags;
-
-typedef struct _iem_init_symargs
-{
- unsigned int x_loadinit:1;
- unsigned int x_rcv_arg_tail_len:6;
- unsigned int x_snd_arg_tail_len:6;
- unsigned int x_rcv_is_arg_num:6;
- unsigned int x_snd_is_arg_num:6;
- unsigned int x_scale:1;
- unsigned int x_flashed:1;
- unsigned int x_locked:1;
- unsigned int dummy:4;
-} t_iem_init_symargs;
-
-
-typedef struct _iemgui
-{
- t_object x_obj;
- void *x_glist;
- void* x_draw;
- int x_h;
- int x_w;
- int x_ldx;
- int x_ldy;
- char x_font[16];
- t_iem_fstyle_flags x_fsf;
- int x_fontsize;
- t_iem_init_symargs x_isa;
- int x_fcol;
- int x_bcol;
- int x_lcol;
- int x_unique_num;
- t_symbol *x_snd;
- t_symbol *x_rcv;
- t_symbol *x_lab;
-} t_iemgui;
-
-
/* hacks .... this duplicates definitions in pd and must be
* adjusted if something changes there !!!! */
@@ -82,10 +20,10 @@ typedef struct _mygatom
{
t_text a_text;
t_atom a_atom;
-} t_mygatom; /* this is not !! the real t_atom ...*/
+} t_mygatom; /* this is not !! the real t_gatom ...*/
#define TATOM(a) (&((t_mygatom*)a)->a_atom)
-
+#define ATOMVAL(a) a->a_w.w_float
/* glist's are not visible, but the only thing we need is to
get the list link from them */
@@ -164,23 +102,22 @@ void state_dosave(t_state *x)
if (a->te_type == T_ATOM) {
if (TATOM(a)->a_type == A_SYMBOL) {
if (strlen(TATOM(a)->a_w.w_symbol->s_name))
-/* fprintf(fp,"%s\n",TATOM(a)->a_w.w_symbol->s_name);*/
fprintf(fp,"%s\n",atom_getsymbol(TATOM(a))->s_name);
else
fprintf(fp,EMPTYSYMBOL"\n");
}
else {
fprintf(fp,"%f\n",atom_getfloat(TATOM(a)));
- fprintf(stderr,"%f\n",atom_getfloat(TATOM(a)));
}
}
/* slider should be an atom as well ... how to do it ? */
if (!strcmp(class_getname(a->te_pd),"slider")) {
- float val = atom_getfloat(TATOM(a));
- fprintf(fp,"%f\n",val);
- fprintf(stderr,"slider %f\n",atom_getfloat(TATOM(a)));
+ fprintf(fp,"%f\n",atom_getfloat(TATOM(a)));
+ }
+ if (!strcmp(class_getname(a->te_pd),"sliderh")) {
+ fprintf(fp,"%f\n",atom_getfloat(TATOM(a)));
}
#if 0
if (!strcmp(class_getname(a->te_pd),"vsl")) {
diff --git a/gui/ticker.c b/gui/ticker.c
index b40b1d7..57a1bfd 100755
--- a/gui/ticker.c
+++ b/gui/ticker.c
@@ -1,337 +1,86 @@
-/* (C) Guenter Geiger <geiger@epy.co.at> */
-
-
-#include <ggee.h>
-#include <m_pd.h>
-#include "g_canvas.h"
-#ifdef NT
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-/* ------------------------ ticker ----------------------------- */
-
-#define DEFAULTSIZE 15
-#define DEFAULTCOLOR "black"
-
-static t_class *ticker_class;
-
-typedef struct _ticker
-{
- t_object x_obj;
- t_glist * x_glist;
- int x_width;
- int x_height;
- t_float x_on;
-} t_ticker;
-
-/* widget helper functions */
-
-
-static void draw_inlets(t_ticker *x, t_glist *glist, int firsttime, int nin, int nout)
-{
- int n = nin;
- int nplus, i;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xo%d\n",
- glist_getcanvas(glist),
- onset, x->x_obj.te_ypix + x->x_height - 1,
- onset + IOWIDTH, x->x_obj.te_ypix + x->x_height,
- x, i);
- else
- sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, x->x_obj.te_ypix + x->x_height - 1,
- onset + IOWIDTH, x->x_obj.te_ypix + x->x_height);
- }
- n = nout;
- nplus = (n == 1 ? 1 : n-1);
- for (i = 0; i < n; i++)
- {
- int onset = x->x_obj.te_xpix + (x->x_width - IOWIDTH) * i / nplus;
- if (firsttime)
- sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xi%d\n",
- glist_getcanvas(glist),
- onset, x->x_obj.te_ypix,
- onset + IOWIDTH, x->x_obj.te_ypix + 1,
- x, i);
- else
- sys_vgui(".x%x.c coords %xi%d %d %d %d %d\n",
- glist_getcanvas(glist), x, i,
- onset, x->x_obj.te_ypix,
- onset + IOWIDTH, x->x_obj.te_ypix + 1);
-
- }
-}
-
-
-
-void ticker_draw(t_ticker *x,t_glist *glist)
-{
- if (x->x_on) {
- sys_vgui(".x%x.c create line \
-%d %d %d %d -tags %xB\n",glist_getcanvas(glist),
- x->x_obj.te_xpix+1,x->x_obj.te_ypix+1,
- x->x_obj.te_xpix + x->x_width -1,
- x->x_obj.te_ypix + x->x_height -1,x);
- sys_vgui(".x%x.c create line \
-%d %d %d %d -tags %xC\n",glist_getcanvas(glist),
- x->x_obj.te_xpix+1,x->x_obj.te_ypix + x->x_height -1,
- x->x_obj.te_xpix + x->x_width -1,x->x_obj.te_ypix+1,
- x);
-
- }
- else {
- sys_vgui(".x%x.c delete %xB\n",
- glist_getcanvas(glist), x);
- sys_vgui(".x%x.c delete %xC\n",
- glist_getcanvas(glist), x);
- }
-}
-
-
-void ticker_update(t_ticker *x,t_glist *glist)
-{
- if (glist_isvisible(glist)) {
- if (x->x_on) {
- sys_vgui(".x%x.c coords %xB \
-%d %d %d %d\n",glist_getcanvas(glist),
- x,x->x_obj.te_xpix+1,x->x_obj.te_ypix+1,
- x->x_obj.te_xpix + x->x_width -1,
- x->x_obj.te_ypix + x->x_height -1);
- sys_vgui(".x%x.c coords %xC \
-%d %d %d %d\n",glist_getcanvas(glist),
- x,x->x_obj.te_xpix+1,x->x_obj.te_ypix + x->x_height -1,
- x->x_obj.te_xpix + x->x_width -1,x->x_obj.te_ypix+1);
-
- }
- }
-}
-
-
-
-void ticker_drawme(t_ticker *x, t_glist *glist, int firsttime)
-{
- if (firsttime) {
- sys_vgui(".x%x.c create rectangle \
-%d %d %d %d -tags %xS "BACKGROUND"\n",
- glist_getcanvas(glist),
- x->x_obj.te_xpix, x->x_obj.te_ypix,
- x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height,
- x);
- ticker_draw(x,glist);
- }
- else {
- sys_vgui(".x%x.c coords %xS \
-%d %d %d %d\n",
- glist_getcanvas(glist), x,
- x->x_obj.te_xpix, x->x_obj.te_ypix,
- x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height);
- ticker_update(x,glist);
- }
-
- draw_inlets(x, glist, firsttime, 1,1);
-
-}
-
-
-
-
-void ticker_erase(t_ticker* x,t_glist* glist)
-{
- int n;
- sys_vgui(".x%x.c delete %xS\n",
- glist_getcanvas(glist), x);
-
- sys_vgui(".x%x.c delete %xP\n",
- glist_getcanvas(glist), x);
-
- n = 1;
- sys_vgui(".x%x.c delete %xB\n",
- glist_getcanvas(glist), x);
- sys_vgui(".x%x.c delete %xC\n",
- glist_getcanvas(glist), x);
-
- while (n--) {
- sys_vgui(".x%x.c delete %xi%d\n",glist_getcanvas(glist),x,n);
- sys_vgui(".x%x.c delete %xo%d\n",glist_getcanvas(glist),x,n);
- }
-}
-
-
-
-/* ------------------------ ticker widgetbehaviour----------------------------- */
-
-
-static void ticker_getrect(t_gobj *z, t_glist *owner,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_ticker* s = (t_ticker*)z;
-
-
- width = s->x_width;
- height = s->x_height;
- *xp1 = s->x_obj.te_xpix;
- *yp1 = s->x_obj.te_ypix;
- *xp2 = s->x_obj.te_xpix + width;
- *yp2 = s->x_obj.te_ypix + height;
-}
-
-static void ticker_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_ticker *x = (t_ticker *)z;
- x->x_obj.te_xpix += dx;
- x->x_obj.te_ypix += dy;
- ticker_drawme(x, glist, 0);
- canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
-}
-
-static void ticker_select(t_gobj *z, t_glist *glist, int state)
-{
- t_ticker *x = (t_ticker *)z;
- sys_vgui(".x%x.c itemconfigure %xS -fill %s\n", glist,
- x, (state? "blue" : BACKGROUNDCOLOR));
-}
-
-
-static void ticker_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void ticker_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- canvas_deletelinesfor(glist_getcanvas(glist), x);
-}
-
-
-static void ticker_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_ticker* s = (t_ticker*)z;
- if (vis)
- ticker_drawme(s, glist, 1);
- else
- ticker_erase(s,glist);
-}
-
-/* can we use the normal text save function ?? */
-
-static void ticker_save(t_gobj *z, t_binbuf *b)
-{
- t_ticker *x = (t_ticker *)z;
- binbuf_addv(b, "ssiisii", gensym("#X"),gensym("obj"),
- (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
- gensym("ticker"),x->x_width,x->x_height);
- binbuf_addv(b, ";");
-}
-
-
-static void ticker_click(t_ticker *x,
- t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
- t_floatarg alt)
-{
- x->x_on = x->x_on == 0.0 ? 1.0:0.0;
- ticker_draw(x,x->x_glist);
- outlet_float(x->x_obj.ob_outlet,x->x_on);
-}
-
-#if (PD_VERSION_MINOR > 31)
-static int ticker_newclick(t_gobj *z, struct _glist *glist,
- int xpix, int ypix, int shift, int alt, int dbl, int doit)
-{
- if (doit)
- ticker_click((t_ticker *)z, (t_floatarg)xpix, (t_floatarg)ypix,
- (t_floatarg)shift, 0, (t_floatarg)alt);
- return (1);
-}
-#endif
-
-t_widgetbehavior ticker_widgetbehavior;
-
-
-void ticker_size(t_ticker* x,t_floatarg w,t_floatarg h) {
- x->x_width = w;
- x->x_height = h;
- ticker_drawme(x, x->x_glist, 0);
-}
-
-
-static void ticker_bang(t_ticker* x)
-{
- x->x_on = x->x_on == 0.0 ? 1.0:0.0;
- if (glist_isvisible(x->x_glist))
- ticker_draw(x,x->x_glist);
- outlet_float(x->x_obj.ob_outlet,x->x_on);
-}
-
-static void ticker_float(t_ticker* x,t_floatarg f)
-{
- x->x_on = f;
- if (glist_isvisible(x->x_glist))
- ticker_draw(x,x->x_glist);
- outlet_float(x->x_obj.ob_outlet,x->x_on);
-}
-
-static void ticker_set(t_ticker* x,t_floatarg f)
-{
- x->x_on = f;
-}
-
-static void *ticker_new(t_floatarg h,t_floatarg o)
-{
- t_ticker *x = (t_ticker *)pd_new(ticker_class);
-
- x->x_glist = (t_glist*) canvas_getcurrent();
- if (h) x->x_width = h;
- else
- x->x_width = DEFAULTSIZE;
-
- if (o) x->x_height = o;
- else
- x->x_height = DEFAULTSIZE;
-
- x->x_on = 0;
-
- outlet_new(&x->x_obj, &s_float);
- return (x);
-}
-
-void ticker_setup(void)
-{
- ticker_class = class_new(gensym("ticker"), (t_newmethod)ticker_new, 0,
- sizeof(t_ticker),0, A_DEFFLOAT,A_DEFFLOAT,0);
-
-
- class_addmethod(ticker_class, (t_method)ticker_click, gensym("click"),
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
- class_addmethod(ticker_class, (t_method)ticker_size, gensym("size"),
- A_FLOAT, A_FLOAT, 0);
-
- class_addfloat(ticker_class, ticker_float);
- class_addbang(ticker_class,ticker_bang);
- class_addmethod(ticker_class,(t_method) ticker_set,gensym("set"),A_FLOAT,0);
- class_setwidget(ticker_class,&ticker_widgetbehavior);
-
- ticker_widgetbehavior.w_getrectfn = ticker_getrect;
- ticker_widgetbehavior.w_displacefn = ticker_displace;
- ticker_widgetbehavior.w_selectfn = ticker_select;
- ticker_widgetbehavior.w_activatefn = ticker_activate;
- ticker_widgetbehavior.w_deletefn = ticker_delete;
- ticker_widgetbehavior.w_visfn = ticker_vis;
-#if (PD_VERSION_MINOR > 31)
- ticker_widgetbehavior.w_clickfn = ticker_newclick;
- ticker_widgetbehavior.w_propertiesfn = NULL;
-#endif
- ticker_widgetbehavior.w_savefn = ticker_save;
-}
-
-
+#include <m_pd.h>
+#include "g_canvas.h"
+#include <ggee.h>
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#include "fatom.h"
+
+/* can we use the normal text save function ?? */
+
+static t_class *ticker_class;
+
+static void ticker_save(t_gobj *z, t_binbuf *b)
+{
+
+ t_fatom *x = (t_fatom *)z;
+
+ binbuf_addv(b, "ssiis", gensym("#X"),gensym("obj"),
+ x->x_obj.te_xpix, x->x_obj.te_ypix ,
+ gensym("ticker"));
+ binbuf_addv(b, ";");
+}
+
+static void ticker_bang(t_fatom* x)
+{
+ x->x_val = !x->x_val;
+ fatom_float(x,x->x_val);
+}
+
+static void *ticker_new()
+{
+ t_fatom *x = (t_fatom *)pd_new(ticker_class);
+ char buf[256];
+
+ x->x_type = gensym("checkbutton");
+ x->x_glist = (t_glist*)NULL;
+/*
+ if (h) x->x_width = h;
+ else
+*/
+/*
+ if (o) x->x_height = o;
+ else
+*/
+
+ /* bind to a symbol for ticker callback (later make this based on the
+ filepath ??) */
+
+ sprintf(buf,"ticker%x",x);
+ x->x_sym = gensym(buf);
+ pd_bind(&x->x_obj.ob_pd, x->x_sym);
+
+/* pipe startup code to slitk */
+
+ sys_vgui("proc fatom_cb%x {val} {\n
+ pd [concat ticker%x f $val \\;]\n
+ }\n",x,x);
+
+ outlet_new(&x->x_obj, &s_float);
+ return (x);
+}
+
+
+t_widgetbehavior ticker_widgetbehavior = {
+ w_getrectfn: fatom_getrect,
+ w_displacefn: fatom_displace,
+ w_selectfn: fatom_select,
+ w_activatefn: fatom_activate,
+ w_deletefn: fatom_delete,
+ w_visfn: fatom_vis,
+ w_savefn: ticker_save,
+ w_clickfn: NULL,
+ w_propertiesfn: NULL,
+};
+
+void ticker_setup() {
+ ticker_class = class_new(gensym("ticker"), (t_newmethod)ticker_new, 0,
+ sizeof(t_fatom),0,0);
+
+ class_addbang(ticker_class,ticker_bang);
+ fatom_setup_common(ticker_class);
+ class_setwidget(ticker_class,&ticker_widgetbehavior);
+}
diff --git a/gui/ticker.pd b/gui/ticker.pd
index b094910..ca33386 100755
--- a/gui/ticker.pd
+++ b/gui/ticker.pd
@@ -1,11 +1,10 @@
-#N canvas 209 91 456 299 12;
-#X obj 40 154 ticker 15 15;
-#X floatatom 40 184;
-#X obj 40 125 metro 200;
-#X obj 40 16 ticker 100 100;
-#X obj 75 151 ticker 30 50;
-#X text 43 245 (C) 1999 - 2000 Guenter Geiger;
-#X connect 0 0 1 0;
-#X connect 2 0 0 0;
-#X connect 2 0 4 0;
-#X connect 3 0 2 0;
+#N canvas 392 208 450 300 10;
+#X obj 60 85 metro 200;
+#X obj 60 41 ticker;
+#X obj 60 129 ticker;
+#X obj 119 130 ticker;
+#X floatatom 60 171 5 0 0;
+#X connect 0 0 2 0;
+#X connect 0 0 3 0;
+#X connect 1 0 0 0;
+#X connect 2 0 4 0;