2
/* Lefteris Koutsofios - AT&T Bell Laboratories */
8
int GScreatewidget (Gwidget_t *parent, Gwidget_t *widget,
9
int attrn, Gwattr_t *attrp) {
11
#if XlibSpecificationRelease < 5
19
Gerr (POS, G_ERRNOPARENTWIDGET);
22
ps.x = ps.y = MINSWSIZE;
24
for (ai = 0; ai < attrn; ai++) {
25
switch (attrp[ai].id) {
27
GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
29
case G_ATTRBORDERWIDTH:
30
ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
32
case G_ATTRCHILDCENTER:
33
Gerr (POS, G_ERRCANNOTSETATTR1, "childcenter");
36
if (Strcmp ("forcebars", attrp[ai].u.t) == 0)
37
ADD2ARGS (XtNforceBars, True);
39
Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
44
color = attrp[ai].u.c.index;
45
if (color != 0 && color != 1) {
46
Gerr (POS, G_ERRBADCOLORINDEX, color);
49
c.red = attrp[ai].u.c.r * 257;
50
c.green = attrp[ai].u.c.g * 257;
51
c.blue = attrp[ai].u.c.b * 257;
53
Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
56
ADD2ARGS (XtNbackground, c.pixel);
58
ADD2ARGS (XtNforeground, c.pixel);
61
Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
64
widget->udata = attrp[ai].u.u;
67
Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
71
ADD2ARGS (XtNallowHoriz, True);
72
ADD2ARGS (XtNallowVert, True);
73
ADD2ARGS (XtNwidth, ps.x);
74
ADD2ARGS (XtNheight, ps.y);
75
if (!(widget->w = XtCreateWidget ("scroll", viewportWidgetClass,
76
parent->w, argp, argn))) {
77
Gerr (POS, G_ERRCANNOTCREATEWIDGET);
80
#if XlibSpecificationRelease < 5
82
ADD2ARGS (XtNwidth, ps.x);
83
ADD2ARGS (XtNheight, ps.y);
84
if (!(w = XtCreateWidget ("owsucks", formWidgetClass,
85
widget->w, argp, argn))) {
86
Gerr (POS, G_ERRCANNOTCREATEWIDGET);
90
Glazymanage (widget->w);
93
Glazymanage (widget->w);
98
int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
101
Dimension width, height;
107
for (ai = 0; ai < attrn; ai++) {
108
switch (attrp[ai].id) {
110
GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
111
ADD2ARGS (XtNwidth, ps.x);
112
ADD2ARGS (XtNheight, ps.y);
114
case G_ATTRBORDERWIDTH:
115
ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
117
case G_ATTRCHILDCENTER:
118
GETORIGIN (attrp[ai].u.p, po);
119
ADD2ARGS (XtNwidth, &width);
120
ADD2ARGS (XtNheight, &height);
121
XtGetValues (widget->w, argp, argn);
122
po.x -= width / 2, po.y -= height / 2;
127
XawViewportSetCoordinates (widget->w, po.x, po.y);
130
if (Strcmp ("forcebars", attrp[ai].u.t) == 0)
131
ADD2ARGS (XtNforceBars, True);
133
Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
138
color = attrp[ai].u.c.index;
139
if (color != 0 && color != 1) {
140
Gerr (POS, G_ERRBADCOLORINDEX, color);
143
c.red = attrp[ai].u.c.r * 257;
144
c.green = attrp[ai].u.c.g * 257;
145
c.blue = attrp[ai].u.c.b * 257;
147
Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
150
ADD2ARGS (XtNbackground, c.pixel);
152
ADD2ARGS (XtNforeground, c.pixel);
155
Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
158
widget->udata = attrp[ai].u.u;
161
Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
165
XtSetValues (widget->w, argp, argn);
169
int GSgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
170
Dimension width, height;
176
for (ai = 0; ai < attrn; ai++) {
178
switch (attrp[ai].id) {
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;
185
case G_ATTRBORDERWIDTH:
186
ADD2ARGS (XtNborderWidth, &width);
187
XtGetValues (widget->w, argp, argn);
188
attrp[ai].u.i = width;
190
case G_ATTRCHILDCENTER:
191
for (wi = 0; wi < Gwidgetn; wi++) {
192
child = &Gwidgets[wi];
193
if (child->inuse && child->pwi == widget - &Gwidgets[0])
196
if (wi == Gwidgetn) {
197
Gerr (POS, G_ERRNOCHILDWIDGET);
200
ADD2ARGS (XtNwidth, &width);
201
ADD2ARGS (XtNheight, &height);
202
XtGetValues (widget->w, argp, argn);
206
XtGetValues (child->w, argp, argn);
207
attrp[ai].u.p.x = width / 2 - x, attrp[ai].u.p.y = height / 2 - y;
210
ADD2ARGS (XtNforceBars, &tf);
211
attrp[ai].u.t = (tf == True) ? "forcebars" : "";
214
sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
215
attrp[ai].u.t = &Gbufp[0];
218
attrp[ai].u.u = widget->udata;
221
Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
228
int GSdestroywidget (Gwidget_t *widget) {
229
XtDestroyWidget (widget->w);
233
#if XlibSpecificationRelease < 5
234
#include <X11/IntrinsicP.h>
235
#include <X11/Xaw/ViewportP.h>
237
void XawViewportSetCoordinates (Widget gw, Position x, Position y) {
238
ViewportWidget w = (ViewportWidget) gw;
239
Widget child = w->viewport.child;
240
Widget clip = w->viewport.clip;
243
if (x > (int) child->core.width)
244
x = child->core.width;
248
if (y > (int) child->core.height)
249
y = child->core.height;
255
if (-mx + (int) clip->core.width > (int) child->core.width)
256
mx = -(child->core.width - clip->core.width);
258
if (-my + (int) clip->core.height > (int) child->core.height)
259
my = -(child->core.height - clip->core.height);
261
/* make sure we never move past left/top borders */
265
XtMoveWidget (child, mx, my);
266
XtUnmanageChild (child);
267
XtManageChild (child);