#ifndef _COBJECTSLIDEBAR_H_
#define _COBJECTSLIDEBAR_H_

#include "CObjectBase.h"
#include "CObjLink.h"
#include "../x/Objstr.h"

#define SLB_MASK	 (1<<(LAST_OBJ_FLAG+1))
#define SLB_DISABLE  (1<<(LAST_OBJ_FLAG+2))
#define SLB_ROLLOVER (1<<(LAST_OBJ_FLAG+3))
#define SLB_GAUGE    (1<<(LAST_OBJ_FLAG+4))

#define SLB_HORIZONTAL 0
#define SLB_VERTICAL   1

#define TIMER_FREQUENCY 100

#define NO_TIMER -1

class CObjectSlideBar:public CObjectBase
{
private:
	int SLBstate;

	int min, max, value, range_min, range_max;
	int offset1, offset2, offset3;
	int direction;  // SLB_VERTICAL ou SLB_HORIZONTAL
	int step;
	int mouseCursorDecal;
	int realObjH, realObjW;
	int reverse;   // par defaut SLB_VERTICAL a le min en haut et SLB_HORIZONTAL le min a gauche, l'inverse si reverse = 1
	int valueStep; // ecart en pixels entre 2 valeurs: depend de min et max

	int timerID;

	void	setLayerDecal( Layer *, int );
	void	setCursorLayerDecal( Layer *, int );
	int		getCursorPosition();
	int		getCursorMiddlePosition();
	int		GetIndexBitmap( int );
	int		GetIndexMask();
	Rect2D	getRect( int, int, int );
	Rect2D	getIntersectedRect( int, int, int, Rect2D );
	int		IsMouseOnCursor( int, int, int );

	int CursorMoveOnBody(int x,int y,int keyFlags, int p_tab,int redrawobject);

	// pour les liens entre objets
	int send_notification_value( int, int, int, int );
	int send_notification_max( int, int, int, int );
	int send_notification_min( int, int, int, int );

public:
	CObjectSlideBar(container *,Layer *,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int);
	~CObjectSlideBar();
	
	// les methodes virtuelles
	int IsMouseOnObject(int,int,int);
	int CursorMove(int,int,int,int,int);
	int CursorMoveIn(int,int,int,int,int);
	int CursorMoveInWithBtnPushed(int,int,int,int,int);
	int CursorMoveOut(int,int,int,int,int);
	int CursorMoveOutWithBtnPushed(int,int,int,int,int);
	int CursorMoveOutsideWithBtnPushed(int,int,int,int,int);
	int ClickIn(int,int,int,int,int,int);
	int UnClickIn(int,int,int,int,int,int);
	int ClickOut(int,int,int,int,int,int);
	int UnClickOut(int,int,int,int,int,int);
	int DblClickIn(int,int,int,int,int,int);
	int MouseWheel(int,int,int,int,int,int);
	int KeyUp(UINT,int,UINT,int);
	int KeyDown(UINT,int,int,UINT,int);
	int SetFocus(int,int,int);
	int KillFocus(int,int);

	int Timer(int);

	int GetValue();
	int GetMax();
	int GetMin();
	int SetValue( int newValue, int notifylinks, int redrawobject );
	int SetMax( int newValue, int scalerange, int notifylinks, int redrawobject );
	int SetMin( int newValue, int scalerange, int notifylinks, int redrawobject );
	int SetRangeMax( int newValue );
	int SetRangeMin( int newValue );
	void SetStep( int newValue );

	Layer *GetLayer(mmachine m,int p_tab);
	Layer *GetLayerPart(mmachine m,Rect2D *area2redraw,int p_tab);
	
	int DestroyAllLayers();
	int ResizeLayer(int,int,int);

	// pour les liens entre objets
	int handle(CObjMessage* msg);
	int supports( int type );

};

int CreateLinkedScrollBar(mmachine,int,int,int,int);

// fonctions scol
int _CRcompSlideBar( mmachine m );
int _DScompSlideBar( mmachine m );
int _SETcompSlideBarValue( mmachine m );
int _SETcompSlideBarMax( mmachine m );
int _SETcompSlideBarMin( mmachine m );
int _SETcompSlideBarStep( mmachine m );
int _CONVERTcompSlideBarToObjNode(mmachine m);
int _CBcompSlideBarValue(mmachine m);
int _SETcompSlideBarRange( mmachine m );
int _CBcompSlideBarResizeResource(mmachine m);
int _CBcompSlideBarResize(mmachine m);

#endif