/*****************************************************************************/
/* htmltext.cpp - 29/07/99 - By Christophe LOREK - CRYO-NETWORKS             */
/*                                                                           */
/* HTMLTEXT class                                                            */
/*                                                                           */
/* last modified on 12/08/99 By Christophe LOREK                             */
/*****************************************************************************/

#ifdef HTML_INCLUDE

#include "htmltext.h"


HTMLTEXT::HTMLTEXT(mmachine m,
									 int givensize,
									 int givenred,
									 int givengreen,
									 int givenblue,
									 char *givenface,
									 char *givenurl,
									 int givenalign,
									 int givenattributes,
									 char	*givenstring,
									 int givenflags)
{
	int				structbuf;
	int				nodetab;
	int				length;
	
	x = 0;
	y = 0;
	w = 0;
	textw = 0;
	h = 0;
	cx = 0;
	cy = 0;
	charheight = 0;

	string			= givenstring;			
	size				= givensize;
	red					= givenred;	
	green				= givengreen;	
	blue				= givenblue;	
	if (givenface != NULL)
	{
		length = strlen(givenface);
		face = (char*) malloc ((length+1)*sizeof(char));
		memcpy(face,givenface,length);
		face[length]='\0';
	}
	else
		face = NULL;
	if (givenurl != NULL)
	{
		length = strlen(givenurl);
		url = (char*) malloc ((length+1)*sizeof(char));
		memcpy(url,givenurl,length);
		url[length]='\0';
	}
	else
		url = NULL;
	align				= givenalign;
	attributes	= givenattributes;
	flags = givenflags;

// creating struct buffer
	structbuf = MMmalloc(m,NODESTRUCT_BUFSIZE,TYPEBUF);
	MMstore(m,structbuf,NODESTRUCT_STRUCT,(int)this);
	MMpush(m,1+(structbuf<<1));

// creating text node
	nodetab = MMmalloc(m,NODE_SIZE,TYPETAB);
	MMstore(m,nodetab,NODE_TYPE,NODE_TYPTEXT<<1);
	MMstore(m,nodetab,NODE_FATHER,NIL);
	MMstore(m,nodetab,NODE_OBJBITMAP,NIL);
	MMstore(m,nodetab,NODE_STRUCT,MMpull(m));
	MMstore(m,nodetab,NODE_BROTHER,MMpull(m));
	MMstore(m,nodetab,NODE_SON,MMpull(m));
	MMpush(m,1+(nodetab<<1));

//	DRAWtext();
}

HTMLTEXT::~HTMLTEXT()
{
	if(face != NULL)
		free(face);

	if(string != NULL)
		free(string);

	if(url != NULL)
		free(url);

}


char *HTMLTEXT::Text()
{
	return string;
}

char *HTMLTEXT::Font()
{
	return face;
}

char *HTMLTEXT::Url()
{
	return url;
}

int HTMLTEXT::Size()
{
	return size;
}

int HTMLTEXT::Align()
{
	return align;
}

int HTMLTEXT::Attributes()
{
	return attributes;
}

int HTMLTEXT::Red()
{
	return red;
}

int HTMLTEXT::Green()
{
	return green;
}

int HTMLTEXT::Blue()
{
	return blue;
}

int HTMLTEXT::Flags()
{
	return flags;
}

int HTMLTEXT::DRAWtext()
{
//	MMechostr(MSKFOO,"HTMLTEXT : '%s'\n",string);
	return 0;
}

#endif