aboutsummaryrefslogtreecommitdiff
path: root/generic/Item.c
diff options
context:
space:
mode:
authorlecoanet2004-03-03 16:40:50 +0000
committerlecoanet2004-03-03 16:40:50 +0000
commita5befb7f79676109c4dab8fcfe54f85e7998afa5 (patch)
tree8438fe75c2fd8dfff66597a483a6175d034d2c0a /generic/Item.c
parente41edb6806917a171fda92a840810cb26e842e18 (diff)
downloadtkzinc-a5befb7f79676109c4dab8fcfe54f85e7998afa5.zip
tkzinc-a5befb7f79676109c4dab8fcfe54f85e7998afa5.tar.gz
tkzinc-a5befb7f79676109c4dab8fcfe54f85e7998afa5.tar.bz2
tkzinc-a5befb7f79676109c4dab8fcfe54f85e7998afa5.tar.xz
Added new attribute types ZN_CONFIG_CHAR and ZN_CONFIG_UCHAR
Changed the ZN_CONFIG_ALPHA type to be processed as a char, this fixes a potentially long standing bug when configuring an alpha value.
Diffstat (limited to 'generic/Item.c')
-rw-r--r--generic/Item.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/generic/Item.c b/generic/Item.c
index ae71348..f6ed14d 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -97,6 +97,8 @@ static char *attribute_type_strings[] = {
"fillrule",
"short",
"unsignedshort"
+ "char"
+ "unsignedchar"
};
@@ -770,6 +772,34 @@ ZnConfigureAttributes(ZnWInfo *wi,
}
}
break;
+ case ZN_CONFIG_CHAR:
+ case ZN_CONFIG_UCHAR:
+ case ZN_CONFIG_ALPHA:
+ {
+ int integer;
+ if (Tcl_GetIntFromObj(wi->interp, args[i+1], &integer) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ switch (desc->type) {
+ case ZN_CONFIG_UCHAR:
+ if (integer < 0) {
+ integer = 0;
+ }
+ case ZN_CONFIG_ALPHA:
+ if (integer < 0) {
+ integer = 0;
+ }
+ if (integer > 100) {
+ integer = 100;
+ }
+ break;
+ }
+ if (integer != *((char *) valp)) {
+ *((char *) valp) = integer;
+ *flags |= desc->flags;
+ }
+ break;
+ }
case ZN_CONFIG_SHORT:
case ZN_CONFIG_USHORT:
{
@@ -806,7 +836,6 @@ ZnConfigureAttributes(ZnWInfo *wi,
case ZN_CONFIG_INT:
case ZN_CONFIG_UINT:
case ZN_CONFIG_ANGLE:
- case ZN_CONFIG_ALPHA:
{
int integer;
if (Tcl_GetIntFromObj(wi->interp, args[i+1], &integer) == TCL_ERROR) {
@@ -823,14 +852,6 @@ ZnConfigureAttributes(ZnWInfo *wi,
integer = 0;
}
break;
- case ZN_CONFIG_ALPHA:
- if (integer < 0) {
- integer = 0;
- }
- if (integer > 100) {
- integer = 100;
- }
- break;
}
if (integer != *((int *) valp)) {
*((int *) valp) = integer;
@@ -1110,6 +1131,13 @@ AttributeToObj(ZnWInfo *wi,
str = Tk_PathName(*((Tk_Window *) valp));
}
break;
+ case ZN_CONFIG_CHAR:
+ Tcl_SetIntObj(result, *((char *) valp));
+ return;
+ case ZN_CONFIG_UCHAR:
+ case ZN_CONFIG_ALPHA:
+ Tcl_SetIntObj(result, *((unsigned char *) valp));
+ return;
case ZN_CONFIG_USHORT:
case ZN_CONFIG_PRI:
Tcl_SetIntObj(result, *((unsigned short *) valp));
@@ -1122,7 +1150,6 @@ AttributeToObj(ZnWInfo *wi,
return;
case ZN_CONFIG_INT:
case ZN_CONFIG_ANGLE:
- case ZN_CONFIG_ALPHA:
Tcl_SetIntObj(result, *((int *) valp));
return;
case ZN_CONFIG_DIM: