//===============================================================================
// Xe UI toolkit
//
// XeTextField
//  Public header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2023-Jun-11 16:03:40
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeTextField_h
#define _XeTextField_h

#include <Xe/Primitive.h>

#include <EUndo.h>

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

extern XeWidgetClass*                 XeTextField_class;
typedef struct _XeTextFieldClassRec*  XeTextFieldClass;
typedef struct _XeTextFieldRec*       XeTextField;


enum { XeMULTI_LINE_EDIT, XeSINGLE_LINE_EDIT };

typedef struct
{
	XeCallbackStructCore;
	uint32_t  Modifiers;
} XeTextCallbackStruct;


// Text directions (for search)
//
typedef enum { XeTEXT_FORWARD, XeTEXT_BACKWARD } XeTextDirection;

typedef Atom	XeTextFormat;

#define XeFormat8_BIT   ((XeTextFormat)XA_STRING)   // 31
#define XeFormat16_BIT  ((XeTextFormat)2)  // They mean XA_SECONDARY ?
#define XeFormatWCHAR   ((XeTextFormat)3)

typedef enum
{
	XeSELECT_POSITION,
	XeSELECT_WHITESPACE,
	XeSELECT_WORD,
	XeSELECT_LINE,
	XeSELECT_ALL,
	XeSELECT_PARAGRAPH,
	XeSELECT_OUT_LINE
} XeTextScanType;


typedef struct
{
	const void*   Ptr;
	int           Length;
	XeTextFormat  Format;
} XeTextBlockRec;


typedef struct
{
	XeCallbackStructCore;
	EBool            DoIt;
	XeTextPosition   CurrInsert, NewInsert;
	XeTextPosition   StartPos, EndPos;
	XeTextBlockRec*  Text;
} XeTextVerifyCallbackStruct;



extern void      XeTextField_SetString(XeWidget PW, const char* PString, const EBool PNotify);
extern void      XeTextField_SetStringUTF8(XeWidget PW, const char* PString, const EBool PNotify);
extern void      XeTextField_SetStringW(XeWidget PW, const wchar_t* PString, const EBool PNotify);

extern char*     XeTextField_GetString(XeWidget PW);
extern char*     XeTextField_GetStringUTF8(XeWidget PW);
extern wchar_t*  XeTextField_GetStringW(XeWidget PW);

extern void      XeTextField_Insert(XeWidget PW,  XeTextPosition PHere, char* PString);
extern void      XeTextField_Replace(XeWidget PW,  XeTextPosition PStart, XeTextPosition PEnd, char* PString);

extern void      XeTextField_ClearSelection(XeWidget PW, Time PTime);

extern void      XeTextField_SetSelection(XeWidget PW, XeTextPosition PStart, XeTextPosition PEnd, Time PTime);

extern XeTextPosition  XeTextField_GetLastPosition(XeWidget PW);

extern XeTextPosition  XeTextField_GetInsertionPosition(XeWidget PW);
extern void      XeTextField_SetInsertionPosition(XeWidget PW, XeTextPosition PPos);

extern void      XeTextField_SelectAll(XeWidget PW);


extern XeTranslations  XeStd_TextWidgetTransTable;


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

#endif // _XeTextField_h
