aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Item.c120
1 files changed, 39 insertions, 81 deletions
diff --git a/generic/Item.c b/generic/Item.c
index 5d9ac86..cf198e7 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -883,14 +883,17 @@ ConfigureAttributes(char *record,
* associated with the tag.
*/
{
- Item item2;
- int num;
+ Item item2;
+ int result;
+ TagSearch *search_var = NULL;
if (strlen(Tcl_GetString(args[i+1])) == 0) {
item2 = ZN_NO_ITEM;
}
else {
- num = ZnItemsWithTagOrId(wi, args[i+1], &item2, NULL);
- if (num == 0) {
+ result = ZnItemWithTagOrId(wi, args[i+1], wi->top_group, True,
+ &item2, &search_var);
+ ZnTagSearchDestroy(search_var);
+ if ((result == ZN_ERROR) || (item2 == ZN_NO_ITEM)) {
return ZN_ERROR;
}
}
@@ -1091,13 +1094,12 @@ ConfigureAttributes(char *record,
* of the fields that serve to anchor the label's leader. More specifically
* the bottom left corner of the left field and the bottom right corner of
* the right field are used as the anchors.
- * If lChar is '%', leftLeaderAnchor and rightLeaderAnchor should be specified
- * as 'valxval', 'val' being a percentage (max 100) of the width/height of
- * the label bounding box. If rightLeaderAnchor is not specified it defaults to
- * field 0. If rightLeaderField is not specified it defaults to
- * leftLeaderAnchor. If neither of them are specified, the center of the label
- * is used as an anchor.
- *
+ * If lChar is '%', leftLeaderAnchor and rightLeaderAnchor should be
+ * specified as 'valxval', 'val' being a percentage (max 100) of the
+ * width/height of the label bounding box.
+ * If rightLeaderAnchor is not specified it defaults to leftLeaderAnchor.
+ * If neither of them are specified, the center of the label is used as an
+ * anchor.
*/
{
LeaderAnchors lanch = NULL;
@@ -1509,24 +1511,30 @@ AttributeToObj(WidgetInfo *wi,
case ZN_CONFIG_LEADER_ANCHORS:
{
- LeaderAnchors lanch = (LeaderAnchors) valp;
+ LeaderAnchors lanch = *((LeaderAnchors *) valp);
char *ptr = buffer;
int count;
- if (lanch->left_y < 0) {
- count = sprintf(ptr, "|%d", lanch->left_x);
+ if (!lanch) {
+ ptr = "%50x50";
}
else {
- count = sprintf(ptr, "%%%dx%d", lanch->left_x, lanch->left_y);
- }
- ptr += count;
- if (lanch->right_y < 0) {
- count = sprintf(ptr, "|%d", lanch->right_x);
- }
- else {
- count = sprintf(ptr, "%%%dx%d", lanch->right_x, lanch->right_y);
+ if (lanch->left_y < 0) {
+ count = sprintf(ptr, "|%d", lanch->left_x);
+ }
+ else {
+ count = sprintf(ptr, "%%%dx%d", lanch->left_x, lanch->left_y);
+ }
+ ptr += count;
+ if (lanch->right_y < 0) {
+ count = sprintf(ptr, "|%d", lanch->right_x);
+ }
+ else {
+ count = sprintf(ptr, "%%%dx%d", lanch->right_x, lanch->right_y);
+ }
+ ptr = buffer;
}
- result = NewStringObj(buffer);
+ result = NewStringObj(ptr);
}
}
@@ -2656,10 +2664,8 @@ static void
AddTag(Item item,
Tk_Uid tag)
{
- int new_entry, num, i;
+ int num, i;
char **ptr;
- Tcl_HashEntry *entry;
- ZnList item_list;
/*
* No tags yet.
@@ -2683,15 +2689,6 @@ AddTag(Item item,
* Add it.
*/
ZnListAdd(item->tags, &tag, ZnListTail);
- entry = Tcl_CreateHashEntry(item->wi->tag_table, tag, &new_entry);
- if (new_entry) {
- item_list = ZnListNew(1, sizeof(Item));
- Tcl_SetHashValue(entry, item_list);
- }
- else {
- item_list = (ZnList) Tcl_GetHashValue(entry);
- }
- ZnListAdd(item_list, &item, ZnListTail);
}
/*
@@ -2707,9 +2704,6 @@ RemoveTag(Item item,
{
int indx, num;
char **ptr;
- Item *item_ptr;
- Tcl_HashEntry *entry;
- ZnList item_list;
if (!item->tags) {
return;
@@ -2724,22 +2718,6 @@ RemoveTag(Item item,
/* The tag list is not freed when empty to avoid
* overhead when using tags intensively. */
ZnListDelete(item->tags, indx);
- entry = Tcl_FindHashEntry(item->wi->tag_table, tag);
- if (entry) { /* Should not fail */
- item_list = (ZnList) Tcl_GetHashValue(entry);
- num = ZnListSize(item_list);
- item_ptr = (Item *) ZnListArray(item_list);
- for (indx = 0; indx < num; indx++) {
- if (item_ptr[indx] == item) {
- /* Should not fail to get here */
- ZnListDelete(item_list, indx);
- if (ZnListSize(item_list) == 0) {
- ZnListFree(item_list);
- Tcl_DeleteHashEntry(entry);
- }
- }
- }
- }
return;
}
}
@@ -2755,35 +2733,9 @@ RemoveTag(Item item,
static void
FreeTags(Item item)
{
- int num, num_items, i, j;
- char **ts;
- Item *item_ptr;
- Tcl_HashEntry *entry;
- ZnList item_list;
-
if (!item->tags) {
return;
}
- num = ZnListSize(item->tags);
- ts = (char **) ZnListArray(item->tags);
- for (i = 0; i < num; i++) {
- entry = Tcl_FindHashEntry(item->wi->tag_table, ts[i]);
- if (entry) { /* Should not fail */
- item_list = (ZnList) Tcl_GetHashValue(entry);
- item_ptr = (Item *) ZnListArray(item_list);
- num_items = ZnListSize(item_list);
- for (j = 0; j < num_items; j++) {
- if (item_ptr[j] == item) {
- /* Should not fail to get here */
- ZnListDelete(item_list, j);
- if (ZnListSize(item_list) == 0) {
- ZnListFree(item_list);
- Tcl_DeleteHashEntry(entry);
- }
- }
- }
- }
- }
ZnListFree(item->tags);
item->tags = NULL;
}
@@ -2811,7 +2763,6 @@ CreateItem(WidgetInfo *wi,
Item item;
item = (Item) ZnMalloc(item_class->item_size);
- wi->num_items++;
/* Initialize common state */
item->class = item_class;
@@ -2832,10 +2783,12 @@ CreateItem(WidgetInfo *wi,
ZnFree(item);
return ZN_NO_ITEM;
}
+
SetId(item);
item->tags = NULL;
SET(wi->events_flags, INTERNAL_NEED_REPICK);
+ wi->num_items++;
return (item);
}
@@ -2888,6 +2841,8 @@ CloneItem(Item model)
item->class->Clone(item);
SET(wi->events_flags, INTERNAL_NEED_REPICK);
+ wi->num_items++;
+
return item;
}
@@ -3606,6 +3561,9 @@ DestroyItem(Item item)
wi->new_item = ZN_NO_ITEM;
wi->new_part = ZN_NO_PART;
}
+ if ((wi->hot_item == item) || (wi->hot_prev) == item) {
+ wi->hot_item = ZN_NO_ITEM;
+ }
if (wi->text_info.sel_item == item) {
wi->text_info.sel_item = ZN_NO_ITEM;
}