//===============================================================================
// Xe UI toolkit
//
// XeMenu
//  Public header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2024-Aug-09 22:15:07
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeMenuWidget_h
#define _XeMenuWidget_h

#include <Xe/Manager.h>

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


#define XeMAX_MENULEVELS     16


// Menu widget types
//
enum
{
	XeMENU_BAR = 0,
	XeMENU_PANE,
	XeOPTION_MENU,
	XeOPTION_MENU_PANE
};

typedef struct
{
	char*           Name;
	EPointer        Value;
	XeCallbackFunc  Callback;
	EPointer        ClientData;
	EpCImage*       Icon;
} XeOptionMenuRec;

typedef struct XeMenuRec_S      XeMenuRec;
typedef struct XeMenuRootRec_S  XeMenuRootRec;

struct XeMenuRec_S
{
	XeMenuRootRec*  MenuBar;
	XeMenuRec*      Parent;
	XeMenuRec*      Sibling;
	XeMenuRec*      Child;
	int             CastShadowOffset;
	XeWidget        CascadeBW, MenuPaneW;
};



// XeMenuBar_New flags
//
#define	XeMenuBarSHADOWS                        0x01
#define	XeMenuBarVERTICAL                       0x02
#define XeMenuBarSHADED_MENUBAR_CASCADEBUTTONS  0x04

// XeMenu_New/XeMenu_NewVa flags
//
#define	EmNORMAL             0x00
#define	EmRADIO              0x01  // Menu has RadioBehavior
#define	EmCASCADE_WIDGET     0x01  // Force the menu's CascadeButtons to be CascadeButtonWidget (the default is xmCascadeButtonGadget)
#define	EmSHOW_ARROW         0x02  // Show menu posting direction with an arrow
#define	EmMENUPOST_ON_LEFT   0x08  // Where to post the menu relative to the CascadeButton
#define	EmMENUPOST_ON_RIGHT  0x10
#define	EmMENUPOST_ON_ABOVE  0x20
#define	EmMENUPOST_ON_BELOW  0x40

#define EmMENU_POST_DIRECTION  (EmMENUPOST_ON_LEFT | EmMENUPOST_ON_RIGHT | EmMENUPOST_ON_ABOVE | EmMENUPOST_ON_BELOW)


#define	EguiMENUBAR_LEVEL  0


//enum { EmCASTSHADOW_XSHAPE = 0, EmCASTSHADOW_SGITRUECOLOR };
//enum { Em_GADGET = 0, Em_WIDGET };
//enum { Em_PUSHBUTTON = 0, Em_TOGGLEBUTTON };


typedef struct
{
	XeCallbackStructCore;

// XeOptionMenuCallbackStruct part
//
	int       Index, NumOfItems;
	EPointer  Value;
} XeOptionMenuCallbackStruct;


//
// Xe/Menu.c
//
extern XeWidgetClass*            XeMenuWidget_class;
typedef struct _XeMenuClassRec*  XeMenuWidgetClass;
typedef struct _XeMenuWRec*      XeMenuWidget;

extern XeWidget  XePulldownMenu_New(XeWidget PParentW, const char* PName,  EArg* Args, const int ArgCnt);

extern XeWidget  XeOptionMenu_New(XeWidget PParentW, const char* PName, XeWidget* PMenuPaneRet,  EArg* PArgs, int PArgCnt);

extern XeWidget	 XeMenu_PaneGetItemByNumber(XeWidget PW, const int PNumber);

extern XeWidget	 XeOptionMenu_GetItemByNumber(XeWidget PW, const int PNumber);

extern XeWidget	 XeOptionMenu_GetPane(XeWidget PW);
extern void      XeOptionMenu_SetOptionByNumber(XeWidget PMenuW, const int POptionNumber, const EBool PForceRedrawCascadeButton);
extern void      XeOptionMenu_SetOptionByValue(XeWidget PMenuW, const EPointer POptionValue, const EBool PForceRedrawCascadeButton);

