#pragma once
#include "History.h"
#include "Rollover.h"

//typedef void (*RolloverCallback)(int x, int y, char* ImageName, int ImageID);


class GML
{
public:
	GML(char* fontPath, char* imagePath, char* defaultPagePath, rect* DisplayTextArea, int tabwidth);	//create a GML display system. Must be called before any other Core APIs
	~GML();																								//destroy a GML display system. Must be called when you no longer need a History system.
	int DisplayGML(char* TextData);																	//Display a page of GML

	ExportHyperlink* ExportHyperlinks();
	GMLHyperlink* GetHyperlink(int Num);		//"click" on the number Num hyperlink.
	GMLHyperlink* GetHyperlink(char* Desc);	//"click" on the hyperlink that has Desc as the text in the Alt tag. GML pages must be constructed with this in mind.

	char* Click(int x, int y);		//pointer click. make sure x/y is relative to the top left corner of the display window
	void RollOver(int x, int y);	//pointer is at this screen location, test for rollover. make sure x/y is relative to the top left corner of the display window
	ExportImageData* ExportImageList();	//Export information on all images.
	void RegisterRollover(ImageData* Image, RolloverCallback* F);	//Register a function to be called in the event that this image is rolled over.

	char* LoadPage(const char* FileName);	//Load page. Supports UNC, http, and local paths. Does _not_ support relative paths! use LocateFile first.
	char* LocateFile(const char* FileName);	//Locates a file given a path that may be relative. It's safe to always run anything sent to LoadFile through this first. Be sure delete the return value eventually.
	
	void ManageVideo(HGOSVIDEO I);
	void ManageImage(DWORD I);
	void SetScrollOffset(int y);
	void SetParserCallback(ParserCallback* PCB);

private:
	GML();	//don't call this

	GmlDisplaySystem* GDS;
	Rollover* Roll;
	Region* Reg;
	rect* TextArea;
	int ScrollX;
	int ScrollY;
};


class HistoryS
{
public:
	HistoryS();					//create a history system.
	~HistoryS();				//destroy a history system.
	char* HistoryBack();		//move the history lists back 1 member and return the previous page **DOES NOT CHANGE THE PAGE DISPLAYED**
	char* HistoryForwards();	//move the history lists forward 1 member and return the next page **DOES NOT CHANGE THE PAGE DISPLAYED**
	bool BackIsEmpty();			//is the back portion of the history list empty? Informational API only.
	bool ForwardsIsEmpty();		//is the forwards portion of the history list empty? Informational API only.
	void HistoryAdd(char* Entry);//call to add an entry to the history list **DOES NOT CHANGE THE PAGE DISPLAYED**
	void HistoryClear();		//call to clear the history lists
	void GMLSetHistoryLen();		//Enable a limited length Back history list. Length is unlimited by default.

private:
	History* HS;
};
