diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Item.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/generic/Item.c b/generic/Item.c index 8fe85f6..4f1cdd8 100644 --- a/generic/Item.c +++ b/generic/Item.c @@ -727,12 +727,27 @@ ZnConfigureAttributes(ZnWInfo *wi, } break; } + case ZN_CONFIG_ANGLE: + { + double angle; + int int_angle; + if (Tcl_GetDoubleFromObj(wi->interp, args[i+1], &angle) == TCL_ERROR) { + return TCL_ERROR; + } + if ((angle > 360) || (angle < -360)) { + angle = fmod(angle, 360.0); + } + int_angle = (int) angle; + if (int_angle != *((int *) valp)) { + *((int *) valp) = int_angle; + *flags |= desc->flags; + } + break; + } case ZN_CONFIG_DIM: { - ZnDim dim; + double dim; if (Tcl_GetDoubleFromObj(wi->interp, args[i+1], &dim) == TCL_ERROR) { - Tcl_AppendResult(wi->interp, " dimension expected for attribute \"", - Tcl_GetString(args[i+1]), "\"", NULL); return TCL_ERROR; } if (dim != *((ZnDim *) valp)) { @@ -899,23 +914,15 @@ ZnConfigureAttributes(ZnWInfo *wi, } case ZN_CONFIG_INT: case ZN_CONFIG_UINT: - case ZN_CONFIG_ANGLE: { int integer; if (Tcl_GetIntFromObj(wi->interp, args[i+1], &integer) == TCL_ERROR) { return TCL_ERROR; } - switch (desc->type) { - case ZN_CONFIG_ANGLE: - if ((integer > 360) || (integer < -360)) { - integer = integer % 360; - } - break; - case ZN_CONFIG_UINT: + if (desc->type == ZN_CONFIG_UINT) { if (integer < 0) { integer = 0; } - break; } if (integer != *((int *) valp)) { *((int *) valp) = integer; @@ -1213,7 +1220,7 @@ AttributeToObj(Tcl_Interp *interp, return Tcl_NewIntObj(*((unsigned int *) valp)); case ZN_CONFIG_INT: case ZN_CONFIG_ANGLE: - return Tcl_NewIntObj(*((int *) valp)); + return Tcl_NewDoubleObj(*((int *) valp)); case ZN_CONFIG_DIM: return Tcl_NewDoubleObj(*((ZnDim *) valp)); case ZN_CONFIG_ALIGNMENT: |