extern XeWidget	 XeMenu_GetChild(XeWidget PW, const int PChild);

//
// Xe/Menu.c
//
extern XeMenuRec*    XeMenuBar_New(const char* PName, XeWidget PParentW, const int PFlags, XeFontList PFontLst);

extern XeMenuRec*    XePopupMenu_RNew(XeWidget PParentW, const int PFlags, XeFontList PFontLst);
extern void          XeMenu_PopUp(XeMenuRec* PMenu,  const int PX, const int PY);

extern XeWidget      XePopupMenu_New(XeWidget PParentW, const char* PName,  EArg* PArgs, const int PArgCnt);

extern XeMenuRec*  XeMenu_New(XeMenuRec* PParentMenu, const char* PName, const char PMnemonic, const int PFlags, const int PCastShadowOffset);
extern XeMenuRec*  XeMenu_NewVa(XeMenuRec* PParentMenu, const char* PName, const int PFlags, ...);


extern XeWidget    XeMenu_SeparatorNew(XeMenuRec* PMenu);
extern XeWidget    XeMenu_PushButtonNew(XeMenuRec* PMenu, const char* PName, const char PMnemonic, const char* PAccelerator, const char* PAcceleratorText, const EBool PCreateOptionsButton, XeCallbackFunc PCallbackID, EPointer PClientData);
extern XeWidget    XeMenu_ToggleButtonNew(XeMenuRec* PMenu, const char* PName, const EBool PDefault, const char PMnemonic, const char* PAccelerator, const char* PAcceleratorText,  const uint8_t PSecondaryButtonType,  XeCallbackFunc PCallbackID, EPointer PClientData);
extern XeWidget    XeMenu_LabelNew(XeMenuRec* PMenu, const char* PName);

extern XeWidget    XeMenuBar_SeparatorNew(XeMenuRec* PMenu);
extern XeWidget    XeMenuBar_PushButtonNew(XeMenuRec* PMenuRoot, const char* PName, const char PMnemonic, const char* PAccelerator, const char* PAcceleratorText, XeCallbackFunc PCallbackID, EPointer PClientData);
extern XeWidget    Xe_BarPushButtonNewVa(XeMenuRec* PMenu, const char* PName, const char PMnemonic, const char* PAccelerator, const char* PAcceleratorText, XeCallbackFunc PCallbackID, EPointer PClientData, ...);
extern XeWidget    XeMenuBar_ToggleButtonNew(XeMenuRootRec* PMenuRoot, XeWidget PParentW, const char* PName, const EBool PDefault, const char PMnemonic, const char* PAccelerator, const char* PAcceleratorText, XeCallbackFunc PCallbackID, EPointer PClientData);

extern const char*  XeOptionMenu_ButtonValueResource;

extern XeWidget    XeOptionMenu_CreateAndInit(XeWidget PParentW, XeWidget* PMenuWRet, XeOptionMenuRec* POptions, const int PNumOfItems, EPointer PValue, const char* PLabel, XeCallbackFunc PCallback, EPointer PClientData,  EArg* PArgs, int PArgCnt);
extern XeWidget    XeOptionMenu_CreateAndInitManaged(XeWidget PParentW, XeWidget* PMenuWRet,  XeOptionMenuRec* POptions, const int PNumOfItems,  EPointer PValue, const char* PLabel,  XeCallbackFunc PCallback, EPointer PClientData,  EArg* PArgs, int PArgCnt);

extern void      XeMenuBar_Free(XeMenuRec* PMenuBar);

extern XeWidget  Xe_RealizeCachedMenuItem(XeMenuRec* PMenu, XeDWidget PItem, XeWidget PBeforeW);

extern void      XeMenus_Free(void);

extern EBool     XeShell_IsMenuPane(XeWidget PShellW);


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

#endif // _XeMenuWidget_h
