2001-05-08 10:21:00 -04:00
|
|
|
#include "xlib.h"
|
2001-06-11 11:25:39 -04:00
|
|
|
#include "scheme48.h"
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Free_Colormap (s48_value Xcolormap, s48_value Xdisplay) {
|
|
|
|
XFreeColormap(SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_COLORMAP(Xcolormap));
|
2001-06-11 11:25:39 -04:00
|
|
|
return S48_UNSPECIFIC;
|
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Alloc_Color(s48_value Xcolormap, s48_value Xcolor,
|
|
|
|
s48_value Xdisplay) {
|
|
|
|
XColor* cp = SCX_EXTRACT_COLOR(Xcolor);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
if (!XAllocColor(SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_COLORMAP(Xcolormap), cp))
|
2001-06-27 09:44:48 -04:00
|
|
|
return S48_FALSE;
|
|
|
|
else
|
2001-07-31 10:51:21 -04:00
|
|
|
return SCX_ENTER_PIXEL(cp->pixel);
|
2001-06-11 11:25:39 -04:00
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value scx_Alloc_Named_Color(s48_value Xcolormap, s48_value color_name,
|
|
|
|
s48_value Xdisplay) {
|
2001-06-11 11:25:39 -04:00
|
|
|
XColor screen, exact;
|
|
|
|
int r;
|
2001-07-31 10:51:21 -04:00
|
|
|
s48_value ret = S48_FALSE;
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-06-11 11:25:39 -04:00
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
r = XAllocNamedColor (SCX_EXTRACT_DISPLAY(Xdisplay),
|
|
|
|
SCX_EXTRACT_COLORMAP(Xcolormap),
|
2001-06-27 09:44:48 -04:00
|
|
|
s48_extract_string(color_name),
|
2001-06-11 11:25:39 -04:00
|
|
|
&screen, &exact);
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
if (r) {
|
2001-06-27 09:44:48 -04:00
|
|
|
S48_GC_PROTECT_1(ret);
|
2001-07-31 10:51:21 -04:00
|
|
|
ret = s48_cons(scx_Int_Extract_RGB_Values(exact), S48_NULL);
|
|
|
|
ret = s48_cons(scx_Int_Extract_RGB_Values(screen), ret);
|
|
|
|
ret = s48_cons(SCX_ENTER_PIXEL(screen.pixel), ret);
|
2001-06-27 09:44:48 -04:00
|
|
|
}
|
2001-05-08 10:21:00 -04:00
|
|
|
|
2001-06-11 11:25:39 -04:00
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
return ret;
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-31 10:51:21 -04:00
|
|
|
void scx_init_colormap(void) {
|
|
|
|
S48_EXPORT_FUNCTION(scx_Free_Colormap);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Alloc_Color);
|
|
|
|
S48_EXPORT_FUNCTION(scx_Alloc_Named_Color);
|
2001-05-08 10:21:00 -04:00
|
|
|
}
|