+
+ switch (sp->relief) {
+ case RR_RELIEF_RAISED:
+ if (!sp->bevel_dark)
+ create_bevel_colors(l);
+
+ switch (sp->bevel) {
+ case RR_BEVEL_1:
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
+ left, bottom, right, bottom);
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
+ right, bottom, right, top);
+
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
+ left, top, right, top);
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
+ left, bottom, left, top);
+ break;
+ case RR_BEVEL_2:
+ XDrawLine(RrDisplay(l->inst), l->pixmap,
+ sp->bevel_dark->gc,
+ left + 1, bottom - 2, right - 2, bottom - 2);
+ XDrawLine(RrDisplay(l->inst), l->pixmap,
+ sp->bevel_dark->gc,
+ right - 2, bottom - 2, right - 2, top + 1);
+
+ XDrawLine(RrDisplay(l->inst), l->pixmap,
+ sp->bevel_light->gc,
+ left + 1, top + 1, right - 2, top + 1);
+ XDrawLine(RrDisplay(l->inst), l->pixmap,
+ sp->bevel_light->gc,
+ left + 1, bottom - 2, left + 1, top + 1);
+ break;
+ default:
+ g_assert_not_reached(); /* unhandled BevelType */
+ }
+ break;
+ case RR_RELIEF_SUNKEN:
+ if (!sp->bevel_dark)
+ create_bevel_colors(l);
+
+ switch (sp->bevel) {
+ case RR_BEVEL_1:
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
+ left, bottom, right, bottom);
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
+ right, bottom, right, top);
+
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
+ left, top, right, top);
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
+ left, bottom, left, top);
+ break;
+ case RR_BEVEL_2:
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
+ left + 1, bottom - 2, right - 2, bottom - 2);
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_light->gc,
+ right - 2, bottom - 2, right - 2, top + 1);
+
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
+ left + 1, top + 1, right - 2, top + 1);
+ XDrawLine(RrDisplay(l->inst), l->pixmap, sp->bevel_dark->gc,
+ left + 1, bottom - 2, left + 1, top + 1);
+
+ break;
+ default:
+ g_assert_not_reached(); /* unhandled BevelType */
+ }
+ break;
+ case RR_RELIEF_FLAT:
+ if (sp->border) {
+ if (sp->border_color->gc == None)
+ RrColorAllocateGC(sp->border_color);
+ XDrawRectangle(RrDisplay(l->inst), l->pixmap, sp->border_color->gc,
+ left, top, right, bottom);
+ }
+ break;
+ default:
+ g_assert_not_reached(); /* unhandled ReliefType */
+ }
+}
+
+/* * * * * * * * * * * * * * GRADIENT MAGIC WOOT * * * * * * * * * * * * * * */
+
+#define VARS(x) \
+ unsigned int color##x[3]; \
+ int len##x, cdelta##x[3], error##x[3] = { 0, 0, 0 }, inc##x[3]; \
+ gboolean bigslope##x[3] /* color slope > 1 */
+
+#define SETUP(x, from, to, w) \
+ len##x = w; \
+ \
+ color##x[0] = from->r; \
+ color##x[1] = from->g; \
+ color##x[2] = from->b; \
+ \
+ cdelta##x[0] = to->r - from->r; \
+ cdelta##x[1] = to->g - from->g; \
+ cdelta##x[2] = to->b - from->b; \
+ \
+ if (cdelta##x[0] < 0) { \
+ cdelta##x[0] = -cdelta##x[0]; \
+ inc##x[0] = -1; \
+ } else \
+ inc##x[0] = 1; \
+ if (cdelta##x[1] < 0) { \
+ cdelta##x[1] = -cdelta##x[1]; \
+ inc##x[1] = -1; \
+ } else \
+ inc##x[1] = 1; \
+ if (cdelta##x[2] < 0) { \
+ cdelta##x[2] = -cdelta##x[2]; \
+ inc##x[2] = -1; \
+ } else \
+ inc##x[2] = 1; \
+ bigslope##x[0] = cdelta##x[0] > w;\
+ bigslope##x[1] = cdelta##x[1] > w;\
+ bigslope##x[2] = cdelta##x[2] > w
+
+#define COLOR_RR(x, c) \
+ c->r = color##x[0]; \
+ c->g = color##x[1]; \
+ c->b = color##x[2]
+
+#define COLOR(x) \
+ ((color##x[0] << RrDefaultRedOffset) + \
+ (color##x[1] << RrDefaultGreenOffset) + \
+ (color##x[2] << RrDefaultBlueOffset))
+
+#define NEXT(x) \
+{ \
+ int i; \
+ for (i = 2; i >= 0; --i) { \
+ if (!cdelta##x[i]) continue; \
+ \
+ if (!bigslope##x[i]) { \
+ /* Y (color) is dependant on X */ \
+ error##x[i] += cdelta##x[i]; \
+ if ((error##x[i] << 1) >= len##x) { \
+ color##x[i] += inc##x[i]; \
+ error##x[i] -= len##x; \
+ } \
+ } else { \
+ /* X is dependant on Y (color) */ \
+ while (1) { \
+ color##x[i] += inc##x[i]; \
+ error##x[i] += len##x; \
+ if ((error##x[i] << 1) >= cdelta##x[i]) { \
+ error##x[i] -= cdelta##x[i]; \
+ break; \
+ } \
+ } \
+ } \
+ } \