//================================================================================
// Xe Widget set
//
// XeMenu
//  Private header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-Jul-14 12:15:36
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeMenuP_h
#define _XeMenuP_h

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

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


//========================================
// Class definition
//========================================

//================================
// Class part
//================================
typedef struct _XeMenuClassPart
{
	EPointer  extension;
} XeMenuClassPart;


//================================
// Class record
//================================
typedef struct _XeMenuClassRec
{
	XeCompositeClassCore;
	XeConstraintClassPart  Constraint;
	XeManagerClassPart     Manager;
	XeMenuClassPart        Menu;
} XeMenuClassRec;

extern XeMenuClassRec xeMenuClassRec;


//================================
// Constraint resources
//================================
typedef struct
{
	XeConstraintCore;

// Unlike Position and Size in XeConstraintCore, these include / account for Widget borders, to make the code simpler
//
	EInt32_2  MPreferredSize;
	EInt32_2  MPosition, 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;
} XeMenuConstraint;


//========================================
// Instance definition
//========================================

//================================
// Instance part
//================================
typedef struct
{
// Resources
//
	XeCoord2        Spacing;
	XeCoordinate    CastShadowWidth,
	                LeftObjectWidth;    // In a menu pane, a left arrow, a ToggleButton indicator or a PushButton MenuSubButton
	uint16_t        ShadowType;
	char            Type, Orientation;
	EBool           RadioBehavior, RadioAlwaysOne;

	XeWidget        CascadeButtonW;              // Back reference to the CascadeButton the Menu is attached to (via SubMenuID)
	XeWidget        LabelW,                      // Label
	                ActiveMenuButtonW;           // The active button Widget in the menu pane
	XeWidget        LastActiveMenuButtonW;       // The last active button widget in the menu pane (need it for 'cancelling a selection')
} XeMenuPart;


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

	XeBasePart     Base;
	XeManagerPart  Manager;
	XeMenuPart     Menu;
} XeMenuWRec;


extern void  _XePopUpMenuPane(XeWidget PMenuPaneW, XeWidget PCascadeBW,  const int PX, const int PY);
extern void  _XePopDownMenuPane(XeWidget PMenuPaneW);


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

#endif // _XeMenuP_h
