//===============================================================================
// Xe UI toolkit
//
// XeMatrix
//  Private header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-May-28 22:29:45
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeMatrixP_h
#define _XeMatrixP_h

#include <Xe/ManagerP.h>
#include <Xe/Matrix.h>

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif


//================================
// Class definition
//================================
// Class part
//================================
typedef struct _XeMatrixClassPart
{
	EPointer  Extension;
} XeMatrixClassPart;


//================================
// Class record	
//================================
typedef struct _XeMatrixClassRec
{
	XeCompositeClassCore;
	XeConstraintClassPart  Constraint;
	XeManagerClassPart     Manager;
	XeMatrixClassPart      Matrix_class;
} XeMatrixClassRec;

extern XeMatrixClassRec  _XeMatrixWidget_class;




//================================
// Instance definition
//================================
// Instance part
//================================
typedef struct
{
// Resources
//
	int            SpacingX, SpacingY;
	uint16_t       ShadowType;
	uint16_t       Layout;
	unsigned int   NumOfColumns, NumOfRows;
	uint8_t        ChildrenAlignmentX, ChildrenAlignmentY;   // When no rows or columns can be resized, but the Matrix size is smaller or larger than needed by the children, align the row-column area this way.
	EBool          RadioBehavior, RadioAlwaysOne,
	               AdjustEntryX, AdjustEntryY,
	               AdjustEntrySizeX, AdjustEntrySizeY,
	               IncludeUnmanagedInPreferredSize;  // Include unmanaged children in _GetPreferredSize

// Private variables
//
	XeWidget       LabelW;      // Label
	XeWidget       WidgetWithHeader;  // If this Matrix is in the ClipWindow of a ScrolledWindow, this points to the ScrolledWindow (if there is a header)
                                    // This is for synchronizing the widths of the Matrix's columns and the widths of the header buttons.
} XeMatrixPart;


//========================================================================
// Constraint Resources and internal data.
// An instance of this struct is added to each child of an XeMatrix.
//========================================================================
typedef struct
{
	XeConstraintCore;

// Unlike Position and Size in XeConstraintCore, these fields include any SpacingLeft, SpacingRight, SpacingTop, SpacingBottom and Border.
// Those need to be subtracted when the child Widget's size is set. This simplifies the code, as Matrix is only concerned by the total size of a child, when computing the layout.
//
	EInt32_2  MPreferredSize;
	EInt32_2  MPosition;
	EInt32_2  MSize;

// Resources
//
	int       SpacingLeft, SpacingRight, SpacingTop, SpacingBottom;  // Spacing applied in addition to SpacingX and SpacingY of the XeMatrix
	char			AlignmentX, AlignmentY;                                // How to align child Widget within enclosing box, when SizeAdjustable* is FALSE
	EBool     SizeAdjustableX, SizeAdjustableY;
} XeMatrixConstraint;




//================================
// Instance record
//================================
typedef struct _XeMatrixRec
{
	XeCompositeWidgetCore;

	XeBasePart      Base;
	XeManagerPart   Manager;
	XeMatrixPart    Matrix;
} XeMatrixRec;


#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
} // Close scope of 'extern "C"' declaration
#endif

#endif  // _XeMatrixP_h
