home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d5xx
/
d559
/
apig.lha
/
APIG
/
apiglib_v11.lzh
/
e11_followmouse.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-09-28
|
4KB
|
119 lines
/* dumb mouse line draw example using mousereports */
/* */
x = addlib("apig.library",0,-30,0)
portname = "example11_port"
p = openport(portname)
call set_apig_globals() /* Create Intuition Global constans */
wintitle = "This is your title"
winidcmp = CLOSEWINDOW+GADGETDOWN+GADGETUP+REFRESHWINDOW+MOUSEBUTTONS+MOUSEMOVE
winflags = WINDOWCLOSE + WINDOWDRAG + WINDOWSIZING + WINDOWDEPTH,
+ REPORTMOUSE + ACTIVATE
/* open window */
w1 = openwindow(portname,0,0,640,200,2,4,winidcmp,winflags,wintitle,0,1,0,0)
rpw1 = getwindowrastport(w1)
z = writeconsole(w1,"This is a dumb mouse line draw example" || '0a'x)
z = writeconsole(w1,"Click Left Mouse Button once to start" || '0a'x)
z = writeconsole(w1,"Click Left Mouse Button again to stop" || '0a'x)
z = writeconsole(w1,"Close window when done" || '0a'x)
exitme = 0
drawon = 0
xstart = 0
ystart = 0
x = 0
y = 0
mouserror = 0
z = reportmouse(0,w1)
z = setdrmd(rpw1,COMPLEMENT)
z = setapen(rpw1,0)
do forever
z = waitpkt(portname)
do forever
msg = '0000 0000'x
msg = getpkt(portname)
if msg = '0000 0000'x then leave
class = getarg(msg,0)
select
when class = CLOSEWINDOW then exitme = 1
when class = MOUSEBUTTONS then
do
if getarg(msg,1) = SELECTDOWN then
do
drawon = drawon + 1
if drawon = 1 then /* start point chosen */
do
z = setapen(rpw1,0)
z = setdrmd(rpw1,JAM1)
xstart = getarg(msg,3)
ystart = getarg(msg,4)
x = xstart
y = ystart
z = move(rpw1,xstart,ystart)
z = setdrmd(rpw1,COMPLEMENT)
z = reportmouse(1,w1) /* want mousereport */
end
if drawon = 2 then /* end point chosen */
do
z = move(rpw1,xstart,ystart)
z = draw(rpw1,x,y) /* erase old */
z = setapen(rpw1,1) /* set color */
z = setdrmd(rpw1,JAM1) /* true line */
z = move(rpw1,xstart,ystart) /* start */
/* end point is:
x = getarg(msg,3)
y = getarg(msg,4)
*/
z = draw(rpw1,getarg(msg,3),getarg(msg,4))
z = setdrmd(rpw1,COMPLEMENT)
z = reportmouse(0,w1) /* no mousereports */
drawon = 0
end
end
end
when class = MOUSEMOVE then /* you are moving the mouse around */
do
if drawon = 1 then /* have start point, but no end point */
do /* redraw line as mouse moves */
z = move(rpw1,xstart,ystart)
z = draw(rpw1,x,y) /* erase old */
z = move(rpw1,xstart,ystart)
x = getarg(msg,3) /* current x position of mouse */
y = getarg(msg,4) /* current y position of mouse */
z = draw(rpw1,x,y) /* draw new */
end
end
otherwise nop
end
z = reply(msg,0)
end
if exitme = 1 then leave
end
a =closewindow(w1)
a =closescreen(scr)
exit