diff options
author | lecoanet | 2000-03-10 12:25:40 +0000 |
---|---|---|
committer | lecoanet | 2000-03-10 12:25:40 +0000 |
commit | 3cab036778c7944d283bfc2e51cdf596c1a2a470 (patch) | |
tree | b323853cdc636928ff0c7a374231f03e29775f5c /generic | |
parent | 320e8e0b54d6218191abc5835b4d8cc397a24920 (diff) | |
download | tkzinc-3cab036778c7944d283bfc2e51cdf596c1a2a470.zip tkzinc-3cab036778c7944d283bfc2e51cdf596c1a2a470.tar.gz tkzinc-3cab036778c7944d283bfc2e51cdf596c1a2a470.tar.bz2 tkzinc-3cab036778c7944d283bfc2e51cdf596c1a2a470.tar.xz |
* R�introduction de DrawRectangleRelief en l'adaptant �
la nouvelle m�thode de relief.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Draw.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/generic/Draw.c b/generic/Draw.c index 037e745..2d96d43 100644 --- a/generic/Draw.c +++ b/generic/Draw.c @@ -361,6 +361,99 @@ ReliefColorOfSegment(ZnReal x1, } +/* + ********************************************************************************** + * + * DrawRectangleRelief -- + * Draw the bevels inside bbox. + * + ********************************************************************************** + */ +void +DrawRectangleRelief(WidgetInfo *wi, + ReliefStyle relief, + ZnColorGradient gradient, + XRectangle *bbox, + unsigned int line_width) +{ + XPoint bevel[4]; + + /* + * If we haven't enough space to draw, exit. + */ + if ((bbox->width < 2*line_width) || (bbox->height < 2*line_width)) { + return; + } + + /* + * 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; + + new_line_width = line_width/2; + offset = line_width - new_line_width; + DrawRectangleRelief(wi, + (relief==RELIEF_GROOVE)?RELIEF_BEVEL_IN:RELIEF_BEVEL_OUT, + gradient, bbox, new_line_width); + internal_bbox = *bbox; + internal_bbox.x +=offset; + internal_bbox.y += offset; + internal_bbox.width -= offset*2; + internal_bbox.height -= offset*2; + DrawRectangleRelief(wi, + (relief==RELIEF_GROOVE)?RELIEF_BEVEL_OUT:RELIEF_BEVEL_IN, + gradient, &internal_bbox, new_line_width); + return; + } + + XSetFillStyle(wi->dpy, wi->gc, FillSolid); + + 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; + XSetForeground(wi->dpy, wi->gc, + ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, 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; + XSetForeground(wi->dpy, wi->gc, + ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, 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; + XSetForeground(wi->dpy, wi->gc, + ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, 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->x; + bevel[1].y = bbox->y; + bevel[2].x = bevel[3].x; + bevel[2].y = bbox->y + line_width; + XSetForeground(wi->dpy, wi->gc, + ReliefColorOfSegment(bevel[1].x, bevel[1].y, bevel[0].x, bevel[0].y, + relief, gradient, wi)); + XFillPolygon(wi->dpy, wi->draw_buffer, wi->gc, bevel, 4, Convex, CoordModeOrigin); +} + + static void DoPolygonRelief(ZnPoint *p, int num_points, |