home *** CD-ROM | disk | FTP | other *** search
- {--------------------------------------------------------------------------
-
- HighSpeed Pascal for the Amiga
-
- MOUSE TRACKING DEMO
-
- Programmed by Martin Eskildsen 1991
-
- Copyright (c) 1991 by D-House I ApS
- All rights reserved
-
-
- Version : Date (dd.mm.yy) : Comment
- -----------------------------------
- 1.00 : 22.07.91 : First version
- 1.01 : 13.08.91 : Uses Init.LegalPosition
- 1.02 : 17.09.91 : Uses new libraries
- 1.03 : 06.11.91 : Final for first release
- 1.10 : 22.04.92 : Updated to use correct unsigned types, Wait() fixed
-
- --------------------------------------------------------------------------}
-
- program MouseDemo;
-
- uses Init, Intuition, Exec, Graphics;
-
- procedure DrawLoop;
- var
- dummy : longint;
- Imessage : pIntuiMessage; { The messages sent to this program }
- class : long; { Message class }
- code : word; { Message code }
- quit : boolean; { TRUE = done showing menu }
- drawing : boolean; { TRUE = we are drawing }
- x, y : integer; { Mouse (x,y) }
-
- begin
- quit := FALSE; { Not done yet }
- drawing := FALSE; { Not drawing at entry }
- Move_(OutputWindow^.RPort, 2,10); { Move to upper left of work area }
- repeat
- dummy := Wait(BitMask(OutputWindow^.UserPort^.MP_SIGBIT));
- { Wait for something to happen }
-
- Imessage := pIntuiMessage(GetMsg(OutputWindow^.UserPort));
- { Find out what }
- while Imessage <> NIL do begin
- class := Imessage^.class; { Save for later use }
- code := Imessage^.code;
- x := Imessage^.MouseX;
- y := Imessage^.MouseY;
- ReplyMsg(pMessage(Imessage)); { Accept this message }
- case class of
- MOUSEBUTTONS : begin
- drawing := code = SELECTDOWN;
- if drawing and LegalPosition(x, y) then
- Move_(OutputWindow^.RPort, x, y)
- end;
- MOUSEMOVE : if drawing and LegalPosition(x, y) then
- Draw(OutputWindow^.RPort, x, y);
- CLOSEWINDOW_ : quit := TRUE
- end;
- Imessage := pIntuiMessage(GetMsg(OutputWindow^.UserPort)) { Get next }
- end;
- until quit
- end;
-
- begin
- if PrepareEnvironment('Mouse Tracking') then begin
-
- Message('First, a window to draw in');
- with OutputWinDef do begin { Tell Intuition that we want }
- IDCMPflags := IDCMPflags or MOUSEBUTTONS or MOUSEMOVE;
- Flags := Flags or REPORTMOUSE_
- end;
- OpenOutputWindow;
-
- Inform('Ready! Press left mouse button to draw; Close gadget to end');
- DrawLoop;
-
- CloseOutputWindow;
- CloseDown
- end
- end.
-