aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-15 17:27:03 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-15 17:27:03 +0000
commit46c8c8f8d8448e72bf384c1de04dcfc7ab44f34a (patch)
tree824b7a6c60e92d2d5bcdf65b440dda08fe326887
parent078d4d3de414a38fa2987a1aa1dc6c3ef3f11654 (diff)
- first working sketch of having a shared dylib for a libdir, I moved
query_options() to the dylib, and it works! :D (on Mac OS X, at least) - minor cleanups in text.c - first test of saving options to the file, it writes data, but there are bugs svn path=/trunk/externals/tkwidgets/; revision=9014
-rw-r--r--shared/tkwidgets.c9
-rw-r--r--shared/tkwidgets.h17
-rw-r--r--text-test.pd8
-rw-r--r--text.c27
4 files changed, 43 insertions, 18 deletions
diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c
index 6439842..587f2d8 100644
--- a/shared/tkwidgets.c
+++ b/shared/tkwidgets.c
@@ -32,6 +32,15 @@ t_symbol *canvas_getname(t_canvas *canvas)
return gensym(buf);
}
+
+void query_options(t_symbol *receive_name, char *widget_id, int argc, char** argv)
+{
+ int i;
+ for(i = 0; i < argc; i++)
+ sys_vgui("pd [concat %s query_callback %s [%s cget -%s] \\;]\n",
+ receive_name->s_name, argv[i], widget_id, argv[i]);
+}
+
/*
I think I'll probably have to follow Krzsztof and make structs to make this work
tkwidgets_setcallbackname(void *x, char *widget_name)
diff --git a/shared/tkwidgets.h b/shared/tkwidgets.h
index 9365a7c..b7fdc00 100644
--- a/shared/tkwidgets.h
+++ b/shared/tkwidgets.h
@@ -37,6 +37,23 @@
#define TKW_HANDLE_WIDTH 15
#define TKW_HANDLE_INSET -2
+/* sketch for a common struct */
+typedef struct _tkwidgets
+{
+ t_symbol *canvas_id; /* the canvas that is showing this widget */
+ t_symbol *receive_name; /* name to bind to, to receive callbacks */
+ t_symbol *window_id; /* the window that contains the widget */
+ t_symbol *widget_id; /* the core widget */
+ t_symbol *all_tag; /* the tag for moving/deleting everything */
+ int resizing; /* flag to tell when being resized */
+ int selected; /* flag for when widget is selected */
+} t_tkwidgets;
+
+
+
+/* query a tk widget for the state of all its options */
+void query_options(t_symbol *receive_name, char *widget_id, int argc, char** argv);
+
/* this should be part of the Pd API */
t_symbol *canvas_getname(t_canvas *canvas);
diff --git a/text-test.pd b/text-test.pd
index 57f713c..b094fea 100644
--- a/text-test.pd
+++ b/text-test.pd
@@ -3,7 +3,7 @@
#X msg 47 29 size 100 100;
#X obj 48 470 text 130 60 0;
#X msg 130 30 size 400 200;
-#X obj 310 11 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
+#X obj 310 11 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X msg 655 333;
#X msg 23 245 highlightthickness \$1;
@@ -24,6 +24,10 @@
#X msg 78 345 query;
#X msg 309 31 scrollbars \$1;
#X msg 85 367 query size;
+#X msg 342 369;
+#X obj 310 335 prepend set;
+#X msg 250 41 bang;
+#X connect 0 0 22 0;
#X connect 0 1 5 0;
#X connect 1 0 0 0;
#X connect 2 1 14 0;
@@ -43,3 +47,5 @@
#X connect 18 0 2 0;
#X connect 19 0 0 0;
#X connect 20 0 2 0;
+#X connect 22 0 21 0;
+#X connect 23 0 0 0;
diff --git a/text.c b/text.c
index b62a251..d420c6d 100644
--- a/text.c
+++ b/text.c
@@ -160,6 +160,7 @@ static void store_options(t_textwidget *x)
post("total options: %d", argc);
for(i = 0; i < argc; i++)
{
+ // TODO: only send if there is a value, not when blank
sys_vgui("lappend ::%s::store_list -%s \n",
x->tcl_namespace, textwidget_tk_options[i]);
sys_vgui("lappend ::%s::store_list [%s cget -%s] \n",
@@ -176,14 +177,6 @@ static void restore_options(t_textwidget *x)
// TODO restore options from x->options_binbuf
}
-static void query_options(t_textwidget *x, int argc, char** argv)
-{
- int i;
- 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];
@@ -321,7 +314,6 @@ static void bind_button_events(t_textwidget *x)
static void create_widget(t_textwidget *x)
{
DEBUG(post("create_widget"););
- /* I guess this is for fine-tuning of the rect size based on width and height? */
sys_vgui("namespace eval text%lx {} \n", x);
@@ -329,11 +321,8 @@ static void create_widget(t_textwidget *x)
sys_vgui("destroy %s\n", x->frame_id);
sys_vgui("frame %s \n", x->frame_id);
sys_vgui("text %s -border 1 \
- -highlightthickness 1 -relief sunken -bg \"%s\" -fg \"%s\" \
- -yscrollcommand {%s set} \n",
- x->text_id,
- DEFAULT_COLOR, "black",
- x->scrollbar_id);
+ -highlightthickness 1 -relief sunken -bg \"%s\" -yscrollcommand {%s set} \n",
+ x->text_id, DEFAULT_COLOR, x->scrollbar_id);
sys_vgui("scrollbar %s -command {%s yview}\n",
x->scrollbar_id, x->text_id);
sys_vgui("pack %s -side left -fill both -expand 1 \n", x->text_id);
@@ -641,10 +630,12 @@ static void textwidget_save(t_gobj *z, t_binbuf *b)
{
t_textwidget *x = (t_textwidget *)z;
- binbuf_addv(b, "ssiisiii;", &s__X, gensym("obj"),
+ binbuf_addv(b, "ssiisiii", &s__X, gensym("obj"),
x->x_obj.te_xpix, x->x_obj.te_ypix,
atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)),
x->size_x, x->size_y, x->x_have_scrollbars);
+ binbuf_addbinbuf(b, x->options_binbuf);
+ binbuf_addv(b, ";");
}
static void textwidget_option(t_textwidget *x, t_symbol *s, int argc, t_atom *argv)
@@ -662,6 +653,7 @@ static void textwidget_option(t_textwidget *x, t_symbol *s, int argc, t_atom *ar
post("argument_buffer: %s", argument_buffer);
sys_vgui("%s configure -%s {%s} \n",
x->text_id, s->s_name, argument_buffer);
+ store_options(x);
}
}
@@ -687,7 +679,8 @@ 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);
+ query_options(x->receive_name, x->text_id,
+ sizeof(textwidget_tk_options)/sizeof(char *), textwidget_tk_options);
query_scrollbars(x);
query_size(x);
}
@@ -696,7 +689,7 @@ static void textwidget_query(t_textwidget *x, t_symbol *s)
else if(s == size_symbol)
query_size(x);
else
- query_options(x, 1, &(s->s_name));
+ query_options(x->receive_name, x->text_id, 1, &(s->s_name));
}
static void textwidget_scrollbars(t_textwidget *x, t_float f)