1/* xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski <jwz@netscape.com> 2 * 3 * Permission to use, copy, modify, distribute, and sell this software and its 4 * documentation for any purpose is hereby granted without fee, provided that 5 * the above copyright notice appear in all copies and that both that 6 * copyright notice and this permission notice appear in supporting 7 * documentation. No representations are made about the suitability of this 8 * software for any purpose. It is provided "as is" without express or 9 * implied warranty. 10 */ 11 12/* 1999-Nov-21 Modified by Jim Knoble <jmknoble@jmknoble.cx> 13 * Modifications: 14 * - Extracted draw_shaded_rectangle() from xscreensaver source for use 15 * in a separate application. Constructed separate header file. 16 */ 17 18#include <X11/Intrinsic.h> 19 20void 21draw_shaded_rectangle (Display *dpy, Window window, 22 int x, int y, 23 int width, int height, 24 int thickness, 25 unsigned long top_color, 26 unsigned long bottom_color) 27{ 28 XPoint points[4]; 29 XGCValues gcv; 30 GC gc1, gc2; 31 if (thickness == 0) return; 32 33 gcv.foreground = top_color; 34 gc1 = XCreateGC (dpy, window, GCForeground, &gcv); 35 gcv.foreground = bottom_color; 36 gc2 = XCreateGC (dpy, window, GCForeground, &gcv); 37 38 points [0].x = x; 39 points [0].y = y; 40 points [1].x = x + width; 41 points [1].y = y; 42 points [2].x = x + width - thickness; 43 points [2].y = y + thickness; 44 points [3].x = x; 45 points [3].y = y + thickness; 46 XFillPolygon (dpy, window, gc1, points, 4, Convex, CoordModeOrigin); 47 48 points [0].x = x; 49 points [0].y = y + thickness; 50 points [1].x = x; 51 points [1].y = y + height; 52 points [2].x = x + thickness; 53 points [2].y = y + height - thickness; 54 points [3].x = x + thickness; 55 points [3].y = y + thickness; 56 XFillPolygon (dpy, window, gc1, points, 4, Convex, CoordModeOrigin); 57 58 points [0].x = x + width; 59 points [0].y = y; 60 points [1].x = x + width - thickness; 61 points [1].y = y + thickness; 62 points [2].x = x + width - thickness; 63 points [2].y = y + height - thickness; 64 points [3].x = x + width; 65 points [3].y = y + height - thickness; 66 XFillPolygon (dpy, window, gc2, points, 4, Convex, CoordModeOrigin); 67 68 points [0].x = x; 69 points [0].y = y + height; 70 points [1].x = x + width; 71 points [1].y = y + height; 72 points [2].x = x + width; 73 points [2].y = y + height - thickness; 74 points [3].x = x + thickness; 75 points [3].y = y + height - thickness; 76 XFillPolygon (dpy, window, gc2, points, 4, Convex, CoordModeOrigin); 77 78 XFreeGC (dpy, gc1); 79 XFreeGC (dpy, gc2); 80} 81 82