/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: html_item.h,v 1.12 1998/08/14 20:57:58 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_ITEM_H
#define HTML_ITEM_H

#include <stdlib.h>
#include "html_box.h"
#include "html_drawspec.h"
#include "../../include/strbuf.h"

class html_item
{
	friend class html_box;
	class html_item		*next;

	FONTSTYLE		fontstyle;
	FONTSIZE		fontsize;
	enum ADJUST		adjust;
	Xcl_strbuf		color;
	unsigned int	nowrap:1;

public:
	int 				x;
	int					y;
	int					width;
	int					height;
	unsigned int		free_width:1,
						finishline:1,
						finishfullline:1,
						hidden:1;

	class html_box		*box;

	html_item(void) : color()
	{
		next=NULL;
		x=0;
		y=0;
		width=0;
		height=0;
		free_width=0;
		finishline=0;
		finishfullline=0;
		box=NULL;
		hidden=0;
	};
	virtual ~html_item() { };

	virtual void CalcSize(void) { };	// set size
	virtual void CalcItem(void) { };	// work
	virtual void Create(class html_drawspec *parent) { };
	virtual void Move(void) { };
	virtual void Draw(int nosub=0) { };
	virtual void Free(void) { };
	virtual void Callback(void) { };
	virtual char *Mark(int x1,int y1,int x2,int y2,int nosub=0) { return NULL; };
	virtual void Unmark(int nosub) { };
};

class html_boxitem : public html_item
{
protected:
	class html_box	*mybox;
public:
	html_boxitem(class html_box *master);
	~html_boxitem();
};
class html_box2item : public html_item
{
protected:
	class html_box	*mybox;
public:
	void SetBox(class html_box *m);
	html_box2item(void);
	~html_box2item();
	void CalcSize(void);
	void CalcItem(void);
	void Create(html_drawspec *parent);
	void Move(void);
	void Draw(int nosub);
	void Free(void);
	char *Mark(int x1,int y1,int x2,int y2,int nosub=0);
	void Unmark(int nosub);
};
class html_boxenditem : public html_item
{
public:
	html_boxenditem(class html_box *master);
	~html_boxenditem();
};

class html_callbackitem : public html_item
{
protected:
	class html_parser *callback;
public:
	html_callbackitem(class html_parser *);
	~html_callbackitem();
	void CalcSize(void);
};

class html_textitem : public html_item
{
protected:
	char *text;
	char *mtext;
public:
	html_textitem(char *txt);
	html_textitem(char *txt,int size);
	~html_textitem();
	void CalcSize(void);
	void Draw(int nosub);
	char *Mark(int x1,int y1,int x2,int y2,int nosub=0);
	void Unmark(int nosub);
};

class html_spaceitem : public html_item
{
public:
	html_spaceitem(void);
	~html_spaceitem();
	void CalcSize(void);
	void Draw(int nosub);
	char *Mark(int x1,int y1,int x2,int y2,int nosub=0);
	void Unmark(int nosub);
};

class html_nextlineitem : public html_item
{
public:
	html_nextlineitem(void);
	~html_nextlineitem();
	void CalcSize(void);
	char *Mark(int x1,int y1,int x2,int y2,int nosub=0);
	void Unmark(int nosub);
};

class html_newlineitem : public html_item
{
public:
	html_newlineitem(void);
	~html_newlineitem();
	void CalcSize(void);
	char *Mark(int x1,int y1,int x2,int y2,int nosub=0);
	void Unmark(int nosub);
};

class html_newparagraphitem : public html_newlineitem
{
protected:
	int size;
public:
	html_newparagraphitem(void);
	~html_newparagraphitem();
	void CalcSize(void);
	char *Mark(int x1,int y1,int x2,int y2,int nosub=0);
	void Unmark(int nosub);
};

class html_offsetitem : public html_item
{
protected:
	int offset;
public:
	html_offsetitem(int val);
	~html_offsetitem();
	void CalcItem(void);
};

class html_adjustitem : public html_item
{
protected:
	enum ADJUST adj;
public:
	html_adjustitem(enum ADJUST a);
	~html_adjustitem();
	void CalcSize(void);
};

class html_fontstyleitem : public html_item
{
protected:
	FONTSTYLE fstyle;
public:
	html_fontstyleitem(FONTSTYLE f);
	~html_fontstyleitem();
	void CalcSize(void);
};

class html_fontsizeitem : public html_item
{
	FONTSIZE fsize;
public:
	html_fontsizeitem(FONTSIZE f);
	~html_fontsizeitem();
	void CalcSize(void);
};

class html_coloritem : public html_item
{
protected:
	char *col;
public:
	html_coloritem(char *c=NULL);
	~html_coloritem();
	void CalcSize(int);
};

class html_backcoloritem : public html_coloritem
{
public:
	html_backcoloritem(char *c);
	~html_backcoloritem();
	void Draw(int);
};

class html_bulletitem : public html_item
{
protected:
	int level;
public:
	html_bulletitem(int level);
	~html_bulletitem();
	void Draw(int);
};

class html_countitem : public html_item
{
protected:
	int number;
public:
	html_countitem(int number);
	~html_countitem();
	void Draw(int);
};

#endif
