//===============================================================================
// Xe UI toolkit
//
// XeScrollBar
//  Private header file
//
// AUTHOR:  Gabor Nagy
// DATE:    2026-May-28 22:28:44
//
// Copyright (C) 1996-2026 by Gabor Nagy. All rights reserved.
//===============================================================================
#ifndef _XeScrollBarP_h
#define _XeScrollBarP_h

#include <Xe/ManagerP.h>
#include <Xe/ScrollBar.h>

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

#define XeScrollBarBACKGROUND_IMAGE_FULL_LENGTH  1

//================================
// Class definition
//================================
// Class part
//================================
typedef struct _XeScrollBarClassPart
{
	EPointer  Extension;
} XeScrollBarClassPart;


//================================
// Class record
//================================
typedef struct _XeScrollBarClassRec
{
	XeCompositeClassCore;
	XeConstraintClassPart  Constraint;
	XeManagerClassPart     Manager;
	XeScrollBarClassPart   ScrollBar;
} XeScrollBarClassRec;

extern XeScrollBarClassRec  _XeScrollBarWidget_class;


//================================
// Instance definition
//================================
// Instance part
//================================
typedef struct
{
// Resources
//
	XeColor         ActiveColor, TroughColor, SliderColor, SliderActiveColor, SliderBorderColor, ButtonColor;

	int             IMinimum, IMaximum,
	                IArrowIncrement,                 // Increment when arrow pressed
	                IScrollWheelIncrement,           // Increment per scroll-wheel click
	                IScrollWheelSmoothSteps,         // Number of intermediate scroll steps to use when we receive a scroll-wheel event
	                IValue, IAlignTo, IAlignOffset;

	XeCallbackList  ValueChangedCallback;

	XeCoord2        MarginSize, SliderPixmapSize;
	XeCoordinate    ScaleWidthInPixels, ScaleShadowThickness,
	                SliderMinimumLengthInPixels, SliderLengthInPixels;

	int             SliderLength, ScaleLengthInPixels, SliderBorderWidth,
	                ScaleWOffset;     // (SliderWidthInPixels - ScaleWidthInPixels) / 2. Used for centering the trough.
	int             SliderWOffset;    // Offset of the slider from the edge of the scale area (perpendicular to the scale orientation)

	int             SmoothScrollSteps;
	uint16_t        ShadowType;

	uint8_t         Orientation, ButtonPlacement, ScaleType;
	EBool           CreateScale, ScaleGroove, CreateUpButton, CreateDownButton;
	EBool           Editable;


// Read-only resources
//
	XeWidget        UpButtonW, DownButtonW;


// Set by a Widget being scrolled (e.g. XeText)
//
	int             (*PixelsToNextPage)(XeWidget LW, const int LDirection);
	XeWidget        ScrolledWidget;


// Private variables
//
	XeIntervalId    SmoothScrollTimerId;

	int             SmoothValueTarget, SmoothSubStep;
	int             PointerLocation;                   // Indicates whether the pointer is outside, on the scale area or on the slider
	XeCoord2        ScalePos, SliderPos, ResetButtonPos;
	XeCoordinate    SliderDragOffset,
	                SliderWidthInPixels, SliderPositionInPixels;

	EpImage*        ScaleImage;
	EpImage*        SliderImage;

	XeTile          ScaleTile, SliderTile;

	int             ScaleAreaWidth, SliderPreferedLength;

	uint32_t        IScrollWheelIncrementSet : 1,
	                DragMode : 8;

	int             SetButtonSizeX, SetButtonSizeY;

	EBool           ShowNonmoveableSlider;  // If TRUE, show the slider, even when it's not moveable (the full window is visible)
} XeScrollBarPart;


//================================
// Instance record
//================================
typedef struct _XeScrollBarRec
{
	XeCompositeWidgetCore;

	XeBasePart       Base;
	XeManagerPart    Manager;
	XeScrollBarPart  ScrollBar;
} XeScrollBarRec;


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

#endif // _XeScrollBarP_h
