Interpreter - Incremental API changes
[rune.git] / dllx11 / pen.c
1 /*
2  * PEN.C
3  */
4
5 #include "defs.h"
6
7 void *
8 isys_XSetForeground(runctx_p ct, Exp *exp, RefStor **prs)
9 {
10         struct {
11                 int32_t gcid;
12                 int32_t color;
13         } *rhs;
14         TmpStor *ts;
15
16         rhs = exp->ex_Rhs->ex_Func(ct, exp->ex_Rhs, prs);
17         ts = getExpTmpData(ct, exp);
18         ts->ts_Int32 = XSetForeground(SaveDisplay,
19                                       hashLookup(rhs->gcid, HASH_GC),
20                                       rhs->color);
21         return(&ts->ts_Int32);
22 }
23
24 void *
25 isys_XSetBackground(runctx_p ct, Exp *exp, RefStor **prs)
26 {
27         struct {
28                 int32_t gcid;
29                 int32_t color;
30         } *rhs;
31         TmpStor *ts;
32
33         rhs = exp->ex_Rhs->ex_Func(ct, exp->ex_Rhs, prs);
34         ts = getExpTmpData(ct, exp);
35         ts->ts_Int32 = XSetBackground(SaveDisplay,
36                                       hashLookup(rhs->gcid, HASH_GC),
37                                       rhs->color);
38         return(&ts->ts_Int32);
39 }
40
41
42 #define COLORMAP DefaultColormap(SaveDisplay, DefaultScreen(SaveDisplay))
43
44 void *
45 isys_XAllocColor(runctx_p ct, Exp *exp, RefStor **prs)
46 {
47         struct {
48                 int32_t r;
49                 int32_t g;
50                 int32_t b;
51         } *rhs;
52         TmpStor *ts;
53         XColor color = { 0 };
54
55         rhs = exp->ex_Rhs->ex_Func(ct, exp->ex_Rhs, prs);
56         ts = getExpTmpData(ct, exp);
57         color.red = rhs->r;
58         color.green = rhs->g;
59         color.blue = rhs->b;
60         ts->ts_Int32 = XAllocColor(SaveDisplay, COLORMAP, &color);
61         ts->ts_Int32 = color.pixel;
62         return(&ts->ts_Int32);
63 }
64
65 void *
66 isys_XFreeColor(runctx_p ct, Exp *exp, RefStor **prs)
67 {
68         struct {
69                 int32_t pixel;
70         } *rhs;
71         TmpStor *ts;
72         unsigned long pixel;
73
74         rhs = exp->ex_Rhs->ex_Func(ct, exp->ex_Rhs, prs);
75         ts = getExpTmpData(ct, exp);
76         pixel = rhs->pixel;
77         ts->ts_Int32 = XFreeColors(SaveDisplay, COLORMAP, &pixel, 1, 0);
78         return(&ts->ts_Int32);
79 }