/* Generated by wbuild from "ScrollWin.w"
** (generator version $Revision: 1.17 $ of $Date: 92/12/07 19:32:00 $)
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#line 456 "ScrollWin.w"
#include <stdio.h>
#line 457 "ScrollWin.w"
#include <Xfwf/Frame.h>
#line 458 "ScrollWin.w"
#include <Xfwf/Board.h>
#line 459 "ScrollWin.w"
#include <Xfwf/VScrollb.h>
#line 460 "ScrollWin.w"
#include <Xfwf/HScrollb.h>
#line 461 "ScrollWin.w"
#include <Xfwf/scroll.h>
#include <Xfwf/ScrollWinP.h>
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
#line 150 "ScrollWin.w"
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 188 "ScrollWin.w"
static Boolean  set_values(
#if NeedFunctionPrototypes
Widget ,Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 223 "ScrollWin.w"
static void resize(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 237 "ScrollWin.w"
static void insert_child(
#if NeedFunctionPrototypes
Widget 
#endif
);
#line 272 "ScrollWin.w"
static void destroy(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 285 "ScrollWin.w"
static void scroll_response(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 320 "ScrollWin.w"
static void compute_sizes(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 355 "ScrollWin.w"
static void copy_vScrollAmount(
#if NeedFunctionPrototypes
Widget,int ,XrmValue *
#endif
);
#line 365 "ScrollWin.w"
static void scroll_callback(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 414 "ScrollWin.w"
static void CW_killed(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XtPointer 
#endif
);
#line 432 "ScrollWin.w"
static void configure(
#if NeedFunctionPrototypes
Widget ,XtPointer ,XEvent *,Boolean *
#endif
);
#line 320 "ScrollWin.w"
/*ARGSUSED*/static void compute_sizes(self)Widget self;
{
    Dimension selfw, selfh, framew, frameh;
    Position selfx, selfy;

    ((XfwfScrolledWindowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &selfx, &selfy, &selfw, &selfh);
    XtConfigureWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll,
		      selfx + selfw - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
		      selfy + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing,
		      ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
		      selfh - 3*((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
		      0);
    XtConfigureWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll,
		      ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing,
		      selfy + selfh - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
		      selfw - 3*((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
		      ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
		      0);
    framew = selfw - 2 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing;
    frameh = selfh - 2 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing;
    if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar) framew -= ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing;
    if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar) frameh -= ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing;
    XtConfigureWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame,
		      selfx + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing,
		      selfy + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing,
		      framew,
		      frameh,
		      0);
}
#line 355 "ScrollWin.w"
/*ARGSUSED*/static void copy_vScrollAmount(self,offset,value)Widget self;int  offset;XrmValue * value;
{
    value->addr = (XtPointer) &((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vScrollAmount;
}
#line 365 "ScrollWin.w"
/*ARGSUSED*/static void scroll_callback(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;
    XfwfScrollInfo *info = (XfwfScrollInfo *) call_data;
    XfwfScrollInfo new;
    Position boardx, boardy, gx, gy, minx, miny;
    Dimension boardwd, boardht, gwd, ght;
    float wd, ht, x, y;

    ((XfwfScrolledWindowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
    XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, &gx, XtNy, &gy, XtNwidth, &gwd,
		  XtNheight, &ght, NULL);
    minx = gwd <= boardwd ? 0 : boardwd - gwd;
    miny = ght <= boardht ? 0 : boardht - ght;
    switch (info->reason) {
    case XfwfSUp: gy = min(gy + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vScrollAmount, 0); break;
    case XfwfSDown: gy = max(gy - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vScrollAmount, miny); break;
    case XfwfSLeft: gx = min(gx + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hScrollAmount, 0); break;
    case XfwfSRight: gx = max(gx - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hScrollAmount, minx); break;
    case XfwfSPageUp: gy = min(gy + boardht, 0); break;
    case XfwfSPageDown: gy = max(gy - boardht, miny); break;
    case XfwfSPageLeft: gx = min(gx + boardwd, 0); break;
    case XfwfSPageRight: gx = max(gx - boardwd, minx); break;
    case XfwfSDrag:
	if (w == ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll) gy = info->vpos * miny;
	else gx = info->hpos * minx;
	break;
    case XfwfSMove: break;
    case XfwfSTop: gy = 0; break;
    case XfwfSBottom: gy = miny; break;
    case XfwfSLeftSide: gx = 0; break;
    case XfwfSRightSide: gx = minx; break;
    }
    XtMoveWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, gx, gy);
    if (info->reason != XfwfSNotify) {
	new.reason = XfwfSNotify;
	new.flags = XFWF_VPOS | XFWF_HPOS;
	new.hpos = minx == 0 ? 0.0 : gx/minx;
	new.vpos = miny == 0 ? 0.0 : gy/miny;
	XtCallCallbackList(self, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollCallback, &info);
    }
}
#line 414 "ScrollWin.w"
/*ARGSUSED*/static void CW_killed(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;

    XtRemoveEventHandler(w, StructureNotifyMask, False, configure, self);
    XtRemoveEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, StructureNotifyMask, False, configure, self);
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW = NULL;
    XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, 0.0, 1.0);
    XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, 0.0, 1.0);
}
#line 432 "ScrollWin.w"
/*ARGSUSED*/static void configure(w,client_data,event,cont)Widget  w;XtPointer  client_data;XEvent * event;Boolean * cont;
{
    Widget self = (Widget) client_data;
    Dimension boardwd, boardht, gwd, ght;
    Position boardx, boardy, gx, gy;
    float wd, ht, x, y;

    if (event != NULL && event->type != ConfigureNotify) return;
    ((XfwfScrolledWindowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
    XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, &gx, XtNy, &gy, XtNwidth, &gwd,
		  XtNheight, &ght, NULL);
    wd = gwd <= boardwd ? 1.0 : (float) boardwd/gwd;
    ht = ght <= boardht ? 1.0 : (float) boardht/ght;
    x = gwd <= boardwd ? 0.0 : (float) gx/(boardwd - gwd);
    y = ght <= boardht ? 0.0 : (float) gy/(boardht - ght);
    if (x > 1.0) x = 1.0;
    if (y > 1.0) y = 1.0;
    XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, x, wd);
    XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, y, ht);
}

