/* Generated by wbuild from "Rows.w"
** (generator version $Revision: 1.4 $ of $Date: 1995/08/29 09:46:15 $)
*/
#include <xite/includes.h>
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <Xfwf/RowsP.h>
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
#line 32 "Rows.w"
static void change_managed(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 41 "Rows.w"
static void layout(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 84 "Rows.w"
static XtGeometryResult  geometry_manager(
#if NeedFunctionPrototypes
Widget ,XtWidgetGeometry *,XtWidgetGeometry *
#endif
);
#line 109 "Rows.w"
static void resize(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 119 "Rows.w"
static Boolean  set_values(
#if NeedFunctionPrototypes
Widget ,Widget ,Widget,ArgList ,Cardinal *
#endif
);

static XtResource resources[] = {
#line 17 "Rows.w"
{XtNalignTop,XtCAlignTop,XtRBoolean,sizeof(((XfwfRowsRec*)NULL)->xfwfRows.alignTop),XtOffsetOf(XfwfRowsRec,xfwfRows.alignTop),XtRImmediate,(XtPointer)True },
#line 23 "Rows.w"
{XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfRowsRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfRowsRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfSunken },
#line 24 "Rows.w"
{XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfRowsRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfRowsRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)2 },
};

XfwfRowsClassRec xfwfRowsClassRec = {
{ /* core_class part */
(WidgetClass) &xfwfBoardClassRec,
"XfwfRows",
sizeof(XfwfRowsRec),
NULL,
_resolve_inheritance,
FALSE,
NULL,
NULL,
XtInheritRealize,
NULL,
0,
resources,
3,
NULLQUARK,
True ,
XtExposeCompressMultiple ,
True ,
False ,
NULL,
resize,
XtInheritExpose,
set_values,
NULL,
XtInheritSetValuesAlmost,
NULL,
XtInheritAcceptFocus,
XtVersion,
NULL,
NULL,
XtInheritQueryGeometry,
XtInheritDisplayAccelerator,
NULL 
},
{ /* composite_class part */
geometry_manager,
change_managed,
XtInheritInsertChild,
XtInheritDeleteChild,
NULL
},
{ /* XfwfCommon_class part */
XtInherit_compute_inside,
XtInherit_total_frame_width,
XtInherit_highlight_border,
XtInherit_unhighlight_border,
XtInherit_would_accept_focus,
XtInherit_traverse,
XtInherit_lighter_color,
XtInherit_darker_color,
NULL ,
},
{ /* XfwfFrame_class part */
0
},
{ /* XfwfBoard_class part */
XtInherit_set_abs_location,
},
{ /* XfwfRows_class part */
layout,
},
};
WidgetClass xfwfRowsWidgetClass = (WidgetClass) &xfwfRowsClassRec;
static void _resolve_inheritance(class)
WidgetClass class;
{
  XfwfRowsWidgetClass c = (XfwfRowsWidgetClass) class;
  XfwfRowsWidgetClass super;
  static CompositeClassExtensionRec extension_rec = {
    NULL, NULLQUARK, XtCompositeExtensionVersion,
    sizeof(CompositeClassExtensionRec), True};
  CompositeClassExtensionRec *ext;
  ext = (CompositeClassExtensionRec *)XtMalloc(sizeof(*ext));
  *ext = extension_rec;
  ext->next_extension = c->composite_class.extension;
  c->composite_class.extension = (XtPointer)ext;
  if (class == xfwfRowsWidgetClass) return;
  super = (XfwfRowsWidgetClass)class->core_class.superclass;
  if (c->xfwfRows_class.layout == XtInherit_layout)
    c->xfwfRows_class.layout = super->xfwfRows_class.layout;
}
#line 32 "Rows.w"
/*ARGSUSED*/static void change_managed(self)Widget self;
{
    ((XfwfRowsWidgetClass)self->core.widget_class)->
      xfwfRows_class.layout(self);
}
#line 41 "Rows.w"
/*ARGSUSED*/static void layout(self)Widget self;
{
    Position top, left, x, y;
    Dimension width, height, w, maxht;
    int i, j;
    Widget child;

    ((XfwfRowsWidgetClass)self->core.widget_class)->
      xfwfCommon_class.compute_inside(self, &left, &top, &width, &height);
    y = top;
    i = 0;
    while (i < ((XfwfRowsWidget)self)->composite.num_children) {
	child = ((XfwfRowsWidget)self)->composite.children[i];
	/* Accumulated width */
	w = ((XfwfRowsWidget)child)->core.width;
	/* Max. height in this row */
	maxht = ((XfwfRowsWidget)child)->core.height;
	j = i + 1;
	do {
	    if (j >= ((XfwfRowsWidget)self)->composite.num_children) break;
	    child = ((XfwfRowsWidget)self)->composite.children[j];
	    if (w + ((XfwfRowsWidget)child)->core.width > width) break;
	    w += ((XfwfRowsWidget)child)->core.width;
	    if (((XfwfRowsWidget)child)->core.height > maxht)
	      maxht = ((XfwfRowsWidget)child)->core.height;
	    j++;
	} while (1);
	for (x = left; i < j; i++) {
	    child = ((XfwfRowsWidget)self)->composite.children[i];
	    if (((XfwfRowsWidget)self)->xfwfRows.alignTop)
		XtMoveWidget(child, x, y);
	    else
		XtMoveWidget(child, x,
			     y + maxht - ((XfwfRowsWidget)child)->core.height);
	    x += ((XfwfRowsWidget)child)->core.width;
	}
	y += maxht;
    }
}
#line 84 "Rows.w"
/*ARGSUSED*/static XtGeometryResult  geometry_manager(child,request,reply)
Widget  child;XtWidgetGeometry * request;XtWidgetGeometry * reply;
{ Widget self = XtParent(child); {
    Dimension newwd, newht, newbd;

    if (request->request_mode & (CWX | CWY)) return XtGeometryNo;
    if (request->request_mode & XtCWQueryOnly) return XtGeometryYes;

    newwd = request->request_mode & CWWidth ?
      request->width : ((XfwfRowsWidget)child)->core.width;
    newht = request->request_mode & CWHeight ?
      request->height : ((XfwfRowsWidget)child)->core.height;
    newbd = request->request_mode & CWBorderWidth
	? request->border_width : ((XfwfRowsWidget)child)->core.border_width;

    if (newwd == ((XfwfRowsWidget)child)->core.width &&
	newht == ((XfwfRowsWidget)child)->core.height
	&& newbd == ((XfwfRowsWidget)child)->core.border_width)
      return XtGeometryNo;

    XtResizeWidget(child, newwd, newht, newbd);
    ((XfwfRowsWidgetClass)self->core.widget_class)->
      xfwfRows_class.layout(self);
    return XtGeometryDone;
}
}
#line 109 "Rows.w"
/*ARGSUSED*/static void resize(self)Widget self;
{
    ((XfwfRowsWidgetClass)self->core.widget_class)->
      xfwfRows_class.layout(self);
}
#line 119 "Rows.w"
/*ARGSUSED*/static Boolean  set_values(old,request,self,args,num_args)
Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
{
    Boolean need_layout = False;
    Boolean need_redisplay = False;

    if (((XfwfRowsWidget)old)->xfwfRows.alignTop !=
	((XfwfRowsWidget)self)->xfwfRows.alignTop) {
	need_layout = True;
    }
    if (need_layout) {
	((XfwfRowsWidgetClass)self->core.widget_class)->
	  xfwfRows_class.layout(self);
	need_redisplay = True;
    }
    return need_redisplay;
}
