//	Zinc Interface Library - Z_STREDT.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#if !defined(Z_STREDT_HPP)
#define Z_STREDT_HPP
#include <z_win.hpp>
#include <z_int1.hpp>
#include <z_dlgwin.hpp>
#include <z_prompt.hpp>
#include <z_text.hpp>
#include <z_icon.hpp>
#include <z_gmgr.hpp>

const ZafLogicalEvent L_STRING_EDITOR = 1150;
const ZafSystemEvent S_STRING_EDITOR  = -150;

const ZafEventType OPT_PUT_KEY = 7000;
const ZafEventType OPT_ACCEPT_EDIT = 7001;
const ZafEventType OPT_CANCEL_EDIT = 7002;

class ZAF_EXPORT EditText : public ZafText
{
public:
	EditText(int left, int top, int width, int height);
	ZafEventType Event(const ZafEventStruct &event);
};

class ZAF_EXPORT HexInteger : public ZafInteger
{
public:
	HexInteger(int left, int top, int width);
	ZafEventType Event(const ZafEventStruct &event);
	virtual ZafError Increment(ZafData *data, bool wrapData = false);
	virtual ZafError Decrement(ZafData *data, bool wrapData = false);
};

class ZAF_EXPORT CharacterMap : public ZafWindowObject
{
public:
	CharacterMap(int left, int top);
	ZafEventType Draw(const ZafEventStruct &event, ZafEventType ccode);
	ZafEventType Event(const ZafEventStruct &event);

private:
	int cellWidth, cellHeight;
};

const ZafClassID ID_ZAF_STRING_EDITOR = 3600;

class ZAF_EXPORT ZafStringEditor : public ZafDialogWindow
{
public:
	ZafStringEditor();
	~ZafStringEditor(void);
	virtual ZafEventType Event(const ZafEventStruct &event);
	ZafLogicalEvent LogicalEvent(const ZafEventStruct &event);

	// --- Class identification ---
	static ZafClassID classID;
	static ZafClassNameChar ZAF_FARDATA className[];
	virtual ZafClassID ClassID(void) const { return (classID); }
	virtual ZafClassName ClassName(void) const { return (className); }
	virtual bool IsA(ZafClassID compareID) const
		{ return ((compareID == classID) ? true : ZafDialogWindow::IsA(compareID)); }
	virtual bool IsA(ZafClassName compareName) const
		{ return (!strcmp(compareName, className) ? true : ZafDialogWindow::IsA(compareName)); }

	// --- String editor ---
	void SetRequestor(ZafWindowObject *setRequestor);
	int Page(void) const { return (page); }
	void SetPage(int setPage);
	void FullPathID(ZafIChar *fullPathID, ZafWindowObject *object);

private:
	int page;
	EditText *editField;
	CharacterMap *mapField;
	ZafPrompt *charField;
    ZafIChar *requestID;
	ZafWindowObject *requestor;
	bool adjusted;
	int recordOffset;
	int fieldOffset;

	static ZafEventMap ZAF_FARDATA defaultEventMap[];

	void CreateFields(void);
};

#endif

