//	Zinc Application Framework - Z_PAL1.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#if !defined(Z_PAL1_HPP)
#define Z_PAL1_HPP
#include <z_pal.hpp>
#include <z_data.hpp>

// --------------------------------------------------------------------------
// ----- ZafPaletteData -----------------------------------------------------
// --------------------------------------------------------------------------

struct ZAF_EXPORT ZafPaletteMap
{
	ZafPaletteType type;
	ZafPaletteState state;
	ZafPaletteStruct palette;
};

class ZAF_EXPORT ZafPaletteData : public ZafData
{
public:
	// --- General members ---
	ZafPaletteData(bool staticData = false);
	ZafPaletteData(ZafPaletteMap *mapTable, bool staticData = false);
	ZafPaletteData(const ZafPaletteData &copy);
	virtual ~ZafPaletteData(void);

	// --- Persistent members ---
	virtual ZafData *Duplicate(void);
#if defined(USE_ZAF_PERSISTENCE)
	ZafPaletteData(const ZafIChar *name, ZafDataPersistence &persist);
	static ZafElement *Read(const ZafIChar *name, ZafDataPersistence &persist);
	virtual void Write(ZafDataPersistence &persist);
#endif

	// --- Attributes & data access ---
	// get
	ZafPaletteStruct GetPalette(ZafPaletteType type, ZafPaletteState state);
	const ZafPaletteMap *MapTable(void) { return (mapTable); }
	bool StaticData(void) const;
	// set
	ZafError AddPalette(ZafPaletteType type, ZafPaletteState state, ZafPaletteStruct &palette);
	virtual void Clear(void);
	virtual ZafError SetMapTable(ZafPaletteMap *paletteMap);
	virtual bool SetStaticData(bool staticData);

	// --- Operators ---
	operator const ZafPaletteMap *() { return (mapTable); }

	// --- 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;
	virtual bool IsA(ZafClassName compareName) const;

protected:
	bool staticData;
	int mapTableSize;
	ZafPaletteMap *mapTable;

#if defined(USE_ZAF_PERSISTENCE)
	// --- Persistent members ---
	void ReadData(ZafDataPersistence &persist);
	virtual ZafDataConstructor ReadFunction(void) { return (ZafPaletteData::Read); }
	void WriteData(ZafDataPersistence &persist);
#endif
};

// --- inline functions ---
inline bool ZafPaletteData::StaticData(void) const { return (staticData); }

#endif // Z_PAL1_HPP

