aboutsummaryrefslogtreecommitdiff
path: root/generic/Arc.c
diff options
context:
space:
mode:
authorlecoanet2003-04-16 09:49:22 +0000
committerlecoanet2003-04-16 09:49:22 +0000
commit3261805fee19e346b4d1f84b23816daa1628764a (patch)
tree63ca1d7e4b0a3d9ae49cc0888e58033c3ef3fe22 /generic/Arc.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/Arc.c')
-rw-r--r--generic/Arc.c562
1 files changed, 287 insertions, 275 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index e50cd22..5b69992 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -27,8 +27,6 @@
*/
-#include <malloc.h>
-
#include "Item.h"
#include "Geo.h"
#include "Draw.h"
@@ -54,7 +52,7 @@ static const char compile_id[]="$Compile: " __FILE__ " " __DATE__ " " __TIME__ "
#define USING_POLY_BIT 1<<5
-static double Pick(Item item, ZnPick ps);
+static double Pick(ZnItem item, ZnPick ps);
/*
@@ -65,7 +63,7 @@ static double Pick(Item item, ZnPick ps);
**********************************************************************************
*/
typedef struct _ArcItemStruct {
- ItemStruct header;
+ ZnItemStruct header;
/* Public data */
ZnPoint coords[2];
@@ -76,7 +74,7 @@ typedef struct _ArcItemStruct {
ZnGradient *fill_color;
ZnGradient *line_color;
ZnDim line_width;
- LineStyle line_style;
+ ZnLineStyle line_style;
ZnLineEnd first_end;
ZnLineEnd last_end;
ZnImage tile;
@@ -96,13 +94,13 @@ static ZnAttrConfig arc_attrs[] = {
{ ZN_CONFIG_BOOL, "-closed", NULL,
Tk_Offset(ArcItemStruct, flags), CLOSED_BIT, ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-composealpha", NULL,
- Tk_Offset(ArcItemStruct, header.flags), COMPOSE_ALPHA_BIT,
+ Tk_Offset(ArcItemStruct, header.flags), ZN_COMPOSE_ALPHA_BIT,
ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-composerotation", NULL,
- Tk_Offset(ArcItemStruct, header.flags), COMPOSE_ROTATION_BIT,
+ Tk_Offset(ArcItemStruct, header.flags), ZN_COMPOSE_ROTATION_BIT,
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_BOOL, "-composescale", NULL,
- Tk_Offset(ArcItemStruct, header.flags), COMPOSE_SCALE_BIT,
+ Tk_Offset(ArcItemStruct, header.flags), ZN_COMPOSE_SCALE_BIT,
ZN_COORDS_FLAG, False },
{ ZN_CONFIG_ANGLE, "-extent", NULL,
Tk_Offset(ArcItemStruct, angle_extent), 0, ZN_COORDS_FLAG, False },
@@ -131,7 +129,7 @@ static ZnAttrConfig arc_attrs[] = {
Tk_Offset(ArcItemStruct, header.priority), 0,
ZN_DRAW_FLAG|ZN_REPICK_FLAG, False },
{ ZN_CONFIG_BOOL, "-sensitive", NULL,
- Tk_Offset(ArcItemStruct, header.flags), SENSITIVE_BIT,
+ Tk_Offset(ArcItemStruct, header.flags), ZN_SENSITIVE_BIT,
ZN_REPICK_FLAG, False },
{ ZN_CONFIG_ANGLE, "-startangle", NULL,
Tk_Offset(ArcItemStruct, start_angle), 0, ZN_COORDS_FLAG, False },
@@ -140,10 +138,10 @@ static ZnAttrConfig arc_attrs[] = {
{ ZN_CONFIG_IMAGE, "-tile", NULL,
Tk_Offset(ArcItemStruct, tile), 0, ZN_DRAW_FLAG, False },
{ ZN_CONFIG_BOOL, "-visible", NULL,
- Tk_Offset(ArcItemStruct, header.flags), VISIBLE_BIT,
+ Tk_Offset(ArcItemStruct, 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 }
};
@@ -155,22 +153,22 @@ static ZnAttrConfig arc_attrs[] = {
**********************************************************************************
*/
static int
-Init(Item item,
+Init(ZnItem item,
int *argc,
Tcl_Obj *CONST *args[])
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
ArcItem arc = (ArcItem) item;
- int num_points;
+ unsigned int num_points;
ZnPoint *points;
/* 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_ARC_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;
arc->start_angle = 0;
arc->angle_extent = 360;
@@ -181,7 +179,7 @@ Init(Item item,
arc->line_pattern = ZnUnspecifiedImage;
arc->fill_pattern = ZnUnspecifiedImage;
arc->tile = ZnUnspecifiedImage;
- arc->line_style = LINE_SIMPLE;
+ arc->line_style = ZN_LINE_SIMPLE;
arc->line_width = 1;
arc->first_end = arc->last_end = NULL;
arc->render_shape = NULL;
@@ -189,15 +187,15 @@ Init(Item item,
if (*argc < 1) {
Tcl_AppendResult(wi->interp, " arc 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 arc coords", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
};
arc->coords[0] = points[0];
arc->coords[1] = points[1];
@@ -207,7 +205,7 @@ Init(Item item,
arc->fill_color = ZnGetGradientByValue(wi->fore_color);
arc->line_color = ZnGetGradientByValue(wi->fore_color);
- return ZN_OK;
+ return TCL_OK;
}
@@ -219,23 +217,18 @@ Init(Item item,
**********************************************************************************
*/
static void
-Clone(Item item)
+Clone(ZnItem item)
{
ArcItem arc = (ArcItem) item;
- if (arc->grad_geo) {
- ZnPoint *grad_geo = ZnMalloc(4*sizeof(ZnPoint));
- memcpy(grad_geo, arc->grad_geo, 4*sizeof(ZnPoint));
- arc->grad_geo = grad_geo;
- }
if (arc->tile != ZnUnspecifiedImage) {
arc->tile = ZnGetImageByValue(arc->tile);
}
if (arc->first_end) {
- LineEndDuplicate(arc->first_end);
+ ZnLineEndDuplicate(arc->first_end);
}
if (arc->last_end) {
- LineEndDuplicate(arc->last_end);
+ ZnLineEndDuplicate(arc->last_end);
}
if (arc->line_pattern != ZnUnspecifiedImage) {
arc->line_pattern = ZnGetImageByValue(arc->line_pattern);
@@ -245,6 +238,7 @@ Clone(Item item)
}
arc->line_color = ZnGetGradientByValue(arc->line_color);
arc->fill_color = ZnGetGradientByValue(arc->fill_color);
+ arc->grad_geo = NULL;
if (arc->render_shape) {
arc->render_shape = ZnListDuplicate(arc->render_shape);
}
@@ -259,7 +253,7 @@ Clone(Item item)
**********************************************************************************
*/
static void
-Destroy(Item item)
+Destroy(ZnItem item)
{
ArcItem arc = (ArcItem) item;
@@ -267,10 +261,10 @@ Destroy(Item item)
ZnListFree(arc->render_shape);
}
if (arc->first_end) {
- LineEndDelete(arc->first_end);
+ ZnLineEndDelete(arc->first_end);
}
if (arc->last_end) {
- LineEndDelete(arc->last_end);
+ ZnLineEndDelete(arc->last_end);
}
if (arc->tile != ZnUnspecifiedImage) {
ZnFreeImage(arc->tile);
@@ -323,13 +317,13 @@ SetRenderFlags(ArcItem arc)
**********************************************************************************
*/
static int
-Configure(Item item,
+Configure(ZnItem item,
int argc,
Tcl_Obj *CONST argv[],
int *flags)
{
ArcItem arc = (ArcItem) item;
- int status = ZN_OK;
+ int status = TCL_OK;
status = ZnConfigureAttributes(item->wi, item, arc_attrs, argc, argv, flags);
if (arc->start_angle < 0) {
@@ -350,15 +344,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, arc_attrs, argv[0]) == ZN_ERROR) {
- return ZN_ERROR;
+ if (ZnQueryAttribute(item->wi, item, arc_attrs, argv[0]) == TCL_ERROR) {
+ return TCL_ERROR;
}
- return ZN_OK;
+ return TCL_OK;
}
@@ -368,7 +362,7 @@ Query(Item item,
* end of the arc. The point is on the tangent segment next to
* the arc (ie: it is suitable for drawing arrows).
*/
-void
+static void
Tangent(ArcItem arc,
ZnBool first,
ZnPoint *p)
@@ -378,10 +372,10 @@ Tangent(ArcItem arc,
ZnPoint p1, center;
if (first) {
- angle = DegreesToRadian(arc->start_angle);
+ angle = ZnDegRad(arc->start_angle);
}
else {
- angle = DegreesToRadian(arc->start_angle + arc->angle_extent);
+ angle = ZnDegRad(arc->start_angle + arc->angle_extent);
}
p1.x = cos(angle);
p1.y = sin(angle);
@@ -417,8 +411,8 @@ Tangent(ArcItem arc,
}
p->y = a2*p->x + b2;
}
- p->x = center.x + REAL_TO_INT(p->x*w_2);
- p->y = center.y + REAL_TO_INT(p->y*h_2);
+ p->x = center.x + ZnNearestInt(p->x*w_2);
+ p->y = center.y + ZnNearestInt(p->y*h_2);
}
@@ -435,7 +429,7 @@ UpdateRenderShape(ArcItem arc)
ZnPoint *p_list, p, p2, o, o2;
ZnReal width, height, d;
int num_p, i, quality;
- ZnTransfo *t = ((Item) arc)->wi->current_transfo;
+ ZnTransfo *t = ((ZnItem) arc)->wi->current_transfo;
if (!arc->render_shape) {
arc->render_shape = ZnListNew(8, sizeof(ZnPoint));
@@ -446,12 +440,12 @@ UpdateRenderShape(ArcItem arc)
height = (arc->coords[1].y - arc->coords[0].y)/2.0;
d = MAX(width, height);
quality = ZN_CIRCLE_COARSE;
- p_list = GetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
- quality,
- DegreesToRadian(arc->start_angle),
- DegreesToRadian(arc->angle_extent),
- &num_p,
- arc->render_shape);
+ p_list = ZnGetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
+ quality,
+ ZnDegRad(arc->start_angle),
+ ZnDegRad(arc->angle_extent),
+ &num_p,
+ arc->render_shape);
/*
* Adapt the number of arc circles to the radius of the arc.
@@ -471,12 +465,12 @@ UpdateRenderShape(ArcItem arc)
quality = ZN_CIRCLE_MEDIUM;
}
if (quality != ZN_CIRCLE_COARSE) {
- p_list = GetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
- quality,
- DegreesToRadian(arc->start_angle),
- DegreesToRadian(arc->angle_extent),
- &num_p,
- arc->render_shape);
+ p_list = ZnGetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
+ quality,
+ ZnDegRad(arc->start_angle),
+ ZnDegRad(arc->angle_extent),
+ &num_p,
+ arc->render_shape);
}
for (i = 0; i < num_p; i++, p_list++) {
@@ -487,18 +481,18 @@ UpdateRenderShape(ArcItem arc)
}
static void
-ComputeCoordinates(Item item,
- ZnBool force)
+ComputeCoordinates(ZnItem item,
+ ZnBool force __unused)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
ArcItem arc = (ArcItem) item;
ZnReal angle, sin1, cos1, sin2, cos2;
ZnReal tmp, w_2, h_2, center_x, center_y;
- int num_p;
+ unsigned int num_p;
ZnPoint *p_list, p;
- ZnPoint end_points[LINE_END_POINTS];
+ ZnPoint end_points[ZN_LINE_END_POINTS];
- ResetBBox(&item->item_bounding_box);
+ ZnResetBBox(&item->item_bounding_box);
/*
* If it is neither filled nor outlined, then nothing to show.
*/
@@ -518,7 +512,7 @@ ComputeCoordinates(Item item,
UpdateRenderShape(arc);
p_list = ZnListArray(arc->render_shape);
num_p = ZnListSize(arc->render_shape);
- AddPointsToBBox(&item->item_bounding_box, p_list, num_p);
+ ZnAddPointsToBBox(&item->item_bounding_box, p_list, num_p);
tmp = (arc->line_width + 1.0) / 2.0 + 1.0;
item->item_bounding_box.orig.x -= tmp;
@@ -530,17 +524,17 @@ ComputeCoordinates(Item item,
* Add the arrows if any.
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
- GetLineEnd(p_list, p_list+1, arc->line_width, CapRound,
- arc->first_end, end_points);
- AddPointsToBBox(&item->item_bounding_box, end_points, LINE_END_POINTS);
+ ZnGetLineEnd(p_list, p_list+1, arc->line_width, CapRound,
+ arc->first_end, end_points);
+ ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS);
}
if (ISSET(arc->flags, LAST_END_OK)) {
- GetLineEnd(&p_list[num_p-1], &p_list[num_p-2], arc->line_width, CapRound,
- arc->last_end, end_points);
- AddPointsToBBox(&item->item_bounding_box, end_points, LINE_END_POINTS);
+ ZnGetLineEnd(&p_list[num_p-1], &p_list[num_p-2], arc->line_width, CapRound,
+ arc->last_end, end_points);
+ ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS);
}
-#ifdef GLX
+#ifdef GL
if (!ZnGradientFlat(arc->fill_color)) {
ZnPoly shape;
ZnPoint p[4];
@@ -555,15 +549,16 @@ ComputeCoordinates(Item item,
p[1].y = p[0].y;
p[3].x = p[0].x;
p[3].y = p[2].y;
- POLY_CONTOUR1(&shape, p, 4, False);
- ZnComputeAxialGradient(wi, &shape, arc->fill_color->g.angle, arc->grad_geo);
+ ZnPolyContour1(&shape, p, 4, False);
+ ZnComputeAxialGradient(wi, &shape, (ZnReal) arc->fill_color->g.angle,
+ arc->grad_geo);
}
else if (arc->fill_color->type == ZN_RADIAL_GRADIENT) {
- POLY_CONTOUR1(&shape, arc->coords, 2, False);
+ ZnPolyContour1(&shape, arc->coords, 2, False);
ZnComputeRadialGradient(wi, &shape, True, &arc->fill_color->g.p, arc->grad_geo);
}
else if (arc->fill_color->type == ZN_PATH_GRADIENT) {
- POLY_CONTOUR1(&shape, arc->coords, 2, False);
+ ZnPolyContour1(&shape, arc->coords, 2, False);
ZnComputePathGradient(wi, &shape, &arc->fill_color->g.p, arc->grad_geo);
}
}
@@ -603,10 +598,10 @@ ComputeCoordinates(Item item,
* to fit the shape.
* Angles are running clockwise and y coordinates are inverted.
*/
- angle = DegreesToRadian(arc->start_angle);
+ angle = ZnDegRad(arc->start_angle);
sin1 = sin(angle);
cos1 = cos(angle);
- angle += DegreesToRadian(arc->angle_extent);
+ angle += ZnDegRad(arc->angle_extent);
sin2 = sin(angle);
cos2 = cos(angle);
@@ -615,16 +610,16 @@ ComputeCoordinates(Item item,
center_x = (arc->corner.x + arc->orig.x) / 2;
center_y = (arc->corner.y + arc->orig.y) / 2;
- arc->center1.x = center_x + REAL_TO_INT(cos1*w_2);
- arc->center1.y = center_y + REAL_TO_INT(sin1*h_2);
- arc->center2.x = center_x + REAL_TO_INT(cos2*w_2);
- arc->center2.y = center_y + REAL_TO_INT(sin2*h_2);
+ arc->center1.x = center_x + ZnNearestInt(cos1*w_2);
+ arc->center1.y = center_y + ZnNearestInt(sin1*h_2);
+ arc->center2.x = center_x + ZnNearestInt(cos2*w_2);
+ arc->center2.y = center_y + ZnNearestInt(sin2*h_2);
/*
* Add the ends centers to the bbox.
*/
- AddPointToBBox(&item->item_bounding_box, arc->center1.x, arc->center1.y);
- AddPointToBBox(&item->item_bounding_box, arc->center2.x, arc->center2.y);
+ ZnAddPointToBBox(&item->item_bounding_box, arc->center1.x, arc->center1.y);
+ ZnAddPointToBBox(&item->item_bounding_box, arc->center2.x, arc->center2.y);
/*
* If the arc is filled or if the outline is closed in pie slice,
@@ -632,7 +627,7 @@ ComputeCoordinates(Item item,
*/
if ((ISSET(arc->flags, FILLED_BIT) || ISSET(arc->flags, CLOSED_BIT)) &&
ISSET(arc->flags, PIE_SLICE_BIT)) {
- AddPointToBBox(&item->item_bounding_box, center_x, center_y);
+ ZnAddPointToBBox(&item->item_bounding_box, center_x, center_y);
}
/*
@@ -644,7 +639,7 @@ ComputeCoordinates(Item item,
tmp += 360;
}
if ((tmp < arc->angle_extent) || ((tmp - 360) > arc->angle_extent)) {
- AddPointToBBox(&item->item_bounding_box, arc->corner.x, center_y);
+ ZnAddPointToBBox(&item->item_bounding_box, arc->corner.x, center_y);
}
tmp = 180 - arc->start_angle;
@@ -652,7 +647,7 @@ ComputeCoordinates(Item item,
tmp += 360;
}
if ((tmp < arc->angle_extent) || ((tmp - 360) > arc->angle_extent)) {
- AddPointToBBox(&item->item_bounding_box, arc->orig.x, center_y);
+ ZnAddPointToBBox(&item->item_bounding_box, arc->orig.x, center_y);
}
tmp = 90 - arc->start_angle;
@@ -660,7 +655,7 @@ ComputeCoordinates(Item item,
tmp += 360;
}
if ((tmp < arc->angle_extent) || ((tmp - 360) > arc->angle_extent)) {
- AddPointToBBox(&item->item_bounding_box, center_x, arc->corner.y);
+ ZnAddPointToBBox(&item->item_bounding_box, center_x, arc->corner.y);
}
tmp = 270 - arc->start_angle;
@@ -668,7 +663,7 @@ ComputeCoordinates(Item item,
tmp += 360;
}
if ((tmp < arc->angle_extent) || ((tmp - 360) > arc->angle_extent)) {
- AddPointToBBox(&item->item_bounding_box, center_x, arc->orig.y);
+ ZnAddPointToBBox(&item->item_bounding_box, center_x, arc->orig.y);
}
/*
@@ -685,15 +680,15 @@ ComputeCoordinates(Item item,
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
Tangent(arc, True, &p);
- GetLineEnd(&arc->center1, &p, arc->line_width, CapRound,
- arc->first_end, end_points);
- AddPointsToBBox(&item->item_bounding_box, end_points, LINE_END_POINTS);
+ ZnGetLineEnd(&arc->center1, &p, arc->line_width, CapRound,
+ arc->first_end, end_points);
+ ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS);
}
if (ISSET(arc->flags, LAST_END_OK)) {
Tangent(arc, False, &p);
- GetLineEnd(&arc->center2, &p, arc->line_width, CapRound,
- arc->last_end, end_points);
- AddPointsToBBox(&item->item_bounding_box, end_points, LINE_END_POINTS);
+ ZnGetLineEnd(&arc->center2, &p, arc->line_width, CapRound,
+ arc->last_end, end_points);
+ ZnAddPointsToBBox(&item->item_bounding_box, end_points, ZN_LINE_END_POINTS);
}
}
@@ -708,15 +703,16 @@ ComputeCoordinates(Item item,
**********************************************************************************
*/
static int
-ToArea(Item item,
+ToArea(ZnItem item,
ZnToArea ta)
{
ArcItem arc = (ArcItem) item;
ZnPoint *points;
- ZnPoint pts[20]; /* Should be at least LINE_END_POINTS large */
+ ZnPoint pts[20]; /* Should be at least ZN_LINE_END_POINTS large */
ZnPoint center, tang;
ZnBBox t_area, *area = ta->area;
- int num_points, result=-1, result2;
+ unsigned int num_points;
+ int result=-1, result2;
ZnReal lw = arc->line_width;
ZnReal rx, ry, angle, tmp;
ZnBool inside, new_inside;
@@ -728,14 +724,14 @@ ToArea(Item item,
num_points = ZnListSize(arc->render_shape);
if (ISSET(arc->flags, FILLED_BIT)) {
- result = PolygonInBBox(points, num_points, area, NULL);
+ result = ZnPolygonInBBox(points, num_points, area, NULL);
if (result == 0) {
return 0;
}
}
if (arc->line_width > 0) {
- result2 = PolylineInBBox(points, num_points, arc->line_width,
- CapRound, JoinRound, area);
+ result2 = ZnPolylineInBBox(points, num_points, arc->line_width,
+ CapRound, JoinRound, area);
if (ISCLEAR(arc->flags, FILLED_BIT)) {
if (result2 == 0) {
return 0;
@@ -748,8 +744,8 @@ ToArea(Item item,
if (ISSET(arc->flags, CLOSED_BIT) && ISSET(arc->flags, PIE_SLICE_BIT)) {
pts[0] = points[num_points-1];
pts[1] = points[0];
- if (PolylineInBBox(pts, 2, arc->line_width,
- CapRound, JoinRound, area) != result) {
+ if (ZnPolylineInBBox(pts, 2, arc->line_width,
+ CapRound, JoinRound, area) != result) {
return 0;
}
}
@@ -757,16 +753,16 @@ ToArea(Item item,
* Check line ends.
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
- arc->first_end, pts);
- if (PolygonInBBox(pts, LINE_END_POINTS, area, NULL) != result) {
+ ZnGetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
+ arc->first_end, pts);
+ if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
return 0;
}
}
if (ISSET(arc->flags, LAST_END_OK)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
- CapRound, arc->last_end, pts);
- if (PolygonInBBox(pts, LINE_END_POINTS, area, NULL) != result) {
+ ZnGetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
+ CapRound, arc->last_end, pts);
+ if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
return 0;
}
}
@@ -807,10 +803,10 @@ ToArea(Item item,
* includes those angles).
*/
points = pts;
- angle = DegreesToRadian(arc->start_angle);
+ angle = ZnDegRad(arc->start_angle);
points->x = rx*cos(angle);
points->y = ry*sin(angle);
- angle += DegreesToRadian(arc->angle_extent);
+ angle += ZnDegRad(arc->angle_extent);
points[1].x = rx*cos(angle);
points[1].y = ry*sin(angle);
num_points = 2;
@@ -867,9 +863,9 @@ ToArea(Item item,
* Now that we've located the extreme points, loop through them all
* to see which are inside the rectangle.
*/
- inside = PointInBBox(&t_area, pts->x, pts->y);
+ inside = ZnPointInBBox(&t_area, pts->x, pts->y);
for (points = pts+1; num_points > 1; points++, num_points--) {
- new_inside = PointInBBox(&t_area, points->x, points->y);
+ new_inside = ZnPointInBBox(&t_area, points->x, points->y);
if (new_inside != inside) {
return 0;
}
@@ -895,19 +891,19 @@ ToArea(Item item,
pts[1] = arc->center2;
num_points = 2;
}
- if (PolylineInBBox(pts, num_points, lw, CapRound, JoinRound, area) != result) {
+ if (ZnPolylineInBBox(pts, num_points, lw, CapRound, JoinRound, area) != result) {
return 0;
}
}
else if (ISSET(arc->flags, FILLED_BIT)) {
if (ISSET(arc->flags, PIE_SLICE_BIT)) {
- if ((LineInBBox(&center, &arc->center1, area) != result) ||
- (LineInBBox(&center, &arc->center2, area) != result)) {
+ if ((ZnLineInBBox(&center, &arc->center1, area) != result) ||
+ (ZnLineInBBox(&center, &arc->center2, area) != result)) {
return 0;
}
}
else {
- if (LineInBBox(&arc->center1, &arc->center2, area) != result) {
+ if (ZnLineInBBox(&arc->center1, &arc->center2, area) != result) {
return 0;
}
}
@@ -918,17 +914,17 @@ ToArea(Item item,
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
Tangent(arc, True, &tang);
- GetLineEnd(&arc->center1, &tang, arc->line_width, CapRound,
- arc->first_end, pts);
- if (PolygonInBBox(pts, LINE_END_POINTS, area, NULL) != result) {
+ ZnGetLineEnd(&arc->center1, &tang, arc->line_width, CapRound,
+ arc->first_end, pts);
+ if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
return 0;
}
}
if (ISSET(arc->flags, LAST_END_OK)) {
Tangent(arc, False, &tang);
- GetLineEnd(&arc->center2, &tang, arc->line_width, CapRound,
- arc->last_end, pts);
- if (PolygonInBBox(pts, LINE_END_POINTS, area, NULL) != result) {
+ ZnGetLineEnd(&arc->center2, &tang, arc->line_width, CapRound,
+ arc->last_end, pts);
+ if (ZnPolygonInBBox(pts, ZN_LINE_END_POINTS, area, NULL) != result) {
return 0;
}
}
@@ -941,27 +937,27 @@ ToArea(Item item,
* outer perimiter of the arc. If the arc isn't filled, then also
* check the inner perimeter of the arc.
*/
- if (HorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.orig.y,
- rx, ry, arc->start_angle, arc->angle_extent) ||
- HorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.corner.y,
- rx, ry, arc->start_angle, arc->angle_extent) ||
- VertLineToArc(t_area.orig.x, t_area.orig.y, t_area.corner.y,
+ if (ZnHorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.orig.y,
+ rx, ry, arc->start_angle, arc->angle_extent) ||
+ ZnHorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.corner.y,
rx, ry, arc->start_angle, arc->angle_extent) ||
- VertLineToArc(t_area.corner.x, t_area.orig.y, t_area.corner.y,
- rx, ry, arc->start_angle, arc->angle_extent)) {
+ ZnVertLineToArc(t_area.orig.x, t_area.orig.y, t_area.corner.y,
+ rx, ry, arc->start_angle, arc->angle_extent) ||
+ ZnVertLineToArc(t_area.corner.x, t_area.orig.y, t_area.corner.y,
+ rx, ry, arc->start_angle, arc->angle_extent)) {
return 0;
}
if ((lw > 1.0) && ISCLEAR(arc->flags, FILLED_BIT)) {
rx -= lw;
ry -= lw;
- if (HorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.orig.y,
- rx, ry, arc->start_angle, arc->angle_extent) ||
- HorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.corner.y,
- rx, ry, arc->start_angle, arc->angle_extent) ||
- VertLineToArc(t_area.orig.x, t_area.orig.y, t_area.corner.y,
- rx, ry, arc->start_angle, arc->angle_extent) ||
- VertLineToArc(t_area.corner.x, t_area.orig.y, t_area.corner.y,
- rx, ry, arc->start_angle, arc->angle_extent)) {
+ if (ZnHorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.orig.y,
+ rx, ry, arc->start_angle, arc->angle_extent) ||
+ ZnHorizLineToArc(t_area.orig.x, t_area.corner.x, t_area.corner.y,
+ rx, ry, arc->start_angle, arc->angle_extent) ||
+ ZnVertLineToArc(t_area.orig.x, t_area.orig.y, t_area.corner.y,
+ rx, ry, arc->start_angle, arc->angle_extent) ||
+ ZnVertLineToArc(t_area.corner.x, t_area.orig.y, t_area.corner.y,
+ rx, ry, arc->start_angle, arc->angle_extent)) {
return 0;
}
}
@@ -990,15 +986,15 @@ ToArea(Item item,
**********************************************************************************
*/
static void
-Draw(Item item)
+Draw(ZnItem item)
{
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
ArcItem arc = (ArcItem) item;
XGCValues values;
- int width=0, height=0;
+ unsigned int width=0, height=0;
ZnPoint *p=NULL;
XPoint *xp=NULL;
- int num_points=0, i;
+ unsigned int num_points=0, i;
if (ISSET(arc->flags, USING_POLY_BIT) &&
(ISSET(arc->flags, FILLED_BIT) || (arc->line_width))) {
@@ -1013,8 +1009,8 @@ Draw(Item item)
p = ZnListArray(arc->render_shape);
}
else {
- width = arc->corner.x - arc->orig.x;
- height = arc->corner.y - arc->orig.y;
+ width = ((int) (arc->corner.x - arc->orig.x));
+ height = ((int) (arc->corner.y - arc->orig.y));
}
/* Fill if requested */
@@ -1023,7 +1019,7 @@ Draw(Item item)
values.arc_mode = ISSET(arc->flags, PIE_SLICE_BIT) ? ArcPieSlice : ArcChord;
if (arc->tile != ZnUnspecifiedImage) { /* Fill Tiled */
values.fill_style = FillTiled;
- values.tile = ZnImagePixmap(arc->tile, NULL);
+ values.tile = ZnImagePixmap(arc->tile);
values.ts_x_origin = (int) item->item_bounding_box.orig.x;
values.ts_y_origin = (int) item->item_bounding_box.orig.y;
XChangeGC(wi->dpy, wi->gc,
@@ -1032,7 +1028,7 @@ Draw(Item item)
}
else if (arc->fill_pattern != ZnUnspecifiedImage) { /* Fill stippled */
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(arc->fill_pattern, NULL);
+ values.stipple = ZnImagePixmap(arc->fill_pattern);
values.ts_x_origin = (int) item->item_bounding_box.orig.x;
values.ts_y_origin = (int) item->item_bounding_box.orig.y;
XChangeGC(wi->dpy, wi->gc,
@@ -1045,11 +1041,14 @@ Draw(Item item)
}
if (ISSET(arc->flags, USING_POLY_BIT)) {
XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc,
- xp, num_points, Nonconvex, CoordModeOrigin);
+ xp, (int) num_points, Nonconvex, CoordModeOrigin);
}
else {
XFillArc(wi->dpy, wi->draw_buffer, wi->gc,
- arc->orig.x, arc->orig.y, width, height,
+ (int) arc->orig.x,
+ (int) arc->orig.y,
+ (unsigned int) width,
+ (unsigned int) height,
-arc->start_angle*64, -arc->angle_extent*64);
}
}
@@ -1058,13 +1057,13 @@ Draw(Item item)
* Draw the arc.
*/
if (arc->line_width) {
- ZnPoint end_points[LINE_END_POINTS];
- XPoint xap[LINE_END_POINTS];
+ ZnPoint end_points[ZN_LINE_END_POINTS];
+ XPoint xap[ZN_LINE_END_POINTS];
ZnPoint tang;
ZnSetLineStyle(wi, arc->line_style);
- values.foreground = ZnPixel(ZnGetGradientColor(arc->line_color, 0, NULL));
- values.line_width = (arc->line_width == 1) ? 0 : arc->line_width;
+ values.foreground = ZnPixel(ZnGetGradientColor(arc->line_color, 0.0, NULL));
+ values.line_width = (arc->line_width == 1) ? 0 : (int) arc->line_width;
values.cap_style = CapRound;
values.join_style = JoinRound;
if (arc->line_pattern == ZnUnspecifiedImage) {
@@ -1074,7 +1073,7 @@ Draw(Item item)
}
else {
values.fill_style = FillStippled;
- values.stipple = ZnImagePixmap(arc->line_pattern, NULL);
+ values.stipple = ZnImagePixmap(arc->line_pattern);
XChangeGC(wi->dpy, wi->gc,
GCFillStyle|GCStipple|GCLineWidth|GCCapStyle|GCJoinStyle|GCForeground,
&values);
@@ -1087,34 +1086,37 @@ Draw(Item item)
}
}
XDrawLines(wi->dpy, wi->draw_buffer, wi->gc,
- xp, num_points, CoordModeOrigin);
+ xp, (int) num_points, CoordModeOrigin);
if (ISSET(arc->flags, FIRST_END_OK)) {
p = (ZnPoint *) ZnListArray(arc->render_shape);
- GetLineEnd(p, p+1, arc->line_width, CapRound,
- arc->first_end, end_points);
- for (i = 0; i < LINE_END_POINTS; i++) {
- xap[i].x = end_points[i].x;
- xap[i].y = end_points[i].y;
+ ZnGetLineEnd(p, p+1, arc->line_width, CapRound,
+ arc->first_end, end_points);
+ for (i = 0; i < ZN_LINE_END_POINTS; i++) {
+ xap[i].x = (short) end_points[i].x;
+ xap[i].y = (short) end_points[i].y;
}
- XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, LINE_END_POINTS,
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
Nonconvex, CoordModeOrigin);
}
if (ISSET(arc->flags, LAST_END_OK)) {
p = (ZnPoint *) ZnListArray(arc->render_shape);
num_points = ZnListSize(arc->render_shape);
- GetLineEnd(&p[num_points-1], &p[num_points-2], arc->line_width,
- CapRound, arc->last_end, end_points);
- for (i = 0; i < LINE_END_POINTS; i++) {
- xap[i].x = end_points[i].x;
- xap[i].y = end_points[i].y;
+ ZnGetLineEnd(&p[num_points-1], &p[num_points-2], arc->line_width,
+ CapRound, arc->last_end, end_points);
+ for (i = 0; i < ZN_LINE_END_POINTS; i++) {
+ xap[i].x = (short) end_points[i].x;
+ xap[i].y = (short) end_points[i].y;
}
- XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, LINE_END_POINTS,
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
Nonconvex, CoordModeOrigin);
}
}
else {
XDrawArc(wi->dpy, wi->draw_buffer, wi->gc,
- arc->orig.x, arc->orig.y, width, height,
+ (int) arc->orig.x,
+ (int) arc->orig.y,
+ (unsigned int) width,
+ (unsigned int) height,
-arc->start_angle*64, -arc->angle_extent*64);
/*
* If the outline is closed, draw the closure.
@@ -1123,39 +1125,43 @@ Draw(Item item)
if (ISSET(arc->flags, PIE_SLICE_BIT)) {
XPoint points[3];
- points[0].x = arc->center1.x;
- points[0].y = arc->center1.y;
- points[1].x = (arc->corner.x + arc->orig.x) / 2;
- points[1].y = (arc->corner.y + arc->orig.y) / 2;
- points[2].x = arc->center2.x;
- points[2].y = arc->center2.y;
- XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, points, 3, CoordModeOrigin);
+ points[0].x = (short) arc->center1.x;
+ points[0].y = (short) arc->center1.y;
+ points[1].x = (short) ((arc->corner.x + arc->orig.x) / 2);
+ points[1].y = (short) ((arc->corner.y + arc->orig.y) / 2);
+ points[2].x = (short) arc->center2.x;
+ points[2].y = (short) arc->center2.y;
+ XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, points, 3,
+ CoordModeOrigin);
}
else {
XDrawLine(wi->dpy, wi->draw_buffer, wi->gc,
- arc->center1.x, arc->center1.y, arc->center2.x, arc->center2.y);
+ (int) arc->center1.x,
+ (int) arc->center1.y,
+ (int) arc->center2.x,
+ (int) arc->center2.y);
}
}
if (ISSET(arc->flags, FIRST_END_OK)) {
Tangent(arc, True, &tang);
- GetLineEnd(&arc->center1, &tang, arc->line_width, CapRound,
- arc->first_end, end_points);
- for (i = 0; i < LINE_END_POINTS; i++) {
- xap[i].x = end_points[i].x;
- xap[i].y = end_points[i].y;
+ ZnGetLineEnd(&arc->center1, &tang, arc->line_width, CapRound,
+ arc->first_end, end_points);
+ for (i = 0; i < ZN_LINE_END_POINTS; i++) {
+ xap[i].x = (short) end_points[i].x;
+ xap[i].y = (short) end_points[i].y;
}
- XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, LINE_END_POINTS,
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
Nonconvex, CoordModeOrigin);
}
if (ISSET(arc->flags, LAST_END_OK)) {
Tangent(arc, False, &tang);
- GetLineEnd(&arc->center2, &tang, arc->line_width, CapRound,
- arc->last_end, end_points);
- for (i = 0; i < LINE_END_POINTS; i++) {
- xap[i].x = end_points[i].x;
- xap[i].y = end_points[i].y;
+ ZnGetLineEnd(&arc->center2, &tang, arc->line_width, CapRound,
+ arc->last_end, end_points);
+ for (i = 0; i < ZN_LINE_END_POINTS; i++) {
+ xap[i].x = (short) end_points[i].x;
+ xap[i].y = (short) end_points[i].y;
}
- XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, LINE_END_POINTS,
+ XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, xap, ZN_LINE_END_POINTS,
Nonconvex, CoordModeOrigin);
}
}
@@ -1170,11 +1176,11 @@ Draw(Item item)
*
**********************************************************************************
*/
-#ifdef GLX
+#ifdef GL
static void
ArcRenderCB(void *closure)
{
- Item item = (Item) closure;
+ ZnItem item = (ZnItem) closure;
ArcItem arc = (ArcItem) item;
int num_points=0, i;
ZnPoint *p=NULL;
@@ -1185,23 +1191,24 @@ ArcRenderCB(void *closure)
p = ZnListArray(arc->render_shape);
num_points = ZnListSize(arc->render_shape);
glBegin(GL_TRIANGLE_FAN);
- glVertex2f(center.x, center.y);
+ glVertex2d(center.x, center.y);
for (i = 0; i < num_points; i++) {
- glVertex2f(p[i].x, p[i].y);
+ glVertex2d(p[i].x, p[i].y);
}
glEnd();
}
#endif
+
+#ifdef GL
static void
-Render(Item item)
+Render(ZnItem item)
{
-#ifdef GLX
- WidgetInfo *wi = item->wi;
+ ZnWInfo *wi = item->wi;
ArcItem arc = (ArcItem) item;
- int num_points=0;
+ unsigned int num_points=0;
ZnPoint *p=NULL;
XColor *color;
- int alpha;
+ unsigned short alpha;
if (ISCLEAR(arc->flags, FILLED_BIT) && !arc->line_width) {
return;
@@ -1219,8 +1226,8 @@ Render(Item item)
if (!ZnGradientFlat(arc->fill_color)) {
ZnPoly poly;
- POLY_CONTOUR1(&poly, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape), False);
+ ZnPolyContour1(&poly, ZnListArray(arc->render_shape),
+ ZnListSize(arc->render_shape), False);
ZnRenderGradient(wi, arc->fill_color, ArcRenderCB, arc,
arc->grad_geo, &poly);
}
@@ -1234,7 +1241,7 @@ Render(Item item)
* Setup polygon stippling.
*/
glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(ZnImagePattern(arc->fill_pattern, NULL));
+ glPolygonStipple(ZnImageMask(arc->fill_pattern, NULL));
}
color = ZnGetGradientColor(arc->fill_color, 0.0, &alpha);
alpha = ZnComposeAlpha(alpha, wi->alpha);
@@ -1272,8 +1279,13 @@ Render(Item item)
glCallList(item->gl_list);
#endif
-#endif
}
+#else
+static void
+Render(ZnItem item __unused)
+{
+}
+#endif
/*
@@ -1284,10 +1296,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));
}
@@ -1299,8 +1311,8 @@ IsSensitive(Item item,
*
**********************************************************************************
*/
-static double
-Pick(Item item,
+static ZnReal
+Pick(ZnItem item,
ZnPick ps)
{
ArcItem arc = (ArcItem) item;
@@ -1309,9 +1321,9 @@ Pick(Item item,
ZnBool in_triangle, acute_angle;
ZnPoint p1, center, tang;
ZnPoint *points, *p = ps->point;
- ZnPoint end_points[LINE_END_POINTS];
- int num_points;
- int width, height;
+ ZnPoint end_points[ZN_LINE_END_POINTS];
+ unsigned int num_points;
+ ZnDim width, height;
ZnDim lw = arc->line_width;
if (ISSET(arc->flags, USING_POLY_BIT) &&
@@ -1320,7 +1332,7 @@ Pick(Item item,
num_points = ZnListSize(arc->render_shape);
if (ISSET(arc->flags, FILLED_BIT)) {
- dist = PolygonToPointDist(points, num_points, p);
+ dist = ZnPolygonToPointDist(points, num_points, p);
if (dist <= 0.0) {
return 0.0;
}
@@ -1332,8 +1344,8 @@ Pick(Item item,
num_points--;
}
}
- new_dist = PolylineToPointDist(points, num_points, arc->line_width,
- CapRound, JoinRound, p);
+ new_dist = ZnPolylineToPointDist(points, num_points, arc->line_width,
+ CapRound, JoinRound, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1345,9 +1357,9 @@ Pick(Item item,
* Check line ends.
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
- GetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
- arc->first_end, end_points);
- new_dist = PolygonToPointDist(end_points, LINE_END_POINTS, p);
+ ZnGetLineEnd(&points[0], &points[1], arc->line_width, CapRound,
+ arc->first_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1356,9 +1368,9 @@ Pick(Item item,
}
}
if (ISSET(arc->flags, LAST_END_OK)) {
- GetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
- CapRound, arc->last_end, end_points);
- new_dist = PolygonToPointDist(end_points, LINE_END_POINTS, p);
+ ZnGetLineEnd(&points[num_points-1], &points[num_points-2], arc->line_width,
+ CapRound, arc->last_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1386,7 +1398,7 @@ Pick(Item item,
*/
p1.y = (p->y - center.y) / height;
p1.x = (p->x - center.x) / width;
- point_in_angle = PointInAngle(arc->start_angle, arc->angle_extent, &p1);
+ point_in_angle = ZnPointInAngle(arc->start_angle, arc->angle_extent, &p1);
/*
* Now try to compute the distance dealing with the
@@ -1402,7 +1414,7 @@ Pick(Item item,
*/
if (!filled && !closed) {
if (point_in_angle) {
- dist = OvalToPointDist(&center, width, height, lw, p);
+ dist = ZnOvalToPointDist(&center, width, height, lw, p);
if (dist < 0.0) {
dist = -dist;
}
@@ -1430,9 +1442,9 @@ Pick(Item item,
*/
if (ISSET(arc->flags, FIRST_END_OK)) {
Tangent(arc, True, &tang);
- GetLineEnd(&arc->center1, &tang, arc->line_width, CapRound,
- arc->first_end, end_points);
- new_dist = PolygonToPointDist(end_points, LINE_END_POINTS, p);
+ ZnGetLineEnd(&arc->center1, &tang, arc->line_width, CapRound,
+ arc->first_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1442,9 +1454,9 @@ Pick(Item item,
}
if (ISSET(arc->flags, LAST_END_OK)) {
Tangent(arc, False, &tang);
- GetLineEnd(&arc->center2, &tang, arc->line_width,
- CapRound, arc->last_end, end_points);
- new_dist = PolygonToPointDist(end_points, LINE_END_POINTS, p);
+ ZnGetLineEnd(&arc->center2, &tang, arc->line_width,
+ CapRound, arc->last_end, end_points);
+ new_dist = ZnPolygonToPointDist(end_points, ZN_LINE_END_POINTS, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1460,8 +1472,8 @@ Pick(Item item,
* angular extent).
*/
if (ISSET(arc->flags, PIE_SLICE_BIT)) {
- dist = LineToPointDist(&center, &arc->center1, p);
- new_dist = LineToPointDist(&center, &arc->center2, p);
+ dist = ZnLineToPointDist(&center, &arc->center1, p);
+ new_dist = ZnLineToPointDist(&center, &arc->center2, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1488,7 +1500,7 @@ Pick(Item item,
return 0.0;
}
if (point_in_angle) {
- new_dist = OvalToPointDist(&center, width, height, lw, p);
+ new_dist = ZnOvalToPointDist(&center, width, height, lw, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1502,7 +1514,7 @@ Pick(Item item,
/*
* This is a chord closed oval.
*/
- dist = LineToPointDist(&arc->center1, &arc->center2, p);
+ dist = ZnLineToPointDist(&arc->center1, &arc->center2, p);
if (arc->line_width > 1) {
if (closed) {
dist -= arc->line_width/2;
@@ -1554,7 +1566,7 @@ Pick(Item item,
}
if (point_in_angle && (!acute_angle || !in_triangle)) {
- new_dist = OvalToPointDist(&center, width, height, lw, p);
+ new_dist = ZnOvalToPointDist(&center, width, height, lw, p);
if (new_dist < dist) {
dist = new_dist;
}
@@ -1575,7 +1587,7 @@ Pick(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.
*
**********************************************************************************
*/
@@ -1589,11 +1601,11 @@ UpdateRenderShapeX(ArcItem arc)
if (!arc->render_shape) {
arc->render_shape = ZnListNew(8, sizeof(ZnPoint));
}
- p_list = GetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
- ZN_CIRCLE_FINE,
- DegreesToRadian(arc->start_angle),
- DegreesToRadian(arc->angle_extent),
- &num_p, arc->render_shape);
+ p_list = ZnGetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
+ ZN_CIRCLE_FINE,
+ ZnDegRad(arc->start_angle),
+ ZnDegRad(arc->angle_extent),
+ &num_p, arc->render_shape);
ox = (arc->corner.x + arc->orig.x) / 2.0;
oy = (arc->corner.y + arc->orig.y) / 2.0;
width_2 = (arc->corner.x - arc->orig.x) / 2.0;
@@ -1605,7 +1617,7 @@ UpdateRenderShapeX(ArcItem arc)
}
static ZnBool
-GetClipVertices(Item item,
+GetClipVertices(ZnItem item,
ZnTriStrip *tristrip)
{
ArcItem arc = (ArcItem) item;
@@ -1622,8 +1634,8 @@ GetClipVertices(Item item,
ZnListEmpty(item->wi->work_pts);
ZnListAdd(item->wi->work_pts, &center, ZnListTail);
ZnListAppend(item->wi->work_pts, arc->render_shape);
- TRI_STRIP1(tristrip, ZnListArray(item->wi->work_pts),
- ZnListSize(item->wi->work_pts), True);
+ ZnTriStrip1(tristrip, ZnListArray(item->wi->work_pts),
+ ZnListSize(item->wi->work_pts), True);
return False;
}
@@ -1634,12 +1646,12 @@ GetClipVertices(Item item,
*
* GetContours --
* Get the external contour(s).
- * Never ever call POLY_FREE on the tristrip returned by GetContours.
+ * Never ever call ZnPolyFree on the tristrip returned by GetContours.
*
**********************************************************************************
*/
static ZnBool
-GetContours(Item item,
+GetContours(ZnItem item,
ZnPoly *poly)
{
ArcItem arc = (ArcItem) item;
@@ -1648,8 +1660,8 @@ GetContours(Item item,
UpdateRenderShapeX(arc);
}
- POLY_CONTOUR1(poly, ZnListArray(arc->render_shape),
- ZnListSize(arc->render_shape), True);
+ ZnPolyContour1(poly, ZnListArray(arc->render_shape),
+ ZnListSize(arc->render_shape), True);
poly->contour1.controls = NULL;
return False;
@@ -1665,36 +1677,36 @@ GetContours(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)
{
ArcItem arc = (ArcItem) 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,
" arcs 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 arcs", NULL);
- return ZN_ERROR;
+ return TCL_ERROR;
}
arc->coords[0] = (*pts)[0];
arc->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;
@@ -1703,16 +1715,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;
}
arc->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 = arc->coords;
}
- else if (cmd == COORDS_READ) {
+ else if (cmd == ZN_COORDS_READ) {
if (index < 0) {
index += 2;
}
@@ -1723,7 +1735,7 @@ Coords(Item item,
*pts = &arc->coords[index];
}
- return ZN_OK;
+ return TCL_OK;
}
/*
@@ -1734,16 +1746,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);
}
/*
@@ -1754,8 +1766,8 @@ GetAnchor(Item item,
**********************************************************************************
*/
static void
-PostScript(Item item,
- PostScriptInfo ps_info)
+PostScript(ZnItem item __unused,
+ ZnPostScriptInfo ps_info __unused)
{
}
@@ -1767,7 +1779,7 @@ PostScript(Item item,
*
**********************************************************************************
*/
-static ItemClassStruct ARC_ITEM_CLASS = {
+static ZnItemClassStruct ARC_ITEM_CLASS = {
sizeof(ArcItemStruct),
0, /* num_parts */
False, /* has_anchors */