#ifndef _COBJLAYERFONT_H_
#define _COBJLAYERFONT_H_

#include "../x/Version.h"
#include "../x/scolplugin.h"
#include "../x/Objstr.h"
#include "Rect.h"
#include "layer.h"
#include <list>


#define DEBUG_FONT 0



class CObjLayerFont
{
private:
	PtrObjFont	CLFfont;
	HDC			CLFdc;
	HFONT		CLFoldfont;
	int			CLFnb;		// nombre d'objets referencant cette fonte



public:
	int			CLFaverageCharHeight;
	int			CLFaverageCharWidth;
	int			CLFdescent;
	int			CLFascent;
	int			CLFcharWidths[255];
	int			CLFtabStop;
	int			CLFid;
	
	CObjLayerFont(PtrObjFont font);
	virtual ~CObjLayerFont();
	
	int GetStringWidth(char *txt,int nCount,int usetab);
	int GetStringHeight(char *txt,int nCount,int usetab);

	int CopyStringOnLayer(Layer *layer,int x,int y,char *txt,int nCount,int color,int transp,int usetab,int multi);
	int CopyStringOnRectLayer(Layer *layer,Rect2D rect,int Flags,char *txt,int nCount,int color,int transp,int usetab);

	// fonction ajoutant et enlevant une reference sur cette fonte par un objet
	int addRef();
	int remRef();
};



class CObjLayerFontService
{
private:
	CObjLayerFont**		CLFlayerFont;				// liste des layers
	int					CLFnblayerFont;				// nbre de layers refrencés

	int				findLayerFont(int id);
	void			addFont(CObjLayerFont* font);
	void			delFont(CObjLayerFont* font);
public:

	CObjLayerFontService();
	virtual ~CObjLayerFontService();

	// fonction renvoyant le layer font crée ou deja referencé
	CObjLayerFont * getLayerFont(PtrObjFont font);

	// fonction detruisant le layer font
	int				delLayerFont(CObjLayerFont * layer);
};

extern CObjLayerFontService Lib2dFontService;

#endif