//===============================================================================
// Xe UI toolkit
//
// Dialog box helper module
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-Apr-11 19:24:22
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeDialog_h
#define _XeDialog_h

#include <Xe/Manager.h>

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

enum
{
	XeDIALOG_ERROR,
	XeDIALOG_INFORMATION,
	XeDIALOG_MESSAGE,
	XeDIALOG_QUESTION,
	XeDIALOG_TEMPLATE,
	XeDIALOG_NETWORK_CONNECTION,
	XeDIALOG_WORKING,
	XeDIALOG_WARNING,
	XeDIALOG_PROMPT,
	XeDIALOG_SELECTION,
	XeDIALOG_FILESELECTION
};


enum
{
	XePLACE_NONE = 0,
	XePLACE_TOP,
	XePLACE_ABOVE_FILENAME,
	XePLACE_BOTTOM
};


enum
{
	XeMOVE_TO_TRASH = 1,
	XeASK_AND_DELETE,
	XeDELETE
};


#define XeCURSOR_KEYS     0x0001
#define XePRIMARY_CLICK   0x0002
#define XePOINTER_MOTION  0x0004


#define XeDialogCore\
	int               Type;\
	XeWidget          MessageBoxW, WorkAreaW;\
	XeWidget          ImageLabelW, MessageLabelW, MessageLabelFrameW;\
	EList(, XeWidget, Buttons);\
	EguiCallbackList  OkCallback, CancelCallback

typedef struct
{
	XeDialogCore;
} XeDialog;


typedef struct
{
	XeWidget        ShowBitmapFontsW, AntiAliasingW, StatusLabelW, ListsMatrixW, FontFamilyListW, FontStyleListW, FontSizeListW, SampleLabelW;

	XeFontList      SampleFontList;  // Used for drawing the Font sample text
	XeCallbackFunc  CallbackFunc;EPointer CallbackClientData;

	uint8_t         Orientation;
	EBool           BitmapFontsEnabled, BitmapFontsShow,
	                ShowFontSizes, AntiAliasing, ShowFontsWithNoLatinGlyphs;
	int             FontFamilyNameSizeY;

	uint8_t         UserSetAntiAliasing;  // EBoolUNSPECIFIED, TRUE, or FALSE. If TRUE, the user turned on anti-aliasing. If FALSE, he/she turned it off, so we should not try to use AA again when available, after we had to turn it off because a Font was selected that did not support AA.

	EList(, XeFontFamily*, DisplayedFontFamilies);

	const XeFontFamily*  CurrentFontFamily;
	XeFontStyleFlags     CurrentFontStyle;
	XeFont*              CurrentFont;
	float                CurrentFontSize;
} XeFontSelectorPanel;



enum
{
	XeCR_FONTFAMILY_SELECTED = 1,
	XeCR_FONTSTYLE_SELECTED,
	XeCR_FONTSIZE_SELECTED
};

typedef struct
{
	XeCallbackStructCore;
	int    ItemIndex;
	EBool  DoubleClick;
} XeFontSelectionCallbackStruct;


#define MAX_MESSAGENUM        16  // Max number of separate message dialogs
#define	MAX_NUM_OF_DIALOGBUTTONS  8


extern void    XeDialogs_Init(XeApp PXeApp, XeWidget PParentW,
 const EcRGBAiColor* PBackgroundColor, const EcRGBAiColor* PListBackgroundColor, const EcRGBAiColor* PForegroundColor,
 const EcRGBAiColor* PTextFieldBackgroundColor, const EcRGBAiColor* PTextFieldForegroundColor, const EcRGBAiColor* PTextFieldFocusColor,
 const EcRGBAiColor* PHighlightColor);

extern void    XeDialogs_SetColors(
 const EcRGBAiColor* PBackgroundColor, const EcRGBAiColor* PListBackgroundColor, const EcRGBAiColor* PForegroundColor,
 const EcRGBAiColor* PTextFieldBackgroundColor, const EcRGBAiColor* PTextFieldForegroundColor, const EcRGBAiColor* PTextFieldFocusColor,
 const EcRGBAiColor* PHighlightColor);

extern void    XeDialogs_Free(void);


extern XeExtensionClass     XeDialog_class;


extern XeWidget  XeDialog_New(const int PType, const char* PName, XeWidget PParentW,  const EArg* PArgList, const int PArgCount);
extern XeWidget  XeDialog_NewVa(const int PType, const char* PName, XeWidget PParentW, ...);

