aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-24 17:39:44 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-24 17:39:44 +0000
commit4a31b8161144bfc677d950ed27f706a33211ef5b (patch)
tree8181fc0d2b921e33f15b81807faa525c9328a3aa
parentd334e8fd711b32194a4442b846a21fcffa046012 (diff)
added [set( and [options( methods, but still have to figure out how to deal with 'offvalue/onvalue' properly
svn path=/trunk/externals/tkwidgets/; revision=9035
-rw-r--r--checkbutton-help.pd18
-rw-r--r--checkbutton.c23
2 files changed, 30 insertions, 11 deletions
diff --git a/checkbutton-help.pd b/checkbutton-help.pd
index 2696dae..5570286 100644
--- a/checkbutton-help.pd
+++ b/checkbutton-help.pd
@@ -3,13 +3,12 @@
#X msg 20 111 query;
#X obj 263 255 print QUERY;
#X msg 24 80 query size;
-#X msg 172 78 size 100 100;
#X obj 144 168 cnv 15 160 80 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 69 259 print DATA;
#X msg 204 144 cursor gumby;
#X obj 155 262 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
-5;
+1;
#X msg 192 121 text gumby;
#X msg 159 53 size 90 20;
#X msg 184 102 text "blah blah";
@@ -22,17 +21,19 @@
#X msg 116 117 bang;
#X obj 127 94 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X msg 53 19 offvalue 3;
-#X connect 0 0 6 0;
-#X connect 0 0 8 0;
+#X msg 125 3 offvalue 3;
+#X msg 172 78 options;
+#X msg 29 140 set 5;
+#X connect 0 0 5 0;
+#X connect 0 0 7 0;
#X connect 0 1 2 0;
#X connect 1 0 0 0;
#X connect 3 0 0 0;
-#X connect 4 0 0 0;
-#X connect 7 0 0 0;
+#X connect 6 0 0 0;
+#X connect 8 0 0 0;
#X connect 9 0 0 0;
#X connect 10 0 0 0;
-#X connect 11 0 0 0;
+#X connect 12 0 0 0;
#X connect 13 0 0 0;
#X connect 14 0 0 0;
#X connect 15 0 0 0;
@@ -40,3 +41,4 @@
#X connect 17 0 0 0;
#X connect 18 0 0 0;
#X connect 19 0 0 0;
+#X connect 20 0 0 0;
diff --git a/checkbutton.c b/checkbutton.c
index 05487a7..52e437a 100644
--- a/checkbutton.c
+++ b/checkbutton.c
@@ -105,6 +105,7 @@ static char *checkbutton_tk_options[] = {
/* -------------------- function prototypes --------------------------------- */
static void checkbutton_query_callback(t_checkbutton *x, t_symbol *s, int argc, t_atom *argv);
+static void checkbutton_set(t_checkbutton* x, t_float f);
/* -------------------- widget helper functions------------------------------ */
@@ -286,14 +287,26 @@ static void checkbutton_bang_output(t_checkbutton* x)
* fuction above */
static void checkbutton_float_output(t_checkbutton* x, t_float f)
{
- /* TODO figure out which matches make sense, in terms of offvalue/onvalue */
- sys_vgui("if {%g != 0} {%s select} else {%s deselect}\n",
- f, x->widget_id->s_name, x->widget_id->s_name, x->widget_id->s_name);
+ checkbutton_set(x, f);
outlet_float(x->x_data_outlet, f);
}
/* --------------------------- methods for pd space ------------------------- */
+static void checkbutton_options(t_checkbutton *x)
+{
+ tkwidgets_list_options(x->x_status_outlet,
+ sizeof(checkbutton_tk_options)/sizeof(char *),
+ (char **)&checkbutton_tk_options);
+}
+
+static void checkbutton_set(t_checkbutton* x, t_float f)
+{
+ /* TODO figure out which matches make sense, in terms of offvalue/onvalue */
+ sys_vgui("if {%g != 0} {%s select} else {%s deselect}\n",
+ f, x->widget_id->s_name, x->widget_id->s_name, x->widget_id->s_name);
+}
+
static void checkbutton_size(t_checkbutton *x, t_float width, t_float height)
{
DEBUG(post("checkbutton_size"););
@@ -421,8 +434,12 @@ void checkbutton_setup(void)
class_addfloat(checkbutton_class, (t_method)checkbutton_float_output);
/* methods for pd space */
+ class_addmethod(checkbutton_class, (t_method)checkbutton_options,
+ gensym("options"), 0);
class_addmethod(checkbutton_class, (t_method)checkbutton_query,
gensym("query"), A_DEFSYMBOL, 0);
+ class_addmethod(checkbutton_class, (t_method)checkbutton_set,
+ gensym("set"), A_DEFFLOAT, 0);
class_addmethod(checkbutton_class, (t_method)checkbutton_size,
gensym("size"), A_DEFFLOAT, A_DEFFLOAT, 0);