aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-22 00:37:59 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-22 00:37:59 +0000
commitff4298c30dfd8e4cee237b40acec599020d14ff1 (patch)
tree3b64e3ba6631b4c87d83c9a6e1d55465dd319925 /shared
parent2a320ac2fbd246be7b0844fe00b543bcd1bae271 (diff)
- moved iolet drawing/erasing to tkwidgets common
- added iolets roughly to [checkbutton] - cleaned up naming in text.c a bit - moved t_widgetbehavior setup to textwidget_setup() svn path=/trunk/externals/tkwidgets/; revision=9021
Diffstat (limited to 'shared')
-rw-r--r--shared/tkwidgets.c73
-rw-r--r--shared/tkwidgets.h16
2 files changed, 62 insertions, 27 deletions
diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c
index fd7f9c3..4d3ec2e 100644
--- a/shared/tkwidgets.c
+++ b/shared/tkwidgets.c
@@ -54,13 +54,6 @@ void tkwidgets_restore_options(t_symbol *receive_name, t_symbol *widget_id,
}
}
-void tkwidgets_set_ids(t_object *x, t_tkwidgets *tkw, t_canvas *canvas)
-{
-
- tkw->canvas = canvas;
-}
-
-
t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name)
{
char buf[MAXPDSTRING];
@@ -96,38 +89,39 @@ t_symbol* tkwidgets_gen_widget_id(t_object* x, t_symbol* parent_id)
return gensym(buf);
}
-t_symbol* tkwidgets_gen_window_id(t_object* x, t_symbol* canvas_id)
+t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id)
{
char buf[MAXPDSTRING];
- sprintf(buf,"%s.window%lx", canvas_id->s_name, (long unsigned int)x);
+ sprintf(buf,"%s.handle%lx", canvas_id->s_name, (long unsigned int)x);
return gensym(buf);
}
-t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id)
+t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id)
{
char buf[MAXPDSTRING];
- sprintf(buf,"%s.handle%lx", canvas_id->s_name, (long unsigned int)x);
+ sprintf(buf,"%s.scrollbar%lx", frame_id->s_name, (long unsigned int)x);
return gensym(buf);
}
-t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id)
+t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* canvas_id)
{
char buf[MAXPDSTRING];
- sprintf(buf,"%s.scrollbar%lx", frame_id->s_name, (long unsigned int)x);
+ sprintf(buf,"%s.window%lx", canvas_id->s_name, (long unsigned int)x);
return gensym(buf);
}
-t_symbol* tkwidgets_gen_all_tag(t_object *x)
+t_symbol* tkwidgets_gen_iolets_tag(t_object* x)
{
char buf[MAXPDSTRING];
- sprintf(buf,"all%lx", (long unsigned int)x);
+ sprintf(buf,"iolets%lx", (long unsigned int)x);
return gensym(buf);
}
-void tkwidgets_draw_inlets(t_object *x, t_glist *glist,
- int total_inlets, int total_outlets)
+t_symbol* tkwidgets_gen_all_tag(t_object *x)
{
- // TODO perhaps I should try to use glist_drawiofor() from g_text.c
+ char buf[MAXPDSTRING];
+ sprintf(buf,"all%lx", (long unsigned int)x);
+ return gensym(buf);
}
void tkwidgets_draw_handle()
@@ -140,13 +134,48 @@ void tkwidgets_draw_resize_window()
// TODO draw the resize window while resizing
}
+/* -------------------- inlets/outlets -------------------------------------- */
+
+static int calculate_onset(int x_location, int width,
+ int current_iolet, int total_iolets)
+{
+ post("calculate_onset");
+ return(x_location + (width - IOWIDTH) \
+ * current_iolet / (total_iolets == 1 ? 1 : total_iolets - 1));
+}
-/*
-void query_options()
+void tkwidgets_draw_inlets(t_object *x, t_glist *glist, t_symbol *canvas_id,
+ t_symbol *iolets_tag, t_symbol *all_tag,
+ int width, int height,
+ int total_inlets, int total_outlets)
{
-
+ int i, onset;
+ int x_location = text_xpix(x, glist);
+ int y_location = text_ypix(x, glist);
+
+ for (i = 0; i < total_inlets; i++) /* inlets */
+ {
+ onset = calculate_onset(x_location, width, i, total_inlets);
+ sys_vgui("%s create rectangle %d %d %d %d -tags {%s %s}\n",
+ canvas_id->s_name, onset, y_location - 2,
+ onset + IOWIDTH, y_location,
+ iolets_tag->s_name, all_tag->s_name);
+ sys_vgui("%s raise %s\n", canvas_id->s_name, iolets_tag->s_name);
+ }
+ for (i = 0; i < total_outlets; i++) /* outlets */
+ {
+ onset = calculate_onset(x_location, width, i, total_outlets);
+ sys_vgui("%s create rectangle %d %d %d %d -tags {%s %s}\n",
+ canvas_id->s_name, onset, y_location + height,
+ onset + IOWIDTH, y_location + height + 2,
+ iolets_tag->s_name, all_tag->s_name);
+ sys_vgui("%s raise %s\n", canvas_id->s_name, iolets_tag->s_name);
+ }
}
+void tkwidgets_erase_inlets(t_symbol* canvas_id, t_symbol* iolets_tag)
+{
+ sys_vgui("%s delete %s\n", canvas_id->s_name, iolets_tag);
+}
-*/
diff --git a/shared/tkwidgets.h b/shared/tkwidgets.h
index aa1d097..9f0dea4 100644
--- a/shared/tkwidgets.h
+++ b/shared/tkwidgets.h
@@ -48,7 +48,7 @@ typedef struct _tkwidgets
t_symbol* tcl_namespace; /* namespace to prevent name collisions */
t_symbol* canvas_id; /* the canvas that is showing this widget */
t_symbol* frame_id; /* the frame around the widget and supporters */
- t_symbol* window_id; /* the window that contains the widget */
+ t_symbol* window_tag; /* the window that contains the widget */
t_symbol* widget_id; /* the core widget */
t_symbol* handle_id; /* the resizing handle */
t_symbol* all_tag; /* the tag for moving/deleting everything */
@@ -73,14 +73,20 @@ t_symbol* tkwidgets_gen_callback_name(t_symbol* tcl_namespace);
t_symbol* tkwidgets_gen_canvas_id(t_canvas* canvas);
t_symbol* tkwidgets_gen_frame_id(t_object* x, t_symbol* canvas_id);
t_symbol* tkwidgets_gen_widget_id(t_object* x, t_symbol* parent_id);
-t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* parent_id);
-t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* parent_id);
+t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id);
+t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id);
+t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* canvas_id);
+t_symbol* tkwidgets_gen_iolets_tag(t_object* x);
t_symbol* tkwidgets_gen_all_tag(t_object *x);
// TODO perhaps I should try to use glist_drawiofor() from g_text.c
-void tkwidgets_draw_inlets(t_object *x, t_glist *glist,
- int total_inlets, int total_outlets);
+void tkwidgets_draw_inlets(t_object *x, t_glist *glist, t_symbol *canvas_id,
+ t_symbol *iolets_tag, t_symbol *all_tag,
+ int width, int height,
+ int total_inlets, int total_outlets);
+void tkwidgets_erase_inlets(t_symbol* canvas_id, t_symbol* iolets_tag);
+
void tkwidgets_draw_handle(); // TODO draw resize handle when selected in editmode
void tkwidgets_draw_resize_window(); // TODO draw the resize window while resizing