aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-27 06:07:07 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-27 06:07:07 +0000
commit321a85a07d3cfa191ddef88b2b8225ca2a0de7bc (patch)
tree0f2dbba758fe59db6a7d4aa5d4324363f1a0ca32
parent135a99417a1a8a100630bd349bd245df3fc5220d (diff)
- added [query id( message to get the Tk ID of the checkbutton widget so
people can do Tcl madness directly using [sys_gui] svn path=/trunk/externals/tkwidgets/; revision=9053
-rw-r--r--checkbutton-help.pd42
-rw-r--r--checkbutton.c33
2 files changed, 49 insertions, 26 deletions
diff --git a/checkbutton-help.pd b/checkbutton-help.pd
index 5570286..e39553b 100644
--- a/checkbutton-help.pd
+++ b/checkbutton-help.pd
@@ -1,29 +1,29 @@
-#N canvas 13 257 467 404 10;
-#X obj 166 173 checkbutton 90 20;
-#X msg 20 111 query;
-#X obj 263 255 print QUERY;
-#X msg 24 80 query size;
-#X obj 144 168 cnv 15 160 80 empty empty empty 20 12 0 14 -233017 -66577
+#N canvas 12 208 467 404 10;
+#X obj 171 211 checkbutton 90 20;
+#X msg 20 131 query;
+#X obj 263 275 print QUERY;
+#X msg 24 100 query size;
+#X obj 144 188 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
+#X obj 69 279 print DATA;
+#X msg 204 164 cursor gumby;
+#X obj 155 282 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X msg 192 121 text gumby;
-#X msg 159 53 size 90 20;
-#X msg 184 102 text "blah blah";
+#X msg 192 141 text gumby;
+#X msg 159 73 size 90 20;
+#X msg 184 122 text "blah blah";
#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
+#X msg 141 41 onvalue 5;
+#X msg 347 136 fg blue;
+#X msg 349 158 bg pink;
+#X msg 348 182 anchor w;
+#X msg 116 137 bang;
+#X obj 127 114 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X msg 125 3 offvalue 3;
-#X msg 172 78 options;
-#X msg 29 140 set 5;
+#X msg 125 23 offvalue 3;
+#X msg 172 98 options;
+#X msg 29 160 set 1;
#X connect 0 0 5 0;
#X connect 0 0 7 0;
#X connect 0 1 2 0;
diff --git a/checkbutton.c b/checkbutton.c
index a47efb8..1ad0bb5 100644
--- a/checkbutton.c
+++ b/checkbutton.c
@@ -21,7 +21,7 @@
*/
/* TODO rectify char and pixel widths/heights ug */
-/* TODO bind to <Configure> so that things are redrawn when the text changes */
+/* TODO bind to <Configure> so that things are redrawn when the label changes */
/* TODO add float method to set state based on == 0 and everything else */
#include "shared/tkwidgets.h"
@@ -102,6 +102,12 @@ static char *checkbutton_tk_options[] = {
"wraplength"
};
+/* -------------------- common symbols to preload --------------------------- */
+
+static t_symbol *id_symbol;
+static t_symbol *query_callback_symbol;
+static t_symbol *size_symbol;
+
/* -------------------- function prototypes --------------------------------- */
static void checkbutton_query_callback(t_checkbutton *x, t_symbol *s, int argc, t_atom *argv);
@@ -150,13 +156,22 @@ static void eraseme(t_checkbutton* x)
/* --------------------- query functions ------------------------------------ */
+static void query_id(t_checkbutton *x)
+{
+ t_atom id[2];
+ t_symbol *widget_id = x->widget_id;
+ SETSYMBOL(id, id_symbol);
+ SETSYMBOL(id + 1, widget_id);
+ checkbutton_query_callback(x, query_callback_symbol, 2, id);
+}
+
static void query_size(t_checkbutton *x)
{
t_atom coords[3];
- SETSYMBOL(coords, gensym("size"));
+ SETSYMBOL(coords, size_symbol);
SETFLOAT(coords + 1, (t_float)x->width);
SETFLOAT(coords + 2, (t_float)x->height);
- checkbutton_query_callback(x, gensym("query_callback"), 3, coords);
+ checkbutton_query_callback(x, query_callback_symbol, 3, coords);
}
static void checkbutton_query(t_checkbutton *x, t_symbol *s)
@@ -167,9 +182,12 @@ static void checkbutton_query(t_checkbutton *x, t_symbol *s)
tkwidgets_query_options(x->receive_name, x->widget_id,
sizeof(checkbutton_tk_options)/sizeof(char *),
checkbutton_tk_options);
+ query_id(x);
query_size(x);
}
- else if(s == gensym("size"))
+ else if(s == id_symbol)
+ query_id(x);
+ else if(s == size_symbol)
query_size(x);
else
tkwidgets_query_options(x->receive_name, x->widget_id, 1, &(s->s_name));
@@ -433,6 +451,11 @@ void checkbutton_setup(void)
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);
+
+/* common symbols to preload */
+ id_symbol = gensym("id");
+ query_callback_symbol = gensym("query_callback");
+ size_symbol = gensym("size");
/* methods for pd space */
class_addmethod(checkbutton_class, (t_method)checkbutton_options,
@@ -448,7 +471,7 @@ void checkbutton_setup(void)
class_addmethod(checkbutton_class, (t_method)checkbutton_output_callback,
gensym("output"), A_DEFFLOAT, 0);
class_addmethod(checkbutton_class, (t_method)checkbutton_query_callback,
- gensym("query_callback"), A_GIMME, 0);
+ query_callback_symbol, A_GIMME, 0);
class_addmethod(checkbutton_class, (t_method)checkbutton_store_callback,
gensym("store_callback"), A_GIMME, 0);
class_addmethod(checkbutton_class, (t_method)checkbutton_resize_click_callback,