/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: html_parser.h,v 1.5 1998/09/09 21:10:34 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_PARSER_H
#define HTML_PARSER_H

#include <stdlib.h>
#include "html_box.h"
#include "html_drawspec.h"
#include "html_stack.h"
#include "../../include/callback.h"

class html_parser
{
	class html_box			*master;
	class html_stack		*stack;
	unsigned int			linemode:1,
							inbody:1;

	class html_valuestack	*fontstylestack;
	class html_valuestack	*fontsizestack;
	class html_valuestack	*olicountstack;

	int		value_blockquote_offset;
	int		value_li_offset;
	int		value_dd_offset;
	void tag_dl_restore(void);

	char *para_value;
	char *parameter(char *buf,char *name,int hasvalue=0);
	int  enti_size;
	char *enti_string;
	char *entity(char *,int size=0);

	void newtag(char *,int size=0);

	callback	cb;	
public:
	html_parser(char *);
	~html_parser();

	void Create(html_drawspec *parent);
	void Free(void);
	void Calc(int x,int y,int w,int &real_w,int &real_h);
	void Draw(int x,int y,int w,int &real_w,int &real_h);
	void Move(int x,int y,int w,int &real_w,int &real_h);	// w must be same as in Draw()

	void Callback(callable *,void (callable::*)(char *));
	void Event(class html_box *);
};

#endif
