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

#if !defined(Z_MOUSE2_HPP)
#define Z_MOUSE2_HPP
#include <z_mouse.hpp>
#include <z_mouse1.hpp>
#include <z_device.hpp>

#if defined(ZAF_INDEPENDENT)
#include <time.h>
#endif

#if defined(USE_UGL_INPUT) || (defined(ZAF_INDEPENDENT) && !defined(ZAF_MSDOS))
#include <uglInput.h> // for UGL_INPUT_DRIVER
#endif

// --------------------------------------------------------------------------
// ----- ZafMouse -----------------------------------------------------------
// --------------------------------------------------------------------------

// --- Mouse image messages ---
const ZafDeviceImage DM_MOUSE_LAST			= -3200;
const ZafDeviceImage DM_VIEW				= -3200;
const ZafDeviceImage DM_EDIT				= -3201;
const ZafDeviceImage DM_WAIT				= -3202;
const ZafDeviceImage DM_CROSS_HAIRS			= -3203;
const ZafDeviceImage DM_MOVE				= -3204;
const ZafDeviceImage DM_LEFT_SIDE			= -3205;
const ZafDeviceImage DM_RIGHT_SIDE			= -3206;
const ZafDeviceImage DM_TOP_SIDE			= -3207;
const ZafDeviceImage DM_BOTTOM_SIDE			= -3208;
const ZafDeviceImage DM_TOP_LEFT_CORNER		= -3209;
const ZafDeviceImage DM_TOP_RIGHT_CORNER	= -3210;
const ZafDeviceImage DM_BOTTOM_LEFT_CORNER	= -3211;
const ZafDeviceImage DM_BOTTOM_RIGHT_CORNER	= -3212;
const ZafDeviceImage DM_CANCEL				= -3213;
const ZafDeviceImage DM_DRAG				= -3214;
const ZafDeviceImage DM_DRAG_MOVE			= -3215;
const ZafDeviceImage DM_DRAG_COPY			= -3216;
const ZafDeviceImage DM_DRAG_LINK			= -3217;
const ZafDeviceImage DM_DRAG_MOVE_MULTIPLE	= -3218;
const ZafDeviceImage DM_DRAG_COPY_MULTIPLE	= -3219;
const ZafDeviceImage DM_DRAG_LINK_MULTIPLE	= -3220;
const ZafDeviceImage DM_SELECT				= -3221;
const ZafDeviceImage DM_VERTICAL_SPLIT		= -3222;
const ZafDeviceImage DM_HORIZONTAL_SPLIT	= -3223;
const ZafDeviceImage DM_MOUSE_FIRST			= -3299;

class ZAF_EXPORT ZafMouse : public ZafDevice
{
public:
	// --- General members ---
	ZafMouse(ZafDeviceState state = D_ON, ZafDeviceImage imageType = DM_WAIT);
	ZafMouse(const ZafMouse &copy);
	virtual ~ZafMouse(void);

	// --- Attributes & data access ---
	// get
	ZafDeviceImage ImageType(void) const;
	// set
	virtual ZafDeviceImage SetImageType(ZafDeviceImage imageType);

	// --- Device members ---
	virtual ZafEventType Event(const ZafEventStruct &event);
	virtual void Poll(void);

	// --- 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;

#	if defined(ZAF_MSDOS)
	void MoveMouse(int deltaX, int deltaY);
#	endif

#	if defined(ZAF_INDEPENDENT)
	void CloseMouse(void);
	void OpenMouse(void);
	static int DoubleClickRate(void);
	bool DoubleClicked(int line, int column);
	static int SetDoubleClickRate(int);
	void TranslateMouseEvent(ZafEventStruct &event);
#	endif

protected:
	ZafPositionStruct offset;
	ZafDeviceImage imageType;
	ZafPositionStruct position;

#if defined(ZAF_INDEPENDENT)
	static int doubleClickRate;
	ZafPositionStruct lastClickPosition;
#if defined(USE_UGL_INPUT) || (defined(ZAF_INDEPENDENT) && !defined(ZAF_MSDOS))
	UGL_INPUT_DRIVER *driver;
#	endif

#	if defined(ZAF_MSDOS)
	clock_t lastClickTime;
#	elif defined(ZAF_VXWORKS)
	timespec lastClickTime;
#	elif defined(ZAF_PSOS)
	unsigned long lastTime, lastTicks;
#	endif
#endif

	// --- Image support ---
	static ZafMouseData **imageTable;
	static void ImageAllocate(void);
	static void ImageFree(bool globalRequest = false);
};

// --- inline functions ---
inline ZafDeviceImage ZafMouse::ImageType(void) const { return (imageType); }

#if defined(ZAF_INDEPENDENT)
inline int ZafMouse::DoubleClickRate(void) { return (doubleClickRate); }
#endif

#endif // Z_MOUSE1_HPP

