
#ifndef _JL_JLMouse_H_
#define _JL_JLMouse_H_

#include <stdlib.h>
#include <iostream.h>

#define NUMBUTTONS 3

class JLMouse {

	private:
		int		_x, _y;
		int		_last_x, _last_y;
		int		_mousedown[NUMBUTTONS];
		float	_ortho_x1, _ortho_x2, _ortho_y1, _ortho_y2;

	public: 
		JLMouse();
		JLMouse(const JLMouse &J) { CopyFrom(J); }
		virtual ~JLMouse();

		JLMouse& CopyFrom(const JLMouse&);
		JLMouse& operator=(const JLMouse &J) { return CopyFrom(J); }

		void Ortho2(float x1, float x2, float y1, float y2) {
			_ortho_x1 = x1; _ortho_x2 = x2; _ortho_y1 = y1; _ortho_y2 = y2; }

		void MouseDown(int button = 0) { _mousedown[button] = 1; }
		void MouseUp(int button = 0) { _mousedown[button] = 0; }

		int IsMouseDown(int button = 0) { return _mousedown[button]; }

		void Update(int x, int y);
		int Moved() const { return ((_x != _last_x) || (_y != _last_y)); }
		int x() const { return _x; }
		int y() const { return _y; }
		int last_x() const { return _last_x; }
		int last_y() const { return _last_y; }

		void GetFloatXY (float &x, float &y) const;
		void GetFloatXYGivenViewport(float &x, float &y, int xsize, int ysize) const;
};

#endif