static XtResource resources[] = {
#line 26 "ScrollWin.w"
{XtNspacing,XtCSpacing,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.spacing),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.spacing),XtRImmediate,(XtPointer)4 },
#line 31 "ScrollWin.w"
{XtNscrollbarWidth,XtCScrollbarWidth,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.scrollbarWidth),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.scrollbarWidth),XtRImmediate,(XtPointer)22 },
#line 38 "ScrollWin.w"
{XtNshadowWidth,XtCShadowWidth,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.shadowWidth),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.shadowWidth),XtRImmediate,(XtPointer)2 },
#line 43 "ScrollWin.w"
{XtNhideHScrollbar,XtCHideHScrollbar,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.hideHScrollbar),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.hideHScrollbar),XtRImmediate,(XtPointer)False },
#line 47 "ScrollWin.w"
{XtNhideVScrollbar,XtCHideVScrollbar,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.hideVScrollbar),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.hideVScrollbar),XtRImmediate,(XtPointer)False },
#line 55 "ScrollWin.w"
{XtNvScrollAmount,XtCVScrollAmount,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.vScrollAmount),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.vScrollAmount),XtRImmediate,(XtPointer)20 },
#line 59 "ScrollWin.w"
{XtNhScrollAmount,XtCHScrollAmount,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.hScrollAmount),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.hScrollAmount),XtRCallProc,(XtPointer)copy_vScrollAmount },
#line 65 "ScrollWin.w"
{XtNinitialX,XtCInitialX,XtRPosition,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.initialX),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.initialX),XtRImmediate,(XtPointer)0 },
#line 69 "ScrollWin.w"
{XtNinitialY,XtCInitialY,XtRPosition,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.initialY),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.initialY),XtRImmediate,(XtPointer)0 },
#line 106 "ScrollWin.w"
{XtNscrollCallback,XtCScrollCallback,XtRCallback,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.scrollCallback),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.scrollCallback),XtRImmediate,(XtPointer)NULL },
#line 113 "ScrollWin.w"
{XtNscrollResponse,XtCScrollResponse,XtRXTCallbackProc,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.scrollResponse),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.scrollResponse),XtRImmediate,(XtPointer)scroll_response },
};

