/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: html_drawspec.h,v 1.8 1998/10/14 22:09:02 schmitzj Exp $)
 * 
 * Copyright (C) 1998 Jürgen Schmitz
 *
 * HTML Parser system
 * (c) 1998 by Jürgen Schmitz - all rights reserved
 * THIS IS NOT GPL OR SOMETHING OTHER FREE LICENSE!!
 * it may only be used together with Xclasses!
 *-----------------------------------------------------------------------
 */

#ifndef HTML_DRAWSPEC_H
#define HTML_DRAWSPEC_H

#define FSY_NONE		0x00
#define FSY_FIXED		0x01
#define FSY_BOLD		0x02
#define FSY_ITALIC		0x04
#define FSY_UNDERLINE	0x08

typedef unsigned int FONTSTYLE;
typedef enum FONTSIZE {NORMAL,FONT1,FONT2,FONT3,FONT4,FONT5,FONT6} FONTSIZE;

class html_drawspec
{
protected:
	class html_box	*box;
public:
	html_drawspec(class html_box *b) { box=b; };
	virtual ~html_drawspec() {};

	virtual void Create(html_drawspec *parent,int x,int y,int width,int height) {};
	virtual void Move(int x,int y,int width,int height) {};
	virtual void Free(void) {};

	virtual void Cursor(int x,int y) {};
	virtual void Text(char *) {};
	virtual int  TextLength(char *) { return 0; };
	virtual int  TextHeight(char *) { return 0; };
	virtual void MarkedText(char *,int x1,int x2) { };
	virtual char *CutText(char *,int x1,int x2,int &size) { size=0; return NULL; };
	virtual void Font(FONTSTYLE style,enum FONTSIZE size) {};
	virtual void Color(char *) {};
	virtual void BackgroundColor(char *) {};
	virtual void Line(int x1,int y1,int x2,int y2) {};
	virtual void Callback(void) {};
};

html_drawspec *CreateDrawspec(class html_box *b);


// --- Xclasses ------------------------------------------------------

#include <Xclasses/callable.h>

class html_drawspecXclasses : public callable, public html_drawspec
{
	class hgadget 		*gg;
	class phtml_gadget 	*phg;
	unsigned int		owngg:1;

	int					x,y;
	int					bufsize;
	char				*txtbuf;
	char				*background;

	html_drawspecXclasses *parent;
	char *handleText(char *);
	void gghandler(class gadget *,int);
public:
	html_drawspecXclasses(class html_box *b);
	html_drawspecXclasses(class hgadget *,class phtml_gadget *);
	~html_drawspecXclasses();

	virtual void Create(html_drawspec *parent,int x,int y,int width,int height);
	virtual void Move(int x,int y,int width,int height);
	virtual void Free(void);

	virtual void Cursor(int x,int y);
	virtual void Text(char *);
	virtual int  TextLength(char *);
	virtual int  TextHeight(char *);
	virtual void MarkedText(char *,int x1,int x2);
	virtual char *CutText(char *,int x1,int x2,int &size);
	virtual void Font(FONTSTYLE font,enum FONTSIZE size);
	virtual void Color(char *);
	virtual void BackgroundColor(char *);
	virtual void Line(int x1,int y1,int x2,int y2);
	virtual void Callback(void);

// for hgadget:
	void Draw(void);
	void Position(int &x,int &y);
	char *Mark(int x1,int y1,int x2,int y2);
	void Unmark(void);
	class phtml_gadget *ParentHTMLGadget(void);
};

#endif
