aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-14 06:16:12 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-14 06:16:12 +0000
commit8f5463c88b3370e922f03fd94b05c379f4cbdb6f (patch)
tree64265453af5b33da4b14b20e41a7690fc4d4f92a
parentb0114d623806df53bce55158e4ef89d62648da68 (diff)
got bulk and individual querying working
svn path=/trunk/externals/tkwidgets/; revision=9003
-rw-r--r--text-test.pd18
-rw-r--r--text.c69
2 files changed, 78 insertions, 9 deletions
diff --git a/text-test.pd b/text-test.pd
index 9153a09..649c63a 100644
--- a/text-test.pd
+++ b/text-test.pd
@@ -1,7 +1,7 @@
#N canvas 165 195 721 672 10;
#X obj 130 117 text 130 60;
#X msg 47 29 size 100 100;
-#X obj 73 543 text 200 50;
+#X obj 48 540 text 130 60;
#X msg 130 30 size 400 200;
#X obj 310 11 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
@@ -19,8 +19,18 @@ find all]];
#X msg 132 515 font "Lucida Sans" 18 bold;
#X msg 272 425 size 200 50;
#X msg 89 490 font Arial 16;
+#X obj 200 612 print QUERY;
+#X floatatom 309 620 5 0 0 0 - - -;
+#X obj 309 596 route highlightthickness font;
+#X obj 396 624 pddp/print;
+#X msg 421 372 width 8;
+#X obj 309 642 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
+-1 -1;
+#X msg 114 435 query highlightthickness;
+#X msg 143 458 query;
#X connect 0 1 6 0;
#X connect 1 0 0 0;
+#X connect 2 1 18 0;
#X connect 3 0 0 0;
#X connect 4 0 5 0;
#X connect 5 0 0 0;
@@ -32,3 +42,9 @@ find all]];
#X connect 13 0 2 0;
#X connect 14 0 2 0;
#X connect 15 0 2 0;
+#X connect 17 0 21 0;
+#X connect 18 0 17 0;
+#X connect 18 1 19 0;
+#X connect 20 0 2 0;
+#X connect 22 0 2 0;
+#X connect 23 0 2 0;
diff --git a/text.c b/text.c
index 77bce2a..0f34c5e 100644
--- a/text.c
+++ b/text.c
@@ -47,6 +47,9 @@ typedef struct _textwidget
t_symbol* receive_name;
+ int optionc;
+ t_atom* optionv;
+
int x_height;
int x_width;
int x_resizing;
@@ -149,6 +152,36 @@ w_clickfn: NULL,
};
/* widget helper functions */
+
+static void save_options(t_textwidget *x, int argc, char** argv)
+{
+ int i;
+ post("total options: %d", argc);
+ for(i = 0; i < argc; i++)
+ {
+// sys_vgui("lappend ::%s::optionsList %s \n", x->tcl_namespace, argv[i]);
+ sys_vgui("pd [concat %s query_callback %s [%s cget -%s] \\;]\n",
+ x->receive_name->s_name, argv[i], x->text_id, argv[i]);
+ post("option %d: %s", i, argv[i]);
+ }
+/* sys_vgui("foreach ::%s::option $::%s::optionsList {\n",x->tcl_namespace,x->tcl_namespace); */
+/* sys_vgui("pd [concat %s query_callback $::%s::option [%s cget [format \"-%%s\" $::%s::option]] \\;]\n", */
+/* x->receive_name->s_name, x->tcl_namespace, x->text_id, x->tcl_namespace); */
+// sys_vgui("puts stderr [concat %s query_callback $::%s::option [%s cget [format \"-%%s\" $::%s::option]] \\;] \n",
+// x->receive_name->s_name, x->tcl_namespace, x->text_id, x->tcl_namespace);
+/* sys_gui("}\n"); */
+/* sys_vgui("unset ::%s::optionsList \n", x->tcl_namespace); */
+}
+
+static void query_options(t_textwidget *x, int argc, char** argv)
+{
+ int i;
+ post("total options: %d", argc);
+ for(i = 0; i < argc; i++)
+ sys_vgui("pd [concat %s query_callback %s [%s cget -%s] \\;]\n",
+ x->receive_name->s_name, argv[i], x->text_id, argv[i]);
+}
+
static void set_tk_widget_ids(t_textwidget *x, t_canvas *canvas)
{
char buf[MAXPDSTRING];
@@ -631,6 +664,15 @@ static void textwidget_option(t_textwidget *x, t_symbol *s, int argc, t_atom *ar
}
}
+static void textwidget_query(t_textwidget *x, t_symbol *s)
+{
+ post("textwidget_query %s", s->s_name);
+ if(s == &s_)
+ query_options(x, sizeof(textwidget_tk_options)/sizeof(char *), textwidget_tk_options);
+ else
+ query_options(x, 1, &(s->s_name));
+}
+
static void textwidget_scrollbar(t_textwidget *x, t_float f)
{
if(f > 0)
@@ -670,6 +712,21 @@ static void textwidget_size(t_textwidget *x, t_float width, t_float height)
}
/* callback functions */
+
+static void textwidget_query_callback(t_textwidget *x, t_symbol *s, int argc, t_atom *argv)
+{
+ t_symbol *tmp_symbol = atom_getsymbolarg(0, argc, argv);
+ if(tmp_symbol != &s_)
+ {
+ post("tmp_symbol %s argc %d", tmp_symbol->s_name, argc);
+ outlet_anything(x->x_status_outlet, tmp_symbol, argc - 1, argv + 1);
+ }
+ else
+ {
+ post("textwidget_query_callback %s %d", s->s_name, argc);
+ }
+}
+
static void textwidget_click_callback(t_textwidget *x, t_floatarg f)
{
if( (x->x_glist->gl_edit) && (x->x_glist == x->x_canvas) )
@@ -759,14 +816,6 @@ static void *textwidget_new(t_symbol *s, int argc, t_atom *argv)
x->x_glist = canvas_getcurrent();
set_tk_widget_ids(x, x->x_glist);
-
- int i;
- int option_argc = sizeof(textwidget_tk_options)/sizeof(char *);
- post("total options: %d", option_argc);
- for(i = 0; i < option_argc; i++)
- {
- post("option %d: %s", i, textwidget_tk_options[i]);
- }
return (x);
}
@@ -780,6 +829,8 @@ void text_setup(void) {
class_addanything(textwidget_class, (t_method)textwidget_option);
+ class_addmethod(textwidget_class, (t_method)textwidget_query,
+ gensym("query"), A_DEFSYMBOL, 0);
class_addmethod(textwidget_class, (t_method)textwidget_scrollbar,
gensym("scrollbar"), A_DEFFLOAT, 0);
class_addmethod(textwidget_class, (t_method)textwidget_size,
@@ -797,6 +848,8 @@ void text_setup(void) {
class_addmethod(textwidget_class, (t_method)textwidget_clear,
gensym("clear"), 0);
/* callbacks */
+ class_addmethod(textwidget_class, (t_method)textwidget_query_callback,
+ gensym("query_callback"), A_GIMME, 0);
class_addmethod(textwidget_class, (t_method)textwidget_keyup_callback,
gensym("keyup"), A_DEFFLOAT, 0);
class_addmethod(textwidget_class, (t_method)textwidget_click_callback,