2
/* Lefteris Koutsofios - AT&T Bell Laboratories */
8
#define WVU widget->u.v
10
int GVcreatewidget (Gwidget_t *parent, Gwidget_t *widget,
11
int attrn, Gwattr_t *attrp) {
23
ps.x = ps.y = MINVWSIZE;
26
for (ai = 0; ai < attrn; ai++) {
27
switch (attrp[ai].id) {
30
GETORIGIN (attrp[ai].u.p, po);
31
ADD2ARGS (XtNx, po.x);
32
ADD2ARGS (XtNy, po.y);
35
GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
41
color = attrp[ai].u.c.index;
42
if (color != 0 && color != 1) {
43
Gerr (POS, G_ERRBADCOLORINDEX, color);
46
c.red = attrp[ai].u.c.r * 257;
47
c.green = attrp[ai].u.c.g * 257;
48
c.blue = attrp[ai].u.c.b * 257;
50
Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
53
ADD2ARGS (XtNbackground, c.pixel);
55
ADD2ARGS (XtNforeground, c.pixel);
58
Gerr (POS, G_ERRCANNOTSETATTR1, "zorder");
61
Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
64
WVU->func = (Gviewcb) attrp[ai].u.func;
67
widget->udata = attrp[ai].u.u;
70
Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
74
ADD2ARGS (XtNwidth, ps.x);
75
ADD2ARGS (XtNheight, ps.y);
76
if (!(widget->w = XtAppCreateShell (s, "LEFTY",
77
topLevelShellWidgetClass, Gdisplay, argp, argn))) {
78
Gerr (POS, G_ERRCANNOTCREATEWIDGET);
82
hints.x = po.x, hints.y = po.y;
83
hints.width = ps.x, hints.height = ps.y;
84
hints.flags = USPosition;
85
Glazyrealize (widget->w, TRUE, &hints);
87
Glazyrealize (widget->w, FALSE, NULL);
91
int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
99
for (ai = 0; ai < attrn; ai++) {
100
switch (attrp[ai].id) {
102
GETORIGIN (attrp[ai].u.p, po);
103
ADD2ARGS (XtNx, po.x);
104
ADD2ARGS (XtNy, po.y);
107
GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
108
ADD2ARGS (XtNwidth, ps.x);
109
ADD2ARGS (XtNheight, ps.y);
112
#if XlibSpecificationRelease < 5
115
XmbSetWMProperties (Gdisplay, XtWindow (widget->w),
116
attrp[ai].u.t, attrp[ai].u.t, NULL, 0, NULL, NULL, NULL);
120
color = attrp[ai].u.c.index;
121
if (color != 0 && color != 1) {
122
Gerr (POS, G_ERRBADCOLORINDEX, color);
125
c.red = attrp[ai].u.c.r * 257;
126
c.green = attrp[ai].u.c.g * 257;
127
c.blue = attrp[ai].u.c.b * 257;
129
Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
132
ADD2ARGS (XtNbackground, c.pixel);
134
ADD2ARGS (XtNforeground, c.pixel);
138
if (Strcmp (attrp[ai].u.t, "top") == 0)
139
XRaiseWindow (Gdisplay, XtWindow (widget->w));
140
else if (Strcmp (attrp[ai].u.t, "bottom") == 0)
141
XLowerWindow (Gdisplay, XtWindow (widget->w));
143
Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
148
Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
151
WVU->func = (Gviewcb) attrp[ai].u.func;
154
widget->udata = attrp[ai].u.u;
157
Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
161
XtSetValues (widget->w, argp, argn);
165
int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
167
Dimension width, height;
170
for (ai = 0; ai < attrn; ai++) {
172
switch (attrp[ai].id) {
176
XtGetValues (widget->w, argp, argn);
177
attrp[ai].u.p.x = x, attrp[ai].u.p.y = y;
180
ADD2ARGS (XtNwidth, &width);
181
ADD2ARGS (XtNheight, &height);
182
XtGetValues (widget->w, argp, argn);
183
attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
186
Gerr (POS, G_ERRNOTIMPLEMENTED);
189
Gerr (POS, G_ERRNOTIMPLEMENTED);
192
sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
193
attrp[ai].u.t = &Gbufp[0];
196
attrp[ai].u.func = WVU->func;
199
attrp[ai].u.u = widget->udata;
202
Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
209
int GVdestroywidget (Gwidget_t *widget) {
211
XtDestroyWidget (widget->w);
215
void Gwmdelaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
219
widget = findwidget ((unsigned long) w, G_VIEWWIDGET);
222
gev.type = 0, gev.code = 0, gev.data = 0;
223
gev.wi = widget - &Gwidgets[0];