From 709009bfb836f4bac7ff74318b295349df1a4a9d Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 20 Dec 2002 13:51:29 +0000 Subject: * Corrige un bug provoquant une boucle infinie lorsque l'on employe un tag dans la commande lower. --- generic/tkZinc.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 8 deletions(-) (limited to 'generic/tkZinc.c') diff --git a/generic/tkZinc.c b/generic/tkZinc.c index d360539..1b5471c 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -1970,6 +1970,80 @@ ZnItemWithTagOrId(WidgetInfo *wi, /* *---------------------------------------------------------------------- * + * LayoutItems -- + * + * Perform layouts on items. It can position items horizontally, + * vertically, along a path or with respect to a reference item. + * It can also align on a grid and resize items to a common + * reference. + * + *---------------------------------------------------------------------- + */ +static int +LayoutItems(WidgetInfo *wi, + int argc, + Tcl_Obj *CONST args[]) +{ + int index, result; + Item item; + static CONST char *layout_cmd_strings[] = { + "bbalign", "valign", "halign", "align", + "position", "grid", "size", NULL + }; + enum layout_cmds { + ZN_L_BBALIGN, ZN_L_VALIGN, ZN_L_HALIGN, ZN_L_ALIGN, + ZN_L_POSITION, ZN_L_GRID, ZN_L_SIZE + }; + + if (Tcl_GetIndexFromObj(wi->interp, args[0], layout_cmd_strings, + "align command", 0, &index) != ZN_OK) { + return ZN_ERROR; + } + switch((enum layout_cmds) index) { + /* + * align + */ + case ZN_L_ALIGN: + break; + /* + * halign + */ + case ZN_L_HALIGN: + break; + /* + * valign + */ + case ZN_L_VALIGN: + break; + /* + * bbalign + */ + case ZN_L_BBALIGN: + break; + /* + * position + */ + case ZN_L_POSITION: + break; + /* + * grid + */ + case ZN_L_GRID: + break; + /* + * size + */ + case ZN_L_SIZE: + break; + } + + return ZN_OK; +} + + +/* + *---------------------------------------------------------------------- + * * ZnDoItem -- * * Either add a tag to an item or add the item id/part to the @@ -2955,7 +3029,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ "coords", "currentpart", "cursor", "dchars", "dtag", "find", "fit", "focus", "gdelete", "gettags", "gname", "group", "hasanchors", "hasfields", "hastag", - "index", "insert", "itemcget", "itemconfigure", + "index", "insert", "itemcget", "itemconfigure", "layout", "lower", "monitor", "numparts", "postscript", "raise", "remove", "rotate", "scale", "select", "smooth", "tapply", "tdelete", "transform", "translate", "treset", @@ -2967,7 +3041,7 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ 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_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_SMOOTH, ZN_W_TAPPLY, ZN_W_TDELETE, ZN_W_TRANSFORM, ZN_W_TRANSLATE, ZN_W_TRESET, @@ -4015,11 +4089,26 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ } break; /* + * layout + */ + case ZN_W_LAYOUT: + { + if (argc < 4) { + Tcl_WrongNumArgs(interp, 1, args, + "layout operator ?args...? tagOrId ?tagOrId...?"); + goto error; + } + if (LayoutItems(wi, argc-2, args+2) == ZN_ERROR) { + goto error; + } + } + break; + /* * lower */ case ZN_W_LOWER: { - Item group, mark = ZN_NO_ITEM; + Item first, group, mark = ZN_NO_ITEM; if (argc < 3) { Tcl_WrongNumArgs(interp, 1, args, "lower tagOrId ?belowThis?"); @@ -4046,19 +4135,19 @@ WidgetObjCmd(ClientData client_data, /* Information about the widget. */ if (item == ZN_NO_ITEM) { goto done; } + first = item; if (mark == ZN_NO_ITEM) { mark = ZnGroupTail(item->parent); } group = mark->parent; - for (; item != ZN_NO_ITEM; item = ZnTagSearchNext(search_var)) { - if (item->parent != group) { - continue; - } - if (item != mark) { + do { + if ((item->parent == group) && (item != mark)) { ITEM.UpdateItemPriority(item, mark, False); mark = item; } + item = ZnTagSearchNext(search_var); } + while ((item != ZN_NO_ITEM) && (item != first)); } break; /* -- cgit v1.1