3 Copyright 1988, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
28 * XmuDrawRoundedRectangle, XmuFillRoundedRectangle
30 * Draw/Fill a rounded rectangle, where x, y, w, h are the dimensions of
31 * the overall rectangle, and ew and eh are the sizes of a bounding box
32 * that the corners are drawn inside of.
39 #include <X11/Xmu/Drawing.h>
42 XmuDrawRoundedRectangle(Display *dpy, Drawable draw, GC gc,
43 int x, int y, int w, int h, int ew, int eh)
48 if ((ew2 = (ew << 1)) > w)
50 if ((eh2 = (eh << 1)) > h)
57 arcs[0].angle1 = 180 * 64;
58 arcs[0].angle2 = -90 * 64;
62 arcs[1].width = w - ew2;
64 arcs[1].angle1 = 180 * 64;
65 arcs[1].angle2 = -180 * 64;
67 arcs[2].x = x + w - ew2;
71 arcs[2].angle1 = 90 * 64;
72 arcs[2].angle2 = -90 * 64;
77 arcs[3].height = h - eh2;
78 arcs[3].angle1 = 90 * 64;
79 arcs[3].angle2 = -180 * 64;
81 arcs[4].x = x + w - ew2;
82 arcs[4].y = y + h - eh2;
86 arcs[4].angle2 = -90 * 64;
90 arcs[5].width = w - ew2;
93 arcs[5].angle2 = -180 * 64;
96 arcs[6].y = y + h - eh2;
99 arcs[6].angle1 = 270 * 64;
100 arcs[6].angle2 = -90 * 64;
105 arcs[7].height = h - eh2;
106 arcs[7].angle1 = 270 * 64;
107 arcs[7].angle2 = -180 * 64;
109 XDrawArcs(dpy, draw, gc, arcs, 8);
113 XmuFillRoundedRectangle(Display *dpy, Drawable draw, GC gc,
114 int x, int y, int w, int h, int ew, int eh)
121 XGetGCValues(dpy, gc, GCArcMode, &vals);
122 if (vals.arc_mode != ArcPieSlice)
123 XSetArcMode(dpy, gc, ArcPieSlice);
125 if ((ew2 = (ew << 1)) > w)
127 if ((eh2 = (eh << 1)) > h)
133 arcs[0].height = eh2;
134 arcs[0].angle1 = 180 * 64;
135 arcs[0].angle2 = -90 * 64;
137 arcs[1].x = x + w - ew2 - 1;
140 arcs[1].height = eh2;
141 arcs[1].angle1 = 90 * 64;
142 arcs[1].angle2 = -90 * 64;
144 arcs[2].x = x + w - ew2 - 1;
145 arcs[2].y = y + h - eh2 - 1;
147 arcs[2].height = eh2;
149 arcs[2].angle2 = -90 * 64;
152 arcs[3].y = y + h - eh2 - 1;
154 arcs[3].height = eh2;
155 arcs[3].angle1 = 270 * 64;
156 arcs[3].angle2 = -90 * 64;
158 XFillArcs(dpy, draw, gc, arcs, 4);
162 rects[0].width = w - ew2;
168 rects[1].height = h - eh2;
170 rects[2].x = x + w - ew;
173 rects[2].height = h - eh2;
175 XFillRectangles(dpy, draw, gc, rects, 3);
177 if (vals.arc_mode != ArcPieSlice)
178 XSetArcMode(dpy, gc, vals.arc_mode);