#include "xlib.h" unsigned long Values_To_GCValues(s48_value values, XGCValues* GCV) { unsigned long mask = 0; int i; for (i=0; i<23; i++) { s48_value value = S48_VECTOR_REF(values, i); if (S48_FALSE != value) { switch (i) { case 0: GCV->function = Symbol_To_Bit(value, Func_Syms); mask |= GCFunction; break; case 1: GCV->plane_mask = SCX_EXTRACT_PIXEL(value); mask |= GCPlaneMask; break; case 2: GCV->foreground = SCX_EXTRACT_PIXEL(value); mask |= GCForeground; break; case 3: GCV->background = SCX_EXTRACT_PIXEL(value); mask |= GCBackground; break; case 4: GCV->line_style = Symbol_To_Bit(value,Line_Style_Syms); mask |= GCLineStyle; break; case 5: GCV->cap_style = Symbol_To_Bit(value, Cap_Style_Syms); mask |= GCCapStyle; break; case 6: GCV->cap_style = Symbol_To_Bit(value, Cap_Style_Syms); mask |= GCCapStyle; break; case 7: GCV->join_style = Symbol_To_Bit(value, Join_Style_Syms); mask |= GCJoinStyle; break; case 8: GCV->fill_style = Symbol_To_Bit(value, Fill_Style_Syms); mask |= GCFillStyle; break; case 9: GCV->fill_rule = Symbol_To_Bit(value, Fill_Rule_Syms); mask |= GCFillRule; break; case 10: GCV->tile = SCX_EXTRACT_PIXMAP(value); mask |= GCTile; break; case 11: GCV->stipple = SCX_EXTRACT_PIXMAP(value); mask |= GCStipple; break; case 12: GCV->ts_x_origin = s48_extract_integer(value); mask |= GCTileStipXOrigin; break; case 13: GCV->ts_y_origin = s48_extract_integer(value); mask |= GCTileStipYOrigin; break; case 14: GCV->font = SCX_EXTRACT_FONT(value); mask |= GCFont; break; case 15: GCV->subwindow_mode = Symbol_To_Bit(value, Subwin_Mode_Syms); mask |= GCSubwindowMode; break; case 16: GCV->graphics_exposures = !S48_FALSE_P(value); mask |= GCGraphicsExposures; break; case 17: GCV->clip_x_origin = s48_extract_integer(value); mask |= GCClipXOrigin; break; case 18: GCV->clip_y_origin = s48_extract_integer(value); mask |= GCClipYOrigin; break; case 19: GCV->clip_mask = SCX_EXTRACT_PIXMAP(value); mask |= GCClipMask; break; case 20: GCV->dash_offset = s48_extract_integer(value); mask |= GCDashOffset; break; case 21: GCV->dashes = (char)s48_extract_integer(value); mask |= GCDashList; break; case 22: GCV->arc_mode = Symbol_To_Bit(value, Arc_Mode_Syms); mask |= GCArcMode; break; } } } return mask; } s48_value scx_Create_Gc(s48_value Xdisplay, s48_value Xdrawable, s48_value values) { XGCValues GCV; unsigned long mask = Values_To_GCValues(values, &GCV); GC Xgcontext = XCreateGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_DRAWABLE(Xdrawable), mask, &GCV); return SCX_ENTER_GCONTEXT(Xgcontext); } 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)); return S48_UNSPECIFIC; } s48_value scx_Copy_Gc_To_Gc(s48_value Xdisplay, s48_value Xfrom, s48_value Xto, s48_value attrs) { unsigned long mask = 0; mask = S48_SYMBOL_P(attrs) ? Symbol_To_Bit(attrs, Gcontext_Values_Syms) : Symbols_To_Bits(attrs, Gcontext_Values_Syms); XCopyGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_GCONTEXT(Xfrom), mask, SCX_EXTRACT_GCONTEXT(Xto)); return S48_UNSPECIFIC; } s48_value scx_Free_Gc(s48_value Xgcontext, s48_value Xdisplay) { XFreeGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_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 scx_Get_Gc_Values (s48_value Xgcontext, s48_value Xdisplay) { unsigned long mask = ValidGCValuesBits; XGCValues GCV; s48_value res = S48_FALSE; S48_DECLARE_GC_PROTECT(1); if (!XGetGCValues (SCX_EXTRACT_DISPLAY(Xdisplay), SCX_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, Bit_To_Symbol(GCV.function, Func_Syms)); 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)); 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, SCX_ENTER_PIXMAP(GCV.tile)); S48_VECTOR_SET(res, 12, SCX_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, SCX_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, SCX_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 scx_Change_Gc (s48_value Xgcontext, s48_value Xdisplay, s48_value args) { XGCValues GCV; unsigned long mask = Values_To_GCValues(args, &GCV); XChangeGC(SCX_EXTRACT_DISPLAY(Xdisplay), SCX_EXTRACT_GCONTEXT(Xgcontext), mask, &GCV); return S48_UNSPECIFIC; } s48_value scx_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