aboutsummaryrefslogtreecommitdiff
path: root/generic/Item.c
diff options
context:
space:
mode:
authorlecoanet2003-10-02 08:29:29 +0000
committerlecoanet2003-10-02 08:29:29 +0000
commit50bb935e3978499146deaa612ec93a4675d18efa (patch)
tree473256b426f6faaf7a247b3a81ccb8202000f964 /generic/Item.c
parentd1c619094efe5c3bc9d7ce1570fb95eb93e6a9bb (diff)
downloadtkzinc-50bb935e3978499146deaa612ec93a4675d18efa.zip
tkzinc-50bb935e3978499146deaa612ec93a4675d18efa.tar.gz
tkzinc-50bb935e3978499146deaa612ec93a4675d18efa.tar.bz2
tkzinc-50bb935e3978499146deaa612ec93a4675d18efa.tar.xz
Adaptation of ZnConfigureAttributes to obtain the item
and the attribute record. This enable the configuration of attributes from fields even if the item record is needed.
Diffstat (limited to 'generic/Item.c')
-rw-r--r--generic/Item.c77
1 files changed, 54 insertions, 23 deletions
diff --git a/generic/Item.c b/generic/Item.c
index 0353b06..27c7347 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -108,6 +108,24 @@ static void AttributeToObj(ZnWInfo *wi, void *record, ZnAttrConfig *desc,
char *buffer, Tcl_Obj *result);
+
+/*
+ **********************************************************************************
+ *
+ * ZnUpdateItemImage --
+ *
+ **********************************************************************************
+ */
+void
+ZnUpdateItemImage(void *client_data)
+{
+ ZnItem item = (ZnItem) client_data;
+
+ /*printf("Invalidation of item %ld\n", item->id);*/
+ Invalidate(item, ZN_CLFC_FLAG | ZN_COORDS_FLAG);
+}
+
+
/*
**********************************************************************************
*
@@ -198,6 +216,7 @@ ZnAttributesInfo(ZnWInfo *wi,
*/
int
ZnConfigureAttributes(ZnWInfo *wi,
+ ZnItem item,
void *record,
ZnAttrConfig *attr_desc,
int argc,
@@ -332,7 +351,7 @@ ZnConfigureAttributes(ZnWInfo *wi,
case ZN_CONFIG_BITMAP:
{
ZnImage image = ZnUnspecifiedImage;
- char *msg;
+ ZnBool is_bmap = True;
#if 0
char *name = "";
@@ -346,20 +365,28 @@ ZnConfigureAttributes(ZnWInfo *wi,
#endif
if (strlen(str) != 0) {
if (desc->type == ZN_CONFIG_IMAGE) {
- image = ZnGetImage(wi, str);
- msg = " image expected for attribute \"";
- }
- else{
- image = ZnGetBitmap(wi, str);
- msg = " bitmap expected for attribute \"";
+ image = ZnGetImage(wi, str, ZnUpdateItemImage, record);
+ if (image == ZnUnspecifiedImage) {
+ Tcl_AppendResult(wi->interp, " image expected for attribute \"",
+ Tcl_GetString(args[i]), "\"", NULL);
+ return TCL_ERROR;
+ }
}
- if (image == ZnUnspecifiedImage) {
- Tcl_AppendResult(wi->interp, msg, Tcl_GetString(args[i]), "\"", NULL);
- return TCL_ERROR;
+ else {
+ image = ZnGetImage(wi, str, NULL, NULL);
+ if ((image == ZnUnspecifiedImage) ||
+ (!(is_bmap = ZnImageIsBitmap(image)))) {
+ if (!is_bmap) {
+ ZnFreeImage(image, NULL, NULL);
+ }
+ Tcl_AppendResult(wi->interp, " bitmap expected for attribute \"",
+ Tcl_GetString(args[i]), "\"", NULL);
+ return TCL_ERROR;
+ }
}
}
if (*((ZnImage *) valp) != ZnUnspecifiedImage) {
- ZnFreeImage(*((ZnImage *) valp));
+ ZnFreeImage(*((ZnImage *) valp), ZnUpdateItemImage, record);
}
*((ZnImage *) valp) = image;
*flags |= desc->flags;
@@ -374,7 +401,8 @@ ZnConfigureAttributes(ZnWInfo *wi,
ZnImage *pats;
unsigned int num_pats, j, k;
Tcl_Obj **elems;
-
+ ZnBool is_bmap = True;
+
if (Tcl_ListObjGetElements(wi->interp, args[i+1],
&num_pats, &elems) == TCL_ERROR) {
Tcl_AppendResult(wi->interp,
@@ -389,14 +417,18 @@ ZnConfigureAttributes(ZnWInfo *wi,
for (j = 0; j < num_pats; j++) {
str = Tcl_GetString(elems[j]);
if (strlen(str) != 0) {
- pats[j] = ZnGetBitmap(wi, str);
- if (pats[j] == None) {
- Tcl_AppendResult(wi->interp, " unknown pattern \"", str,
- "\" in pattern list", NULL);
+ pats[j] = ZnGetImage(wi, str, NULL, NULL);
+ if ((pats[j] == ZnUnspecifiedImage) ||
+ !(is_bmap = ZnImageIsBitmap(pats[j]))) {
+ if (!is_bmap) {
+ ZnFreeImage(pats[j], NULL, NULL);
+ }
for (k = 0; k < j; k++) {
- ZnFreeImage(pats[k]);
+ ZnFreeImage(pats[k], NULL, NULL);
}
ZnListFree(new_pat_list);
+ Tcl_AppendResult(wi->interp, " unknown pattern \"", str,
+ "\" in pattern list", NULL);
return TCL_ERROR;
}
}
@@ -410,7 +442,7 @@ ZnConfigureAttributes(ZnWInfo *wi,
pats = ZnListArray(*((ZnList *) valp));
for (j = 0; j < num_pats; j++) {
if (pats[j] != ZnUnspecifiedImage) {
- ZnFreeImage(pats[j]);
+ ZnFreeImage(pats[j], NULL, NULL);
}
}
ZnListFree(*((ZnList *) valp));
@@ -438,12 +470,12 @@ ZnConfigureAttributes(ZnWInfo *wi,
return TCL_ERROR;
}
if (*((ZnList *) valp)) {
- ZnITEM.FreeTags((ZnItem) record);
+ ZnITEM.FreeTags(item);
*flags |= desc->flags;
}
if (num_tags) {
for (j = 0; j < num_tags; j++) {
- ZnITEM.AddTag((ZnItem) record, Tk_GetUid(Tcl_GetString(elems[j])));
+ ZnITEM.AddTag(item, Tk_GetUid(Tcl_GetString(elems[j])));
}
*flags |= desc->flags;
}
@@ -653,7 +685,7 @@ ZnConfigureAttributes(ZnWInfo *wi,
}
if (pri != *((int *) valp)) {
*((int *) valp) = pri;
- ZnITEM.UpdateItemPriority((ZnItem) record, ZN_NO_ITEM, True);
+ ZnITEM.UpdateItemPriority(item, ZN_NO_ITEM, True);
*flags |= desc->flags;
}
break;
@@ -822,7 +854,6 @@ ZnConfigureAttributes(ZnWInfo *wi,
str++;
}
if (strlen(str) != 0) {
- ZnItem item = (ZnItem) record;
frmt = ZnLFCreate(wi->interp, str,
ZnFIELD.NumFields(item->class->GetFieldSet(item)));
if (frmt == NULL) {
@@ -1633,7 +1664,7 @@ ConfigureItem(ZnItem item,
}
else if (item->class->GetFieldSet) {
if (ZnFIELD.ConfigureField(item->class->GetFieldSet(item),
- field, argc, argv, &flags) == TCL_ERROR) {
+ field, argc, argv, &flags) == TCL_ERROR) {
return TCL_ERROR;
}
}