#ifndef _LAYER_H_
#define _LAYER_H_

#include "../x/Version.h"
#include "../x/scolplugin.h"
#include "../x/Objstr.h"
#include "Macro.h"
#include "Rect.h"



#define DEBUG_LAYER 0
#define DEBUG_ALLOCATED 0

class Layer
{
private:
#if DEBUG_LAYER
	static int ctr;
#endif
#if DEBUG_ALLOCATED	
	static int size_allocated;
	static int nb_obj;
#endif
	Layer *			Next;			// layer coming upon this layer if any, NULL otherwise
	short int		allocated;		// need to allocate structures and also to destroy them after

public:
	PtrObjBitmap RGBbitmap;
	PtrObjBitmap AlphaBitmap;
	int          Transparency;
	Rect2D		 sourceRect;        // clipping in source bitmap
	int			 Xdecal;			// decalage du layer par rapport au pt superieur gauche de l'objet
	int			 Ydecal;			// en faire un Point2D ?
	
	//$BLG - v5.01: Add
	int	BLG_Type;

	Layer ( PtrObjBitmap rgb, PtrObjBitmap alpha, int transparency );
	Layer ( int width, int height, int transparency, int withalpha );
	//$BLG - v5.01: new constructor
	Layer (int width, int height, PtrObjBitmap B);
	virtual ~Layer ();

	void fillLayer ( int color );
	void copyLayer ( Layer *source );

	
	void fillPartLayer ( int color ,Rect2D rect);
	void copyPartLayer ( Layer *source, Rect2D rect);
	
	void fillAlphaLayer (unsigned char coefficiency);
	void fillPartAlphaLayer(unsigned char coefficiency,Rect2D rect);
	
	void clearAlphaLayer(Rect2D rect);
	
	void drawLine(int x1,int y1,int x2,int y2,int mode,int taille,int color);

	// list
	Layer *nextLayer( );
	Layer *addLayer( Layer *next ); // permet de concatener 2 listes de layers
	Layer *removeNext();
	Layer *removeAllNext();
	Layer *nulifyAllNext();
	Layer *nulifyNext();
};

void deleteLayers( Layer *first );
int  dsAlphaBitmap(mmachine m,int abmp);

#endif
