scx/c/xlib/pixel.c

49 lines
1.3 KiB
C
Raw Normal View History

2001-05-08 10:21:00 -04:00
#include "xlib.h"
Generic_Predicate (Pixel)
Generic_Simple_Equal (Pixel, PIXEL, pix)
Generic_Print (Pixel, "#[pixel 0x%lx]", PIXEL(x)->pix)
s48_value Make_Pixel (val) unsigned long val; {
s48_value pix;
2001-05-08 10:21:00 -04:00
pix = Find_Object (T_Pixel, (GENERIC)0, Match_X_Obj, val);
if (S48_NULL_P (pix)) {
2001-05-08 10:21:00 -04:00
pix = Alloc_Object (sizeof (struct S_Pixel), T_Pixel, 0);
PIXEL(pix)->tag = S48_NULL;
2001-05-08 10:21:00 -04:00
PIXEL(pix)->pix = val;
Register_Object (pix, (GENERIC)0, (PFO)0, 0);
}
return pix;
}
unsigned long Get_Pixel (p) s48_value p; {
2001-05-08 10:21:00 -04:00
Check_Type (p, T_Pixel);
return PIXEL(p)->pix;
}
static s48_value P_Pixel_Value (p) s48_value p; {
return s48_enter_integer (Get_Pixel (p));
2001-05-08 10:21:00 -04:00
}
static s48_value P_Black_Pixel (d) s48_value d; {
2001-05-08 10:21:00 -04:00
Check_Type (d, T_Display);
return Make_Pixel (BlackPixel (DISPLAY(d)->dpy,
DefaultScreen (DISPLAY(d)->dpy)));
}
static s48_value P_White_Pixel (d) s48_value d; {
2001-05-08 10:21:00 -04:00
Check_Type (d, T_Display);
return Make_Pixel (WhitePixel (DISPLAY(d)->dpy,
DefaultScreen (DISPLAY(d)->dpy)));
}
elk_init_xlib_pixel () {
Generic_Define (Pixel, "pixel", "pixel?");
Define_Primitive (P_Pixel_Value, "pixel-value", 1, 1, EVAL);
Define_Primitive (P_Black_Pixel, "black-pixel", 1, 1, EVAL);
Define_Primitive (P_White_Pixel, "white-pixel", 1, 1, EVAL);
}