From d334e8fd711b32194a4442b846a21fcffa046012 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 24 Nov 2007 07:30:33 +0000 Subject: added float and bang methods to checkbutton, the float method needs some work on the logic svn path=/trunk/externals/tkwidgets/; revision=9034 --- checkbutton-help.pd | 13 +++++++++++++ checkbutton.c | 17 +++++++++++++++-- shared/tkwidgets.c | 2 ++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/checkbutton-help.pd b/checkbutton-help.pd index a134218..2696dae 100644 --- a/checkbutton-help.pd +++ b/checkbutton-help.pd @@ -16,6 +16,13 @@ #X obj 51 337 pddp/pddplink http://tcl.tk/man/tcl8.4/TkCmd/checkbutton.htm ; #X msg 141 21 onvalue 5; +#X msg 347 116 fg blue; +#X msg 349 138 bg pink; +#X msg 367 188 anchor w; +#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 connect 0 1 2 0; @@ -27,3 +34,9 @@ #X connect 10 0 0 0; #X connect 11 0 0 0; #X connect 13 0 0 0; +#X connect 14 0 0 0; +#X connect 15 0 0 0; +#X connect 16 0 0 0; +#X connect 17 0 0 0; +#X connect 18 0 0 0; +#X connect 19 0 0 0; diff --git a/checkbutton.c b/checkbutton.c index 162f233..05487a7 100644 --- a/checkbutton.c +++ b/checkbutton.c @@ -22,6 +22,7 @@ /* TODO rectify char and pixel widths/heights ug */ /* TODO bind to so that things are redrawn when the text changes */ +/* TODO add float method to set state based on == 0 and everything else */ #include "shared/tkwidgets.h" @@ -274,11 +275,21 @@ static void checkbutton_set_option(t_checkbutton *x, t_symbol *s, int argc, t_at } } -/* Pass the contents of the text widget onto the textwidget_output_callback +/* Pass the contents of the text widget onto the checkbutton_output_callback * fuction above */ static void checkbutton_bang_output(t_checkbutton* x) { - sys_vgui("%s invoke", x->widget_id->s_name); + sys_vgui("%s invoke\n", x->widget_id->s_name); +} + +/* Pass the contents of the text widget onto the checkbutton_output_callback + * 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); + outlet_float(x->x_data_outlet, f); } /* --------------------------- methods for pd space ------------------------- */ @@ -406,6 +417,8 @@ void checkbutton_setup(void) sizeof(t_checkbutton), 0, A_GIMME,0); /* methods for atoms */ class_addanything(checkbutton_class, (t_method)checkbutton_set_option); + class_addbang(checkbutton_class, (t_method)checkbutton_bang_output); + class_addfloat(checkbutton_class, (t_method)checkbutton_float_output); /* methods for pd space */ class_addmethod(checkbutton_class, (t_method)checkbutton_query, diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c index a5d1b8c..f238669 100644 --- a/shared/tkwidgets.c +++ b/shared/tkwidgets.c @@ -20,6 +20,8 @@ */ +/* TODO apply store logic to query so query doesn't send blank options */ + #include "tkwidgets.h" #include #include -- cgit v1.2.1