aboutsummaryrefslogtreecommitdiff
path: root/generic/tkZinc.c
diff options
context:
space:
mode:
authorlecoanet2004-05-14 09:14:31 +0000
committerlecoanet2004-05-14 09:14:31 +0000
commit38b84e7182065415fc7d100af02c5e95bce99c34 (patch)
tree70bcfcf1d58e80f4d6d48ae8b979555047805df0 /generic/tkZinc.c
parentf8be1e9121b467ea02037f3265b0066f8cf6c832 (diff)
downloadtkzinc-38b84e7182065415fc7d100af02c5e95bce99c34.zip
tkzinc-38b84e7182065415fc7d100af02c5e95bce99c34.tar.gz
tkzinc-38b84e7182065415fc7d100af02c5e95bce99c34.tar.bz2
tkzinc-38b84e7182065415fc7d100af02c5e95bce99c34.tar.xz
Suppressed the fieldbbox command. It has been merged with bbox and
can be called by the -field and -label options.
Diffstat (limited to 'generic/tkZinc.c')
-rw-r--r--generic/tkZinc.c103
1 files changed, 46 insertions, 57 deletions
diff --git a/generic/tkZinc.c b/generic/tkZinc.c
index ef92355..88b10d9 100644
--- a/generic/tkZinc.c
+++ b/generic/tkZinc.c
@@ -4050,7 +4050,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
"add", "addtag", "anchorxy", "bbox", "becomes", "bind",
"cget", "chggroup", "clone", "configure", "contour",
"coords", "currentpart", "cursor", "dchars",
- "dtag", "fieldbbox", "find", "fit", "focus", "gdelete",
+ "dtag", "find", "fit", "focus", "gdelete",
"gettags", "gname", "group", "hasanchors", "hasfields",
"hastag", "index", "insert", "itemcget", "itemconfigure",
"layout", "lower", "monitor", "numparts", "postscript",
@@ -4063,7 +4063,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
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_FIELD_BBOX, ZN_W_FIND, ZN_W_FIT, ZN_W_FOCUS, ZN_W_GDELETE,
+ 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,
@@ -4217,9 +4217,11 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
case ZN_W_BBOX:
{
ZnBBox bbox;
+ ZnDim width, height;
+ ZnFieldSet fs;
if (argc < 3) {
- Tcl_WrongNumArgs(interp, 1, args, "bbox tagOrId ?tagOrId ...?");
+ Tcl_WrongNumArgs(interp, 1, args, "bbox ?-field fieldNo? ?-label? tagOrId ?tagOrId ...?");
goto error;
}
argc -= 2;
@@ -4228,55 +4230,37 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
Update(wi);
ZnResetBBox(&bbox);
- for (i = 0; i < (unsigned int) argc; i++) {
- if (ZnTagSearchScan(wi, args[i], &search_var) == TCL_ERROR) {
+ str = Tcl_GetString(args[0]);
+ if (*str == '-') {
+ if ((strcmp(str, "-field") == 0) && (argc > 2)) {
+ if (Tcl_GetIntFromObj(wi->interp, args[1], &field) == TCL_ERROR) {
+ goto error;
+ }
+ argc -= 2;
+ args += 2;
+ }
+ else if ((strcmp(str, "-label") == 0) && (argc > 1)) {
+ field = -1;
+ argc--;
+ args++;
+ }
+ else {
+ Tcl_AppendResult(interp, "bbox option should be -field numField or -label",
+ NULL);
goto error;
- }
- for (item = ZnTagSearchFirst(search_var);
- item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
- 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) {
+ result = ZnItemWithTagOrId(wi, args[0], &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[0]), "\"", NULL);
+ goto error;
+ }
+ fs = item->class->GetFieldSet(item);
+ if (field >= 0) {
+ ZnFIELD.GetFieldBBox(fs, field, &bbox);
+ }
+ else {
ZnFIELD.GetLabelBBox(fs, &width, &height);
p.x = ZnNearestInt(fs->label_pos.x);
p.y = ZnNearestInt(fs->label_pos.y);
@@ -4284,15 +4268,20 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */
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;
+ }
+ }
+ else {
+ for (i = 0; i < (unsigned int) argc; i++) {
+ if (ZnTagSearchScan(wi, args[i], &search_var) == TCL_ERROR) {
+ goto error;
+ }
+ for (item = ZnTagSearchFirst(search_var);
+ item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) {
+ ZnAddBBoxToBBox(&bbox, &item->item_bounding_box);
+ }
}
}
-
+
if (!ZnIsEmptyBBox(&bbox)) {
l = Tcl_GetObjResult(interp);
Tcl_ListObjAppendElement(interp, l, Tcl_NewDoubleObj(bbox.orig.x));