aboutsummaryrefslogtreecommitdiff
path: root/checkbutton.c
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 /checkbutton.c
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
Diffstat (limited to 'checkbutton.c')
-rw-r--r--checkbutton.c33
1 files changed, 28 insertions, 5 deletions
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,