aboutsummaryrefslogtreecommitdiff
path: root/generic/Item.c
diff options
context:
space:
mode:
authorlecoanet2004-01-26 09:38:56 +0000
committerlecoanet2004-01-26 09:38:56 +0000
commitc68c018bc093c74ddf57b0501ee59a9aa914c296 (patch)
treed80ccb63454726779e20221bb8e02a1a456b1ef9 /generic/Item.c
parentb4de93b9f382617fa660b31851b0516cd26f7040 (diff)
downloadtkzinc-c68c018bc093c74ddf57b0501ee59a9aa914c296.zip
tkzinc-c68c018bc093c74ddf57b0501ee59a9aa914c296.tar.gz
tkzinc-c68c018bc093c74ddf57b0501ee59a9aa914c296.tar.bz2
tkzinc-c68c018bc093c74ddf57b0501ee59a9aa914c296.tar.xz
* Added new attribute types Short and unsigned short.
* Adaptation to use doubles instead of ZnReal for calls to Tcl_GetDoubleFromObj. * (RotateItem): Added a flag to choose between degrees and radians. * (ScaleItem): Added an optional scale center * Added conditional inclusion of overlap manager include
Diffstat (limited to 'generic/Item.c')
-rw-r--r--generic/Item.c69
1 files changed, 62 insertions, 7 deletions
diff --git a/generic/Item.c b/generic/Item.c
index dca189f..d1d6962 100644
--- a/generic/Item.c
+++ b/generic/Item.c
@@ -39,7 +39,9 @@
#include "Image.h"
#include "Color.h"
#include "tkZinc.h"
+#ifdef OM
#include "OverlapMan.h"
+#endif
#include <limits.h> /* For INT_MAX */
#include <stdarg.h>
@@ -57,7 +59,7 @@ static ZnList item_stack = NULL;
/*
* This array must be kept in sync with the
- * corresponding defines in Types.h.
+ * corresponding defines in Item.h.
*/
static char *attribute_type_strings[] = {
"",
@@ -93,6 +95,8 @@ static char *attribute_type_strings[] = {
"window",
"alpha",
"fillrule",
+ "short",
+ "unsignedshort"
};
@@ -632,6 +636,7 @@ ZnConfigureAttributes(ZnWInfo *wi,
ZnPoint point;
int largc;
Tcl_Obj **largv;
+ double d;
if ((Tcl_ListObjGetElements(wi->interp, args[i+1],
&largc, &largv) == TCL_ERROR) ||
@@ -641,10 +646,14 @@ ZnConfigureAttributes(ZnWInfo *wi,
Tcl_GetString(args[i]), "\"", NULL);
return TCL_ERROR;
}
- if ((Tcl_GetDoubleFromObj(wi->interp, largv[0], &point.x) == TCL_ERROR) ||
- (Tcl_GetDoubleFromObj(wi->interp, largv[1], &point.y) == TCL_ERROR)) {
+ if (Tcl_GetDoubleFromObj(wi->interp, largv[0], &d) == TCL_ERROR) {
+ goto point_error;
+ }
+ point.x = d;
+ if (Tcl_GetDoubleFromObj(wi->interp, largv[1], &d) == TCL_ERROR) {
goto point_error;
}
+ point.y = d;
if ((point.x != ((ZnPoint *) valp)->x) ||
(point.y != ((ZnPoint *) valp)->y)) {
*((ZnPoint *) valp) = point;
@@ -677,8 +686,8 @@ ZnConfigureAttributes(ZnWInfo *wi,
Tcl_GetString(args[i+1]), "\"", NULL);
return TCL_ERROR;
}
- if (pri != *((int *) valp)) {
- *((int *) valp) = pri;
+ if (pri != *((unsigned short *) valp)) {
+ *((unsigned short *) valp) = pri;
ZnITEM.UpdateItemPriority(item, ZN_NO_ITEM, True);
*flags |= desc->flags;
}
@@ -761,6 +770,39 @@ ZnConfigureAttributes(ZnWInfo *wi,
}
}
break;
+ case ZN_CONFIG_SHORT:
+ case ZN_CONFIG_USHORT:
+ {
+ int integer;
+ if (Tcl_GetIntFromObj(wi->interp, args[i+1], &integer) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (desc->type == ZN_CONFIG_SHORT) {
+ if (integer < SHRT_MIN) {
+ integer = SHRT_MIN;
+ }
+ else if (integer > SHRT_MAX) {
+ integer = SHRT_MAX;
+ }
+ if (integer != *((short *) valp)) {
+ *((short *) valp) = integer;
+ *flags |= desc->flags;
+ }
+ }
+ else {
+ if (integer < 0) {
+ integer = 0;
+ }
+ else if (integer > USHRT_MAX) {
+ integer = USHRT_MAX;
+ }
+ if (integer != *((unsigned short *) valp)) {
+ *((unsigned short *) valp) = integer;
+ *flags |= desc->flags;
+ }
+ }
+ break;
+ }
case ZN_CONFIG_INT:
case ZN_CONFIG_UINT:
case ZN_CONFIG_ANGLE:
@@ -2347,12 +2389,19 @@ TranslateItem(ZnItem item,
static void
ScaleItem(ZnItem item,
ZnReal sx,
- ZnReal sy)
+ ZnReal sy,
+ ZnPoint *p)
{
if (!item->transfo) {
item->transfo = ZnTransfoNew();
}
+ if (p) {
+ ZnTranslate(item->transfo, -p->x, -p->y);
+ }
ZnScale(item->transfo, sx, sy);
+ if (p) {
+ ZnTranslate(item->transfo, p->x, p->y);
+ }
Invalidate(item, ZN_TRANSFO_FLAG);
}
@@ -2373,6 +2422,7 @@ SkewItem(ZnItem item,
static void
RotateItem(ZnItem item,
ZnReal angle,
+ ZnBool deg,
ZnPoint *p)
{
if (!item->transfo) {
@@ -2381,7 +2431,12 @@ RotateItem(ZnItem item,
if (p) {
ZnTranslate(item->transfo, -p->x, -p->y);
}
- ZnRotateRad(item->transfo, angle);
+ if (deg) {
+ ZnRotateDeg(item->transfo, angle);
+ }
+ else {
+ ZnRotateRad(item->transfo, angle);
+ }
if (p) {
ZnTranslate(item->transfo, p->x, p->y);
}