aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared/tkwidgets.c46
-rw-r--r--shared/tkwidgets.h8
-rw-r--r--text-test.pd2
-rw-r--r--text.c40
4 files changed, 54 insertions, 42 deletions
diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c
index 4d3ec2e..a2c520f 100644
--- a/shared/tkwidgets.c
+++ b/shared/tkwidgets.c
@@ -32,6 +32,7 @@ t_symbol *canvas_getname(t_canvas *canvas)
return gensym(buf);
}
+/* -------------------- options handling ------------------------------------ */
void tkwidgets_query_options(t_symbol *receive_name, t_symbol *widget_id,
int argc, char** argv)
@@ -42,6 +43,29 @@ void tkwidgets_query_options(t_symbol *receive_name, t_symbol *widget_id,
receive_name->s_name, argv[i], widget_id->s_name, argv[i]);
}
+/* this function queries the widget and sends the data to the store_callback */
+void tkwidgets_store_options(t_symbol *receive_name, t_symbol *tcl_namespace,
+ t_symbol *widget_id, int argc, char **argv)
+{
+ // build list then send the whole shebang to store_callback
+ int i;
+ post("tkwidgets_store_options total options: %d", argc);
+ for(i = 0; i < argc; i++)
+ {
+ // TODO: only send if there is a value, not when blank
+ sys_vgui("set ::%s::ret [%s cget -%s]\n",
+ tcl_namespace->s_name, widget_id->s_name, argv[i]);
+ sys_vgui("if {[string length $::%s::ret] > 0} {\n",
+ tcl_namespace->s_name);
+ sys_vgui("lappend ::%s::store_list -%s ; lappend ::%s::store_list $::%s::ret}\n",
+ tcl_namespace->s_name, argv[i],
+ tcl_namespace->s_name, tcl_namespace->s_name);
+ }
+ sys_vgui("pd [concat %s store_callback $::%s::store_list \\;]\n",
+ receive_name->s_name, tcl_namespace->s_name);
+ sys_vgui("unset ::%s::store_list \n", tcl_namespace->s_name);
+}
+
void tkwidgets_restore_options(t_symbol *receive_name, t_symbol *widget_id,
int argc, char** argv)
{
@@ -54,6 +78,8 @@ void tkwidgets_restore_options(t_symbol *receive_name, t_symbol *widget_id,
}
}
+/* -------------------- generate names for various elements ----------------- */
+
t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name)
{
char buf[MAXPDSTRING];
@@ -124,16 +150,6 @@ t_symbol* tkwidgets_gen_all_tag(t_object *x)
return gensym(buf);
}
-void tkwidgets_draw_handle()
-{
- // TODO draw resize handle when selected in editmode
-}
-
-void tkwidgets_draw_resize_window()
-{
- // TODO draw the resize window while resizing
-}
-
/* -------------------- inlets/outlets -------------------------------------- */
static int calculate_onset(int x_location, int width,
@@ -178,4 +194,14 @@ void tkwidgets_erase_inlets(t_symbol* canvas_id, t_symbol* iolets_tag)
sys_vgui("%s delete %s\n", canvas_id->s_name, iolets_tag);
}
+/* -------------------- gui elements for resizing --------------------------- */
+void tkwidgets_draw_handle()
+{
+ // TODO draw resize handle when selected in editmode
+}
+
+void tkwidgets_draw_resize_window()
+{
+ // TODO draw the resize window while resizing
+}
diff --git a/shared/tkwidgets.h b/shared/tkwidgets.h
index 9f0dea4..999e2ac 100644
--- a/shared/tkwidgets.h
+++ b/shared/tkwidgets.h
@@ -68,6 +68,14 @@ t_symbol* canvas_getname(t_canvas *canvas);
void tkwidgets_setcallbackname(void *x, char *widget_name);
+/* handle options */
+void tkwidgets_store_options(t_symbol *receive_name, t_symbol *tcl_namespace,
+ t_symbol *widget_id, int argc, char **argv);
+void tkwidgets_query_options(t_symbol *receive_name, t_symbol *widget_id,
+ int argc, char** argv);
+
+
+/* generate ID and tag names for using in Tcl/Tk space */
t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name);
t_symbol* tkwidgets_gen_callback_name(t_symbol* tcl_namespace);
t_symbol* tkwidgets_gen_canvas_id(t_canvas* canvas);
diff --git a/text-test.pd b/text-test.pd
index b094fea..38ad04f 100644
--- a/text-test.pd
+++ b/text-test.pd
@@ -1,4 +1,4 @@
-#N canvas 171 184 721 672 10;
+#N canvas 137 196 721 672 10;
#X obj 256 77 text 400 200 1;
#X msg 47 29 size 100 100;
#X obj 48 470 text 130 60 0;
diff --git a/text.c b/text.c
index 318197e..65eab40 100644
--- a/text.c
+++ b/text.c
@@ -29,6 +29,7 @@
/* TODO: add scrollbars to query and save */
/* TODO: remove glist from _erase() args */
/* TODO: window name "handle1376fc00" already exists in parent */
+/* TODO: figure out window vs. text width/height */
#define DEFAULT_COLOR "grey70"
@@ -135,31 +136,6 @@ static void textwidget_query_callback(t_textwidget *x, t_symbol *s, int argc, t_
/* -------------------- widget helper functions ----------------------------- */
-static void store_options(t_textwidget *x)
-{
- // build list then send the whole shebang to store_callback
- int i;
- int argc = sizeof(textwidget_tk_options)/sizeof(char *);
- 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->s_name, textwidget_tk_options[i]);
- sys_vgui("lappend ::%s::store_list [%s cget -%s] \n",
- x->tcl_namespace->s_name, x->widget_id, textwidget_tk_options[i]);
- post("option %d: %s", i, textwidget_tk_options[i]);
- }
- sys_vgui("pd [concat %s store_callback $::%s::store_list \\;]\n",
- x->receive_name->s_name, x->tcl_namespace->s_name);
- sys_vgui("unset ::%s::store_list \n", x->tcl_namespace->s_name);
-}
-
-static void restore_options(t_textwidget *x)
-{
- // TODO restore options from x->options_binbuf
-}
-
static void set_tkwidgets_ids(t_textwidget *x, t_canvas *canvas)
{
x->x_canvas = canvas;
@@ -307,7 +283,7 @@ static void textwidget_displace(t_gobj *z, t_glist *glist, int dx, int dy)
{
set_tkwidgets_ids(x,glist_getcanvas(glist));
sys_vgui("%s move %s %d %d\n", x->canvas_id->s_name, x->all_tag->s_name, dx, dy);
- sys_vgui("%s move RSZ %d %d\n", x->canvas_id->s_name, dx, dy);
+ sys_vgui("%s move RESIZE %d %d\n", x->canvas_id->s_name, dx, dy);
canvas_fixlinesfor(glist_getcanvas(glist), (t_text*) x);
}
DEBUG(post("displace end"););
@@ -353,7 +329,7 @@ static void textwidget_activate(t_gobj *z, t_glist *glist, int state)
/* no worky, this should draw MAC OS X style lines on the resize handle */
/* sys_vgui("%s create line %d %d %d %d -fill black -tags RESIZE_LINES\n", */
/* x->handle_id->s_name, handle_x2, handle_y1, handle_x1, handle_y2); */
- sys_vgui("%s create window %d %d -anchor nw -width %d -height %d -window %s -tags RSZ\n",
+ sys_vgui("%s create window %d %d -anchor nw -width %d -height %d -window %s -tags RESIZE\n",
x->canvas_id->s_name, handle_x1, handle_y1,
TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT,
x->handle_id->s_name, x->all_tag->s_name);
@@ -562,7 +538,9 @@ 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->widget_id->s_name, s->s_name, argument_buffer);
- store_options(x);
+ tkwidgets_store_options(x->receive_name, x->tcl_namespace, x->widget_id,
+ sizeof(textwidget_tk_options)/sizeof(char *),
+ &textwidget_tk_options);
}
}
@@ -646,7 +624,7 @@ static void textwidget_query_callback(t_textwidget *x, t_symbol *s, int argc, t_
}
else
{
- post("textwidget_query_callback %s %d", s->s_name, argc);
+ post("ERROR: textwidget_query_callback %s %d", s->s_name, argc);
}
}
@@ -692,7 +670,7 @@ static void textwidget_resize_motion_callback(t_textwidget *x, t_floatarg f1, t_
sys_vgui("%s itemconfigure %s -width %d -height %d\n",
x->canvas_id->s_name, x->window_tag->s_name,
x->width, x->height);
- sys_vgui("%s move RSZ %d %d\n",
+ sys_vgui("%s move RESIZE %d %d\n",
x->canvas_id->s_name, dx, dy);
canvas_fixlinesfor(x->x_glist, (t_text *)x);
}
@@ -731,7 +709,7 @@ static void *textwidget_new(t_symbol *s, int argc, t_atom *argv)
if(argc > 3)
{
binbuf_add(x->options_binbuf, argc - 3, argv + 3);
- restore_options(x);
+//TODO tkwidgets_restore_options(x->receive_name, x->widget_id);
}
}