aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlecoanet2004-03-26 16:24:39 +0000
committerlecoanet2004-03-26 16:24:39 +0000
commit076286c9a2b0029c8852237aa89a9b080279af41 (patch)
tree2f56e05c118fad101782e8d119f5e22dc66107a8
parentc5ffe14f3a69402458d5c954b9abb440d71db568 (diff)
downloadtkzinc-076286c9a2b0029c8852237aa89a9b080279af41.zip
tkzinc-076286c9a2b0029c8852237aa89a9b080279af41.tar.gz
tkzinc-076286c9a2b0029c8852237aa89a9b080279af41.tar.bz2
tkzinc-076286c9a2b0029c8852237aa89a9b080279af41.tar.xz
Added a new fieldbbox method and restored the old behavior of the bbox method.
-rw-r--r--Perl/Zinc.pm2
-rw-r--r--debian/changelog6
-rw-r--r--generic/tkZinc.c129
3 files changed, 81 insertions, 56 deletions
diff --git a/Perl/Zinc.pm b/Perl/Zinc.pm
index 5acb2ea..1806c80 100644
--- a/Perl/Zinc.pm
+++ b/Perl/Zinc.pm
@@ -28,7 +28,7 @@ sub CreateOptions
Tk::Methods("add", "addtag", "anchorxy", "bbox", "becomes", "bind", "cget",
"chggroup", "clone", "configure", "contour", "coords", "currentpart",
- "cursor", "dchars", "dtag", "find", "fit", "focus", "gdelete", "gettags",
+ "cursor", "dchars", "dtag", "fieldbbox", "find", "fit", "focus", "gdelete", "gettags",
"gname", "group", "hasanchors", "hasfields", "hastag", "index",
"insert", "itemcget", "itemconfigure", "lower", "monitor",
"numparts", "postscript", "raise", "remove", "rotate", "scale",
diff --git a/debian/changelog b/debian/changelog
index c9add61..461ce41 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -60,9 +60,9 @@ zinc-tk (3.2.97) unstable; urgency=low
groups overriding the atomic specification. The
recursive flag takes the new value 'override' to do
so.
- * bbox no longer works on multiple tagOrIds but handles
- label (say 'label' as second parameter) and field bboxes
- on items with fields.
+ * a new command fieldbbox has been added. It returns the bounding
+ box of the given field for the specified item or the item's label
+ bounding box.
* The bounding box reported for groups with clip areas
takes into account the clipping. This was a long
standing bug.
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index 9f0ad08..9200c6d 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -3696,27 +3696,27 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"add", "addtag", "anchorxy", "bbox", "becomes", "bind",
"cget", "chggroup", "clone", "configure", "contour",
"coords", "currentpart", "cursor", "dchars",
- "dtag", "find", "fit", "focus", "gdelete", "gettags",
- "gname", "group", "hasanchors", "hasfields", "hastag",
- "index", "insert", "itemcget", "itemconfigure", "layout",
- "lower", "monitor", "numparts", "postscript", "raise",
- "remove", "rotate", "scale", "select", "skew", "smooth",
- "tapply", "tcompose", "tdelete", "tget", "transform",
- "translate", "treset", "trestore", "tsave", "tset",
- "type", "vertexat", "xview", "yview", NULL
+ "dtag", "fieldbbox", "find", "fit", "focus", "gdelete",
+ "gettags", "gname", "group", "hasanchors", "hasfields",
+ "hastag", "index", "insert", "itemcget", "itemconfigure",
+ "layout", "lower", "monitor", "numparts", "postscript",
+ "raise", "remove", "rotate", "scale", "select", "skew",
+ "smooth", "tapply", "tcompose", "tdelete", "tget",
+ "transform", "translate", "treset", "trestore", "tsave",
+ "tset", "type", "vertexat", "xview", "yview", NULL
};
enum sub_cmds {
ZN_W_ADD, ZN_W_ADDTAG, ZN_W_ANCHORXY, ZN_W_BBOX, ZN_W_BECOMES, ZN_W_BIND,
ZN_W_CGET, ZN_W_CHGGROUP, ZN_W_CLONE, ZN_W_CONFIGURE,
ZN_W_CONTOUR, ZN_W_COORDS, ZN_W_CURRENTPART, ZN_W_CURSOR, ZN_W_DCHARS,
- ZN_W_DTAG, ZN_W_FIND, ZN_W_FIT, ZN_W_FOCUS, ZN_W_GDELETE, ZN_W_GETTAGS,
- ZN_W_GNAME, ZN_W_GROUP, ZN_W_HASANCHORS, ZN_W_HASFIELDS, ZN_W_HASTAG,
- ZN_W_INDEX, ZN_W_INSERT, ZN_W_ITEMCGET, ZN_W_ITEMCONFIGURE, ZN_W_LAYOUT,
- ZN_W_LOWER, ZN_W_MONITOR, ZN_W_NUMPARTS, ZN_W_POSTSCRIPT, ZN_W_RAISE,
- ZN_W_REMOVE, ZN_W_ROTATE, ZN_W_SCALE, ZN_W_SELECT, ZN_W_SKEW, ZN_W_SMOOTH,
- ZN_W_TAPPLY, ZN_W_TCOMPOSE, ZN_W_TDELETE, ZN_W_TGET, ZN_W_TRANSFORM,
- ZN_W_TRANSLATE, ZN_W_TRESET, ZN_W_TRESTORE, ZN_W_TSAVE, ZN_W_TSET,
- ZN_W_TYPE, ZN_W_VERTEX_AT, ZN_W_XVIEW, ZN_W_YVIEW
+ ZN_W_DTAG, ZN_W_FIELD_BBOX, ZN_W_FIND, ZN_W_FIT, ZN_W_FOCUS, ZN_W_GDELETE,
+ ZN_W_GETTAGS, ZN_W_GNAME, ZN_W_GROUP, ZN_W_HASANCHORS, ZN_W_HASFIELDS,
+ ZN_W_HASTAG, ZN_W_INDEX, ZN_W_INSERT, ZN_W_ITEMCGET, ZN_W_ITEMCONFIGURE,
+ ZN_W_LAYOUT, ZN_W_LOWER, ZN_W_MONITOR, ZN_W_NUMPARTS, ZN_W_POSTSCRIPT,
+ ZN_W_RAISE, ZN_W_REMOVE, ZN_W_ROTATE, ZN_W_SCALE, ZN_W_SELECT, ZN_W_SKEW,
+ ZN_W_SMOOTH, ZN_W_TAPPLY, ZN_W_TCOMPOSE, ZN_W_TDELETE, ZN_W_TGET,
+ ZN_W_TRANSFORM, ZN_W_TRANSLATE, ZN_W_TRESET, ZN_W_TRESTORE, ZN_W_TSAVE,
+ ZN_W_TSET, ZN_W_TYPE, ZN_W_VERTEX_AT, ZN_W_XVIEW, ZN_W_YVIEW
};
#ifdef PTK_800
static char *sel_cmd_strings[] =
@@ -3863,49 +3863,19 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
case ZN_W_BBOX:
{
ZnBBox bbox;
- ZnDim width, height;
- ZnFieldSet fs;
- if ((argc != 3) && (argc != 4)) {
- Tcl_WrongNumArgs(interp, 1, args, "bbox tagOrId ?field?");
+ if (argc < 3) {
+ Tcl_WrongNumArgs(interp, 1, args, "bbox tagOrId ?tagOrId ...?");
goto error;
}
+ argc -= 2;
+ args += 2;
Update(wi);
ZnResetBBox(&bbox);
- if (argc == 4) {
- result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
- if ((result == TCL_ERROR) || (item == ZN_NO_ITEM) ||
- ! item->class->GetFieldSet) {
- Tcl_AppendResult(interp, ", unknown item or doesn't support fields\" ",
- Tcl_GetString(args[2]), "\"", NULL);
- goto error;
- }
- fs = item->class->GetFieldSet(item);
- if (Tcl_GetIntFromObj(wi->interp, args[3], &field) != TCL_ERROR) {
- ZnFIELD.GetFieldBBox(fs, field, &bbox);
- }
- else {
- str = Tcl_GetString(args[3]);
- if (strcmp(str, "label") == 0) {
- ZnFIELD.GetLabelBBox(fs, &width, &height);
- p.x = ZnNearestInt(fs->label_pos.x);
- p.y = ZnNearestInt(fs->label_pos.y);
- ZnAddPointToBBox(&bbox, p.x, p.y);
- p.x += width;
- p.y += height;
- ZnAddPointToBBox(&bbox, p.x, p.y);
- }
- else {
- Tcl_AppendResult(interp, ", bbox second parameter should be",
- "either a field index or the tag \"label\"",
- NULL);
- goto error;
- }
- }
- } else {
- if (ZnTagSearchScan(wi, args[2], &search_var) == TCL_ERROR) {
+ for (i = 0; i < (unsigned int) argc; i++) {
+ if (ZnTagSearchScan(wi, args[i], &search_var) == TCL_ERROR) {
goto error;
}
for (item = ZnTagSearchFirst(search_var);
@@ -3913,7 +3883,62 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
ZnAddBBoxToBBox(&bbox, &item->item_bounding_box);
}
}
+ if (!ZnIsEmptyBBox(&bbox)) {
+ l = Tcl_GetObjResult(interp);
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.orig.x));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.orig.y));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.corner.x));
+ Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.corner.y));
+ }
+ }
+ break;
+ /*
+ * fieldbbox
+ */
+ case ZN_W_FIELD_BBOX:
+ {
+ ZnBBox bbox;
+ ZnDim width, height;
+ ZnFieldSet fs;
+
+ if (argc != 4) {
+ Tcl_WrongNumArgs(interp, 1, args, "fieldbbox tagOrId fieldNo|label");
+ goto error;
+ }
+
+ Update(wi);
+ ZnResetBBox(&bbox);
+ result = ZnItemWithTagOrId(wi, args[2], &item, &search_var);
+ if ((result == TCL_ERROR) || (item == ZN_NO_ITEM) ||
+ ! item->class->GetFieldSet) {
+ Tcl_AppendResult(interp, ", unknown item or doesn't support fields\" ",
+ Tcl_GetString(args[2]), "\"", NULL);
+ goto error;
+ }
+ fs = item->class->GetFieldSet(item);
+ if (Tcl_GetIntFromObj(wi->interp, args[3], &field) != TCL_ERROR) {
+ ZnFIELD.GetFieldBBox(fs, field, &bbox);
+ }
+ else {
+ str = Tcl_GetString(args[3]);
+ if (strcmp(str, "label") == 0) {
+ ZnFIELD.GetLabelBBox(fs, &width, &height);
+ p.x = ZnNearestInt(fs->label_pos.x);
+ p.y = ZnNearestInt(fs->label_pos.y);
+ ZnAddPointToBBox(&bbox, p.x, p.y);
+ p.x += width;
+ p.y += height;
+ ZnAddPointToBBox(&bbox, p.x, p.y);
+ }
+ else {
+ Tcl_AppendResult(interp, ", fieldbbox second parameter should be",
+ "either a field index or the tag \"label\"",
+ NULL);
+ goto error;
+ }
+ }
+
if (!ZnIsEmptyBBox(&bbox)) {
l = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.orig.x));