extern XeWidget  Xe_TopDialogNew(XeApp PApp, const int PType, const char* PName,  const EArg* PArgList, const int PArgCount);
extern XeWidget  Xe_TopDialogNewVa(XeApp PApp, const int PType, const char* PName, XeWidget PParentW, ...);

extern XeWidget  XeDialog_GetChild(XeWidget PDialogW, const int PChild);
extern void      XeDialog_SetValuesVa(XeWidget PDialogW, ...);

extern XeWidget  XeDialog_AddButton(const char* PName, XeWidgetClass* PClass, XeWidget PParentW, const EBool PDefault);

extern void    Xe_ErrorDisplayVa(XeWidget PParentW, const char* PTitle, const char* PMessage, XeCallbackFunc PCallback, ...);

extern void    Xe_QuestionDisplayVa(XeWidget PParentW, const char* PTitle, const char* PQuestion, XeCallbackFunc PCallback, ...);
extern void    Xe_QuestionUndisplay(void);

extern void    Xe_QuestionYesNo(XeWidget PParentW, const char* PTitle,  const char* PQuestion, const char* PYesText, const char* PNoText,  XeCallbackFunc PCallback, XeWidget PuCenterToWidget);

extern void    Xe_MessageDisplayVa(XeWidget PParentW, const char* PTitle, const char* PMessage, XeCallbackFunc PCallback, ...);
extern void    Xe_MessageDisplay(void);

extern void    Xe_ErrorDisplay(XeWidget PParentW, const char* PTitle, const XeString PXeStr);

extern XeWidget  Xe_SingleWorkingMessageDisplayVa(XeWidget PParentW, const char* PMessage, ...);

extern XeWidget  Xe_ProgressMessageDisplayVa(XeWidget PParentW, const int PWMessageID, const char* PMessage, ...);
extern void      XeUndisplayMessageWithTimer(unsigned long PMSecs, void (*PFunction)(void));

extern void    XeDialog_GetValuesVa(XeWidget PDialogW, ...);

extern void    XeStdSetFolderButtonArgs(const XeCoordinate PMarginLeft, const XeCoordinate PMarginRight,  const XeCoordinate PMarginTop, const XeCoordinate PMarginBottom,  EArg* PArgs, int* PArgCnt);


// ConnectionDialog
//
extern void    Xe_HostListRefresh(XeWidget PW);
extern void    Xe_HostListSetFromString(char* PString);


// XeFontSelectorPanel
//
extern int          XeFontSelectorPanel_LoadFonts(XeFontSelectorPanel* PPanel, XeDisplay* PDisplay);

extern XeFontSize*  XeFontSelectorPanel_CurrentFontSize(XeFontSelectorPanel* PPanel);
extern void         XeFontSelectorPanel_SetFontFaimly(XeFontSelectorPanel* PPanel, const XeFontFamily* PFontFamily);
extern int          XeFontSelectorPanel_New(XeFontSelectorPanel* PPanel, XeWidget PParentW,  XeCallbackFunc PCallbackFunc, EPointer PCallbackClientData,  const EArg* PArgs, const int PNArgs);
extern void         XeFontSelectorPanel_Free(XeFontSelectorPanel* PPanel);
extern void         XeFontSelectorPanel_Update(XeFontSelectorPanel* PPanel, XeFont* PFont, XeFontSize* PFontSize);

extern XeWidget     XeFontSelectionDialog_New(XeFontSelectorPanel* PPanel, const char* PTitle, XeWidget PParentW,  XeCallbackFunc PCallbackFunc, EPointer PCallbackData,  const EBool PBitmapFontsShow);
extern int          XeFontSelectionDialog_LoadFonts(XeFontSelectorPanel* PPanel, const char* PFontCacheFileName);

extern void     XeFontSelectorPanel_StyleListUpdate(XeFontSelectorPanel* PPanel);
extern int      XeFontSelectorPanel_FaimlyListUpdate(XeFontSelectorPanel* PFontSelectionPanel, const EBool PShowBitmapFonts, const EBool PRedrawSamples);
extern void     XeFontSelectorPanel_SizeListUpdate(XeFontSelectorPanel* PPanel);

extern XeFont*  XeFont_ByFamilyAndStyle(XeDisplay* PDisplay, const char* PFamilyName, const char* PStyleName, const EBool PBitmapFonts);

extern void	    _XeEH_FocusBack(XeWidget PW, XeEvent* PEvent, EPointer PClientData, EBool* PCDR);

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

#endif // _XeDialog_h
