2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
2001-06-27 09:44:48 -04:00
|
|
|
#include "scheme48.h"
|
|
|
|
|
|
|
|
unsigned long AList_To_GCValues(s48_value alist, XGCValues* GCV) {
|
2001-07-19 11:33:50 -04:00
|
|
|
unsigned long mask = 0;
|
2001-07-30 10:15:34 -04:00
|
|
|
s48_value l, p;
|
2001-06-27 09:44:48 -04:00
|
|
|
char* cname;
|
|
|
|
s48_value name, value;
|
|
|
|
|
|
|
|
for (l = alist; !S48_NULL_P(l); l = S48_CDR(l)) {
|
2001-07-30 10:15:34 -04:00
|
|
|
p = S48_CAR(l);
|
|
|
|
name = S48_CAR(p);
|
|
|
|
value = S48_CDR(p);
|
2001-06-27 09:44:48 -04:00
|
|
|
cname = s48_extract_string(S48_SYMBOL_TO_STRING(name));
|
|
|
|
|
2001-07-16 07:52:01 -04:00
|
|
|
if (strcmp(cname, "function") == 0) {
|
2001-07-30 10:15:34 -04:00
|
|
|
GCV->function = Symbol_To_Bit(value, Func_Syms);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCFunction;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "plane-mask") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->plane_mask = SCX_EXTRACT_PIXEL(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCPlaneMask;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "foreground") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->foreground = SCX_EXTRACT_PIXEL(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCForeground;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "background") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->background = SCX_EXTRACT_PIXEL(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCBackground;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "line-width") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->line_width = s48_extract_integer(value);
|
|
|
|
mask |= GCLineWidth;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "line-style") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->line_style = Symbol_To_Bit(value,Line_Style_Syms);
|
|
|
|
mask |= GCLineStyle;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "cap-style") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->cap_style = Symbol_To_Bit(value, Cap_Style_Syms);
|
|
|
|
mask |= GCCapStyle;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "join-style") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->join_style = Symbol_To_Bit(value, Join_Style_Syms);
|
|
|
|
mask |= GCJoinStyle;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "fill-style") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->fill_style = Symbol_To_Bit(value, Fill_Style_Syms);
|
|
|
|
mask |= GCFillStyle;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "fill-rule") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->fill_rule = Symbol_To_Bit(value, Fill_Rule_Syms);
|
|
|
|
mask |= GCFillRule;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "arc-mode") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->arc_mode = Symbol_To_Bit(value, Arc_Mode_Syms);
|
|
|
|
mask |= GCArcMode;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "tile") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->tile = SCX_EXTRACT_PIXMAP(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCTile;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "stipple") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->stipple = SCX_EXTRACT_PIXMAP(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCStipple;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "ts-x") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->ts_x_origin = s48_extract_integer(value);
|
|
|
|
mask |= GCTileStipXOrigin;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "ts-y") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->ts_y_origin = s48_extract_integer(value);
|
|
|
|
mask |= GCTileStipYOrigin;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "font") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->font = SCX_EXTRACT_FONT(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCFont;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "subwindow-mode") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->subwindow_mode = Symbol_To_Bit(value, Subwin_Mode_Syms);
|
|
|
|
mask |= GCSubwindowMode;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "exposures") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->graphics_exposures = !S48_FALSE_P(value);
|
|
|
|
mask |= GCGraphicsExposures;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "clip-x") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->clip_x_origin = s48_extract_integer(value);
|
|
|
|
mask |= GCClipXOrigin;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "clip-y") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->clip_y_origin = s48_extract_integer(value);
|
|
|
|
mask |= GCClipYOrigin;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "clip-mask") == 0) {
|
2001-07-31 10:51:21 -04:00
|
|
|
GCV->clip_mask = SCX_EXTRACT_PIXMAP(value);
|
2001-06-27 09:44:48 -04:00
|
|
|
mask |= GCClipMask;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "dash-offset") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->dash_offset = s48_extract_integer(value);
|
|
|
|
mask |= GCDashOffset;
|
2001-07-16 07:52:01 -04:00
|
|
|
} else if (strcmp(cname, "dashes") == 0) {
|
2001-06-27 09:44:48 -04:00
|
|
|
GCV->dashes = (char)s48_extract_integer(value);
|
|
|
|
mask |= GCDashList;
|
|
|
|
}
|
|
|
|
// else error ??
|
|
|
|
} // for
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-06-27 09:44:48 -04:00
|
|
|
return mask;
|
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Create_Gc(s48_value Xdisplay, s48_value Xdrawable, s48_value args) {
|
2001-06-27 09:44:48 -04:00
|
|
|
XGCValues GCV;
|
|
|
|
unsigned long mask = AList_To_GCValues(args, &GCV);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
GC Xgcontext = XCreateGC(SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_DRAWABLE(Xdrawable),
|
2001-06-27 09:44:48 -04:00
|
|
|
mask, &GCV);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
return SCX_ENTER_GCONTEXT(Xgcontext);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Copy_Gc(s48_value Xdisplay, s48_value Xsource, s48_value Xdest) {
|
|
|
|
XCopyGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_GCONTEXT(Xsource),
|
|
|
|
~0L, SCX_EXTRACT_GCONTEXT(Xdest));
|
2001-06-27 09:44:48 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Free_Gc(s48_value Xgcontext, s48_value Xdisplay) {
|
|
|
|
XFreeGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_GCONTEXT(Xgcontext));
|
2001-06-27 09:44:48 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-06-27 09:44:48 -04:00
|
|
|
#define ValidGCValuesBits \
|
|
|
|
(GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth |\
|
|
|
|
GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule |\
|
|
|
|
GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont |\
|
|
|
|
GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin |\
|
|
|
|
GCDashOffset | GCArcMode)
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Get_Gc_Values (s48_value Xgcontext, s48_value Xdisplay) {
|
2001-06-27 09:44:48 -04:00
|
|
|
unsigned long mask = ValidGCValuesBits;
|
|
|
|
|
|
|
|
XGCValues GCV;
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value res = S48_FALSE;
|
2001-06-27 09:44:48 -04:00
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
if (!XGetGCValues (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext),
|
2001-06-27 09:44:48 -04:00
|
|
|
mask, &GCV))
|
|
|
|
res = S48_FALSE;
|
|
|
|
else {
|
|
|
|
res = s48_make_vector(23, S48_FALSE);
|
|
|
|
S48_GC_PROTECT_1(res);
|
|
|
|
|
2001-07-30 10:15:34 -04:00
|
|
|
S48_VECTOR_SET(res, 0, Bit_To_Symbol(GCV.function, Func_Syms));
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_VECTOR_SET(res, 1, SCX_ENTER_PIXEL(GCV.plane_mask));
|
|
|
|
S48_VECTOR_SET(res, 2, SCX_ENTER_PIXEL(GCV.foreground));
|
|
|
|
S48_VECTOR_SET(res, 3, SCX_ENTER_PIXEL(GCV.background));
|
2001-06-27 09:44:48 -04:00
|
|
|
S48_VECTOR_SET(res, 4, s48_enter_integer(GCV.line_width));
|
|
|
|
S48_VECTOR_SET(res, 5, Bit_To_Symbol(GCV.line_style, Line_Style_Syms));
|
|
|
|
S48_VECTOR_SET(res, 6, Bit_To_Symbol(GCV.cap_style, Cap_Style_Syms));
|
|
|
|
S48_VECTOR_SET(res, 7, Bit_To_Symbol(GCV.join_style, Join_Style_Syms));
|
|
|
|
S48_VECTOR_SET(res, 8, Bit_To_Symbol(GCV.fill_style, Fill_Style_Syms));
|
|
|
|
S48_VECTOR_SET(res, 9, Bit_To_Symbol(GCV.fill_rule, Fill_Rule_Syms));
|
|
|
|
S48_VECTOR_SET(res, 10, Bit_To_Symbol(GCV.arc_mode, Arc_Mode_Syms));
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_VECTOR_SET(res, 11, SCX_ENTER_PIXMAP(GCV.tile));
|
|
|
|
S48_VECTOR_SET(res, 12, SCX_ENTER_PIXMAP(GCV.stipple));
|
2001-06-27 09:44:48 -04:00
|
|
|
S48_VECTOR_SET(res, 13, s48_enter_integer(GCV.ts_x_origin));
|
|
|
|
S48_VECTOR_SET(res, 14, s48_enter_integer(GCV.ts_y_origin));
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_VECTOR_SET(res, 15, SCX_ENTER_FONT(GCV.font));
|
2001-06-27 09:44:48 -04:00
|
|
|
S48_VECTOR_SET(res, 16, Bit_To_Symbol(GCV.subwindow_mode,
|
|
|
|
Subwin_Mode_Syms));
|
|
|
|
S48_VECTOR_SET(res, 17, GCV.graphics_exposures ? S48_TRUE : S48_FALSE);
|
|
|
|
S48_VECTOR_SET(res, 18, s48_enter_integer(GCV.clip_x_origin));
|
|
|
|
S48_VECTOR_SET(res, 19, s48_enter_integer(GCV.clip_y_origin));
|
2001-07-31 10:51:21 -04:00
|
|
|
S48_VECTOR_SET(res, 20, SCX_ENTER_PIXMAP(GCV.clip_mask));
|
2001-06-27 09:44:48 -04:00
|
|
|
S48_VECTOR_SET(res, 21, s48_enter_integer(GCV.dash_offset));
|
|
|
|
S48_VECTOR_SET(res, 22, s48_enter_integer(GCV.dashes));
|
|
|
|
}
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
return res;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Change_Gc (s48_value Xgcontext, s48_value Xdisplay, s48_value args) {
|
2001-06-27 09:44:48 -04:00
|
|
|
XGCValues GCV;
|
|
|
|
unsigned long mask = AList_To_GCValues(args, &GCV);
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
XChangeGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_GCONTEXT(Xgcontext),
|
2001-06-27 09:44:48 -04:00
|
|
|
mask, &GCV);
|
|
|
|
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Set_Gcontext_Dashlist(s48_value Xgcontext, s48_value Xdisplay,
|
2001-06-27 09:44:48 -04:00
|
|
|
s48_value dashoffset, s48_value dashlist) {
|
|
|
|
int n = S48_VECTOR_LENGTH(dashlist);
|
|
|
|
char v[n];
|
|
|
|
int i;
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
v[i] = (char)s48_extract_integer(S48_VECTOR_REF(dashlist, i));
|
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
XSetDashes( SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_GCONTEXT(Xgcontext),
|
2001-06-27 09:44:48 -04:00
|
|
|
s48_extract_integer(dashoffset), v, n);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-06-27 09:44:48 -04:00
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Set_Gcontext_Clip_Rectangles (s48_value Xgcontext,
|
2001-06-27 09:44:48 -04:00
|
|
|
s48_value Xdisplay, s48_value x,
|
|
|
|
s48_value y, s48_value v,
|
|
|
|
s48_value ord) {
|
|
|
|
int n = S48_VECTOR_LENGTH(v);
|
|
|
|
|
|
|
|
XRectangle p[n];
|
|
|
|
|
|
|
|
int i;
|
|
|
|
s48_value rect;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
rect = S48_VECTOR_REF(v, 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));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
XSetClipRectangles (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_GCONTEXT(Xgcontext),
|
2001-06-27 09:44:48 -04:00
|
|
|
(int)s48_extract_integer (x),
|
|
|
|
(int)s48_extract_integer (y), p, n,
|
|
|
|
Symbol_To_Bit(ord, Ordering_Syms));
|
|
|
|
|
|
|
|
return S48_UNSPECIFIC;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Query_Best_Size (s48_value Xdisplay, s48_value width,
|
2001-06-27 09:44:48 -04:00
|
|
|
s48_value height, s48_value shape) {
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-06-27 09:44:48 -04:00
|
|
|
unsigned int rw, rh;
|
2001-07-31 10:51:21 -04:00
|
|
|
Display* dpy = SCX_EXTRACT_DISPLAY(Xdisplay);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-06-27 09:44:48 -04:00
|
|
|
if (!XQueryBestSize (dpy,
|
|
|
|
Symbol_To_Bit (shape, Shape_Syms),
|
|
|
|
DefaultRootWindow (dpy), //??
|
|
|
|
(int)s48_extract_integer (width),
|
|
|
|
(int)s48_extract_integer (height),
|
|
|
|
&rw, &rh))
|
|
|
|
return S48_FALSE;
|
|
|
|
else
|
|
|
|
return s48_cons (s48_enter_integer (rw), s48_enter_integer (rh));
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
2001-06-27 09:44:48 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
void scx_init_gcontext(void) {
|
|
|
|
S48_EXPORT_FUNCTION(scx_Create_Gc);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Free_Gc);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Copy_Gc);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Get_Gc_Values);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Change_Gc);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Set_Gcontext_Dashlist);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Set_Gcontext_Clip_Rectangles);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Query_Best_Size);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|