[comp.lang.ada] WANTED: mouse routines for Ada Z, Meridian ADA

naasif@eyrie.img.uu.oz.au (Naasif Gierdien) (04/29/91)

The subject line says it all..I'm looking for mouse routines
to run under the Ada Z or Meridian ada environment on a 286/386.

If anyone can suggest anything or lead me in the right direction..??

Thanks in advance,

-Naasif

-- 
Naasif Gierdien             \_/                Melbourne, Australia.
                            ( )     -- Could someone please stop the planet --
                           (   )             -- I want to get off ! --
Internet: naasif@eyrie.img.uu.oz.au     UUCP: ...!uunet!eyrie.uu.oz.au!naasif

mfeldman@seas.gwu.edu (Michael Feldman) (05/01/91)

-- Package MSMOUSE:
--
-- Developed by: 
--	Philip K. Thomas, The George Washington University
--	04/20/88
--
-- This must used with the microsoft mouse driver active.
-- It is used to communicate with the microsoft mouse.  The various
-- procedures are specified below.
--
-- This package uses the Meridian package INTERRUPT
--
-- Specification:
--
with Interrupt; use Interrupt;

Package MSMOUSE is

	function Are_You_There return Boolean;
	-- If mouse is active, resets mouse and returns True
	-- Else returns False

	procedure Show_Cursor;
	-- Turns Cursor On

	procedure Hide_Cursor;
	-- Turns Cursor Off

	procedure Get_Position(x:out Integer; y:out Integer);
	-- Returns x,y position of cursor

	procedure Set_Cursor(x:in Integer; y:in Integer);
	-- Positions Coursor at location x,y

	procedure Left_Button_Press(x:out Integer; y:out Integer; c:out Integer);
	-- Returns number of times LEFT button was pressed since last call
	--	also x,y position of cursor at last press

	procedure Right_Button_Press(x:out Integer; y:out Integer; c:out Integer);
	-- Returns number of times RIGHT button was pressed since last call
	--	also x,y position of cursor at last press

	procedure Left_Button_Release(x:out Integer; y:out Integer; c:out Integer);
	-- Returns number of times LEFT button was released since last call
	--	also x,y position of cursor at last release

	procedure Right_Button_Release(x:out Integer; y:out Integer; c:out Integer);
	-- Returns number of times RIGHT button was released since last call
	--	also x,y position of cursor at last release

	procedure Set_X_Window(min:in Integer; max:in Integer);
	-- Restricts cursor movement to between min and max in the horizontal direction

	procedure Set_Y_Window(min:in Integer; max:in Integer);
	-- Restricts cursor movement to between min and max in the vertical direction

end MSMOUSE;


Package body MSMOUSE is

	ms_vec: constant Interrupt_Range := 51; -- Microsoft's interrupt vector
	Reg_File: Registers;			-- Registers used for communication


	procedure ms_int is
	begin
		vector (
			on => ms_vec,
			register_block => reg_file
			);
	end ms_int;

	function Are_You_There return Boolean is
	begin
		reg_file.Ax:=0;
		ms_int;
		return not (reg_file.Ax = 0);
	end Are_You_There;


	procedure Show_Cursor is
	begin
		reg_file.Ax:=1;
		ms_int;
	end Show_Cursor;


	procedure Hide_Cursor is
	begin
		reg_file.Ax:=2;
		ms_int;
	end Hide_Cursor;


	procedure Get_Position(x:out Integer; y:out Integer) is
	begin
		reg_file.Ax:=3;
		ms_int;
		x:= reg_file.Cx;
		y:= reg_file.Dx;
	end Get_Position;


	procedure Set_Cursor(x:in Integer; y:in Integer) is
	begin
		reg_file.Ax:=4;
		reg_file.Cx:=x;
		reg_file.Dx:=y;
		ms_int;
	end Set_Cursor;


	procedure Left_Button_Press(x:out Integer; y:out Integer; c:out Integer) is
	begin
		reg_file.Ax:=5;
		reg_file.Bx:=0;
		ms_int;
		x:= reg_file.Cx;
		y:= reg_file.Dx;
		c:= reg_file.Bx;
	end Left_Button_Press;


	procedure Right_Button_Press(x:out Integer; y:out Integer; c:out Integer) is
	begin
		reg_file.Ax:=5;
		reg_file.Bx:=1;
		ms_int;
		x:= reg_file.Cx;
		y:= reg_file.Dx;
		c:= reg_file.Bx;
	end Right_Button_Press;


	procedure Left_Button_Release(x:out Integer; y:out Integer; c:out Integer) is
	begin
		reg_file.Ax:=6;
		reg_file.Bx:=0;
		ms_int;
		x:= reg_file.Cx;
		y:= reg_file.Dx;
		c:= reg_file.Bx;
	end Left_Button_Release;


	procedure Right_Button_Release(x:out Integer; y:out Integer; c:out Integer) is
	begin
		reg_file.Ax:=6;
		reg_file.Bx:=1;
		ms_int;
		x:= reg_file.Cx;
		y:= reg_file.Dx;
		c:= reg_file.Bx;
	end Right_Button_Release;


	procedure Set_X_Window(min:in Integer; max:in Integer) is
	begin
		reg_file.Ax:=7;
		reg_file.Cx:=min;
		reg_file.Dx:=max;
		ms_int;
	end Set_X_Window;


	procedure Set_Y_Window(min:in Integer; max:in Integer) is
	begin
		reg_file.Ax:=8;
		reg_file.Cx:=min;
		reg_file.Dx:=max;
		ms_int;
	end Set_Y_Window;

end MSMOUSE;