//================================================================================
// Xe UI toolkit
//
// Composite Widget:  the base class for all Widgets with children.
// Constraint Widget: composite Widget with geometry management
// Private header file.
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-Jul-11 01:28:04
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeCompositeP_h
#define _XeCompositeP_h

#include <Xe/XeP.h>
#include <Xe/Composite.h>

typedef void  (*XeChangeManagedFunc)(XeWidget PW);
typedef void  (*XeInsertChildFunc)(XeWidget PW, const int PInsertAtIndex);

#define XeCompositeClassCore\
	XeCoreClassCore;\
	XeGeometryHandler    GeometryManager;  /* Geometry manager for children        */\
	XeChangeManagedFunc  ChangeManaged;    /* Change the managed state of a child  */\
	XeInsertChildFunc    InsertChild;\
	XeWidgetFunc         DeleteChild


typedef struct _XeCompositeWidgetClass
{
	XeCompositeClassCore;
} _XeCompositeWidgetClass;


#define XeCompositeWidgetCore\
	XeWidgetCore;\
	EListA(, XeWidget, Children)       /* List of all Widget children                      */\

typedef struct _XeCompositeRec
{
	XeCompositeWidgetCore;
} XeCompositeRec;



externalref _XeCompositeWidgetClass  _XeCompositeWidget_class;


//
// Instance
//
typedef struct
{
	XeCompositeWidgetCore;
} XeConstraintWidgetRec;


typedef void  (*XeLayoutFunc)(XeWidget PW,  const int PSizeX, const int PSizeY);

//
// Class
//
typedef struct
{
	int              StructSize;       // Size of constraint record on each child Widget
	XeResource*      Resources;Cardinal  NResources;  // Constraint resource list
	XeInitFunc       Init;             // Constraint constructor
	XeWidgetFunc     Free;             // Constraint destructor
	XeSetValuesFunc  SetValues;        // Constraint SetValues method
	XeLayoutFunc     Layout;           // Lay out children and set their position and size in their constraint records (but not the Widget's position and size!)
} XeConstraintClassPart;


// Base of constraint information added to Widgets that are children of an XeConstraintWidget.
// This is common to all derived Constraint structs (for XeMatrix, XeMessageBox etc.).
//
#define XeConstraintCore\
	XeCoord2  Position;\
	XeCoord2  Size;\
	XeCoord2  SizeByParent;\
	XeCoord2  PreferredSize;\
	XeCoord2  ProposedSize    /* The compromise size for this child that the parent's GeometryManager returned with an XeGeometryALMOST. Includes Widget border, if any. */

typedef struct
{
	XeConstraintCore;
} XeConstraint;


typedef struct _XeConstraintClassRec
{
	XeCompositeClassCore;
	XeConstraintClassPart  Constraint;
} XeConstraintClassRec;



externalref XeConstraintClassRec     _XeConstraintWidget_class;
extern void              XeConstraint_ChildrenSetGeometry(XeCompositeWidget PEW, XeWidget PExceptThisChildW);
extern XeGeometryResult  Xe_DefaultGeometryManager(XeWidget PChildW, XeWidgetGeometry* PRequest, XeWidgetGeometry* PReply);

// Dummy functions for inheriting methods from superclasses
//
extern XeGeometryResult  XeInheritGeometryManager(XeWidget PChildW, XeWidgetGeometry* PRequest, XeWidgetGeometry* PReply);
extern void              XeInheritChangeManaged(XeWidget PW);
extern void              XeInheritInsertChild(XeWidget PW, const int PInsertAtIndex);
extern void              XeInheritDeleteChild(XeWidget PW);

extern XeCoord2          XeWidget_GetMargin(const XeWidget PW);

#endif // _XeCompositeP_h
