Ported to Scheme48.
This commit is contained in:
parent
732288dd13
commit
743f003202
|
@ -1,267 +1,318 @@
|
||||||
#include "xlib.h"
|
#include "xlib.h"
|
||||||
|
#include "scheme48.h"
|
||||||
|
|
||||||
|
|
||||||
extern XDrawPoints(), XDrawLines(), XDrawRectangle(), XFillRectangle();
|
extern XDrawPoints(), XDrawLines(), XDrawRectangle(), XFillRectangle();
|
||||||
extern XDrawRectangles(), XFillRectangles(), XDrawArc(), XFillArc();
|
extern XDrawRectangles(), XFillRectangles(), XDrawArc(), XFillArc();
|
||||||
extern XDrawArcs(), XFillArcs(), XFillPolygon();
|
extern XDrawArcs(), XFillArcs(), XFillPolygon();
|
||||||
|
|
||||||
static s48_value P_Clear_Area (win, x, y, w, h, e) s48_value win, x, y, w, h, e; {
|
|
||||||
Check_Type (win, T_Window);
|
|
||||||
Check_Type (e, T_Boolean);
|
s48_value Clear_Area(s48_value Xwindow, s48_value Xdisplay, s48_value x,
|
||||||
XClearArea (WINDOW(win)->dpy, WINDOW(win)->win, (int)s48_extract_integer (x),
|
s48_value y, s48_value w, s48_value h, s48_value e){
|
||||||
(int)s48_extract_integer (y), (int)s48_extract_integer (w), (int)s48_extract_integer (h), S48_EQ_P(e, S48_TRUE));
|
Window win = EXTRACT_WINDOW(Xwindow);
|
||||||
return Void;
|
Display* dpy = EXTRACT_DISPLAY(Xdisplay);
|
||||||
|
|
||||||
|
XClearArea (dpy, win, (int)s48_extract_integer (x),
|
||||||
|
(int)s48_extract_integer (y), (int)s48_extract_integer (w),
|
||||||
|
(int)s48_extract_integer (h),
|
||||||
|
!S48_FALSE_P(e));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Copy_Area (src, gc, sx, sy, w, h, dst, dx, dy) s48_value src, gc,
|
|
||||||
sx, sy, w, h, dst, dx, dy; {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable ddst = Get_Drawable (dst, &dpy), dsrc = Get_Drawable (src, &dpy);
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Copy_Area(s48_value Xdisplay,
|
||||||
XCopyArea (dpy, dsrc, ddst, GCONTEXT(gc)->gc, (int)s48_extract_integer (sx),
|
s48_value srcXdrawable,s48_value Xgcontext,s48_value srcx,
|
||||||
(int)s48_extract_integer (sy), (int)s48_extract_integer (w), (int)s48_extract_integer (h),
|
s48_value srcy, s48_value width, s48_value height,
|
||||||
(int)s48_extract_integer (dx), (int)s48_extract_integer (dy));
|
s48_value destXdrawable, s48_value destx,s48_value desty){
|
||||||
return Void;
|
|
||||||
|
XCopyArea (EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(srcXdrawable),
|
||||||
|
EXTRACT_DRAWABLE(destXdrawable), EXTRACT_GCONTEXT(Xgcontext),
|
||||||
|
(int)s48_extract_integer(srcx), (int)s48_extract_integer(srcy),
|
||||||
|
(int)s48_extract_integer(width), (int)s48_extract_integer(height),
|
||||||
|
(int)s48_extract_integer(destx), (int)s48_extract_integer(desty));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Copy_Plane (src, gc, plane, sx, sy, w, h, dst, dx, dy)
|
/** REPLACED by NF in Copy_Plane:
|
||||||
s48_value src, gc, plane, sx, sy, w, h, dst, dx, dy; {
|
...
|
||||||
Display *dpy;
|
|
||||||
Drawable ddst = Get_Drawable (dst, &dpy), dsrc = Get_Drawable (src, &dpy);
|
|
||||||
register unsigned long p;
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
|
||||||
p = (unsigned long)s48_extract_integer (plane);
|
p = (unsigned long)s48_extract_integer (plane);
|
||||||
if (p & (p-1))
|
if (p & (p-1))
|
||||||
Primitive_Error ("invalid plane: ~s", plane);
|
Primitive_Error ("invalid plane: ~s", plane);
|
||||||
XCopyPlane (dpy, dsrc, ddst, GCONTEXT(gc)->gc, (int)s48_extract_integer (sx),
|
...
|
||||||
(int)s48_extract_integer (sy), (int)s48_extract_integer (w), (int)s48_extract_integer (h),
|
|
||||||
(int)s48_extract_integer (dx), (int)s48_extract_integer (dy), p);
|
*/
|
||||||
return Void;
|
|
||||||
|
s48_value Copy_Plane(s48_value Xdisplay, s48_value srcXdrawable,
|
||||||
|
s48_value Xgcontext, s48_value plane, s48_value srcx,
|
||||||
|
s48_value srcy, s48_value width, s48_value height,
|
||||||
|
s48_value destXdrawable, s48_value destx, s48_value desty){
|
||||||
|
|
||||||
|
// Note: plane must have been set exactly one bit to 1.
|
||||||
|
// For further details, see the man-page.
|
||||||
|
unsigned long p = (unsigned long)s48_extract_integer(plane);
|
||||||
|
XCopyPlane(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(srcXdrawable),
|
||||||
|
EXTRACT_DRAWABLE(destXdrawable), EXTRACT_GCONTEXT(Xgcontext),
|
||||||
|
(int)s48_extract_integer(srcx), (int)s48_extract_integer(srcy),
|
||||||
|
(int)s48_extract_integer(width), (int)s48_extract_integer(height),
|
||||||
|
(int)s48_extract_integer(destx), (int)s48_extract_integer(desty),
|
||||||
|
(unsigned long)s48_extract_integer(plane));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Point (d, gc, x, y) s48_value d, gc, x, y; {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
|
||||||
XDrawPoint (dpy, dr, GCONTEXT(gc)->gc, (int)s48_extract_integer (x), (int)s48_extract_integer (y));
|
s48_value Draw_Point(s48_value Xdisplay, s48_value Xdrawable,
|
||||||
return Void;
|
s48_value Xgcontext, s48_value x, s48_value y){
|
||||||
|
|
||||||
|
XDrawPoint(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x),
|
||||||
|
(int)s48_extract_integer (y));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value Internal_Draw_Points (d, gc, v, relative, func, shape)
|
/* This Function is for internal use only! */
|
||||||
s48_value d, gc, v, relative, shape; int (*func)(); {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
register XPoint *p;
|
|
||||||
register i, n;
|
|
||||||
int rel, sh;
|
|
||||||
Alloca_Begin;
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
void Vector_To_XPoints(s48_value vec, XPoint* p, int n){
|
||||||
Check_Type (relative, T_Boolean);
|
int i;
|
||||||
rel = S48_EQ_P(relative, S48_TRUE) ? CoordModePrevious : CoordModeOrigin;
|
for(i = 0; i < n; i++){
|
||||||
if (func == XFillPolygon)
|
s48_value point = S48_VECTOR_REF(vec, i);
|
||||||
sh = Symbols_To_Bits (shape, 0, Polyshape_Syms);
|
p[i].x = (int)s48_extract_integer (S48_CAR (point));
|
||||||
n = S48_VECTOR_LENGTH(v);
|
p[i].y = (int)s48_extract_integer (S48_CDR (point));
|
||||||
Alloca (p, XPoint*, n * sizeof (XPoint));
|
}
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
s48_value point;
|
|
||||||
|
|
||||||
point = S48_VECTOR_REF(v, i);
|
|
||||||
Check_Type (point, T_Pair);
|
|
||||||
p[i].x = (int)s48_extract_integer (S48_CAR (point));
|
|
||||||
p[i].y = (int)s48_extract_integer (S48_CDR (point));
|
|
||||||
}
|
|
||||||
if (func == XFillPolygon)
|
|
||||||
XFillPolygon (dpy, dr, GCONTEXT(gc)->gc, p, n, sh, rel);
|
|
||||||
else
|
|
||||||
(*func)(dpy, dr, GCONTEXT(gc)->gc, p, n, rel);
|
|
||||||
Alloca_End;
|
|
||||||
return Void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Points (d, gc, v, relative) s48_value d, gc, v, relative; {
|
|
||||||
return Internal_Draw_Points (d, gc, v, relative, XDrawPoints, S48_NULL);
|
s48_value Draw_Points (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
|
s48_value Xgcontext, s48_value vec, s48_value relative){
|
||||||
|
|
||||||
|
// First, create a new XPoint from the vector of pairs...
|
||||||
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
|
XPoint p[n];
|
||||||
|
int mode;
|
||||||
|
Vector_To_XPoints(vec, p, n);
|
||||||
|
mode = !S48_EQ_P(relative, S48_FALSE) ? CoordModePrevious : CoordModeOrigin;
|
||||||
|
XDrawPoints(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n, mode);
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Line (d, gc, x1, y1, x2, y2)
|
|
||||||
s48_value d, gc, x1, y1, x2, y2; {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Draw_Line (s48_value Xdisplay,s48_value Xdrawable,
|
||||||
XDrawLine (dpy, dr, GCONTEXT(gc)->gc, (int)s48_extract_integer (x1), (int)s48_extract_integer (y1),
|
s48_value Xgcontext, s48_value x1, s48_value y1,
|
||||||
(int)s48_extract_integer (x2), (int)s48_extract_integer (y2));
|
s48_value x2, s48_value y2){
|
||||||
return Void;
|
|
||||||
|
XDrawLine (EXTRACT_DISPLAY(Xdisplay),EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x1),
|
||||||
|
(int)s48_extract_integer (y1), (int)s48_extract_integer (x2),
|
||||||
|
(int)s48_extract_integer (y2));
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Lines (d, gc, v, relative) s48_value d, gc, v, relative; {
|
|
||||||
return Internal_Draw_Points (d, gc, v, relative, XDrawLines, S48_NULL);
|
s48_value Draw_Lines(s48_value Xdisplay, s48_value Xdrawalbe,
|
||||||
|
s48_value Xgcontext, s48_value vec, s48_value relative){
|
||||||
|
int n = S48_VECTOR_LENGHT(vec);
|
||||||
|
XPoint p[n];
|
||||||
|
int mode;
|
||||||
|
Vector_To_Points(vec, p, n);
|
||||||
|
mode = !S48_EQ_P(relative, S48_FALSE) ? CoordModePrevious : CoordModeOrigin;
|
||||||
|
XDrawLines(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawalbe),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n, mode);
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Segments (d, gc, v) s48_value d, gc, v; {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
register XSegment *p;
|
|
||||||
register i, n;
|
|
||||||
Alloca_Begin;
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Draw_Segments (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
n = S48_VECTOR_LENGTH(v);
|
s48_value Xgcontext, s48_value vec){
|
||||||
Alloca (p, XSegment*, n * sizeof (XSegment));
|
int i;
|
||||||
for (i = 0; i < n; i++) {
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
s48_value seg;
|
XSegment p[n];
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
s48_value seg = S48_VECTOR_REF(vec, i);
|
||||||
|
p[i].x1 = (int)s48_extract_integer (S48_CAR (seg)); seg = S48_CDR (seg);
|
||||||
|
p[i].y1 = (int)s48_extract_integer (S48_CAR (seg)); seg = S48_CDR (seg);
|
||||||
|
p[i].x2 = (int)s48_extract_integer (S48_CAR (seg)); seg = S48_CDR (seg);
|
||||||
|
p[i].y2 = (int)s48_extract_integer (S48_CAR (seg));
|
||||||
|
}
|
||||||
|
XDrawSegments (EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n);
|
||||||
|
|
||||||
seg = S48_VECTOR_REF(v, i);
|
return S48_UNSPECIFIC;
|
||||||
Check_Type (seg, T_Pair);
|
|
||||||
if (Fast_Length (seg) != 4)
|
|
||||||
Primitive_Error ("invalid segment: ~s", seg);
|
|
||||||
p[i].x1 = (int)s48_extract_integer (S48_CAR (seg)); seg = S48_CDR (seg);
|
|
||||||
p[i].y1 = (int)s48_extract_integer (S48_CAR (seg)); seg = S48_CDR (seg);
|
|
||||||
p[i].x2 = (int)s48_extract_integer (S48_CAR (seg)); seg = S48_CDR (seg);
|
|
||||||
p[i].y2 = (int)s48_extract_integer (S48_CAR (seg));
|
|
||||||
}
|
|
||||||
XDrawSegments (dpy, dr, GCONTEXT(gc)->gc, p, n);
|
|
||||||
Alloca_End;
|
|
||||||
return Void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value Internal_Draw_Rectangle (d, gc, x, y, w, h, func)
|
|
||||||
s48_value d, gc, x, y, w, h; int (*func)(); {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Draw_Rectangle(s48_value Xdisplay, s48_value Xdrawable,
|
||||||
(*func)(dpy, dr, GCONTEXT(gc)->gc, (int)s48_extract_integer (x),
|
s48_value Xgcontext, s48_value x, s48_value y,
|
||||||
(int)s48_extract_integer (y), (int)s48_extract_integer (w), (int)s48_extract_integer (h));
|
s48_value w, s48_value h){
|
||||||
return Void;
|
XDrawRectangle (EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x),
|
||||||
|
(int)s48_extract_integer(y), (int)s48_extract_integer(w),
|
||||||
|
(int)s48_extract_integer(h));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Rectangle (d, gc, x, y, w, h) s48_value d, gc, x, y, w, h; {
|
|
||||||
return Internal_Draw_Rectangle (d, gc, x, y, w, h, XDrawRectangle);
|
s48_value Fill_Rectangle (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
|
s48_value Xgcontext, s48_value x, s48_value y,
|
||||||
|
s48_value w, s48_value h){
|
||||||
|
XFillRectangle(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x),
|
||||||
|
(int)s48_extract_integer(y), (int)s48_extract_integer(w),
|
||||||
|
(int)s48_extract_integer(h));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Fill_Rectangle (d, gc, x, y, w, h) s48_value d, gc, x, y, w, h; {
|
|
||||||
return Internal_Draw_Rectangle (d, gc, x, y, w, h, XFillRectangle);
|
//This Function is for internal use only!
|
||||||
|
|
||||||
|
void Vector_To_XRectangle(s48_value vec, XRectangle* p, int n){
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < n; i++){
|
||||||
|
s48_value rect;
|
||||||
|
rect = S48_VECTOR_REF(vec, i);
|
||||||
|
p[i].x = (int)s48_extract_integer (S48_CAR (rect)); rect = S48_CDR (rect);
|
||||||
|
p[i].y = (int)s48_extract_integer (S48_CAR (rect)); rect = S48_CDR (rect);
|
||||||
|
p[i].width = (int)s48_extract_integer (S48_CAR (rect));
|
||||||
|
rect = S48_CDR (rect);
|
||||||
|
p[i].height = (int)s48_extract_integer (S48_CAR (rect));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value Internal_Draw_Rectangles (d, gc, v, func)
|
|
||||||
s48_value d, gc, v; int (*func)(); {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
register XRectangle *p;
|
|
||||||
register i, n;
|
|
||||||
Alloca_Begin;
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Draw_Rectangles (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
n = S48_VECTOR_LENGTH(v);
|
s48_value Xgcontext, s48_value vec){
|
||||||
Alloca (p, XRectangle*, n * sizeof (XRectangle));
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
for (i = 0; i < n; i++) {
|
XRectangle p[n];
|
||||||
s48_value rect;
|
Vector_To_XRectangle(vec, p, n);
|
||||||
|
XDrawRectangles(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n);
|
||||||
|
|
||||||
rect = S48_VECTOR_REF(v, i);
|
return S48_UNSPECIFIC;
|
||||||
Check_Type (rect, T_Pair);
|
|
||||||
if (Fast_Length (rect) != 4)
|
|
||||||
Primitive_Error ("invalid rectangle: ~s", rect);
|
|
||||||
p[i].x = (int)s48_extract_integer (S48_CAR (rect)); rect = S48_CDR (rect);
|
|
||||||
p[i].y = (int)s48_extract_integer (S48_CAR (rect)); rect = S48_CDR (rect);
|
|
||||||
p[i].width = (int)s48_extract_integer (S48_CAR (rect)); rect = S48_CDR (rect);
|
|
||||||
p[i].height = (int)s48_extract_integer (S48_CAR (rect));
|
|
||||||
}
|
|
||||||
(*func)(dpy, dr, GCONTEXT(gc)->gc, p, n);
|
|
||||||
Alloca_End;
|
|
||||||
return Void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Rectangles (d, gc, v) s48_value d, gc, v; {
|
|
||||||
return Internal_Draw_Rectangles (d, gc, v, XDrawRectangles);
|
s48_value Fill_Rectangles (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
|
s48_value Xgcontext, s48_value vec){
|
||||||
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
|
XRectangle p[n];
|
||||||
|
Vector_To_Rectangle(vec, p, n);
|
||||||
|
XFillRectangles(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n);
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Fill_Rectangles (d, gc, v) s48_value d, gc, v; {
|
|
||||||
return Internal_Draw_Rectangles (d, gc, v, XFillRectangles);
|
s48_value Draw_Arc (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
|
s48_value Xgcontext, s48_value x,s48_value y, s48_value w,
|
||||||
|
s48_value h, s48_value a1, s48_value a2){
|
||||||
|
XDrawArc(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x),
|
||||||
|
(int)s48_extract_integer(y), (int)s48_extract_integer(w),
|
||||||
|
(int)s48_extract_integer(h), (int)s48_extract_integer(a1),
|
||||||
|
(int)s48_extract_integer(a2));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value Internal_Draw_Arc (d, gc, x, y, w, h, a1, a2, func)
|
|
||||||
s48_value d, gc, x, y, w, h, a1, a2; int (*func)(); {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Fill_Arc (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
(*func)(dpy, dr, GCONTEXT(gc)->gc, (int)s48_extract_integer (x), (int)s48_extract_integer (y),
|
s48_value Xgcontext, s48_value x,s48_value y, s48_value w,
|
||||||
(int)s48_extract_integer (w), (int)s48_extract_integer (h), (int)s48_extract_integer (a1), (int)s48_extract_integer (a2));
|
s48_value h, s48_value a1, s48_value a2){
|
||||||
return Void;
|
XFillArc(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x),
|
||||||
|
(int)s48_extract_integer(y), (int)s48_extract_integer(w),
|
||||||
|
(int)s48_extract_integer(h), (int)s48_extract_integer(a1),
|
||||||
|
(int)s48_extract_integer(a2));
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Arc (d, gc, x, y, w, h, a1, a2)
|
//This Function is for internal use only!
|
||||||
s48_value d, gc, x, y, w, h, a1, a2; {
|
|
||||||
return Internal_Draw_Arc (d, gc, x, y, w, h, a1, a2, XDrawArc);
|
void Vector_To_XArc(s48_value vec, XArc* p, int n){
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < n; i++){
|
||||||
|
s48_value arc;
|
||||||
|
arc = S48_VECTOR_REF(vec, i);
|
||||||
|
p[i].x = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
||||||
|
p[i].y = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
||||||
|
p[i].width = (int)s48_extract_integer (S48_CAR (arc));
|
||||||
|
arc = S48_CDR (arc);
|
||||||
|
p[i].height = (int)s48_extract_integer (S48_CAR (arc));
|
||||||
|
arc = S48_CDR (arc);
|
||||||
|
p[i].angle1 = (int)s48_extract_integer (S48_CAR (arc));
|
||||||
|
arc = S48_CDR (arc);
|
||||||
|
p[i].angle2 = (int)s48_extract_integer (S48_CAR (arc));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Fill_Arc (d, gc, x, y, w, h, a1, a2)
|
|
||||||
s48_value d, gc, x, y, w, h, a1, a2; {
|
s48_value Draw_Arcs (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
return Internal_Draw_Arc (d, gc, x, y, w, h, a1, a2, XFillArc);
|
s48_value Xgcontext, s48_value vec){
|
||||||
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
|
XArc p[n];
|
||||||
|
Vector_To_XArc(vec, p, n);
|
||||||
|
XDrawArcs(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n);
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value Internal_Draw_Arcs (d, gc, v, func) s48_value d, gc, v;
|
|
||||||
int (*func)(); {
|
|
||||||
Display *dpy;
|
|
||||||
Drawable dr = Get_Drawable (d, &dpy);
|
|
||||||
register XArc *p;
|
|
||||||
register i, n;
|
|
||||||
Alloca_Begin;
|
|
||||||
|
|
||||||
Check_Type (gc, T_Gc);
|
s48_value Fill_Arcs (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
n = S48_VECTOR_LENGTH(v);
|
s48_value Xgcontext, s48_value vec){
|
||||||
Alloca (p, XArc*, n * sizeof (XArc));
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
for (i = 0; i < n; i++) {
|
XArc p[n];
|
||||||
s48_value arc;
|
Vector_To_XArc(vec, p, n);
|
||||||
|
XFillArcs(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n);
|
||||||
|
|
||||||
arc = S48_VECTOR_REF(v, i);
|
return S48_UNSPECIFIC;
|
||||||
Check_Type (arc, T_Pair);
|
|
||||||
if (Fast_Length (arc) != 6)
|
|
||||||
Primitive_Error ("invalid arc: ~s", arc);
|
|
||||||
p[i].x = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
|
||||||
p[i].y = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
|
||||||
p[i].width = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
|
||||||
p[i].height = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
|
||||||
p[i].angle1 = (int)s48_extract_integer (S48_CAR (arc)); arc = S48_CDR (arc);
|
|
||||||
p[i].angle2 = (int)s48_extract_integer (S48_CAR (arc));
|
|
||||||
}
|
|
||||||
(*func)(dpy, dr, GCONTEXT(gc)->gc, p, n);
|
|
||||||
Alloca_End;
|
|
||||||
return Void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Draw_Arcs (d, gc, v) s48_value d, gc, v; {
|
|
||||||
return Internal_Draw_Arcs (d, gc, v, XDrawArcs);
|
s48_value Fill_Polygon (s48_value Xdisplay, s48_value Xdrawable,
|
||||||
|
s48_value Xgcontext, s48_value vec,
|
||||||
|
s48_value relative, s48_value shape){
|
||||||
|
int n = S48_VECTOR_LENGTH(vec);
|
||||||
|
int mode;
|
||||||
|
int sh = (int)Symbol_To_Bit(shape, Polyshape_Syms);
|
||||||
|
XPoint p[n];
|
||||||
|
Vector_To_XPoints(vec, p, n);
|
||||||
|
mode = !S48_EQ_P(relative, S48_FALSE) ? CoordModePrevious : CoordModeOrigin;
|
||||||
|
XFillPolygon(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable),
|
||||||
|
EXTRACT_GCONTEXT(Xgcontext), p, n, sh, mode);
|
||||||
|
|
||||||
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static s48_value P_Fill_Arcs (d, gc, v) s48_value d, gc, v; {
|
|
||||||
return Internal_Draw_Arcs (d, gc, v, XFillArcs);
|
|
||||||
}
|
|
||||||
|
|
||||||
static s48_value P_Fill_Polygon (d, gc, v, relative, shape)
|
void s48_init_graphics(void) {
|
||||||
s48_value d, gc, v, relative, shape; {
|
S48_EXPORT_FUNCTION(Clear_Area);
|
||||||
return Internal_Draw_Points (d, gc, v, relative, XFillPolygon, shape);
|
S48_EXPORT_FUNCTION(Copy_Area);
|
||||||
}
|
S48_EXPORT_FUNCTION(Copy_Plane);
|
||||||
|
S48_EXPORT_FUNCTION(Draw_Point);
|
||||||
elk_init_xlib_graphics () {
|
S48_EXPORT_FUNCTION(Draw_Points);
|
||||||
Define_Primitive (P_Clear_Area, "clear-area", 6, 6, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Line);
|
||||||
Define_Primitive (P_Copy_Area, "copy-area", 9, 9, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Lines);
|
||||||
Define_Primitive (P_Copy_Plane, "copy-plane", 10,10, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Segments);
|
||||||
Define_Primitive (P_Draw_Point, "draw-point", 4, 4, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Rectangle);
|
||||||
Define_Primitive (P_Draw_Points, "draw-points", 4, 4, EVAL);
|
S48_EXPORT_FUNCTION(Fill_Rectangle);
|
||||||
Define_Primitive (P_Draw_Line, "draw-line", 6, 6, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Rectangles);
|
||||||
Define_Primitive (P_Draw_Lines, "draw-lines", 4, 4, EVAL);
|
S48_EXPORT_FUNCTION(Fill_Rectangles);
|
||||||
Define_Primitive (P_Draw_Segments, "draw-segments", 3, 3, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Arc);
|
||||||
Define_Primitive (P_Draw_Rectangle, "draw-rectangle", 6, 6, EVAL);
|
S48_EXPORT_FUNCTION(Fill_Arc);
|
||||||
Define_Primitive (P_Fill_Rectangle, "fill-rectangle", 6, 6, EVAL);
|
S48_EXPORT_FUNCTION(Draw_Arcs);
|
||||||
Define_Primitive (P_Draw_Rectangles, "draw-rectangles", 3, 3, EVAL);
|
S48_EXPORT_FUNCTION(Fill_Arcs);
|
||||||
Define_Primitive (P_Fill_Rectangles, "fill-rectangles", 3, 3, EVAL);
|
S48_EXPORT_FUNCTION(Fill_Polygon);
|
||||||
Define_Primitive (P_Draw_Arc, "draw-arc", 8, 8, EVAL);
|
|
||||||
Define_Primitive (P_Fill_Arc, "fill-arc", 8, 8, EVAL);
|
|
||||||
Define_Primitive (P_Draw_Arcs, "draw-arcs", 3, 3, EVAL);
|
|
||||||
Define_Primitive (P_Fill_Arcs, "fill-arcs", 3, 3, EVAL);
|
|
||||||
Define_Primitive (P_Fill_Polygon, "fill-polygon", 5, 5, EVAL);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue