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

#if !defined(Z_REAL1_HPP)
#define Z_REAL1_HPP
#include <z_real.hpp>
#include <z_str1.hpp>

// --------------------------------------------------------------------------
// ----- ZafReal ------------------------------------------------------------
// --------------------------------------------------------------------------

class ZAF_EXPORT ZafReal : public ZafString
{
public:
	// --- General members ---
	ZafReal(int left, int top, int width,
		ZafRealData *realData = ZAF_NULLP(ZafRealData));
	ZafReal(int left, int top, int width,
		double value);
	ZafReal(const ZafReal &copy);
	virtual ~ZafReal(void);

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

	// --- Attributes & data access ---
	// get
	ZafRealData *RealData(void) const;
	double Value(void);
	// set
	virtual ZafError SetReal(double value);
	virtual ZafError SetRealData(ZafRealData *number);

	// --- String members ---
	virtual bool SetLowerCase(bool lowerCase);
	virtual bool SetPassword(bool password);
	virtual ZafError SetStringData(ZafStringData *string);
	virtual bool SetUpperCase(bool upperCase);
	virtual bool SetVariableName(bool variableName);

	// --- Window object members ---
	virtual ZafEventType Event(const ZafEventStruct &event);
	virtual ZafError SetText(const ZafIChar *text);

	// --- 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:
	friend class ZAF_EXPORT OSReal;

	// --- General members ---
	ZafRealData *realData;

	// --- Data access ---
	static ZafError Update(ZafReal *real, ZafUpdateType type);

	// --- Special OS members ---
	ZafError OSGetReal(void);
	ZafError OSSetReal(void);

	// --- Language & locale support ---
	ZafLanguageData *messages;

	// --- Validation members ---
	virtual int Compare(ZafData *value1, ZafData *value2); // -1, 0, 1
	virtual ZafData *DynamicDataPtr(void);
	virtual ZafIChar *ErrorString(ZafNumberID errorID, bool useDefault = false);
	virtual int GetValue(ZafData *data, ZafIChar *text, int maxLength,
		const ZafIChar *format = 0);
	virtual const ZafIChar *RangeErrorSeparator(void);
	virtual ZafError RestoreText(void);
	virtual ZafError SetValue(ZafData *data, ZafIChar *text, const ZafIChar *format);
	virtual ZafError DecrementData(ZafData *data, ZafData *delta);
	virtual ZafError IncrementData(ZafData *data, ZafData *delta);
	virtual ZafError SetValue(ZafData *data, ZafData *newValue);
	virtual bool ValidDelta(ZafData *delta);  
	virtual ZafData *DataPtr(void);

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

// --- inline functions ---
inline ZafRealData *ZafReal::RealData(void) const { return (realData); }

#endif // Z_REAL1_HPP

