//========================================================================
// Xe UI toolkit
//
// XeList
// Private  header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2024-May-29 02:59:47
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//========================================================================
#ifndef _XeListP_h
#define _XeListP_h

#include <Xe/LabelP.h>
#include <Xe/List.h>

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


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

#define XeListClassCore\
	XePrimitiveClassCore

//================================
// Class record
//================================
typedef struct _XeListClassRec
{
	XeListClassCore;
} XeListClassRec;

extern XeListClassRec  _XeListWidget_class;


#ifdef EX11
typedef struct
{
	Pixmap    XPixmap;
	int16_t   SizeX, SizeY,  DrawnSizeX, DrawnSizeY;
	EBool     Uptodate;
} xeListPixmap;

typedef struct
{
	xeListPixmap  NormalPixmap;
	xeListPixmap  SelectedPixmap;
} xeListItemX11;
#endif

typedef struct
{
	XeLabel   Label;
	EpImage*  SelectedImage;
	EPointer  UserData;
	EBool     Selected;
#ifdef EX11
	xeListItemX11  X;
#endif
} xeListItem;


//================================
// Instance definition
//================================
// Instance part
//================================
typedef struct
{
// Resources
//
	XeColor         ForegroundColor, ItemHighlightColor;

	XeCoord2        Spacing,  ItemMarginSize;
	XeFontList      FontList;

	int             VisibleItemCount,
	                TopItemPosition;

	EBool           RecomputeSize;
	EBool           AlignStringBeginnings;  // If some entries have Images, or Images + Strings, align the beginning of all strings.
	                                        // You want to do this, in a file list, where some entries have icons, others don't, but
	                                        // you don't want to do this, if a string is used *instead* of an image (e.g. in a font list, you
	                                        // could not render the name of a font, with the font itself, so you fall back to a string, with the default font)

	XeCallbackList  ActivateCallback, BrowseSelectionCallback, DefaultActionCallback,
	                ExtendedSelectionCallback, MultipleSelectionCallback, SingleSelectionCallback, ItemsRebuildCallback;

	char            ShadowType;
	uint8_t         SelectionPolicy, StringAntiAliasing;

// Internal variables
//
	int             MaxItemSizeY;
	xeListItem*     ActiveItem;    // Last activated Item

	EList(, xeListItem*, Items);

	XeIntervalId    DoubleClickTimer;
	uint16_t        MultiSelectMode;int  MultiSelectAnchorItemIndex;
	EBool           MotionSelectEnabled, ReceivedResize;

#ifdef EX11
	GC              X_ListBackgroundGC;
#endif
} XeListPart;


//================================
// Instance record
//================================
typedef struct _XeListRec
{
	XeWidgetCore;
	XeBasePart       Base;
	XePrimitivePart  Primitive;
	XeListPart       List;
} XeListRec;


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

#endif // _XeListP_h
