aboutsummaryrefslogtreecommitdiff
path: root/generic/Rectangle.c
diff options
context:
space:
mode:
authorlecoanet2003-04-16 09:49:22 +0000
committerlecoanet2003-04-16 09:49:22 +0000
commit3261805fee19e346b4d1f84b23816daa1628764a (patch)
tree63ca1d7e4b0a3d9ae49cc0888e58033c3ef3fe22 /generic/Rectangle.c
parenteed2656db0adae2c234c3d74af0913746ed5c444 (diff)
downloadtkzinc-3261805fee19e346b4d1f84b23816daa1628764a.zip
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.gz
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.bz2
tkzinc-3261805fee19e346b4d1f84b23816daa1628764a.tar.xz
Update from the Windows port and general cleanup/restructure
Diffstat (limited to 'generic/Rectangle.c')
-rw-r--r--generic/Rectangle.c274
1 files changed, 137 insertions, 137 deletions
diff --git a/generic/Rectangle.c b/generic/Rectangle.c
index 2552884..9aa98cb 100644
--- a/generic/Rectangle.c
+++ b/generic/Rectangle.c
@@ -27,8 +27,6 @@
*/
-#include <malloc.h>
-
#include "Item.h"
#include "Geo.h"
#include "Draw.h"
@@ -58,13 +56,13 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
*/
typedef struct _RectangleItemStruct {
- ItemStruct header;
+ ZnItemStruct header;
/* Public data */
ZnPoint coords[2];
unsigned short flags;
- ReliefStyle relief;
- LineStyle line_style;
+ ZnReliefStyle relief;
+ ZnLineStyle line_style;
ZnDim line_width;
ZnGradient *line_color;
ZnImage fill_pattern;
@@ -81,13 +79,13 @@ typedef struct _RectangleItemStruct {
static ZnAttrConfig rect_attrs[] = {
{ ZN_CONFIG_BOOL, "-composealpha", NULL,
- Tk_Offset(RectangleItemStruct, header.flags), COMPOSE_ALPHA_BIT,
+ Tk_Offset(RectangleItemStruct, header.flags), ZN_COMPOSE_ALPHA_BIT,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
- Tk_Offset(RectangleItemStruct, header.flags), COMPOSE_ROTATION_BIT,
+ Tk_Offset(RectangleItemStruct, header.flags), ZN_COMPOSE_ROTATION_BIT,
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-composescale", NULL,
- Tk_Offset(RectangleItemStruct, header.flags), COMPOSE_SCALE_BIT,
+ Tk_Offset(RectangleItemStruct, header.flags), ZN_COMPOSE_SCALE_BIT,
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_GRADIENT, "-fillcolor", NULL,
Tk_Offset(RectangleItemStruct, fill_color), 0,
@@ -111,17 +109,17 @@ static ZnAttrConfig rect_attrs[] = {
{ ZN_CONFIG_RELIEF, "-relief", NULL, Tk_Offset(RectangleItemStruct, relief), 0,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-sensitive", NULL,
- Tk_Offset(RectangleItemStruct, header.flags), SENSITIVE_BIT,
+ Tk_Offset(RectangleItemStruct, header.flags), ZN_SENSITIVE_BIT,
ZN_REPICK_FLAG, False },
{ ZN_CONFIG_TAG_LIST, "-tags", NULL,
Tk_Offset(RectangleItemStruct, header.tags), 0, 0, False },
{ ZN_CONFIG_IMAGE, "-tile", NULL,
Tk_Offset(RectangleItemStruct, tile), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-visible", NULL,
- Tk_Offset(RectangleItemStruct, header.flags), VISIBLE_BIT,
+ Tk_Offset(RectangleItemStruct, header.flags), ZN_VISIBLE_BIT,
ZN_DRAW_FLAG|ZN_REPICK_FLAG|ZN_VIS_FLAG, False },
- { ZN_CONFIG_END, NULL, NULL, 0, 0, 0 }
+ { ZN_CONFIG_END, NULL, NULL, 0, 0, 0, False }
};
@@ -134,37 +132,37 @@ static ZnAttrConfig rect_attrs[] = {
**********************************************************************************
*/
static int
-Init(Item item,
+Init(ZnItem item,
int *argc,
Tcl_Obj *CONST *args[])
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
RectangleItem rect = (RectangleItem) item;
- int num_points;
+ unsigned int num_points;
ZnPoint *points;
rect->gradient = NULL;
rect->grad_geo = NULL;
/* Init attributes */
- SET(item->flags, VISIBLE_BIT);
- SET(item->flags, SENSITIVE_BIT);
- SET(item->flags, COMPOSE_ALPHA_BIT);
- SET(item->flags, COMPOSE_ROTATION_BIT);
- SET(item->flags, COMPOSE_SCALE_BIT);
- item->priority = DEFAULT_RECTANGLE_PRIORITY;
+ SET(item->flags, ZN_VISIBLE_BIT);
+ SET(item->flags, ZN_SENSITIVE_BIT);
+ SET(item->flags, ZN_COMPOSE_ALPHA_BIT);
+ SET(item->flags, ZN_COMPOSE_ROTATION_BIT);
+ SET(item->flags, ZN_COMPOSE_SCALE_BIT);
+ item->priority = 1;
if (*argc < 1) {
Tcl_AppendResult(wi->interp, " rectangle coords expected", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (ZnParseCoordList(wi, (*args)[0], &points,
- NULL, &num_points, NULL) == ZN_ERROR) {
- return ZN_ERROR;
+ NULL, &num_points, NULL) == TCL_ERROR) {
+ return TCL_ERROR;
}
if (num_points != 2) {
Tcl_AppendResult(wi->interp, " malformed rectangle coords", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
};
rect->coords[0] = points[0];
rect->coords[1] = points[1];
@@ -172,8 +170,8 @@ Init(Item item,
(*argc)--;
CLEAR(rect->flags, FILLED_BIT);
- rect->relief = RELIEF_FLAT;
- rect->line_style = LINE_SIMPLE;
+ rect->relief = ZN_RELIEF_FLAT;
+ rect->line_style = ZN_LINE_SIMPLE;
rect->line_width = 1;
rect->line_pattern = ZnUnspecifiedImage;
rect->tile = ZnUnspecifiedImage;
@@ -181,7 +179,7 @@ Init(Item item,
rect->line_color = ZnGetGradientByValue(wi->fore_color);
rect->fill_color = ZnGetGradientByValue(wi->fore_color);
- return ZN_OK;
+ return TCL_OK;
}
@@ -193,18 +191,13 @@ Init(Item item,
**********************************************************************************
*/
static void
-Clone(Item item)
+Clone(ZnItem item)
{
RectangleItem rect = (RectangleItem) item;
if (rect->gradient) {
rect->gradient = ZnGetGradientByValue(rect->gradient);
}
- if (rect->grad_geo) {
- ZnPoint *grad_geo = ZnMalloc(4*sizeof(ZnPoint));
- memcpy(grad_geo, rect->grad_geo, 4*sizeof(ZnPoint));
- rect->grad_geo = grad_geo;
- }
if (rect->tile != ZnUnspecifiedImage) {
rect->tile = ZnGetImageByValue(rect->tile);
}
@@ -216,6 +209,7 @@ Clone(Item item)
}
rect->line_color = ZnGetGradientByValue(rect->line_color);
rect->fill_color = ZnGetGradientByValue(rect->fill_color);
+ rect->grad_geo = NULL;
}
@@ -227,7 +221,7 @@ Clone(Item item)
**********************************************************************************
*/
static void
-Destroy(Item item)
+Destroy(ZnItem item)
{
RectangleItem rect = (RectangleItem) item;
@@ -262,30 +256,30 @@ Destroy(Item item)
**********************************************************************************
*/
static int
-Configure(Item item,
+Configure(ZnItem item,
int argc,
Tcl_Obj *CONST argv[],
int *flags)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
RectangleItem rect = (RectangleItem) item;
- int status = ZN_OK;
+ int status = TCL_OK;
XColor *color;
- int alpha;
+ unsigned short alpha;
status = ZnConfigureAttributes(wi, item, rect_attrs, argc, argv, flags);
if (rect->gradient &&
- (ISSET(*flags, ZN_BORDER_FLAG) || (rect->relief == RELIEF_FLAT))) {
+ (ISSET(*flags, ZN_BORDER_FLAG) || (rect->relief == ZN_RELIEF_FLAT))) {
ZnFreeGradient(rect->gradient);
rect->gradient = NULL;
}
- if ((rect->relief != RELIEF_FLAT) && !rect->gradient) {
+ if ((rect->relief != ZN_RELIEF_FLAT) && !rect->gradient) {
color = ZnGetGradientColor(rect->line_color, 51.0, &alpha);
rect->gradient = ZnGetReliefGradient(wi->interp, wi->win,
- ZnNameOfColor(color), alpha);
+ Tk_NameOfColor(color), alpha);
if (rect->gradient == NULL) {
- status = ZN_ERROR;
+ status = TCL_ERROR;
}
}
@@ -301,15 +295,15 @@ Configure(Item item,
**********************************************************************************
*/
static int
-Query(Item item,
- int argc,
+Query(ZnItem item,
+ int argc __unused,
Tcl_Obj *CONST argv[])
{
- if (ZnQueryAttribute(item->wi, item, rect_attrs, argv[0]) == ZN_ERROR) {
- return ZN_ERROR;
+ if (ZnQueryAttribute(item->wi, item, rect_attrs, argv[0]) == TCL_ERROR) {
+ return TCL_ERROR;
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -321,17 +315,17 @@ Query(Item item,
**********************************************************************************
*/
static void
-ComputeCoordinates(Item item,
- ZnBool force)
+ComputeCoordinates(ZnItem item,
+ ZnBool force __unused)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
RectangleItem rect = (RectangleItem) item;
ZnPoint p[4];
int i;
ZnBool aligned;
ZnDim delta;
- ResetBBox(&item->item_bounding_box);
+ ZnResetBBox(&item->item_bounding_box);
if (!rect->line_width && ISCLEAR(rect->flags, FILLED_BIT)) {
return;
}
@@ -344,15 +338,15 @@ ComputeCoordinates(Item item,
p[3].y = p[2].y;
ZnTransformPoints(wi->current_transfo, p, rect->dev, 4);
for (i = 0; i < 4; i++) {
- rect->dev[i].x = REAL_TO_INT(rect->dev[i].x);
- rect->dev[i].y = REAL_TO_INT(rect->dev[i].y);
+ rect->dev[i].x = ZnNearestInt(rect->dev[i].x);
+ rect->dev[i].y = ZnNearestInt(rect->dev[i].y);
}
/*
* Add all points to the bounding box. Then expand by the line
* width to account for mitered corners. This is an overestimate.
*/
- AddPointsToBBox(&item->item_bounding_box, rect->dev, 4);
+ ZnAddPointsToBBox(&item->item_bounding_box, rect->dev, 4);
if (rect->line_width > 0) {
item->item_bounding_box.orig.x -= rect->line_width;
item->item_bounding_box.orig.y -= rect->line_width;
@@ -372,7 +366,7 @@ ComputeCoordinates(Item item,
aligned |= delta < X_PRECISION_LIMIT;
ASSIGN(rect->flags, ALIGNED_BIT, aligned);
-#ifdef GLX
+#ifdef GL
/*
* If there is an axial gradient with an unaligned axis
* compute the bbox in the coordinate system defined
@@ -388,8 +382,8 @@ ComputeCoordinates(Item item,
if (!rect->grad_geo) {
rect->grad_geo = ZnMalloc(6*sizeof(ZnPoint));
}
- POLY_CONTOUR1(&shape, p, 4, False);
- ZnComputeAxialGradient(wi, &shape, angle, rect->grad_geo);
+ ZnPolyContour1(&shape, p, 4, False);
+ ZnComputeAxialGradient(wi, &shape, (ZnReal) angle, rect->grad_geo);
}
else {
goto free_ggeo;
@@ -407,14 +401,14 @@ ComputeCoordinates(Item item,
pp[1].y = pp[0].y;
pp[3].x = pp[0].x;
pp[3].y = pp[2].y;
- POLY_CONTOUR1(&shape, pp, 4, False);
+ ZnPolyContour1(&shape, pp, 4, False);
ZnComputeRadialGradient(wi, &shape, False, &rect->fill_color->g.p, rect->grad_geo);
}
else if (rect->fill_color->type == ZN_PATH_GRADIENT) {
if (!rect->grad_geo) {
rect->grad_geo = ZnMalloc(6*sizeof(ZnPoint));
}
- POLY_CONTOUR1(&shape, rect->coords, 2, False);
+ ZnPolyContour1(&shape, rect->coords, 2, False);
ZnComputePathGradient(wi, &shape, &rect->fill_color->g.p, rect->grad_geo);
}
}
@@ -439,7 +433,7 @@ ComputeCoordinates(Item item,
**********************************************************************************
*/
static int
-ToArea(Item item,
+ToArea(ZnItem item,
ZnToArea ta)
{
RectangleItem rect = (RectangleItem) item;
@@ -449,7 +443,7 @@ ToArea(Item item,
result = -1;
if (ISSET(rect->flags, FILLED_BIT)) {
- result = PolygonInBBox(rect->dev, 4, area, NULL);
+ result = ZnPolygonInBBox(rect->dev, 4, area, NULL);
}
else if (rect->line_width > 0) {
int i;
@@ -459,8 +453,8 @@ ToArea(Item item,
pts[i] = rect->dev[i];
}
pts[4] = pts[0];
- result = PolylineInBBox(pts, 5, rect->line_width,
- CapProjecting, JoinMiter, area);
+ result = ZnPolylineInBBox(pts, 5, rect->line_width,
+ CapProjecting, JoinMiter, area);
}
return result;
@@ -475,37 +469,37 @@ ToArea(Item item,
**********************************************************************************
*/
static void
-Draw(Item item)
+Draw(ZnItem item)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
RectangleItem rect = (RectangleItem) item;
XGCValues values;
- int i, gc_mask;
+ unsigned int i, gc_mask;
XRectangle r;
XPoint xp[5];
if (ISSET(rect->flags, ALIGNED_BIT)) {
if (rect->dev[0].x < rect->dev[2].x) {
- r.x = rect->dev[0].x;
- r.width = rect->dev[2].x - r.x;
+ r.x = (int) rect->dev[0].x;
+ r.width = ((int) rect->dev[2].x) - r.x;
}
else {
- r.x = rect->dev[2].x;
- r.width = rect->dev[0].x - r.x;
+ r.x = (int) rect->dev[2].x;
+ r.width = ((int) rect->dev[0].x) - r.x;
}
if (rect->dev[0].y < rect->dev[2].y) {
- r.y = rect->dev[0].y;
- r.height = rect->dev[2].y - r.y;
+ r.y = (int) rect->dev[0].y;
+ r.height = ((int) rect->dev[2].y) - r.y;
}
else {
- r.y = rect->dev[2].y;
- r.height = rect->dev[0].y - r.y;
+ r.y = (int) rect->dev[2].y;
+ r.height = ((int) rect->dev[0].y) - r.y;
}
}
else {
for (i = 0; i < 4; i++) {
- xp[i].x = rect->dev[i].x;
- xp[i].y = rect->dev[i].y;
+ xp[i].x = (int) rect->dev[i].x;
+ xp[i].y = (int) rect->dev[i].y;
}
xp[i] = xp[0];
}
@@ -517,7 +511,7 @@ Draw(Item item)
values.foreground = ZnPixel(ZnGetGradientColor(rect->fill_color, 0.0, NULL));
if (rect->tile != ZnUnspecifiedImage) { /* Fill tiled */
values.fill_style = FillTiled;
- values.tile = ZnImagePixmap(rect->tile, NULL);
+ values.tile = ZnImagePixmap(rect->tile);
if (ISSET(rect->flags, ALIGNED_BIT)) {
values.ts_x_origin = (int) r.x;
values.ts_y_origin = (int) r.y;
@@ -531,7 +525,7 @@ Draw(Item item)
}
else if (rect->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(rect->fill_pattern, NULL);
+ values.stipple = ZnImagePixmap(rect->fill_pattern);
if (ISSET(rect->flags, ALIGNED_BIT)) {
values.ts_x_origin = (int) r.x;
values.ts_y_origin = (int) r.y;
@@ -559,7 +553,7 @@ Draw(Item item)
/* Draw the outline */
if (rect->line_width) {
- if (rect->relief != RELIEF_FLAT) {
+ if (rect->relief != ZN_RELIEF_FLAT) {
if (ISSET(rect->flags, ALIGNED_BIT)) {
ZnDrawRectangleRelief(wi, rect->relief, rect->gradient,
&r, rect->line_width);
@@ -578,8 +572,8 @@ Draw(Item item)
else {
ZnSetLineStyle(wi, rect->line_style);
gc_mask = GCFillStyle|GCLineWidth|GCForeground|GCJoinStyle;
- values.foreground = ZnPixel(ZnGetGradientColor(rect->line_color, 0, NULL));
- values.line_width = (rect->line_width == 1) ? 0 : rect->line_width;
+ values.foreground = ZnPixel(ZnGetGradientColor(rect->line_color, 0.0, NULL));
+ values.line_width = (rect->line_width == 1) ? 0 : (int) rect->line_width;
values.join_style = JoinMiter;
if (ISCLEAR(rect->flags, ALIGNED_BIT)) {
gc_mask |= GCCapStyle;
@@ -591,7 +585,7 @@ Draw(Item item)
}
else {
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(rect->line_pattern, NULL);
+ values.stipple = ZnImagePixmap(rect->line_pattern);
gc_mask |= GCStipple;
XChangeGC(wi->dpy, wi->gc, gc_mask, &values);
}
@@ -614,30 +608,31 @@ Draw(Item item)
*
**********************************************************************************
*/
-#ifdef GLX
+#ifdef GL
static void
RectRenderCB(void *closure)
{
RectangleItem rect = (RectangleItem) closure;
glBegin(GL_TRIANGLE_STRIP);
- glVertex2f(rect->dev[0].x, rect->dev[0].y);
- glVertex2f(rect->dev[3].x, rect->dev[3].y);
- glVertex2f(rect->dev[1].x, rect->dev[1].y);
- glVertex2f(rect->dev[2].x, rect->dev[2].y);
+ glVertex2d(rect->dev[0].x, rect->dev[0].y);
+ glVertex2d(rect->dev[3].x, rect->dev[3].y);
+ glVertex2d(rect->dev[1].x, rect->dev[1].y);
+ glVertex2d(rect->dev[2].x, rect->dev[2].y);
glEnd();
}
#endif
+#ifdef GL
static void
-Render(Item item)
+Render(ZnItem item)
{
-#ifdef GLX
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
RectangleItem rect = (RectangleItem) item;
XColor *color;
- int i, alpha;
-
+ int i;
+ unsigned short alpha;
+
#ifdef GL_LIST
if (!item->gl_list) {
item->gl_list = glGenLists(1);
@@ -650,7 +645,7 @@ Render(Item item)
ZnBool fast = (rect->fill_color->type == ZN_AXIAL_GRADIENT) && !rect->grad_geo;
ZnPoly poly;
- POLY_CONTOUR1(&poly, rect->dev, 4, False);
+ ZnPolyContour1(&poly, rect->dev, 4, False);
ZnRenderGradient(wi, rect->fill_color,
fast ? NULL: RectRenderCB, rect,
fast ? rect->dev : rect->grad_geo, &poly);
@@ -666,7 +661,7 @@ Render(Item item)
* Setup polygon stippling.
*/
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(ZnImagePattern(rect->fill_pattern, NULL));
+ glPolygonStipple(ZnImageMask(rect->fill_pattern, NULL));
}
color = ZnGetGradientColor(rect->fill_color, 0.0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
@@ -684,7 +679,7 @@ Render(Item item)
p[4-i].y = rect->dev[i].y;
}
p[0] = p[4];
- if (rect->relief != RELIEF_FLAT) {
+ if (rect->relief != ZN_RELIEF_FLAT) {
ZnRenderPolygonRelief(wi, rect->relief, rect->gradient, False,
p, 5, rect->line_width);
}
@@ -700,9 +695,14 @@ Render(Item item)
glCallList(item->gl_list);
#endif
-#endif
}
-
+#else
+static void
+Render(ZnItem item __unused)
+{
+}
+#endif
+
/*
**********************************************************************************
@@ -712,10 +712,10 @@ Render(Item item)
**********************************************************************************
*/
static ZnBool
-IsSensitive(Item item,
- int item_part)
+IsSensitive(ZnItem item,
+ int item_part __unused)
{
- return (ISSET(item->flags, SENSITIVE_BIT) &&
+ return (ISSET(item->flags, ZN_SENSITIVE_BIT) &&
item->parent->class->IsSensitive(item->parent, ZN_NO_PART));
}
@@ -728,14 +728,14 @@ IsSensitive(Item item,
**********************************************************************************
*/
static double
-Pick(Item item,
+Pick(ZnItem item,
ZnPick ps)
{
RectangleItem rect = (RectangleItem) item;
double best_dist;
ZnPoint *p = ps->point;
- best_dist = PolygonToPointDist(rect->dev, 4, p);
+ best_dist = ZnPolygonToPointDist(rect->dev, 4, p);
if (ISSET(rect->flags, FILLED_BIT)) {
if (best_dist <= 0.0) {
@@ -753,8 +753,8 @@ Pick(Item item,
pts[i] = rect->dev[i];
}
pts[4] = pts[0];
- dist = PolylineToPointDist(pts, 5, rect->line_width,
- CapProjecting, JoinMiter, p);
+ dist = ZnPolylineToPointDist(pts, 5, rect->line_width,
+ CapProjecting, JoinMiter, p);
if (dist <= 0.0) {
return 0.0;
}
@@ -773,8 +773,8 @@ Pick(Item item,
**********************************************************************************
*/
static void
-PostScript(Item item,
- PostScriptInfo ps_info)
+PostScript(ZnItem item __unused,
+ ZnPostScriptInfo ps_info __unused)
{
}
@@ -784,12 +784,12 @@ PostScript(Item item,
*
* GetClipVertices --
* Get the clipping shape.
- * Never ever call TRI_FREE on the tristrip returned by GetClipVertices.
+ * Never ever call ZnTriFree on the tristrip returned by GetClipVertices.
*
**********************************************************************************
*/
static ZnBool
-GetClipVertices(Item item,
+GetClipVertices(ZnItem item,
ZnTriStrip *tristrip)
{
RectangleItem rect = (RectangleItem) item;
@@ -798,7 +798,7 @@ GetClipVertices(Item item,
if (ISSET(rect->flags, ALIGNED_BIT)) {
ZnListAssertSize(item->wi->work_pts, 2);
points = (ZnPoint *) ZnListArray(item->wi->work_pts);
- TRI_STRIP1(tristrip, points, 2, False);
+ ZnTriStrip1(tristrip, points, 2, False);
tristrip->strips[0].fan = False;
if (rect->dev[0].x < rect->dev[2].x) {
@@ -819,7 +819,7 @@ GetClipVertices(Item item,
}
}
else {
- TRI_STRIP1(tristrip, rect->dev, 4, False);
+ ZnTriStrip1(tristrip, rect->dev, 4, False);
}
return ISSET(rect->flags, ALIGNED_BIT);
@@ -835,36 +835,36 @@ GetClipVertices(Item item,
**********************************************************************************
*/
static int
-Coords(Item item,
- int contour,
- int index,
- int cmd,
- ZnPoint **pts,
- char **controls,
- int *num_pts)
+Coords(ZnItem item,
+ int contour __unused,
+ int index,
+ int cmd,
+ ZnPoint **pts,
+ char **controls __unused,
+ unsigned int *num_pts)
{
RectangleItem rect = (RectangleItem) item;
- if ((cmd == COORDS_ADD) || (cmd == COORDS_ADD_LAST) || (cmd == COORDS_REMOVE)) {
+ if ((cmd == ZN_COORDS_ADD) || (cmd == ZN_COORDS_ADD_LAST) || (cmd == ZN_COORDS_REMOVE)) {
Tcl_AppendResult(item->wi->interp,
" rectangles can't add or remove vertices", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
- else if (cmd == COORDS_REPLACE_ALL) {
+ else if (cmd == ZN_COORDS_REPLACE_ALL) {
if (*num_pts != 2) {
Tcl_AppendResult(item->wi->interp,
" coords command need 2 points on rectangles", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
rect->coords[0] = (*pts)[0];
rect->coords[1] = (*pts)[1];
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
}
- else if (cmd == COORDS_REPLACE) {
+ else if (cmd == ZN_COORDS_REPLACE) {
if (*num_pts < 1) {
Tcl_AppendResult(item->wi->interp,
" coords command need at least 1 point", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
if (index < 0) {
index += 2;
@@ -873,16 +873,16 @@ Coords(Item item,
range_err:
Tcl_AppendResult(item->wi->interp,
" incorrect coord index, should be between -2 and 1", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
rect->coords[index] = (*pts)[0];
- ITEM.Invalidate(item, ZN_COORDS_FLAG);
+ ZnITEM.Invalidate(item, ZN_COORDS_FLAG);
}
- else if (cmd == COORDS_READ_ALL) {
+ else if (cmd == ZN_COORDS_READ_ALL) {
*num_pts = 2;
*pts = rect->coords;
}
- else if (cmd == COORDS_READ) {
+ else if (cmd == ZN_COORDS_READ) {
if (index < 0) {
index += 2;
}
@@ -893,7 +893,7 @@ Coords(Item item,
*pts = &rect->coords[index];
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -905,16 +905,16 @@ Coords(Item item,
**********************************************************************************
*/
static void
-GetAnchor(Item item,
- ZnAnchor anchor,
+GetAnchor(ZnItem item,
+ Tk_Anchor anchor,
ZnPoint *p)
{
ZnBBox *bbox = &item->item_bounding_box;
- Origin2Anchor(&bbox->orig,
- bbox->corner.x - bbox->orig.x,
- bbox->corner.y - bbox->orig.y,
- anchor, p);
+ ZnOrigin2Anchor(&bbox->orig,
+ bbox->corner.x - bbox->orig.x,
+ bbox->corner.y - bbox->orig.y,
+ anchor, p);
}
@@ -924,8 +924,8 @@ GetAnchor(Item item,
* Exported functions struct --
*
**********************************************************************************
- */
-static ItemClassStruct RECTANGLE_ITEM_CLASS = {
+ */
+static ZnItemClassStruct RECTANGLE_ITEM_CLASS = {
sizeof(RectangleItemStruct),
0, /* num_parts */
False, /* has_anchors */