XfwfScrolledWindowClassRec xfwfScrolledWindowClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfBoardClassRec,
"XfwfScrolledWindow",
sizeof(XfwfScrolledWindowRec),
NULL,
_resolve_inheritance,
FALSE,
initialize,
NULL,
XtInheritRealize,
NULL,
0,
resources,
11,
NULLQUARK,
False ,
FALSE ,
False ,
False ,
destroy,
resize,
XtInheritExpose,
set_values,
NULL,
XtInheritSetValuesAlmost,
NULL,
XtInheritAcceptFocus,
XtVersion,
NULL,
NULL,
XtInheritQueryGeometry,
XtInheritDisplayAccelerator,
NULL 
},
{ /* composite_class part */
XtInheritGeometryManager,
XtInheritChangeManaged,
insert_child,
XtInheritDeleteChild,
NULL
},
{ /* XfwfCommon_class part */
XtInherit_compute_inside,
XtInherit_highlight_border,
XtInherit_unhighlight_border,
XtInherit_would_accept_focus,
XtInherit_traverse,
XtInherit_choose_color,
XtInherit_lighter_color,
XtInherit_darker_color,
NULL ,
},
{ /* XfwfFrame_class part */
0
},
{ /* XfwfBoard_class part */
XtInherit_set_abs_location,
},
{ /* XfwfScrolledWindow_class part */
scroll_response,
},
};
WidgetClass xfwfScrolledWindowWidgetClass = (WidgetClass) &xfwfScrolledWindowClassRec;
static void _resolve_inheritance(class)
WidgetClass class;
{
  XfwfScrolledWindowWidgetClass c = (XfwfScrolledWindowWidgetClass) class;
  XfwfScrolledWindowWidgetClass super;
  if (class == xfwfScrolledWindowWidgetClass) return;
  super = (XfwfScrolledWindowWidgetClass) c->core_class.superclass;
  if (c->xfwfScrolledWindow_class.scroll_response == XtInherit_scroll_response)
    c->xfwfScrolledWindow_class.scroll_response = super->xfwfScrolledWindow_class.scroll_response;
}
#line 150 "ScrollWin.w"
/*ARGSUSED*/static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initializing = True;
    if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialX > 0) ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialX = 0;
    if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialY > 0) ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialY = 0;
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW = NULL;
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame = XtVaCreateManagedWidget
	("_frame", xfwfFrameWidgetClass, self, XtNframeType, XfwfSunken,
	 XtNframeWidth, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.shadowWidth, XtNborderWidth, 0,
	 XtNhighlightThickness, 0, NULL);
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board = XtVaCreateManagedWidget
	("_board", xfwfBoardWidgetClass, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNframeWidth, 0,
	 XtNborderWidth, 0, XtNhighlightThickness, 0, NULL);
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll = XtVaCreateWidget
	("_vscroll", xfwfVScrollbarWidgetClass, self, XtNframeWidth,
	 ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.shadowWidth, XtNframeType, XfwfSunken, XtNborderWidth, 0, NULL);
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll = XtVaCreateWidget
	("_hscroll", xfwfHScrollbarWidgetClass, self, XtNframeWidth,
	 ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.shadowWidth, XtNframeType, XfwfSunken, XtNborderWidth, 0, NULL);
    if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar) XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll);
    if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar) XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll);
    compute_sizes(self);
    XtAddCallback(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, XtNscrollCallback, scroll_callback, self);
    XtAddCallback(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, XtNscrollCallback, scroll_callback, self);
    XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, XtNscrollResponse, &((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll_resp, NULL);
    XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, XtNscrollResponse, &((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll_resp, NULL);
    ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initializing = False;
    if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse != scroll_response) {
	((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse = scroll_response;
	XtWarning("scrollResponse resource may only be queried, not set");
    }
}
#line 188 "ScrollWin.w"
/*ARGSUSED*/static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    Dimension selfw, selfh, framew, frameh;
    Position selfx, selfy;

    if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.spacing != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing
	|| ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.scrollbarWidth != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth
	|| ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.shadowWidth != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.shadowWidth
	|| ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideHScrollbar != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar
	|| ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideVScrollbar != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar)
	compute_sizes(self);
    if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideVScrollbar && ! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar)
	XtUnmanageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll);
    else if (! ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideVScrollbar && ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar)
	XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll);
    if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideHScrollbar && ! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar)
	XtUnmanageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll);
    else if (! ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideHScrollbar && ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar)
	XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll);
    if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse != ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.scrollResponse) {
	((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse = ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.scrollResponse;
	XtWarning("scrollResponse resource may only be queried, not set");
    }
    return False;
}
#line 223 "ScrollWin.w"
/*ARGSUSED*/static void resize(self)Widget self;
{
    compute_sizes(self);
}
#line 237 "ScrollWin.w"
/*ARGSUSED*/static void insert_child(child)Widget  child;
{ Widget self = XtParent(child); {
    Widget board;
    Position boardx, boardy, gx, gy;
    Dimension boardwd, boardht, gwd, ght;
    float wd, ht, x, y;
    Boolean dummy;

    if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initializing) {
	xfwfBoardClassRec.composite_class.insert_child(child);
    } else if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW == NULL) {
	((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW = child;
	((XfwfScrolledWindowWidget)child)->core.parent = ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board;
	XtAddCallback(child, XtNdestroyCallback, CW_killed, self);
	xfwfBoardClassRec.composite_class.insert_child(child);
	XtAddEventHandler(child, StructureNotifyMask, False, configure, self);
	XtAddEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, StructureNotifyMask, False, configure, self);
	((XfwfScrolledWindowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
	XtVaGetValues(child, XtNwidth, &gwd, XtNheight, &ght, NULL);
	gx = gwd <= boardwd ? 0 : max(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialX, boardwd - gwd);
	gy = ght <= boardht ? 0 : max(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialY, boardht - ght);
	XtMoveWidget(child, gx, gy);
	configure(self, self, NULL, &dummy);
    } else {
	char s[500];
	(void) sprintf(s, "Cannot add <%s>, %s <%s> already has a child\n",
		       XtName(child), "ScrolledWindow", XtName(self));
	XtWarning(s);
    }
}
}
#line 272 "ScrollWin.w"
/*ARGSUSED*/static void destroy(self)Widget self;
{
    if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW != NULL) {
	XtRemoveEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, StructureNotifyMask, False,
			     configure, self);
	XtRemoveEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, StructureNotifyMask, False,
			     configure, self);
    }
}
#line 285 "ScrollWin.w"
/*ARGSUSED*/static void scroll_response(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
{
    Widget self = (Widget) client_data;
    XfwfScrollInfo *info = (XfwfScrollInfo *) call_data;
    XfwfScrollInfo new;
    Position boardx, boardy, gx, gy, minx, miny;
    Dimension boardwd, boardht, gwd, ght;
    float wd, ht, x, y;

    ((XfwfScrolledWindowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
    XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, &gx, XtNy, &gy, XtNwidth, &gwd,
		  XtNheight, &ght, NULL);
    minx = gwd <= boardwd ? 0 : boardwd - gwd;
    miny = ght <= boardht ? 0 : boardht - ght;

    if (info->flags & XFWF_VPOS) gy = info->vpos * miny;
    if (info->flags & XFWF_HPOS) gx = info->hpos * minx;

    XtMoveWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, gx, gy);

    if (info->reason != XfwfSNotify) {
	new.reason = XfwfSNotify;
	new.flags = XFWF_VPOS | XFWF_HPOS;
	new.hpos = info->hpos;
	new.vpos = info->vpos;
	XtCallCallbackList(self, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollCallback, &info);
    }
}
