320 lines
11 KiB
C
320 lines
11 KiB
C
#include "xlib.h"
|
|
#include "scheme48.h"
|
|
|
|
/*
|
|
extern XDrawPoints(), XDrawLines(), XDrawRectangle(), XFillRectangle();
|
|
extern XDrawRectangles(), XFillRectangles(), XDrawArc(), XFillArc();
|
|
extern XDrawArcs(), XFillArcs(), XFillPolygon();
|
|
*/
|
|
|
|
|
|
s48_value scx_Clear_Area(s48_value Xwindow, s48_value Xdisplay, s48_value x,
|
|
s48_value y, s48_value w, s48_value h, s48_value e){
|
|
Window win = SCX_EXTRACT_WINDOW(Xwindow);
|
|
Display* dpy = SCX_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;
|
|
}
|
|
|
|
|
|
s48_value scx_Copy_Area(s48_value Xdisplay,
|
|
s48_value srcXdrawable,s48_value Xgcontext,s48_value srcx,
|
|
s48_value srcy, s48_value width, s48_value height,
|
|
s48_value destXdrawable, s48_value destx,s48_value desty){
|
|
|
|
XCopyArea (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(srcXdrawable),
|
|
SCX_EXTRACT_DRAWABLE(destXdrawable), SCX_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;
|
|
}
|
|
|
|
/** REPLACED by NF in Copy_Plane:
|
|
...
|
|
p = (unsigned long)s48_extract_integer (plane);
|
|
if (p & (p-1))
|
|
Primitive_Error ("invalid plane: ~s", plane);
|
|
...
|
|
|
|
*/
|
|
|
|
s48_value scx_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(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(srcXdrawable),
|
|
SCX_EXTRACT_DRAWABLE(destXdrawable), SCX_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;
|
|
}
|
|
|
|
|
|
|
|
s48_value scx_Draw_Point(s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value x, s48_value y){
|
|
|
|
XDrawPoint(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), (int)s48_extract_integer(x),
|
|
(int)s48_extract_integer (y));
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
/* This Function is for internal use only! */
|
|
|
|
void Vector_To_XPoints(s48_value vec, XPoint* p, int n){
|
|
int i;
|
|
for(i = 0; i < n; i++){
|
|
s48_value point = S48_VECTOR_REF(vec, i);
|
|
p[i].x = (int)s48_extract_integer (S48_CAR (point));
|
|
p[i].y = (int)s48_extract_integer (S48_CDR (point));
|
|
}
|
|
}
|
|
|
|
|
|
s48_value scx_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_FALSE_P(relative) ? CoordModePrevious : CoordModeOrigin;
|
|
XDrawPoints(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n, mode);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_Draw_Line (s48_value Xdisplay,s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value x1, s48_value y1,
|
|
s48_value x2, s48_value y2){
|
|
|
|
XDrawLine (SCX_EXTRACT_DISPLAY(Xdisplay),SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_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;
|
|
}
|
|
|
|
|
|
s48_value scx_Draw_Lines(s48_value Xdisplay, s48_value Xdrawalbe,
|
|
s48_value Xgcontext, s48_value vec, s48_value relative){
|
|
int n = S48_VECTOR_LENGTH(vec);
|
|
XPoint p[n];
|
|
int mode;
|
|
Vector_To_XPoints(vec, p, n);
|
|
mode = !S48_FALSE_P(relative) ? CoordModePrevious : CoordModeOrigin;
|
|
XDrawLines(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawalbe),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n, mode);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_Draw_Segments (s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value vec){
|
|
int i;
|
|
int n = S48_VECTOR_LENGTH(vec);
|
|
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_VECTOR_REF(seg, 0));
|
|
p[i].y1 = (int)s48_extract_integer (S48_VECTOR_REF(seg, 1));
|
|
p[i].x2 = (int)s48_extract_integer (S48_VECTOR_REF(seg, 2));
|
|
p[i].y2 = (int)s48_extract_integer (S48_VECTOR_REF(seg, 3));
|
|
}
|
|
XDrawSegments (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_Draw_Rectangle(s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value rect) {
|
|
|
|
XDrawRectangle (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 0)),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 1)),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 2)),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 3)));
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_Fill_Rectangle (s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value rect) {
|
|
XFillRectangle(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 0)),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 1)),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 2)),
|
|
(int)s48_extract_integer(S48_VECTOR_REF(rect, 3)));
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
//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_VECTOR_REF(rect, 0));
|
|
p[i].y = (int)s48_extract_integer(S48_VECTOR_REF(rect, 1));
|
|
p[i].width = (int)s48_extract_integer(S48_VECTOR_REF(rect, 2));
|
|
p[i].height = (int)s48_extract_integer(S48_VECTOR_REF(rect, 3));
|
|
}
|
|
}
|
|
|
|
s48_value scx_Draw_Rectangles (s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value vec){
|
|
int n = S48_VECTOR_LENGTH(vec);
|
|
XRectangle p[n];
|
|
Vector_To_XRectangle(vec, p, n);
|
|
XDrawRectangles(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_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_XRectangle(vec, p, n);
|
|
XFillRectangles(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_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(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_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;
|
|
}
|
|
|
|
|
|
s48_value scx_Fill_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){
|
|
XFillArc(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_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;
|
|
}
|
|
|
|
//This Function is for internal use only!
|
|
|
|
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));
|
|
}
|
|
}
|
|
|
|
|
|
s48_value scx_Draw_Arcs (s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value vec){
|
|
int n = S48_VECTOR_LENGTH(vec);
|
|
XArc p[n];
|
|
Vector_To_XArc(vec, p, n);
|
|
XDrawArcs(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_Fill_Arcs (s48_value Xdisplay, s48_value Xdrawable,
|
|
s48_value Xgcontext, s48_value vec){
|
|
int n = S48_VECTOR_LENGTH(vec);
|
|
XArc p[n];
|
|
Vector_To_XArc(vec, p, n);
|
|
XFillArcs(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
s48_value scx_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 = s48_extract_integer(shape);
|
|
XPoint p[n];
|
|
Vector_To_XPoints(vec, p, n);
|
|
mode = !S48_FALSE_P(relative) ? CoordModePrevious : CoordModeOrigin;
|
|
XFillPolygon(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable),
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext), p, n, sh, mode);
|
|
|
|
return S48_UNSPECIFIC;
|
|
}
|
|
|
|
|
|
void scx_init_graphics(void) {
|
|
S48_EXPORT_FUNCTION(scx_Clear_Area);
|
|
S48_EXPORT_FUNCTION(scx_Copy_Area);
|
|
S48_EXPORT_FUNCTION(scx_Copy_Plane);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Point);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Points);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Line);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Lines);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Segments);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Rectangle);
|
|
S48_EXPORT_FUNCTION(scx_Fill_Rectangle);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Rectangles);
|
|
S48_EXPORT_FUNCTION(scx_Fill_Rectangles);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Arc);
|
|
S48_EXPORT_FUNCTION(scx_Fill_Arc);
|
|
S48_EXPORT_FUNCTION(scx_Draw_Arcs);
|
|
S48_EXPORT_FUNCTION(scx_Fill_Arcs);
|
|
S48_EXPORT_FUNCTION(scx_Fill_Polygon);
|
|
}
|