diff options
author | lecoanet | 2003-04-16 09:49:22 +0000 |
---|---|---|
committer | lecoanet | 2003-04-16 09:49:22 +0000 |
commit | 3261805fee19e346b4d1f84b23816daa1628764a (patch) | |
tree | 63ca1d7e4b0a3d9ae49cc0888e58033c3ef3fe22 /generic/Draw.c | |
parent | eed2656db0adae2c234c3d74af0913746ed5c444 (diff) | |
download | tkzinc-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/Draw.c')
-rw-r--r-- | generic/Draw.c | 670 |
1 files changed, 385 insertions, 285 deletions
diff --git a/generic/Draw.c b/generic/Draw.c index f033e49..29552ea 100644 --- a/generic/Draw.c +++ b/generic/Draw.c @@ -36,7 +36,6 @@ ********************************************************************************** */ -#include "config.h" #include "Types.h" #include "Draw.h" #include "Geo.h" @@ -66,6 +65,11 @@ #define LIGHTNING_SHAPE_A_RATIO 10.0 #define LIGHTNING_SHAPE_B_RATIO 8.0 +#define LIGHTNING_POINTS 4 +#define CORNER_POINTS 3 +#define DOUBLE_CORNER_POINTS 4 +#define STRAIGHT_POINTS 2 + /* ********************************************************************************** @@ -75,21 +79,21 @@ ********************************************************************************** */ void -ZnSetLineStyle(WidgetInfo *wi, - LineStyle line_style) +ZnSetLineStyle(ZnWInfo *wi, + ZnLineStyle line_style) { if (wi->render) { -#ifdef GLX +#ifdef GL switch (line_style) { - case LINE_DASHED : + case ZN_LINE_DASHED : glLineStipple(1, 0xF0F0); glEnable(GL_LINE_STIPPLE); break; - case LINE_MIXED : + case ZN_LINE_MIXED : glLineStipple(1, 0x27FF); glEnable(GL_LINE_STIPPLE); break; - case LINE_DOTTED : + case ZN_LINE_DOTTED : glLineStipple(1, 0x18C3); glEnable(GL_LINE_STIPPLE); break; @@ -106,13 +110,13 @@ ZnSetLineStyle(WidgetInfo *wi, values.line_style = LineOnOffDash; switch (line_style) { - case LINE_DASHED : + case ZN_LINE_DASHED : XSetDashes(wi->dpy, wi->gc, 0, dashed, 1); break; - case LINE_MIXED : + case ZN_LINE_MIXED : XSetDashes(wi->dpy, wi->gc, 0, mixed, 4); break; - case LINE_DOTTED : + case ZN_LINE_DOTTED : XSetDashes(wi->dpy, wi->gc, 0, dotted, 2); break; default: @@ -127,7 +131,7 @@ ZnSetLineStyle(WidgetInfo *wi, /* ********************************************************************************** * - * ZnGetLineShape -- + * ZnLineShapePoints -- * Compute the points describing the given line shape between point p1 and p2. * If bbox is non null, it is filled with the bounding box of the shape. * @@ -162,21 +166,21 @@ ZnSetLineStyle(WidgetInfo *wi, ********************************************************************************** */ void -ZnGetLineShape(ZnPoint *p1, - ZnPoint *p2, - unsigned int line_width, - LineShape shape, - ZnBBox *bbox, - ZnList to_points) +ZnLineShapePoints(ZnPoint *p1, + ZnPoint *p2, + ZnDim line_width, + ZnLineShape shape, + ZnBBox *bbox, + ZnList to_points) { ZnPoint *points; - int num_points, i; + unsigned int num_points, i; /* * Compute all line points according to shape. */ - if ((shape == LINE_LEFT_LIGHTNING) || - (shape == LINE_RIGHT_LIGHTNING)) { + if ((shape == ZN_LINE_LEFT_LIGHTNING) || + (shape == ZN_LINE_RIGHT_LIGHTNING)) { double alpha, theta; double length, length2; double shape_a, shape_b; @@ -193,10 +197,10 @@ ZnGetLineShape(ZnPoint *p1, dx = p2->x - p1->x; dy = p2->y - p1->y; length = hypot(dx, dy); - shape_a = length/LIGHTNING_SHAPE_A_RATIO + ((double) line_width)/2; - shape_b = length/LIGHTNING_SHAPE_B_RATIO + ((double) line_width)/2; + shape_a = length/LIGHTNING_SHAPE_A_RATIO + line_width/2.0; + shape_b = length/LIGHTNING_SHAPE_B_RATIO + line_width/2.0; - if (shape == LINE_LEFT_LIGHTNING) + if (shape == ZN_LINE_LEFT_LIGHTNING) alpha = atan2(shape_a, shape_b); else alpha = -atan2(shape_a, shape_b); @@ -212,8 +216,8 @@ ZnGetLineShape(ZnPoint *p1, points[1].y = dy - temp; points[2].y = dy + temp; } - else if (shape == LINE_LEFT_CORNER || - shape == LINE_RIGHT_CORNER) { + else if (shape == ZN_LINE_LEFT_CORNER || + shape == ZN_LINE_RIGHT_CORNER) { num_points = CORNER_POINTS; ZnListAssertSize(to_points, num_points); points = (ZnPoint *) ZnListArray(to_points); @@ -221,7 +225,7 @@ ZnGetLineShape(ZnPoint *p1, points[0] = *p1; points[2] = *p2; - if (shape == LINE_LEFT_CORNER) { + if (shape == ZN_LINE_LEFT_CORNER) { points[1].x = p1->x; points[1].y = p2->y; } @@ -230,8 +234,8 @@ ZnGetLineShape(ZnPoint *p1, points[1].y = p1->y; } } - else if (shape == LINE_DOUBLE_LEFT_CORNER || - shape == LINE_DOUBLE_RIGHT_CORNER) { + else if (shape == ZN_LINE_DOUBLE_LEFT_CORNER || + shape == ZN_LINE_DOUBLE_RIGHT_CORNER) { int dx, dy; num_points = DOUBLE_CORNER_POINTS; @@ -241,20 +245,20 @@ ZnGetLineShape(ZnPoint *p1, points[0] = *p1; points[3] = *p2; - if (shape == LINE_DOUBLE_LEFT_CORNER) { - dy = p2->y - p1->y; + if (shape == ZN_LINE_DOUBLE_LEFT_CORNER) { + dy = (int) (p2->y - p1->y); points[1].x = p1->x; points[2].x = p2->x; points[1].y = points[2].y = p1->y + dy/2; } else { - dx = p2->x - p1->x; + dx = (int) (p2->x - p1->x); points[1].x = points[2].x = p1->x + dx/2; points[1].y = p1->y; points[2].y = p2->y; } } - else /* if (shape) == LINE_STRAIGHT) */ { + else /* if (shape) == ZN_LINE_STRAIGHT) */ { num_points = STRAIGHT_POINTS; ZnListAssertSize(to_points, num_points); points = (ZnPoint *) ZnListArray(to_points); @@ -267,14 +271,14 @@ ZnGetLineShape(ZnPoint *p1, * Fill in the bbox, if requested. */ if (bbox) { - ResetBBox(bbox); + ZnResetBBox(bbox); for (i = 0; i < num_points; i++) { - AddPointToBBox(bbox, points[i].x, points[i].y); + ZnAddPointToBBox(bbox, points[i].x, points[i].y); } /* Enlarge to take line_width into account. */ if (line_width > 1) { - int lw_2 = (line_width+1)/2; + ZnDim lw_2 = (line_width+1)/2; bbox->orig.x -= lw_2; bbox->orig.y -= lw_2; @@ -298,16 +302,16 @@ ZnGetLineShape(ZnPoint *p1, ********************************************************************************** */ void -ZnDrawLineShape(WidgetInfo *wi, +ZnDrawLineShape(ZnWInfo *wi, ZnPoint *p, - int num_p, - LineStyle line_style, - ZnColor foreground, - unsigned int line_width, - LineShape shape) + unsigned int num_p, + ZnLineStyle line_style, + XColor *foreground, + ZnDim line_width, + ZnLineShape shape __unused) { XPoint *xpoints; - int i; + unsigned int i; XGCValues values; /* @@ -315,7 +319,7 @@ ZnDrawLineShape(WidgetInfo *wi, */ ZnSetLineStyle(wi, line_style); values.foreground = ZnPixel(foreground); - values.line_width = (line_width == 1) ? 0 : line_width; + values.line_width = (line_width == 1) ? 0 : (int) line_width; values.fill_style = FillSolid; values.join_style = JoinRound; values.cap_style = CapRound; @@ -324,10 +328,94 @@ ZnDrawLineShape(WidgetInfo *wi, ZnListAssertSize(wi->work_xpts, num_p); xpoints = (XPoint *) ZnListArray(wi->work_xpts); for (i = 0; i < num_p; i++) { - xpoints[i].x = p[i].x; - xpoints[i].y = p[i].y; + xpoints[i].x = (short) p[i].x; + xpoints[i].y = (short) p[i].y; + } + XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, xpoints, (int) num_p, CoordModeOrigin); +} + + +/* + ********************************************************************************** + * + * ZnGetLineEnd -- + * Compute the points describing the given line end style at point p1 for + * the line p1,p2. Point p1 is adjusted to fit the line end. + * If bbox is non null, it is filled with the bounding box of the end. + * + * For the time being this procedure handles open/filled arrows. + * + * Here are the parameters describing arrows. + * + * * | ARROW_SHAPE_C + * ** | + * * *************************** + * * * + * * * +p1 +p2 + * | * |* + * | * *************************** + * | | ** + * | | * + * | | | + * |---| | ARROW_SHAPE_A + * | | + * |-------| ARROW_SHAPE_B + * + ********************************************************************************** + */ +void +ZnGetLineEnd(ZnPoint *p1, + ZnPoint *p2, + ZnDim line_width, + int cap_style, + ZnLineEnd end_style, + ZnPoint *points) +{ + ZnReal dx, dy, length, temp, backup; + ZnReal frac_height, sin_theta, cos_theta; + ZnReal vert_x, vert_y; + ZnReal shape_a, shape_b, shape_c; + + if (end_style != NULL) { + shape_a = end_style->shape_a + 0.001; + shape_b = end_style->shape_b + 0.001; + shape_c = end_style->shape_c + line_width/2.0 + 0.001; + + frac_height = (line_width/2.0) / shape_c; + dx = p1->x - p2->x; + dy = p1->y - p2->y; + length = hypot(dx, dy); + if (length == 0) { + sin_theta = cos_theta = 0.0; + } + else { + sin_theta = dy/length; + cos_theta = dx/length; + } + + if (cap_style != CapProjecting) { + temp = frac_height; + } + else { + temp = line_width / shape_c; + } + backup = temp * shape_b + shape_a * (1.0 - temp) / 2.0; + points[0].x = points[5].x = p1->x + backup * cos_theta; + points[0].y = points[5].y = p1->y + backup * sin_theta; + + vert_x = points[0].x - shape_a*cos_theta; + vert_y = points[0].y - shape_a*sin_theta; + temp = shape_c*sin_theta; + points[1].x = ZnNearestInt(points[0].x - shape_b*cos_theta + temp); + points[4].x = ZnNearestInt(points[1].x - 2*temp); + temp = shape_c*cos_theta; + points[1].y = ZnNearestInt(points[0].y - shape_b*sin_theta - temp); + points[4].y = ZnNearestInt(points[1].y + 2*temp); + points[2].x = ZnNearestInt(points[1].x*frac_height + vert_x*(1.0-frac_height)); + points[2].y = ZnNearestInt(points[1].y*frac_height + vert_y*(1.0-frac_height)); + points[3].x = ZnNearestInt(points[4].x*frac_height + vert_x*(1.0-frac_height)); + points[3].y = ZnNearestInt(points[4].y*frac_height + vert_y*(1.0-frac_height)); } - XDrawLines(wi->dpy, wi->draw_buffer, wi->gc, xpoints, num_p, CoordModeOrigin); } @@ -339,21 +427,21 @@ ReliefColorOfSegment(ZnReal x1, ZnReal y1, ZnReal x2, ZnReal y2, - ReliefStyle relief, + ZnReliefStyle relief, ZnGradient *gradient, - WidgetInfo *wi) + ZnWInfo *wi) { ZnReal angle, angle_step, origin, position; int num_colors, color_index; - num_colors = RELIEF_STEPS*2+1; + num_colors = ZN_RELIEF_STEPS*2+1; angle_step = M_PI / (num_colors-1); - origin = -(DegreesToRadian(wi->light_angle))-(angle_step/2.0); - if (relief == RELIEF_SUNKEN) { + origin = -(ZnDegRad(wi->light_angle))-(angle_step/2.0); + if (relief == ZN_RELIEF_SUNKEN) { origin += M_PI; } - angle = ProjectionToAngle(y1 - y2, x2 - x1) + M_PI - origin; + angle = ZnProjectionToAngle(y1 - y2, x2 - x1) + M_PI - origin; while (angle < 0.0) { angle += 2*M_PI; } @@ -394,11 +482,11 @@ ReliefColorOfSegment(ZnReal x1, ********************************************************************************** */ void -ZnDrawRectangleRelief(WidgetInfo *wi, - ReliefStyle relief, +ZnDrawRectangleRelief(ZnWInfo *wi, + ZnReliefStyle relief, ZnGradient *gradient, XRectangle *bbox, - unsigned int line_width) + ZnDim line_width) { XPoint bevel[4]; @@ -413,23 +501,23 @@ ZnDrawRectangleRelief(WidgetInfo *wi, * Grooves and ridges are drawn with two recursives calls with * half the width of the original one. */ - if ((relief == RELIEF_RIDGE) || (relief == RELIEF_GROOVE)) { - unsigned int new_line_width; - int offset; - XRectangle internal_bbox; + if ((relief == ZN_RELIEF_RIDGE) || (relief == ZN_RELIEF_GROOVE)) { + ZnDim new_line_width; + unsigned int offset; + XRectangle internal_bbox; - new_line_width = line_width/2; - offset = line_width - new_line_width; + new_line_width = line_width/2.0; + offset = (unsigned) (line_width - new_line_width); ZnDrawRectangleRelief(wi, - (relief==RELIEF_GROOVE)?RELIEF_SUNKEN:RELIEF_RAISED, + (unsigned) ((relief==ZN_RELIEF_GROOVE)?ZN_RELIEF_SUNKEN:ZN_RELIEF_RAISED), gradient, bbox, new_line_width); internal_bbox = *bbox; - internal_bbox.x +=offset; + internal_bbox.x += offset; internal_bbox.y += offset; internal_bbox.width -= offset*2; internal_bbox.height -= offset*2; ZnDrawRectangleRelief(wi, - (relief==RELIEF_GROOVE)?RELIEF_RAISED:RELIEF_SUNKEN, + (unsigned) ((relief==ZN_RELIEF_GROOVE)?ZN_RELIEF_RAISED:ZN_RELIEF_SUNKEN), gradient, &internal_bbox, new_line_width); return; } @@ -439,29 +527,32 @@ ZnDrawRectangleRelief(WidgetInfo *wi, bevel[0].x = bbox->x; bevel[0].y = bevel[1].y = bbox->y; bevel[1].x = bbox->x + bbox->width; - bevel[2].y = bevel[3].y = bbox->y + line_width; - bevel[2].x = bevel[1].x - line_width; - bevel[3].x = bevel[0].x + line_width; + bevel[2].y = bevel[3].y = bbox->y + (short) line_width; + bevel[2].x = bevel[1].x - (short) line_width; + bevel[3].x = bevel[0].x + (short) line_width; XSetForeground(wi->dpy, wi->gc, - ZnPixel(ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, bevel[0].y, + ZnPixel(ReliefColorOfSegment((ZnReal) bevel[1].x, (ZnReal) bevel[1].y, + (ZnReal) bevel[0].x, (ZnReal) bevel[0].y, relief, gradient, wi))); XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, bevel, 4, Convex, CoordModeOrigin); bevel[0] = bevel[1]; bevel[3] = bevel[2]; bevel[1].y += bbox->height; - bevel[2].y = bevel[1].y - line_width; + bevel[2].y = bevel[1].y - (short) line_width; XSetForeground(wi->dpy, wi->gc, - ZnPixel(ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, bevel[0].y, + ZnPixel(ReliefColorOfSegment((ZnReal) bevel[1].x, (ZnReal) bevel[1].y, + (ZnReal) bevel[0].x, (ZnReal) bevel[0].y, relief, gradient, wi))); XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, bevel, 4, Convex, CoordModeOrigin); bevel[0] = bevel[1]; bevel[3] = bevel[2]; bevel[1].x -= bbox->width; - bevel[2].x = bevel[1].x + line_width; + bevel[2].x = bevel[1].x + (short) line_width; XSetForeground(wi->dpy, wi->gc, - ZnPixel(ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, bevel[0].y, + ZnPixel(ReliefColorOfSegment((ZnReal) bevel[1].x, (ZnReal) bevel[1].y, + (ZnReal) bevel[0].x, (ZnReal) bevel[0].y, relief, gradient, wi))); XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, bevel, 4, Convex, CoordModeOrigin); @@ -470,24 +561,25 @@ ZnDrawRectangleRelief(WidgetInfo *wi, bevel[1].x = bbox->x; bevel[1].y = bbox->y; bevel[2].x = bevel[3].x; - bevel[2].y = bbox->y + line_width; + bevel[2].y = bbox->y + (short) line_width; XSetForeground(wi->dpy, wi->gc, - ZnPixel(ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, bevel[0].y, + ZnPixel(ReliefColorOfSegment((ZnReal) bevel[1].x, (ZnReal) bevel[1].y, + (ZnReal) bevel[0].x, (ZnReal) bevel[0].y, relief, gradient, wi))); XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, bevel, 4, Convex, CoordModeOrigin); } typedef struct { - WidgetInfo *wi; + ZnWInfo *wi; ZnPoint *pp; ZnPoint *p0; ZnPoint *p1; double dist; ZnBBox *bbox; - ReliefStyle relief; + ZnReliefStyle relief; ZnGradient *gradient; - int alpha; + unsigned short alpha; ZnBool smooth; int result; int count; @@ -496,18 +588,23 @@ typedef struct { static void DoPolygon(ZnPoint *p, - int num_points, - int line_width, + unsigned int num_points, + ZnDim line_width, ZnBool (*cb)(ZnPoint *bevels, PolygonData *pd), PolygonData *pd) { - int i, processed_points; - ZnPoint *p1, *p11=NULL, *p2; - ZnPoint pp1, pp2, new_pp1, new_pp2; - ZnPoint perp, c, shift1, shift2; - ZnPoint bevel_points[4]; - ZnBool folded, closed, colinear; - ZnReal dx, dy; + int i; + unsigned int processed_points; + ZnPoint *p1, *p11=NULL, *p2; + ZnPoint pp1, pp2, new_pp1, new_pp2; + ZnPoint perp, c, shift1, shift2; + ZnPoint bevel_points[4]; + ZnBool folded, closed, colinear; + ZnReal dx, dy; + + if (num_points < 2) { + return; + } /* * If the polygon is closed (last point is the same as first) open it by @@ -583,11 +680,11 @@ DoPolygon(ZnPoint *p, p1 = &p[num_points-2]; } - for (p2 = p1+1; i < num_points; i++, p2++) { + for (p2 = p1+1; i < (int) num_points; i++, p2++) { /* * When it is time to wrap, do it */ - if ((i == -1) || (i == num_points-1)) { + if ((i == -1) || (i == (int) num_points-1)) { p2 = p; } /* @@ -599,7 +696,7 @@ DoPolygon(ZnPoint *p, continue; } - ShiftLine(p1, p2, line_width, &new_pp1, &new_pp2); + ZnShiftLine(p1, p2, line_width, &new_pp1, &new_pp2); bevel_points[3] = *p1; folded = False; colinear = False; @@ -610,12 +707,12 @@ DoPolygon(ZnPoint *p, if ((processed_points == 0) && !closed) { perp.x = p1->x + (p2->y - p1->y); perp.y = p1->y - (p2->x - p1->x); - IntersectLines(p1, &perp, &new_pp1, &new_pp2, &bevel_points[2]); + ZnIntersectLines(p1, &perp, &new_pp1, &new_pp2, &bevel_points[2]); } else if ((processed_points == num_points-1) && !closed) { perp.x = p1->x + (p11->y - p1->y); perp.y = p1->y - (p11->x - p1->x); - IntersectLines(p1, &perp, &pp1, &pp2, &bevel_points[2]); + ZnIntersectLines(p1, &perp, &pp1, &pp2, &bevel_points[2]); } else if (processed_points >= 1) { ZnReal dotp, dist, odx, ody; @@ -627,15 +724,15 @@ DoPolygon(ZnPoint *p, odx = p11->x - p1->x; ody = p11->y - p1->y; dotp = odx*dx + ody*dy; - dist = LineToPointDist(p11, p2, p1); + dist = ZnLineToPointDist(p11, p2, p1); if ((dist < 4.0) && (dotp <= 0)) { perp.x = p1->x + (p2->y - p1->y); perp.y = p1->y - (p2->x - p1->x); - IntersectLines(p1, &perp, &new_pp1, &new_pp2, &bevel_points[2]); + ZnIntersectLines(p1, &perp, &new_pp1, &new_pp2, &bevel_points[2]); colinear = True; } else { - folded = !IntersectLines(&new_pp1, &new_pp2, &pp1, &pp2, &bevel_points[2]); + folded = !ZnIntersectLines(&new_pp1, &new_pp2, &pp1, &pp2, &bevel_points[2]); /*printf("new_pp1 %g@%g, new_pp2 %g@%g, pp1 %g@%g, pp2 %g@%g, inter %g@%g\n", new_pp1.x, new_pp1.y, new_pp2.x, new_pp2.y, pp1.x, pp1.y, pp2.x, pp2.y, @@ -647,10 +744,10 @@ DoPolygon(ZnPoint *p, new_pp2.x, new_pp2.y);*/ perp.x = p1->x + (p2->y - p1->y); perp.y = p1->y - (p2->x - p1->x); - IntersectLines(p1, &perp, &pp1, &pp2, &bevel_points[2]); - IntersectLines(p1, &perp, &new_pp1, &new_pp2, &c); - ShiftLine(p1, &perp, line_width, &shift1, &shift2); - IntersectLines(p1, p2, &shift1, &shift2, &bevel_points[3]); + ZnIntersectLines(p1, &perp, &pp1, &pp2, &bevel_points[2]); + ZnIntersectLines(p1, &perp, &new_pp1, &new_pp2, &c); + ZnShiftLine(p1, &perp, line_width, &shift1, &shift2); + ZnIntersectLines(p1, p2, &shift1, &shift2, &bevel_points[3]); } } } @@ -700,21 +797,21 @@ PolygonBBoxCB(ZnPoint *bevels, int i; for (i = 0; i < 4; i++) { - AddPointToBBox(pd->bbox, bevels[i].x, bevels[i].y); + ZnAddPointToBBox(pd->bbox, bevels[i].x, bevels[i].y); } return 0; } void -ZnGetPolygonReliefBBox(ZnPoint *points, - int num_points, - int line_width, - ZnBBox *bbox) +ZnGetPolygonReliefBBox(ZnPoint *points, + unsigned int num_points, + ZnDim line_width, + ZnBBox *bbox) { PolygonData pd; pd.bbox = bbox; - ResetBBox(bbox); + ZnResetBBox(bbox); DoPolygon(points, num_points, line_width, PolygonBBoxCB, &pd); } @@ -734,13 +831,13 @@ PolygonInBBoxCB(ZnPoint *bevels, { if (pd->count == 0) { pd->count++; - pd->result = PolygonInBBox(bevels, 4, pd->bbox, NULL); + pd->result = ZnPolygonInBBox(bevels, 4, pd->bbox, NULL); if (pd->result == 0) { return 1; } } else { - if (PolygonInBBox(bevels, 4, pd->bbox, NULL) != pd->result) { + if (ZnPolygonInBBox(bevels, 4, pd->bbox, NULL) != pd->result) { pd->result = 0; return 1; } @@ -749,10 +846,10 @@ PolygonInBBoxCB(ZnPoint *bevels, } int -ZnPolygonReliefInBBox(ZnPoint *points, - int num_points, - int line_width, - ZnBBox *area) +ZnPolygonReliefInBBox(ZnPoint *points, + unsigned int num_points, + ZnDim line_width, + ZnBBox *area) { PolygonData pd; @@ -780,7 +877,7 @@ PolygonDistCB(ZnPoint *bevels, { double new_dist; - new_dist = PolygonToPointDist(bevels, 4, pd->pp); + new_dist = ZnPolygonToPointDist(bevels, 4, pd->pp); if (new_dist < 0.0) { new_dist = 0.0; } @@ -792,8 +889,8 @@ PolygonDistCB(ZnPoint *bevels, double ZnPolygonReliefToPointDist(ZnPoint *points, - int num_points, - int line_width, + unsigned int num_points, + ZnDim line_width, ZnPoint *pp) { PolygonData pd; @@ -818,7 +915,7 @@ static ZnBool PolygonDrawCB(ZnPoint *bevels, PolygonData *pd) { - WidgetInfo *wi = pd->wi; + ZnWInfo *wi = pd->wi; XPoint bevel_xpoints[5]; XGCValues values; int j; @@ -831,8 +928,8 @@ PolygonDrawCB(ZnPoint *bevels, XChangeGC(wi->dpy, wi->gc, GCFillStyle|GCForeground, &values); for (j = 0; j < 4; j++) { - bevel_xpoints[j].x = REAL_TO_INT(bevels[j].x); - bevel_xpoints[j].y = REAL_TO_INT(bevels[j].y); + bevel_xpoints[j].x = ZnNearestInt(bevels[j].x); + bevel_xpoints[j].y = ZnNearestInt(bevels[j].y); } XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, bevel_xpoints, 4, @@ -842,12 +939,12 @@ PolygonDrawCB(ZnPoint *bevels, } void -ZnDrawPolygonRelief(WidgetInfo *wi, - ReliefStyle relief, - ZnGradient *gradient, - ZnPoint *points, - int num_points, - int line_width) +ZnDrawPolygonRelief(ZnWInfo *wi, + ZnReliefStyle relief, + ZnGradient *gradient, + ZnPoint *points, + unsigned int num_points, + ZnDim line_width) { PolygonData pd; @@ -858,10 +955,10 @@ ZnDrawPolygonRelief(WidgetInfo *wi, * Grooves and ridges are drawn with two calls. The first * with the original width, the second with half the width. */ - if ((relief == RELIEF_RIDGE) || (relief == RELIEF_GROOVE)) { - pd.relief = (relief==RELIEF_GROOVE)?RELIEF_RAISED:RELIEF_SUNKEN; + if ((relief == ZN_RELIEF_RIDGE) || (relief == ZN_RELIEF_GROOVE)) { + pd.relief = (relief==ZN_RELIEF_GROOVE)?ZN_RELIEF_RAISED:ZN_RELIEF_SUNKEN; DoPolygon(points, num_points, line_width, PolygonDrawCB, &pd); - pd.relief = (relief==RELIEF_GROOVE)?RELIEF_SUNKEN:RELIEF_RAISED; + pd.relief = (relief==ZN_RELIEF_GROOVE)?ZN_RELIEF_SUNKEN:ZN_RELIEF_RAISED; DoPolygon(points, num_points, line_width/2, PolygonDrawCB, &pd); } else { @@ -878,7 +975,7 @@ ZnDrawPolygonRelief(WidgetInfo *wi, * ********************************************************************************** */ -#ifdef GLX +#ifdef GL static ZnBool PolygonRenderCB(ZnPoint *bevels, PolygonData *pd) @@ -886,17 +983,17 @@ PolygonRenderCB(ZnPoint *bevels, int i; ZnPoint p[6]; XColor *c[8]; - XColor *color = ZnGetGradientColor(pd->gradient, 51, NULL); - ReliefStyle relief, int_relief; + XColor *color = ZnGetGradientColor(pd->gradient, 51.0, NULL); + ZnReliefStyle relief, int_relief; ZnBool two_faces, round, rule; - rule = pd->relief & RELIEF_RULE; - round = pd->relief & RELIEF_ROUND; - two_faces = pd->relief & RELIEF_TWO_FACES; - relief = pd->relief & RELIEF_MASK; + rule = pd->relief & ZN_RELIEF_RULE; + round = pd->relief & ZN_RELIEF_ROUND; + two_faces = pd->relief & ZN_RELIEF_TWO_FACES; + relief = pd->relief & ZN_RELIEF_MASK; for (i = 0; i < 4; i++) { - p[i].x = REAL_TO_INT(bevels[i].x); - p[i].y = REAL_TO_INT(bevels[i].y); + p[i].x = ZnNearestInt(bevels[i].x); + p[i].y = ZnNearestInt(bevels[i].y); } if (two_faces) { @@ -905,11 +1002,11 @@ PolygonRenderCB(ZnPoint *bevels, p[5].x = (p[2].x+p[3].x)/2; p[5].y = (p[2].y+p[3].y)/2; - if (relief == RELIEF_SUNKEN) { - int_relief = RELIEF_RAISED; + if (relief == ZN_RELIEF_SUNKEN) { + int_relief = ZN_RELIEF_RAISED; } else { - int_relief = RELIEF_SUNKEN; + int_relief = ZN_RELIEF_SUNKEN; } c[0]=c[1]=c[2]=c[3] = ReliefColorOfSegment(bevels[0].x, bevels[0].y, bevels[3].x, bevels[3].y, @@ -935,28 +1032,28 @@ PolygonRenderCB(ZnPoint *bevels, } glBegin(GL_QUADS); glColor4us(c[0]->red, c[0]->green, c[0]->blue, pd->alpha); - glVertex2f(p[0].x, p[0].y); + glVertex2d(p[0].x, p[0].y); glColor4us(c[1]->red, c[1]->green, c[1]->blue, pd->alpha); - glVertex2f(p[4].x, p[4].y); + glVertex2d(p[4].x, p[4].y); glColor4us(c[2]->red, c[2]->green, c[2]->blue, pd->alpha); - glVertex2f(p[5].x, p[5].y); + glVertex2d(p[5].x, p[5].y); glColor4us(c[3]->red, c[3]->green, c[3]->blue, pd->alpha); - glVertex2f(p[3].x, p[3].y); + glVertex2d(p[3].x, p[3].y); glColor4us(c[4]->red, c[4]->green, c[4]->blue, pd->alpha); - glVertex2f(p[4].x, p[4].y); + glVertex2d(p[4].x, p[4].y); glColor4us(c[5]->red, c[5]->green, c[5]->blue, pd->alpha); - glVertex2f(p[1].x, p[1].y); + glVertex2d(p[1].x, p[1].y); glColor4us(c[6]->red, c[6]->green, c[6]->blue, pd->alpha); - glVertex2f(p[2].x, p[2].y); + glVertex2d(p[2].x, p[2].y); glColor4us(c[7]->red, c[7]->green, c[7]->blue, pd->alpha); - glVertex2f(p[5].x, p[5].y); + glVertex2d(p[5].x, p[5].y); glEnd(); } else { /* Single face */ @@ -973,13 +1070,13 @@ PolygonRenderCB(ZnPoint *bevels, } glBegin(GL_QUADS); glColor4us(c[0]->red, c[0]->green, c[0]->blue, pd->alpha); - glVertex2f(p[0].x, p[0].y); + glVertex2d(p[0].x, p[0].y); glColor4us(c[1]->red, c[1]->green, c[1]->blue, pd->alpha); - glVertex2f(p[1].x, p[1].y); + glVertex2d(p[1].x, p[1].y); glColor4us(c[2]->red, c[2]->green, c[2]->blue, pd->alpha); - glVertex2f(p[2].x, p[2].y); + glVertex2d(p[2].x, p[2].y); glColor4us(c[3]->red, c[3]->green, c[3]->blue, pd->alpha); - glVertex2f(p[3].x, p[3].y); + glVertex2d(p[3].x, p[3].y); glEnd(); } @@ -987,19 +1084,19 @@ PolygonRenderCB(ZnPoint *bevels, } void -ZnRenderPolygonRelief(WidgetInfo *wi, - ReliefStyle relief, +ZnRenderPolygonRelief(ZnWInfo *wi, + ZnReliefStyle relief, ZnGradient *gradient, ZnBool smooth, ZnPoint *points, - int num_points, - ZnReal line_width) + unsigned int num_points, + ZnDim line_width) { PolygonData pd; pd.wi = wi; pd.gradient = gradient; - ZnGetGradientColor(gradient, 0, &pd.alpha); + ZnGetGradientColor(gradient, 0.0, &pd.alpha); pd.alpha = ZnComposeAlpha(pd.alpha, wi->alpha); pd.smooth = smooth; glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -1010,24 +1107,24 @@ ZnRenderPolygonRelief(WidgetInfo *wi, } void -ZnRenderPolyline(WidgetInfo *wi, +ZnRenderPolyline(ZnWInfo *wi, ZnPoint *points, - int num_points, - ZnReal line_width, - LineStyle line_style, + unsigned int num_points, + ZnDim line_width, + ZnLineStyle line_style, int cap_style, - int join_style, + int join_style __unused, ZnLineEnd first_end, ZnLineEnd last_end, ZnGradient *gradient) { int num_clips = ZnListSize(wi->clip_stack); - ZnPoint end_points[LINE_END_POINTS]; + ZnPoint end_points[ZN_LINE_END_POINTS]; ZnBool need_rcaps, thin, closed, transparent; int pass, num_passes, i, k, m; ZnPoint c1, c2; XColor *color; - int alpha; + unsigned short alpha; /* * The code below draws curves thiner than the min @@ -1040,11 +1137,11 @@ ZnRenderPolyline(WidgetInfo *wi, thin = ((line_width <= wi->max_line_width) && (line_width <= wi->max_point_width)); closed = (points->x == points[num_points-1].x) && (points->y == points[num_points-1].y); - color = ZnGetGradientColor(gradient, 0, &alpha); + color = ZnGetGradientColor(gradient, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); glColor4us(color->red, color->green, color->blue, alpha); ZnSetLineStyle(wi, line_style); - glLineWidth(line_width); + glLineWidth((GLfloat) line_width); /* * Do not use joints under this transparency value. */ @@ -1064,11 +1161,11 @@ ZnRenderPolyline(WidgetInfo *wi, * We have chosen to drawn transparent lines with a * correct coverage but NOT antialiased. */ - glPointSize(line_width>1?line_width-1:line_width); + glPointSize((GLfloat)(line_width>1.0?line_width-1:line_width)); glDisable(GL_LINE_SMOOTH); } else { - glPointSize(line_width>1?line_width-1:line_width); + glPointSize((GLfloat)(line_width>1.0?line_width-1:line_width)); } num_passes = 1; @@ -1079,55 +1176,55 @@ ZnRenderPolyline(WidgetInfo *wi, for (pass = 0; pass < num_passes; pass++) { if (transparent) { if (pass == 0) { - GLX_START_CLIP(num_clips, True); + ZnGlStartClip(num_clips, True); } else { - GLX_RESTORE_STENCIL(num_clips, False); + ZnGlRestoreStencil(num_clips, False); } } if (first_end) { - GetLineEnd(&points[0], &points[1], line_width, cap_style, - first_end, end_points); + ZnGetLineEnd(&points[0], &points[1], line_width, cap_style, + first_end, end_points); glBegin(GL_TRIANGLE_FAN); - for (m = 0; m < LINE_END_POINTS; m++) { - glVertex2f(end_points[m].x, end_points[m].y); + for (m = 0; m < ZN_LINE_END_POINTS; m++) { + glVertex2d(end_points[m].x, end_points[m].y); } glEnd(); } if (last_end) { - GetLineEnd(&points[num_points-1], &points[num_points-2], - line_width, cap_style, last_end, end_points); + ZnGetLineEnd(&points[num_points-1], &points[num_points-2], + line_width, cap_style, last_end, end_points); glBegin(GL_TRIANGLE_FAN); - for (m = 0; m < LINE_END_POINTS; m++) { - glVertex2f(end_points[m].x, end_points[m].y); + for (m = 0; m < ZN_LINE_END_POINTS; m++) { + glVertex2d(end_points[m].x, end_points[m].y); } glEnd(); } if (thin) { glBegin(GL_LINE_STRIP); - for (i = 0; i < num_points; i++) { - glVertex2f(points[i].x, points[i].y); + for (i = 0; i < (int) num_points; i++) { + glVertex2d(points[i].x, points[i].y); } glEnd(); } else { glBegin(GL_QUADS); - for (i = 0; i < num_points-1; i++) { - GetButtPoints(&points[i+1], &points[i], line_width, False, &c1, &c2); - glVertex2f(c1.x, c1.y); - glVertex2f(c2.x, c2.y); - GetButtPoints(&points[i], &points[i+1], line_width, False, &c1, &c2); - glVertex2f(c1.x, c1.y); - glVertex2f(c2.x, c2.y); + for (i = 0; i < (int) num_points-1; i++) { + ZnGetButtPoints(&points[i+1], &points[i], line_width, False, &c1, &c2); + glVertex2d(c1.x, c1.y); + glVertex2d(c2.x, c2.y); + ZnGetButtPoints(&points[i], &points[i+1], line_width, False, &c1, &c2); + glVertex2d(c1.x, c1.y); + glVertex2d(c2.x, c2.y); } glEnd(); } /* if (pass == 0) { - GLX_RENDER_CLIPPED(); + ZnGlRenderClipped(); } else { - GLX_END_CLIP(num_clips); + ZnGlEndClip(num_clips); break; }*/ need_rcaps = ((line_width > 1) && (cap_style == CapRound)); @@ -1146,21 +1243,21 @@ ZnRenderPolyline(WidgetInfo *wi, if (thin) { glBegin(GL_POINTS); for ( ; i < k; i++) { - glVertex2f(points[i].x, points[i].y); + glVertex2d(points[i].x, points[i].y); } glEnd(); } else { int num_cpoints; ZnReal lw_2 = line_width / 2.0; - ZnPoint *cpoints = GetCirclePoints(3, ZN_CIRCLE_COARSE, - 0, 2*M_PI, &num_cpoints, NULL); + ZnPoint *cpoints = ZnGetCirclePoints(3, ZN_CIRCLE_COARSE, + 0.0, 2*M_PI, &num_cpoints, NULL); for ( ; i < k; i++) { glBegin(GL_TRIANGLE_FAN); - glVertex2f(points[i].x, points[i].y); + glVertex2d(points[i].x, points[i].y); for (m = 0; m < num_cpoints; m++) { - glVertex2f(points[i].x + cpoints[m].x*lw_2, + glVertex2d(points[i].x + cpoints[m].x*lw_2, points[i].y + cpoints[m].y*lw_2); } glEnd(); @@ -1168,7 +1265,7 @@ ZnRenderPolyline(WidgetInfo *wi, } } - GLX_END_CLIP(num_clips); + ZnGlEndClip(num_clips); if (thin) { glEnable(GL_LINE_SMOOTH); } @@ -1176,7 +1273,7 @@ ZnRenderPolyline(WidgetInfo *wi, void -ZnRenderIcon(WidgetInfo *wi, +ZnRenderIcon(ZnWInfo *wi, ZnImage image, ZnGradient *gradient, ZnPoint *origin, @@ -1198,18 +1295,18 @@ ZnRenderIcon(WidgetInfo *wi, void -ZnRenderImage(WidgetInfo *wi, +ZnRenderImage(ZnWInfo *wi, ZnImage image, ZnGradient *gradient, ZnPoint *quad, ZnBool modulate) { - XColor *color; - int alpha; - ZnReal t, s; - GLuint texobj; + XColor *color; + unsigned short alpha; + ZnReal t, s; + GLuint texobj; - color = ZnGetGradientColor(gradient, 0, &alpha); + color = ZnGetGradientColor(gradient, 0.0, &alpha); alpha = ZnComposeAlpha(alpha, wi->alpha); texobj = ZnImageTex(image, &t, &s); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -1223,28 +1320,29 @@ ZnRenderImage(WidgetInfo *wi, glColor4us(65535, 65535, 65535, alpha); } glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); - glVertex2f(quad[0].x, quad[0].y); - glTexCoord2f(0.0, t); - glVertex2f(quad[1].x, quad[1].y); - glTexCoord2f(s, t); - glVertex2f(quad[2].x, quad[2].y); - glTexCoord2f(s, 0.0); - glVertex2f(quad[3].x, quad[3].y); + glTexCoord2d(0.0, 0.0); + glVertex2d(quad[0].x, quad[0].y); + glTexCoord2d(0.0, t); + glVertex2d(quad[1].x, quad[1].y); + glTexCoord2d(s, t); + glVertex2d(quad[2].x, quad[2].y); + glTexCoord2d(s, 0.0); + glVertex2d(quad[3].x, quad[3].y); glEnd(); glDisable(GL_TEXTURE_2D); } void -ZnRenderTile(WidgetInfo *wi, +ZnRenderTile(ZnWInfo *wi, ZnImage tile, ZnGradient *gradient, - void cb(void *), + void (*cb)(void *), void *closure, ZnPoint *quad) /* Right now it's a ZnBBox */ { ZnReal x, y, nx, ny, lx, ly, s, t, tiles, tilet; - int width, height, alpha, num_clips = ZnListSize(wi->clip_stack); + int width, height, num_clips = ZnListSize(wi->clip_stack); + unsigned short alpha; GLuint texobj; if (gradient) { @@ -1259,10 +1357,10 @@ ZnRenderTile(WidgetInfo *wi, /* * Setup the stencil buffer with the shape to be drawn. */ - GLX_START_CLIP(num_clips, False); + ZnGlStartClip(num_clips, False); (*cb)(closure); - GLX_RESTORE_STENCIL(num_clips, True); + ZnGlRestoreStencil(num_clips, True); } /* @@ -1298,14 +1396,14 @@ ZnRenderTile(WidgetInfo *wi, s = (lx - x) / (ZnReal) width; } s *= tiles; - glTexCoord2f(0.0, 0.0); - glVertex2f(x, y); - glTexCoord2f(0.0, t); - glVertex2f(x, ny); - glTexCoord2f(s, t); - glVertex2f(nx, ny); - glTexCoord2f(s, 0.0); - glVertex2f(nx, y); + glTexCoord2d(0.0, 0.0); + glVertex2d(x, y); + glTexCoord2d(0.0, t); + glVertex2d(x, ny); + glTexCoord2d(s, t); + glVertex2d(nx, ny); + glTexCoord2d(s, 0.0); + glVertex2d(nx, y); x = nx; } while (x != lx); @@ -1315,29 +1413,29 @@ ZnRenderTile(WidgetInfo *wi, glEnd(); if (cb) { - GLX_END_CLIP(num_clips); + ZnGlEndClip(num_clips); } glDisable(GL_TEXTURE_2D); } void -ZnComputeAxialGradient(WidgetInfo *wi, - ZnPoly *shape, - int angle, - ZnPoint *grad_geo) +ZnComputeAxialGradient(ZnWInfo *wi, + ZnPoly *shape, + ZnReal angle, + ZnPoint *grad_geo) { ZnTransfo *transfo1, *transfo2; ZnContour *c; ZnBBox bbox; ZnPoint *points, p[4]; - int i; + unsigned int i; transfo1 = ZnTransfoNew(); transfo2 = ZnTransfoNew(); ZnRotateDeg(transfo1, angle); ZnRotateDeg(transfo2, -angle); c = shape->contours; - ResetBBox(&bbox); + ZnResetBBox(&bbox); for (i = 0; i < shape->num_contours; i++, c++) { if (c->cw) { continue; @@ -1345,7 +1443,7 @@ ZnComputeAxialGradient(WidgetInfo *wi, ZnListAssertSize(wi->work_pts, c->num_points); points = ZnListArray(wi->work_pts); ZnTransformPoints(transfo1, c->points, points, c->num_points); - AddPointsToBBox(&bbox, points, c->num_points); + ZnAddPointsToBBox(&bbox, points, c->num_points); } bbox.orig.x--; bbox.orig.y--; @@ -1365,7 +1463,7 @@ ZnComputeAxialGradient(WidgetInfo *wi, } void -ZnComputeRadialGradient(WidgetInfo *wi, +ZnComputeRadialGradient(ZnWInfo *wi, ZnPoly *shape, ZnBool oval, ZnPoint *focal_pp, /* in percent of bbox */ @@ -1377,19 +1475,19 @@ ZnComputeRadialGradient(WidgetInfo *wi, ZnPoint offset, focal_point, radius; ZnPoint *points; ZnTransfo t1; - int i, j; + unsigned int i, j; /* * Compute the shape bbox (which should be in the item space). */ - ResetBBox(&bbox); + ZnResetBBox(&bbox); c = shape->contours; dist = 0.0; for (j = 0; j < shape->num_contours; j++, c++) { if (c->cw) { continue; } - AddPointsToBBox(&bbox, c->points, c->num_points); + ZnAddPointsToBBox(&bbox, c->points, c->num_points); } /* @@ -1476,26 +1574,26 @@ ZnComputeRadialGradient(WidgetInfo *wi, } void -ZnComputePathGradient(WidgetInfo *wi, - ZnPoly *shape, - ZnPoint *focal_pp, /* in percent of the bbox */ - ZnPoint *grad_geo) +ZnComputePathGradient(ZnWInfo *wi, + ZnPoly *shape, + ZnPoint *focal_pp, /* in percent of the bbox */ + ZnPoint *grad_geo) { ZnBBox bbox; ZnContour *c; ZnPoint focal_point; - int j; + unsigned int j; /* * Compute the shape bbox (which should be in the item space). */ - ResetBBox(&bbox); + ZnResetBBox(&bbox); c = shape->contours; for (j = 0; j < shape->num_contours; j++, c++) { if (c->cw) { continue; } - AddPointsToBBox(&bbox, c->points, c->num_points); + ZnAddPointsToBBox(&bbox, c->points, c->num_points); } /* @@ -1510,10 +1608,10 @@ ZnComputePathGradient(WidgetInfo *wi, } void -ZnRenderGradient(WidgetInfo *wi, +ZnRenderGradient(ZnWInfo *wi, ZnGradient *gradient, /* The grdient to be drawn (static * parameters). */ - void cb(void *), /* A callback called to clip the shape + void (*cb)(void *), /* A callback called to clip the shape * containing the gradient. */ void *closure, /* The callback parameter. */ ZnPoint *quad, /* The gradient geometric parameters @@ -1521,14 +1619,16 @@ ZnRenderGradient(WidgetInfo *wi, ZnPoly *poly /* Used only by ZN_PATH_GRADIENT */ ) { - int alpha, angle, i, j; + unsigned short alpha, alpha2; + int angle; + unsigned int i, j; int type = gradient->type; XColor *color; ZnPoint p; ZnPoint dposa, dposb, dposc, dposd; ZnPoint dcontrol; ZnReal npos, pos, control; - int num_clips = ZnListSize(wi->clip_stack); + unsigned int num_clips = ZnListSize(wi->clip_stack); ZnPoint iquad[4]; if (!cb && (type == ZN_AXIAL_GRADIENT)) { /* Render an aligned @@ -1568,9 +1668,9 @@ ZnRenderGradient(WidgetInfo *wi, * Draw the gradient shape in the stencil using the provided * callback (clipping). */ - GLX_START_CLIP(num_clips, False); + ZnGlStartClip(num_clips, False); (*cb)(closure); - GLX_RESTORE_STENCIL(num_clips, True); + ZnGlRestoreStencil(num_clips, True); } if (type == ZN_AXIAL_GRADIENT) { @@ -1591,13 +1691,13 @@ ZnRenderGradient(WidgetInfo *wi, dposa.y = (quad[1].y - quad[0].y)*pos/100.0; p.x = quad[0].x + dposa.x; p.y = quad[0].y + dposa.y; - glVertex2f(p.x, p.y); + glVertex2d(p.x, p.y); dposb.x = (quad[2].x - quad[3].x)*pos/100.0; dposb.y = (quad[2].y - quad[3].y)*pos/100.0; p.x = quad[3].x + dposb.x; p.y = quad[3].y + dposb.y; - glVertex2f(p.x, p.y); + glVertex2d(p.x, p.y); if ((control != 50.0) && (i != gradient->num_colors-1)) { color = gradient->colors[i].mid_rgb; @@ -1611,7 +1711,7 @@ ZnRenderGradient(WidgetInfo *wi, dcontrol.y = (dposc.y - dposa.y)*control/100.0; p.x = quad[0].x + dposa.x + dcontrol.x; p.y = quad[0].y + dposa.y + dcontrol.y; - glVertex2f(p.x, p.y); + glVertex2d(p.x, p.y); dposd.x = (quad[2].x - quad[3].x)*npos/100.0; dposd.y = (quad[2].y - quad[3].y)*npos/100.0; @@ -1619,20 +1719,20 @@ ZnRenderGradient(WidgetInfo *wi, dcontrol.y = (dposd.y - dposb.y)*control/100.0; p.x = quad[3].x + dposb.x + dcontrol.x; p.y = quad[3].y + dposb.y + dcontrol.y; - glVertex2f(p.x, p.y); + glVertex2d(p.x, p.y); } } glEnd(); } else if (type == ZN_RADIAL_GRADIENT) { - ZnReal x, position, position2, position3; - ZnReal y; - int num_p, alpha2; - ZnPoint *genarc, *tarc, p, focalp; - XColor *color2; + ZnReal x, position, position2, position3; + ZnReal y; + unsigned int num_p; + ZnPoint *genarc, *tarc, p, focalp; + XColor *color2; - genarc = GetCirclePoints(3, ZN_CIRCLE_FINE, 0, 2*M_PI, &num_p, NULL); + genarc = ZnGetCirclePoints(3, ZN_CIRCLE_FINE, 0.0, 2*M_PI, &num_p, NULL); ZnListAssertSize(wi->work_pts, num_p); tarc = ZnListArray(wi->work_pts); ZnTransformPoints((ZnTransfo *) quad, genarc, tarc, num_p); @@ -1654,11 +1754,11 @@ ZnRenderGradient(WidgetInfo *wi, x = focalp.x + (tarc[i].x-focalp.x) * position; y = focalp.y + (tarc[i].y-focalp.y) * position; glColor4us(color->red, color->green, color->blue, alpha); - glVertex2f(x, y); + glVertex2d(x, y); x = focalp.x + (tarc[i].x-focalp.x) * position3; y = focalp.y + (tarc[i].y-focalp.y) * position3; glColor4us(color2->red, color2->green, color2->blue, alpha); - glVertex2f(x, y); + glVertex2d(x, y); } position = position3; color = color2; @@ -1672,11 +1772,11 @@ ZnRenderGradient(WidgetInfo *wi, x = focalp.x + (tarc[i].x-focalp.x) * position; y = focalp.y + (tarc[i].y-focalp.y) * position; glColor4us(color->red, color->green, color->blue, alpha); - glVertex2f(x, y); + glVertex2d(x, y); x = focalp.x + (tarc[i].x-focalp.x) * position2; y = focalp.y + (tarc[i].y-focalp.y) * position2; glColor4us(color2->red, color2->green, color2->blue, alpha2); - glVertex2f(x, y); + glVertex2d(x, y); } glEnd(); position = position2; @@ -1686,10 +1786,10 @@ ZnRenderGradient(WidgetInfo *wi, } } else if (type == ZN_PATH_GRADIENT) { - ZnPoint p, pp, p2, pp2, p3, pp3; - int num_p, k, ii; - ZnPoint *points; - ZnReal position; + ZnPoint p, pp, p2, pp2, p3, pp3; + unsigned int num_p, k, ii; + ZnPoint *points; + ZnReal position; for (k = 0; k < poly->num_contours; k++) { if (poly->contours[k].cw) { @@ -1713,8 +1813,8 @@ ZnRenderGradient(WidgetInfo *wi, alpha = ZnComposeAlpha(gradient->colors[0].alpha, wi->alpha); color = gradient->colors[0].rgb; glColor4us(color->red, color->green, color->blue, alpha); - glVertex2f(quad[0].x+p.x, quad[0].y+p.y); - glVertex2f(quad[0].x+pp.x, quad[0].y+pp.y); + glVertex2d(quad[0].x+p.x, quad[0].y+p.y); + glVertex2d(quad[0].x+pp.x, quad[0].y+pp.y); for (j = 0; j < gradient->num_colors-1; j++) { position = gradient->colors[j+1].position; p2.x = (points[i].x-quad[0].x)*position/100.0; @@ -1729,8 +1829,8 @@ ZnRenderGradient(WidgetInfo *wi, pp3.x = pp.x+(pp2.x-pp.x)*control/100.0; pp3.y = pp.y+(pp2.y-pp.y)*control/100.0; glColor4us(color->red, color->green, color->blue, alpha); - glVertex2f(quad[0].x+p3.x, quad[0].y+p3.y); - glVertex2f(quad[0].x+pp3.x, quad[0].y+pp3.y); + glVertex2d(quad[0].x+p3.x, quad[0].y+p3.y); + glVertex2d(quad[0].x+pp3.x, quad[0].y+pp3.y); } control = gradient->colors[j+1].control; alpha = ZnComposeAlpha(gradient->colors[j+1].alpha, wi->alpha); @@ -1738,8 +1838,8 @@ ZnRenderGradient(WidgetInfo *wi, p = p2; pp = pp2; glColor4us(color->red, color->green, color->blue, alpha); - glVertex2f(quad[0].x+p.x, quad[0].y+p.y); - glVertex2f(quad[0].x+pp.x, quad[0].y+pp.y); + glVertex2d(quad[0].x+p.x, quad[0].y+p.y); + glVertex2d(quad[0].x+pp.x, quad[0].y+pp.y); } glEnd(); } @@ -1750,44 +1850,44 @@ ZnRenderGradient(WidgetInfo *wi, /* * Restore the previous GL state. */ - GLX_END_CLIP(num_clips); + ZnGlEndClip(num_clips); } } void -ZnRenderHollowDot(WidgetInfo *wi, +ZnRenderHollowDot(ZnWInfo *wi, ZnPoint *p, ZnReal size) { int num_clips = ZnListSize(wi->clip_stack); - GLX_START_CLIP(num_clips, False); + ZnGlStartClip(num_clips, False); - glPointSize(size-2); + glPointSize((GLfloat) (size-2)); glBegin(GL_POINTS); - glVertex2f(p->x, p->y); + glVertex2d(p->x, p->y); glEnd(); - GLX_RENDER_CLIPPED(); + ZnGlRenderClipped(); - glPointSize(size); + glPointSize((GLfloat) size); glBegin(GL_POINTS); - glVertex2f(p->x, p->y); + glVertex2d(p->x, p->y); glEnd(); - GLX_RESTORE_STENCIL(num_clips, False); + ZnGlRestoreStencil(num_clips, False); glBegin(GL_POINTS); - glVertex2f(p->x, p->y); + glVertex2d(p->x, p->y); glEnd(); - GLX_END_CLIP(num_clips); + ZnGlEndClip(num_clips); } #endif -#ifdef GLX +#ifdef GL /* Copyright (c) Mark J. Kilgard, 1997. */ /* This program is freely distributable without licensing fees and is @@ -1819,9 +1919,9 @@ ZnRenderGlyph(ZnTexFontInfo *tfi, void ZnRenderString(ZnTexFontInfo *tfi, unsigned char *string, - int len) + unsigned int len) { - int i; + unsigned int i; for (i = 0; i < len; i++) { ZnRenderGlyph(tfi, string[i]); @@ -1835,12 +1935,12 @@ enum { void ZnRenderFancyString(ZnTexFontInfo *tfi, unsigned char *string, - int len) + unsigned int len) { ZnTexGVI *tgvi; GLubyte c[4][3]; int mode = MONO; - int i; + unsigned int i; for (i = 0; i < len; i++) { if (string[i] == 27) { |