//================================================================
// Xe UI toolkit
//
// Main public header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-May-21 01:09:14
//
// Copyright (C) 2014-2026 by Gabor Nagy. All rights reserved.
//================================================================
#ifndef _XeFSBox_h
#define _XeFSBox_h

#include <stdarg.h>

#include <EDir.h>

#include <Xe/XeTypes.h>


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

typedef int  XeFSDialogGrpID;

#define XeFSDialogGrpNONE  -2
#define XeFSDialogGrpNEW   -1

#define XeCR_FILENAME_CHANGED  0x01

typedef struct XeFileSelectionPanel_S  XeFileSelectionPanel;

typedef struct
{
	XeCallbackStructCore;
	char*   Path;
	EList(, char*, Paths);  // Used if the XeList in the FSBox has multi-select enabled
} XeFileSelectionBoxCallbackStruct;

typedef void (*XeFSBoxCallbackFunc)(XeFileSelectionPanel* PPanel, EPointer PClientData, XeFileSelectionBoxCallbackStruct* PCallData);

struct XeFileSelectionPanel_S
{
	XeWidget             ParentShellW;
	XeWidget             FileNameDialogW, MatrixW, LabelW, TextW, LoadW, SaveW;
	XeFSBoxCallbackFunc  CallbackFunc;EPointer  CallbackClientData;
	uint16_t             KeepFSBoxAfterOK:1, AbsolutePath:1, AutofillTextField:1, FSBoxMultiSelect:1;
};


#define XeFSPanelCREATE_HMATRIX         0x01
#define XeFSPanelLABEL_IS_TOGGLEBUTTON  0x02
#define XeFSPanelCREATE_TEXTFIELD       0x04
#define XeFSPanelAUTOFILL_TEXTFIELD     0x08
#define XeFSPanelSAVE_BUTTON            0x10
#define XeFSPanelMULTISELECT            0x20

// FSPanel
//
extern XeFileSelectionPanel*  XeFileSelectionPanel_New(XeFileSelectionPanel* PPanel, const char* PName, XeWidget PParentW, XeWidget PParentShellW, const uint16_t PFlags,  const int PBlendLayersMax,  const XeCoordinate PSpacingLeft, const XeCoordinate PSpacingRight,  XeFSBoxCallbackFunc PCallbackFunc, EPointer PClientData);
extern void                   XeFileSelectionPanel_Update(XeFileSelectionPanel* PPanel, const char* PFileName);
extern void                   XeFileSelectionPanel_Free(XeFileSelectionPanel* PPanel, const EBool PFreeStruct);
extern XeWidget               XeFileSelectionDialog_New(XeWidget PParentW,  const EArg* PArgs, const int PArgCnt);
extern void                   XeFileSelectionDialog_Unmap(XeWidget PShellW);



// Procedure, provided by the application, to determine the type of a directory entry
//
typedef int  (*XeEntryIdFunc)(EDirEntry*, EDirEntry*);

extern void      XeFSBox_SetFilterList(XeWidget PDialogW, char* PFilterList);
extern char*     XeFSBox_GetFile(XeWidget PDialogW);
extern void      XeFSBox_SetFile(XeWidget PDialogW, char* PFileName);
extern EIndex    XeFSBox_GetSelectedFiles(XeWidget PDialogW, char*** PListRet, const EBool PFullPaths);

extern XeWidget  XeFSBox_GetChild(XeWidget PDialogW, const int PChild);
extern void      XeFSBox_DoSearch(XeWidget PDialogW, char* PPath);


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

#endif // _XeFSBox_h
