#ifndef CPP_INTUITION_SCREEN_H
#define CPP_INTUITION_SCREEN_H

// Screen Klassen
//
// Autor: Jochen Becher
//
// Historie:
// Version 1.0, am 9. Januar 94

#ifndef CPP_UTILITY_TAGITEM_H
#include <classes/utility/tagitem.h>
#endif

#ifndef INTUITION_SCREENS_H
#include <intuition/screens.h>
#endif

#ifndef CPP_DATASTRUCTURES_GENARRAYLIST_H
#include <classes/DataStructures/GenArraylist.h>
#endif

#ifndef INCLUDE_TOOLS_STR_H
#include <tools/str.h>
#endif

class ScreenC {
friend class PublicScreenC;
public:
	ScreenC(Tag tag1Type, ...) throw (MemoryX);
	ScreenC(struct TagItem *tags = NULL) throw (MemoryX);
	ScreenC(const ScreenC &);
	~ScreenC();
	ScreenC &operator= (const ScreenC &);
	BOOL isOpen() const { return screen_ob != NULL; };
	struct Screen *screen() const { return screen_ob; };
	virtual VOID open(Tag tag1Type, ...) throw (ScreenX, MemoryX)
		{ open((struct TagItem *) &tag1Type); };
	virtual VOID open(struct TagItem *taglist = NULL) throw (ScreenX, MemoryX);
	virtual BOOL close();
	VOID toFront();
	VOID toBack();
	VOID move(WORD dx, WORD dy);
	VOID beep(BOOL all = FALSE);
	VOID showTitle(BOOL infront = TRUE);
private:
	struct Screen *screen_ob;
	TagItemC inittags;
};

class PublicScreenC : public ScreenC {
public:
	PublicScreenC(STRPTR name = NULL) throw (MemoryX);
	~PublicScreenC();
	VOID open(struct TagItem *tagList = NULL) throw (ScreenX, MemoryX);
	BOOL close();
	virtual BOOL lock(STRPTR name = NULL);
	virtual VOID unlock();
	STRPTR name() { return pubname; };
private:
	STRPTR pubname;
};

class DrawInfoC {
public:
	DrawInfoC();
	DrawInfoC(ScreenC &) throw (ScreenDrawInfoX);
	~DrawInfoC();
	BOOL isValid() const { return di != NULL; };
	struct DrawInfo *info() const { return di; };
	struct DrawInfo *getInfo(ScreenC &) throw (ScreenDrawInfoX);
	VOID freeInfo();
private:
	struct DrawInfo *di;
	struct Screen *screen;
};

class PublicScreenInfoC {
friend class PublicScreenListC;
public:
	PublicScreenInfoC() { };
	STRPTR name() const { return (STRPTR) screenname; };
private:
	String screenname;
};

class PublicScreenListC {
friend class PublicScreenCursorC;
public:
	PublicScreenListC() throw (MemoryX);
	VOID update() throw (MemoryX);
private:
	gen_arraylist infos;
};

class PublicScreenCursorC : public gen_arraycursor {
public:
	PublicScreenCursorC(PublicScreenListC &l)
		: gen_arraycursor(l.infos) { };
	PublicScreenInfoC &item() throw (MemoryX)
		{ return (PublicScreenInfoC &) gen_arraycursor::item(); };
};

#endif
