Re: Bug in tkined-0.9

Juergen Schoenwaelder (schoenw@bayes)
Wed, 13 Apr 94 00:15:50 +0200

Hi!

John> When a group(child) is put into another group(parent), the expanded
John> size of the parent doesn't change when the child group is
John> expanded. This leads to some really strange looking digrams.

John> Does anybody have any ideas how to work around this?

Below is a patch that should fix this problem. Its taken from my
current source tree and it may need some tinkering to get it into
your sources.

Juergen

*** tkined_objects.tcl.old Sun Apr 10 21:09:19 1994
--- tkined_objects.tcl Tue Apr 12 23:32:39 1994
***************
*** 502,507 ****
--- 502,525 ----
$group items $item
}

+ proc GROUP::resize { group } {
+ set c [$group canvas]
+
+ set memberitems ""
+ foreach id [$group member] {
+ lappend memberitems [$id items]
+ }
+ if {$memberitems == ""} return
+
+ set bb [eval $c bbox [join $memberitems]]
+ set x1 [expr {[lindex $bb 0]-3}]
+ set y1 [expr {[lindex $bb 1]-3}]
+ set x2 [expr {[lindex $bb 2]+3}]
+ set y2 [expr {[lindex $bb 3]+3}]
+
+ $c coords "id $group" $x1 $y1 $x1 $y2 $x2 $y2 $x2 $y1 $x1 $y1
+ }
+
proc GROUP::select { group } {
set c [$group canvas]
foreach item [$group items] {
*** methods.c.old Sun Apr 10 19:00:09 1994
--- methods.c Tue Apr 12 23:33:23 1994
***************
*** 133,138 ****
--- 133,160 ----
(char *) NULL);
}

+ /*
+ * Update the size of an expanded parent objects.
+ */
+
+ static void
+ parent_resize (interp, object)
+ Tcl_Interp *interp;
+ tkined_object *object;
+ {
+ char *tmp = "reset";
+
+ if (object->parent != '\0') {
+ tkined_object *parent = id_to_object (object->parent);
+ if ((parent != NULL) && (! (parent->collapsed))) {
+ Tcl_VarEval (interp, type_to_string (parent->type),
+ "::resize ", parent->id, (char *) NULL);
+ m_label (interp, parent, 1, &tmp);
+ parent_resize (interp, parent);
+ }
+ }
+ }
+


/*
***************
*** 1288,1294 ****
Tcl_VarEval (interp, type_to_string (object->type),
"::icon ", object->id, (char *) NULL);

! m_label (interp, object, 1, &tmp);

if (selected) {
m_select (interp, object, 0, (char **) NULL);
--- 1310,1320 ----
Tcl_VarEval (interp, type_to_string (object->type),
"::icon ", object->id, (char *) NULL);

! m_label (interp, object, 1, &tmp);
!
! /* adjust the size of a parent group if necessary */
!
! parent_resize (interp, object);

if (selected) {
m_select (interp, object, 0, (char **) NULL);
***************
*** 1494,1499 ****
--- 1520,1529 ----
}
free ((char*) largv);

+ /* adjust the size of a parent group if necessary */
+
+ parent_resize (interp, object);
+
sprintf (buffer, "ined move %s %f %f", object->id, x, y);
sprintf (buf, "%f %f", object->x, object->y);
trace (object->editor, buf, buffer);
***************
*** 2412,2425 ****
}
}
free ((char*) largv);
!
Tcl_VarEval (interp, type_to_string (object->type),
"::expand ", object->id, (char *) NULL);

m_color (interp, object, 1, &object->color);
m_font (interp, object, 1, &object->font);
m_label (interp, object, 1, &object->label);

if (selected) {
m_select (interp, object, 0, (char **) NULL);
}
--- 2442,2459 ----
}
}
free ((char*) largv);
!
Tcl_VarEval (interp, type_to_string (object->type),
"::expand ", object->id, (char *) NULL);

m_color (interp, object, 1, &object->color);
m_font (interp, object, 1, &object->font);
m_label (interp, object, 1, &object->label);
+
+ /* adjust the size of a parent group if necessary */

+ parent_resize (interp, object);
+
if (selected) {
m_select (interp, object, 0, (char **) NULL);
}
***************
*** 2532,2537 ****
--- 2566,2573 ----
}

m_label (interp, object, 1, &tmp);
+
+ parent_resize (interp, object);
}
}