aboutsummaryrefslogtreecommitdiff
path: root/generic/tkZinc.c
diff options
context:
space:
mode:
authorlecoanet2004-03-04 10:11:24 +0000
committerlecoanet2004-03-04 10:11:24 +0000
commit174f8612fdb56eb1e21fceb67debdd5c73e1b550 (patch)
tree4537fc2ef7077fbc389bd6bceec255f39361553d /generic/tkZinc.c
parentc924463312c85c71902addaa39a874214d7e6f77 (diff)
downloadtkzinc-174f8612fdb56eb1e21fceb67debdd5c73e1b550.zip
tkzinc-174f8612fdb56eb1e21fceb67debdd5c73e1b550.tar.gz
tkzinc-174f8612fdb56eb1e21fceb67debdd5c73e1b550.tar.bz2
tkzinc-174f8612fdb56eb1e21fceb67debdd5c73e1b550.tar.xz
The coords command will return a flat point instead of a list
of one point for all items with a -position.
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r--generic/tkZinc.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 5782f6a..cab10d3 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -3419,16 +3419,28 @@ Coords(ZnWInfo *wi,
/*printf(" coords: read %d points, first is %g@%g\n",
num_points, points->x, points->y);*/
l = Tcl_GetObjResult(wi->interp);
- for (i = 0; i < num_points; i++, points++) {
- entries[0] = Tcl_NewDoubleObj(points->x);
- entries[1] = Tcl_NewDoubleObj(points->y);
- if (controls && controls[i]) {
- c[0] = controls[i];
- entries[2] = Tcl_NewStringObj(c, -1);
- Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(3, entries));
- }
- else {
- Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(2, entries));
+ if (item->class->pos_offset >= 0) {
+ /*
+ * Special case for items with a -position. In this case
+ * we are guaranteed to return exactly one point, it is
+ * then more friendly to return it flat instead of as the
+ * only element of a list.
+ */
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(points->x));
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewDoubleObj(points->y));
+ }
+ else {
+ for (i = 0; i < num_points; i++, points++) {
+ entries[0] = Tcl_NewDoubleObj(points->x);
+ entries[1] = Tcl_NewDoubleObj(points->y);
+ if (controls && controls[i]) {
+ c[0] = controls[i];
+ entries[2] = Tcl_NewStringObj(c, -1);
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(3, entries));
+ }
+ else {
+ Tcl_ListObjAppendElement(wi->interp, l, Tcl_NewListObj(2, entries));
+ }
}
}
return TCL_OK;