aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generic/Draw.c93
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,