aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-24 04:07:23 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-24 04:07:23 +0000
commit6abfeaada311a61a9590f076ae100531cff42666 (patch)
treece3c9d3cc639fd30f58ca1ca4dfd6e7f6991181a
parentc00ea30f26399a1e94e923bcb5707434e745530a (diff)
moved inlet/outlet counts to tkwidgets.h
svn path=/trunk/externals/tkwidgets/; revision=9030
-rw-r--r--checkbutton.c5
-rw-r--r--shared/tkwidgets.c15
-rw-r--r--shared/tkwidgets.h7
-rw-r--r--text.c11
4 files changed, 20 insertions, 18 deletions
diff --git a/checkbutton.c b/checkbutton.c
index 8764907..6f9ff81 100644
--- a/checkbutton.c
+++ b/checkbutton.c
@@ -121,7 +121,7 @@ static void checkbutton_drawme(t_checkbutton *x, t_glist *glist)
x->widget_id->s_name);
tkwidgets_draw_iolets((t_object*)x, glist,
x->canvas_id, x->iolets_tag, x->all_tag,
- x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS);
+ x->width, x->height);
sys_vgui("%s create window %d %d -anchor nw -window %s -tags {%s %s}\n",
x->canvas_id->s_name,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
@@ -218,8 +218,6 @@ static void checkbutton_size(t_checkbutton *x, t_float width, t_float height)
{
sys_vgui("%s itemconfigure %s -width %d -height %d\n",
x->canvas_id->s_name, x->window_tag->s_name, x->width, x->height);
-// erase_inlets(x);
-// tkwidgets_draw_iolets(x, x->x_glist, TOTAL_INLETS, TOTAL_OUTLETS);
canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet
}
}
@@ -261,7 +259,6 @@ static void *checkbutton_new(t_symbol* s, int argc, t_atom *argv)
pd_bind(&x->x_obj.ob_pd, x->receive_name);
x->x_glist = canvas_getcurrent();
- set_tkwidgets_ids(x, x->x_glist);
x->iolets_tag = tkwidgets_gen_iolets_tag((t_object*)x);
x->all_tag = tkwidgets_gen_all_tag((t_object*)x);
diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c
index 65dba8f..d58f643 100644
--- a/shared/tkwidgets.c
+++ b/shared/tkwidgets.c
@@ -169,28 +169,31 @@ static int calculate_onset(int x_location, int width,
* current_iolet / (total_iolets == 1 ? 1 : total_iolets - 1));
}
+/* standard method for drawing inlets and outlets. Currently, the number of
+ * inlets and outlets is set in tkwidgets.h since I think all of the
+ * objectclasses will have the same ones. If that needs to change, then this
+ * function can use obj_ninlets() and obj_noutlets() */
void tkwidgets_draw_iolets(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 width, int height)
{
int i, onset;
int x_location = text_xpix(x, glist);
int y_location = text_ypix(x, glist);
/* TODO: make inlets draw on top of widget */
- for (i = 0; i < total_inlets; i++) /* inlets */
+ for (i = 0; i < TOTAL_INLETS; i++) /* inlets */
{
- onset = calculate_onset(x_location, width, i, total_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 */
+ for (i = 0; i < TOTAL_OUTLETS; i++) /* outlets */
{
- onset = calculate_onset(x_location, width, i, total_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,
diff --git a/shared/tkwidgets.h b/shared/tkwidgets.h
index fa444fa..0bc3996 100644
--- a/shared/tkwidgets.h
+++ b/shared/tkwidgets.h
@@ -33,6 +33,10 @@
#pragma warning( disable : 4305 )
#endif
+/* so far, all of the tkwidgets objects have the same inlets/outlets */
+#define TOTAL_INLETS 1
+#define TOTAL_OUTLETS 2
+
/* size and offset for the resizing handle */
#define TKW_HANDLE_HEIGHT 15
#define TKW_HANDLE_WIDTH 15
@@ -92,8 +96,7 @@ 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_iolets(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 width, int height);
void tkwidgets_erase_iolets(t_symbol* canvas_id, t_symbol* iolets_tag);
void tkwidgets_draw_handle(); // TODO draw resize handle when selected in editmode
diff --git a/text.c b/text.c
index a9c8266..ca0e1a1 100644
--- a/text.c
+++ b/text.c
@@ -37,9 +37,6 @@
#define TEXT_MIN_WIDTH 40
#define TEXT_MIN_HEIGHT 20
-#define TOTAL_INLETS 1
-#define TOTAL_OUTLETS 2
-
#define DEBUG(x) x
static t_class *textwidget_class;
@@ -109,6 +106,8 @@ static char *textwidget_tk_options[] = {
"undo",
"width",
"wrap",
+// "xscrollcommand", /* problematic since it uses the canvas_id, etc. */
+// "yscrollcommand", /* problematic since it uses the canvas_id, etc. */
};
@@ -187,7 +186,7 @@ static void textwidget_drawme(t_textwidget *x, t_glist *glist)
create_widget(x);
tkwidgets_draw_iolets((t_object*)x, glist,
x->canvas_id, x->iolets_tag, x->all_tag,
- x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS);
+ x->width, x->height);
if(x->have_scrollbars) draw_scrollbar(x);
sys_vgui("%s create window %d %d -anchor nw -window %s \
-tags {%s %s} -width %d -height %d \n", x->canvas_id->s_name,
@@ -557,7 +556,7 @@ static void textwidget_size(t_textwidget *x, t_float width, t_float height)
tkwidgets_erase_iolets(x->canvas_id, x->iolets_tag);
tkwidgets_draw_iolets((t_object*)x, x->x_glist,
x->canvas_id, x->iolets_tag, x->all_tag,
- x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS);
+ x->width, x->height);
canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet
}
}
@@ -605,7 +604,7 @@ static void textwidget_resize_click_callback(t_textwidget *x, t_floatarg f)
{
tkwidgets_draw_iolets((t_object*)x, canvas,
x->canvas_id, x->iolets_tag, x->all_tag,
- x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS);
+ x->width, x->height);
canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet
}
if (!x->x_resizing && button_state)