#include "xlib.h" #include "scheme48.h" unsigned long AList_To_GCValues(s48_value alist, XGCValues* GCV) { unsigned long mask = 0; s48_value l; char* cname; s48_value name, value; for (l = alist; !S48_NULL_P(l); l = S48_CDR(l)) { name = S48_CAR(l); value = S48_CDR(l); cname = s48_extract_string(S48_SYMBOL_TO_STRING(name)); if (strcmp(cname, "function") == 0) { GCV->function = Symbols_To_Bits(value, 0, Func_Syms); mask |= GCFunction; } else if (strcmp(cname, "plane-mask") == 0) { GCV->plane_mask = EXTRACT_PIXEL(value); mask |= GCPlaneMask; } else if (strcmp(cname, "foreground") == 0) { GCV->foreground = EXTRACT_PIXEL(value); mask |= GCForeground; } else if (strcmp(cname, "background") == 0) { GCV->background = EXTRACT_PIXEL(value); mask |= GCBackground; } else if (strcmp(cname, "line-width") == 0) { GCV->line_width = s48_extract_integer(value); mask |= GCLineWidth; } else if (strcmp(cname, "line-style") == 0) { GCV->line_style = Symbol_To_Bit(value,Line_Style_Syms); mask |= GCLineStyle; } else if (strcmp(cname, "cap-style") == 0) { GCV->cap_style = Symbol_To_Bit(value, Cap_Style_Syms); mask |= GCCapStyle; } else if (strcmp(cname, "join-style") == 0) { GCV->join_style = Symbol_To_Bit(value, Join_Style_Syms); mask |= GCJoinStyle; } else if (strcmp(cname, "fill-style") == 0) { GCV->fill_style = Symbol_To_Bit(value, Fill_Style_Syms); mask |= GCFillStyle; } else if (strcmp(cname, "fill-rule") == 0) { GCV->fill_rule = Symbol_To_Bit(value, Fill_Rule_Syms); mask |= GCFillRule; } else if (strcmp(cname, "arc-mode") == 0) { GCV->arc_mode = Symbol_To_Bit(value, Arc_Mode_Syms); mask |= GCArcMode; } else if (strcmp(cname, "tile") == 0) { GCV->tile = EXTRACT_PIXMAP(value); mask |= GCTile; } else if (strcmp(cname, "stipple") == 0) { GCV->stipple = EXTRACT_PIXMAP(value); mask |= GCStipple; } else if (strcmp(cname, "ts-x") == 0) { GCV->ts_x_origin = s48_extract_integer(value); mask |= GCTileStipXOrigin; } else if (strcmp(cname, "ts-y") == 0) { GCV->ts_y_origin = s48_extract_integer(value); mask |= GCTileStipYOrigin; } else if (strcmp(cname, "font") == 0) { GCV->font = EXTRACT_FONT(value); mask |= GCFont; } else if (strcmp(cname, "subwindow-mode") == 0) { GCV->subwindow_mode = Symbol_To_Bit(value, Subwin_Mode_Syms); mask |= GCSubwindowMode; } else if (strcmp(cname, "exposures") == 0) { GCV->graphics_exposures = !S48_FALSE_P(value); mask |= GCGraphicsExposures; } else if (strcmp(cname, "clip-x") == 0) { GCV->clip_x_origin = s48_extract_integer(value); mask |= GCClipXOrigin; } else if (strcmp(cname, "clip-y") == 0) { GCV->clip_y_origin = s48_extract_integer(value); mask |= GCClipYOrigin; } else if (strcmp(cname, "clip-mask") == 0) { GCV->clip_mask = EXTRACT_PIXMAP(value); mask |= GCClipMask; } else if (strcmp(cname, "dash-offset") == 0) { GCV->dash_offset = s48_extract_integer(value); mask |= GCDashOffset; } else if (strcmp(cname, "dashes") == 0) { GCV->dashes = (char)s48_extract_integer(value); mask |= GCDashList; } // else error ?? } // for return mask; } s48_value Create_Gc(s48_value Xdisplay, s48_value Xdrawable, s48_value args) { XGCValues GCV; unsigned long mask = AList_To_GCValues(args, &GCV); GC Xgcontext = XCreateGC(EXTRACT_DISPLAY(Xdisplay), EXTRACT_DRAWABLE(Xdrawable), mask, &GCV); return ENTER_GCONTEXT(Xgcontext); } s48_value Copy_Gc(s48_value Xdisplay, s48_value Xsource, s48_value Xdest) { XCopyGC(EXTRACT_DISPLAY(Xdisplay), EXTRACT_GCONTEXT(Xsource), ~0L, EXTRACT_GCONTEXT(Xdest)); return S48_UNSPECIFIC; } s48_value Free_Gc(s48_value Xgcontext, s48_value Xdisplay) { XFreeGC(EXTRACT_DISPLAY(Xdisplay), EXTRACT_GCONTEXT(Xgcontext)); return S48_UNSPECIFIC; } #define ValidGCValuesBits \ (GCFunction | GCPlaneMask | GCForeground | GCBackground | GCLineWidth |\ GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle | GCFillRule |\ GCTile | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin | GCFont |\ GCSubwindowMode | GCGraphicsExposures | GCClipXOrigin | GCClipYOrigin |\ GCDashOffset | GCArcMode) s48_value Get_Gc_Values (s48_value Xgcontext, s48_value Xdisplay) { unsigned long mask = ValidGCValuesBits; XGCValues GCV; s48_value res; S48_DECLARE_GC_PROTECT(1); if (!XGetGCValues (EXTRACT_DISPLAY(Xdisplay), EXTRACT_GCONTEXT(Xgcontext), mask, &GCV)) res = S48_FALSE; else { res = s48_make_vector(23, S48_FALSE); S48_GC_PROTECT_1(res); S48_VECTOR_SET(res, 0, s48_enter_integer(GCV.function)); S48_VECTOR_SET(res, 1, ENTER_PIXEL(GCV.plane_mask)); S48_VECTOR_SET(res, 2, ENTER_PIXEL(GCV.foreground)); S48_VECTOR_SET(res, 3, ENTER_PIXEL(GCV.background)); 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)); S48_VECTOR_SET(res, 11, ENTER_PIXMAP(GCV.tile)); S48_VECTOR_SET(res, 12, ENTER_PIXMAP(GCV.stipple)); S48_VECTOR_SET(res, 13, s48_enter_integer(GCV.ts_x_origin)); S48_VECTOR_SET(res, 14, s48_enter_integer(GCV.ts_y_origin)); S48_VECTOR_SET(res, 15, ENTER_FONT(GCV.font)); 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)); S48_VECTOR_SET(res, 20, ENTER_PIXMAP(GCV.clip_mask)); 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; } s48_value Change_Gc (s48_value Xgcontext, s48_value Xdisplay, s48_value args) { XGCValues GCV; unsigned long mask = AList_To_GCValues(args, &GCV); XChangeGC(EXTRACT_DISPLAY(Xdisplay), EXTRACT_GCONTEXT(Xgcontext), mask, &GCV); return S48_UNSPECIFIC; } s48_value Set_Gcontext_Dashlist(s48_value Xgcontext, s48_value Xdisplay, s48_value dashoffset, s48_value dashlist) { int n = S48_VECTOR_LENGTH(dashlist); char v[n]; int i; for (i=0; i