aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2003-10-27 18:23:10 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2003-10-27 18:23:10 +0000
commit4bd577d35b15a03da727316b5ffdea43abc7c104 (patch)
tree0187fff87fda2d4b0d1bc8f931d64478375796cc
parent791b9c638aa9a38517206328d6d54f46df465d44 (diff)
setsavefn fixes for 0.37
svn path=/trunk/externals/ggee/; revision=1145
-rw-r--r--gui/button.c14
-rwxr-xr-xgui/envgen.c18
-rw-r--r--gui/fatom.h15
-rw-r--r--gui/gcanvas.c54
-rw-r--r--gui/image.c5
-rwxr-xr-xgui/slider.c9
-rw-r--r--gui/sliderh.c7
-rwxr-xr-xgui/ticker.c8
-rwxr-xr-xgui/w_envgen.h20
9 files changed, 85 insertions, 65 deletions
diff --git a/gui/button.c b/gui/button.c
index 9831057..f954d10 100644
--- a/gui/button.c
+++ b/gui/button.c
@@ -10,11 +10,13 @@
#pragma warning( disable : 4305 )
#endif
-#if PD_VERSION_MINOR < 37
+#if PD_MINOR_VERSION < 37
#define t_rtext t_text
#endif
+#ifndef IOWIDTH
#define IOWIDTH 4
+#endif
typedef struct _button
{
@@ -264,9 +266,13 @@ t_widgetbehavior button_widgetbehavior = {
w_activatefn: button_activate,
w_deletefn: button_delete,
w_visfn: button_vis,
+#if PD_MINOR_VERSION < 37
w_savefn: button_save,
+#endif
w_clickfn: NULL,
+#if PD_MINOR_VERSION < 37
w_propertiesfn: NULL,
+#endif
};
@@ -311,7 +317,6 @@ static void button_save(t_gobj *z, t_binbuf *b)
static t_class *button_class;
-
static void *button_new(t_symbol* text)
{
t_button *x = (t_button *)pd_new(button_class);
@@ -342,7 +347,6 @@ static void *button_new(t_symbol* text)
}
void button_setup(void) {
- post("button setup");
button_class = class_new(gensym("button"), (t_newmethod)button_new, 0,
sizeof(t_button),0,A_DEFSYM,0);
@@ -350,7 +354,9 @@ void button_setup(void) {
class_addmethod(button_class, (t_method)button_b,gensym("b"),0);
class_setwidget(button_class,&button_widgetbehavior);
-
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(button_class,&button_save);
+#endif
}
diff --git a/gui/envgen.c b/gui/envgen.c
index 5df03df..e80eb72 100755
--- a/gui/envgen.c
+++ b/gui/envgen.c
@@ -296,6 +296,20 @@ void envgen_click(t_envgen *x,
t_floatarg alt);
void envgen_key(t_envgen *x, t_floatarg f);
+t_widgetbehavior envgen_widgetbehavior = {
+ w_getrectfn: envgen_getrect,
+ w_displacefn: envgen_displace,
+ w_selectfn: envgen_select,
+ w_activatefn: envgen_activate,
+ w_deletefn: envgen_delete,
+ w_visfn: envgen_vis,
+ w_clickfn: envgen_newclick,
+#if PD_MINOR_VERSION < 37
+ w_propertiesfn: NULL,
+ w_savefn: envgen_save
+#endif
+};
+
void envgen_setup(void)
{
@@ -320,7 +334,9 @@ void envgen_setup(void)
class_addmethod(envgen_class,(t_method)envgen_freeze,gensym("freeze"),A_FLOAT,NULL);
class_addmethod(envgen_class,(t_method)envgen_setresize,gensym("resize"),A_FLOAT,A_NULL);
- envgen_setwidget();
class_setwidget(envgen_class,&envgen_widgetbehavior);
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(envgen_class,&envgen_save);
+#endif
class_addmethod(envgen_class,(t_method)envgen_dump,gensym("dump"),A_NULL);
}
diff --git a/gui/fatom.h b/gui/fatom.h
index 5900acd..82d804f 100644
--- a/gui/fatom.h
+++ b/gui/fatom.h
@@ -3,6 +3,8 @@
#define x_val a_pos.a_w.w_float
#define DEBUG(x)
+#include <string.h>
+#include <stdio.h>
typedef struct _fatom
{
@@ -317,9 +319,11 @@ t_widgetbehavior fatom_widgetbehavior = {
w_activatefn: fatom_activate,
w_deletefn: fatom_delete,
w_visfn: fatom_vis,
+#if PD_MINOR_VERSION < 37
w_savefn: fatom_save,
- w_clickfn: NULL,
w_propertiesfn: NULL,
+#endif
+ w_clickfn: NULL,
};
@@ -363,6 +367,11 @@ static void fatom_f(t_fatom* x,t_floatarg f)
}
+static void fatom_properties(t_gobj *z, t_glist *owner)
+{
+ post("N/I");
+}
+
static void fatom_save(t_gobj *z, t_binbuf *b)
{
@@ -428,5 +437,7 @@ void fatom_setup_common(t_class* class)
A_SYMBOL, 0);
*/
class_setwidget(class,&fatom_widgetbehavior);
-
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(class,&fatom_save);
+#endif
}
diff --git a/gui/gcanvas.c b/gui/gcanvas.c
index dccba01..d59c983 100644
--- a/gui/gcanvas.c
+++ b/gui/gcanvas.c
@@ -1,15 +1,13 @@
-/* (C) Guenter Geiger <geiger@epy.co.at> */
+/* (C) Guenter Geiger <geiger@xdv.org> */
#include <m_pd.h>
#include "g_canvas.h"
/* ------------------------ gcanvas ----------------------------- */
-/* an area with gcanvas information */
#define BACKGROUNDCOLOR "grey"
-#define DEFAULTCOLOR "grey"
#define DEFAULTSIZE 80
@@ -19,10 +17,9 @@ typedef struct _gcanvas
{
t_object x_obj;
t_glist * x_glist;
- t_outlet* out2;
+ t_outlet* out2;
int x_width;
int x_height;
- t_symbol* x_color;
int x;
int y;
} t_gcanvas;
@@ -37,7 +34,7 @@ void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime)
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,x->x_color);
+ x,BACKGROUNDCOLOR);
}
else {
sys_vgui(".x%x.c coords %xS \
@@ -47,9 +44,9 @@ void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime)
x->x_obj.te_xpix + x->x_width, x->x_obj.te_ypix + x->x_height);
}
-
{
- int n = 1;
+ /* outlets */
+ int n = 2;
int nplus, i;
nplus = (n == 1 ? 1 : n-1);
for (i = 0; i < n; i++)
@@ -67,7 +64,8 @@ void gcanvas_drawme(t_gcanvas *x, t_glist *glist, int firsttime)
onset, x->x_obj.te_ypix + x->x_height - 1,
onset + IOWIDTH, x->x_obj.te_ypix + x->x_height);
}
- n = 1;
+ /* inlets */
+ n = 0;
nplus = (n == 1 ? 1 : n-1);
for (i = 0; i < n; i++)
{
@@ -97,9 +95,8 @@ void gcanvas_erase(t_gcanvas* x,t_glist* glist)
int n;
sys_vgui(".x%x.c delete %xS\n",
glist_getcanvas(glist), x);
- n = 1;
+ n = 2;
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);
}
}
@@ -170,9 +167,9 @@ static void gcanvas_vis(t_gobj *z, t_glist *glist, int vis)
static void gcanvas_save(t_gobj *z, t_binbuf *b)
{
t_gcanvas *x = (t_gcanvas *)z;
- binbuf_addv(b, "ssiissii", gensym("#X"),gensym("obj"),
+ binbuf_addv(b, "ssiisii", gensym("#X"),gensym("obj"),
(t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix,
- gensym("gcanvas"),x->x_color,x->x_width,x->x_height);
+ gensym("gcanvas"),x->x_width,x->x_height);
binbuf_addv(b, ";");
}
@@ -183,8 +180,8 @@ static void gcanvas_motion(t_gcanvas *x, t_floatarg dx, t_floatarg dy)
{
x->x += dx;
x->y += dy;
- outlet_float(x->x_obj.ob_outlet,x->x);
outlet_float(x->out2,x->y);
+ outlet_float(x->x_obj.ob_outlet,x->x);
}
void gcanvas_key(t_gcanvas *x, t_floatarg f)
@@ -197,13 +194,13 @@ static void gcanvas_click(t_gcanvas *x,
t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl,
t_floatarg alt)
{
- glist_grab(x->x_glist, &x->x_obj.te_g, (t_glistmotionfn) gcanvas_motion,
+ glist_grab(x->x_glist, &x->x_obj.te_g, (t_glistmotionfn) gcanvas_motion,
(t_glistkeyfn) NULL, xpos, ypos);
x->x = xpos - x->x_obj.te_xpix;
x->y = ypos - x->x_obj.te_ypix;
- outlet_float(x->x_obj.ob_outlet,x->x);
outlet_float(x->out2,x->y);
+ outlet_float(x->x_obj.ob_outlet,x->x);
}
static int gcanvas_newclick(t_gobj *z, struct _glist *glist,
@@ -221,14 +218,6 @@ void gcanvas_size(t_gcanvas* x,t_floatarg w,t_floatarg h) {
gcanvas_drawme(x, x->x_glist, 0);
}
-void gcanvas_color(t_gcanvas* x,t_symbol* col)
-{
- x->x_color = 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 gcanvas_setwidget(void)
{
gcanvas_widgetbehavior.w_getrectfn = gcanvas_getrect;
@@ -238,12 +227,14 @@ static void gcanvas_setwidget(void)
gcanvas_widgetbehavior.w_deletefn = gcanvas_delete;
gcanvas_widgetbehavior.w_visfn = gcanvas_vis;
gcanvas_widgetbehavior.w_clickfn = gcanvas_newclick;
+#if PD_MINOR_VERSION < 37
gcanvas_widgetbehavior.w_propertiesfn = NULL;
gcanvas_widgetbehavior.w_savefn = gcanvas_save;
+#endif
}
-static void *gcanvas_new(t_symbol* col,t_floatarg h,t_floatarg o)
+static void *gcanvas_new(t_floatarg h,t_floatarg o)
{
t_gcanvas *x = (t_gcanvas *)pd_new(gcanvas_class);
@@ -256,11 +247,6 @@ static void *gcanvas_new(t_symbol* col,t_floatarg h,t_floatarg o)
else
x->x_height = DEFAULTSIZE;
- if (col != &s_)
- x->x_color = col;
- else
- x->x_color = gensym(DEFAULTCOLOR);
-
outlet_new(&x->x_obj, &s_float);
x->out2 = outlet_new(&x->x_obj, &s_float);
return (x);
@@ -269,7 +255,7 @@ static void *gcanvas_new(t_symbol* col,t_floatarg h,t_floatarg o)
void gcanvas_setup(void)
{
gcanvas_class = class_new(gensym("gcanvas"), (t_newmethod)gcanvas_new, 0,
- sizeof(t_gcanvas),0, A_DEFSYM,A_DEFFLOAT,A_DEFFLOAT,0);
+ sizeof(t_gcanvas),0, A_DEFFLOAT,A_DEFFLOAT,0);
class_addcreator((t_newmethod)gcanvas_new,gensym("bng"),A_DEFSYM,A_DEFFLOAT,A_DEFFLOAT,A_GIMME,0);
@@ -278,11 +264,11 @@ void gcanvas_setup(void)
class_addmethod(gcanvas_class, (t_method)gcanvas_size, gensym("size"),
A_FLOAT, A_FLOAT, 0);
- class_addmethod(gcanvas_class, (t_method)gcanvas_color, gensym("color"),
- A_SYMBOL, 0);
-
gcanvas_setwidget();
class_setwidget(gcanvas_class,&gcanvas_widgetbehavior);
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(gcanvas_class,&gcanvas_save);
+#endif
}
diff --git a/gui/image.c b/gui/image.c
index 7d57744..65e4801 100644
--- a/gui/image.c
+++ b/gui/image.c
@@ -171,7 +171,9 @@ static void image_setwidget(void)
image_widgetbehavior.w_clickfn = NULL;
image_widgetbehavior.w_propertiesfn = NULL;
#endif
+#if PD_MINOR_VERSION < 37
image_widgetbehavior.w_savefn = image_save;
+#endif
}
@@ -207,6 +209,9 @@ void image_setup(void)
*/
image_setwidget();
class_setwidget(image_class,&image_widgetbehavior);
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(image_class,&image_widgetbehavior);
+#endif
}
diff --git a/gui/slider.c b/gui/slider.c
index 140f7c3..076df57 100755
--- a/gui/slider.c
+++ b/gui/slider.c
@@ -40,16 +40,21 @@ t_widgetbehavior slider_widgetbehavior = {
w_activatefn: fatom_activate,
w_deletefn: fatom_delete,
w_visfn: fatom_vis,
+#if PD_MINOR_VERSION < 37
w_savefn: slider_save,
- w_clickfn: NULL,
w_propertiesfn: NULL,
+#endif
+ w_clickfn: 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);
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(slider_class,&slider_save);
+#endif
+ class_setpropertiesfn(slider_class,&fatom_properties);
}
diff --git a/gui/sliderh.c b/gui/sliderh.c
index 50671a2..cbecea5 100644
--- a/gui/sliderh.c
+++ b/gui/sliderh.c
@@ -40,9 +40,11 @@ t_widgetbehavior sliderh_widgetbehavior = {
w_activatefn: fatom_activate,
w_deletefn: fatom_delete,
w_visfn: fatom_vis,
+#if PD_MINOR_VERSION < 37
w_savefn: sliderh_save,
- w_clickfn: NULL,
w_propertiesfn: NULL,
+#endif
+ w_clickfn: NULL,
};
@@ -52,4 +54,7 @@ void sliderh_setup() {
fatom_setup_common(sliderh_class);
class_setwidget(sliderh_class,&sliderh_widgetbehavior);
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(sliderh_class,&sliderh_save);
+#endif
}
diff --git a/gui/ticker.c b/gui/ticker.c
index 4fc3b7f..95e6c2e 100755
--- a/gui/ticker.c
+++ b/gui/ticker.c
@@ -45,9 +45,11 @@ t_widgetbehavior ticker_widgetbehavior = {
w_activatefn: fatom_activate,
w_deletefn: fatom_delete,
w_visfn: fatom_vis,
+#if PD_MINOR_VERSION < 37
w_savefn: ticker_save,
- w_clickfn: NULL,
w_propertiesfn: NULL,
+#endif
+ w_clickfn: NULL,
};
void ticker_setup() {
@@ -58,4 +60,8 @@ void ticker_setup() {
fatom_setup_common(ticker_class);
class_addbang(ticker_class, (t_method)ticker_bang);
class_setwidget(ticker_class,&ticker_widgetbehavior);
+#if PD_MINOR_VERSION >= 37
+ class_setsavefn(ticker_class,&ticker_save);
+#endif
}
+
diff --git a/gui/w_envgen.h b/gui/w_envgen.h
index aa4b8c6..02439f2 100755
--- a/gui/w_envgen.h
+++ b/gui/w_envgen.h
@@ -478,23 +478,3 @@ static int envgen_newclick(t_gobj *z, struct _glist *glist,
}
#endif
-
-
-t_widgetbehavior envgen_widgetbehavior;
-
-void envgen_setwidget(void)
-{
- envgen_widgetbehavior.w_getrectfn = envgen_getrect;
- envgen_widgetbehavior.w_displacefn = envgen_displace;
- envgen_widgetbehavior.w_selectfn = envgen_select;
- envgen_widgetbehavior.w_activatefn = envgen_activate;
- envgen_widgetbehavior.w_deletefn = envgen_delete;
- envgen_widgetbehavior.w_visfn = envgen_vis;
-#if (PD_VERSION_MINOR > 31)
- envgen_widgetbehavior.w_clickfn = envgen_newclick;
- envgen_widgetbehavior.w_propertiesfn = NULL;
-#endif
- envgen_widgetbehavior.w_savefn = envgen_save;
-
-}
-