home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
fortran
/
mslang
/
mouse_32
/
m_test.for
< prev
next >
Wrap
Text File
|
1993-06-16
|
6KB
|
177 lines
C This program does some basic tests of the mouse routines in MOUSE.ASM
C
include 'flib.fi'
include 'fgraph.fi'
include 'mouse.fi'
include 'flib.fd'
include 'fgraph.fd'
include 'mouse.fd'
integer*4 ix,iy, ip, ir
character*40 buf
character*1 ans
RECORD / rccoord / pos
RECORD / EVENT / pEvent
RECORD / BTN_STS / btns
open(1,file='mousetst.out')
i=setvideomode($VRES16COLOR)
call settextposition(1,1,pos)
call outtext('Note: This test reqires full screen mode')
if (getcharQQ() .eq. 'q') stop
C Test 1: call MOUSEINIT
C
C The following call is not required, each mouse function checks to see
C if initialization is required, and calls MOUSEINIT if necessary.
if (mouseinit() .eq. 0) stop 'No Mouse Driver'
write(1,*) 'Mouse exists (test 1 - Pass)'
C Test 2: test GETMOUSEEVENT (with no event)
call settextposition(1,1,pos)
call outtext('Without moving cursor, press a key ')
if (getcharQQ() .eq. 'q') stop
if (getmouseevent(pEvent)) then
call settextposition(2,2,pos)
call outtext('Mouse Event')
write(1,*) 'Mouse event - test failed'
else
write(1,*) 'No Event (test 2 - Pass)'
endif
C Test 3: test GETMOUSEEVENT (with an event)
call settextposition(1,1,pos)
call outtext('Move the cursor then press a key ')
if (getcharQQ() .eq. 'q') stop
if (getmouseevent(pEvent)) then
call settextposition(2,2,pos)
call outtext('Mouse Event')
write(1,*) 'Read mouse move (test 3 - Pass)'
else
call settextposition(2,2,pos)
call outtext(' ')
write(1,*) 'Did not read mouse move'
endif
C Test 4: test Cursor Move (GETPTRPOS and SETPTRPOS)
call settextposition(1,1,pos)
call outtext('Press a key and watch the cursor move')
call settextposition(3,3,pos)
write(buf,'(I3,'','',I3)') pEvent.x, pEvent.y
call outtext('Current position:'//buf)
if (getcharQQ() .eq. 'q') stop
ix = pEvent.x +10
iy = pEvent.y +10
call setptrpos(ix,iy)
call settextposition(1,1,pos)
call outtext('Did the cursor move down and left? ')
call settextposition(2,2,pos)
call outtext(' ')
call settextposition(3,3,pos)
call getptrpos(pEvent)
write(buf,'(I3,'','',I3)') pEvent.x, pEvent.y
call outtext('New position:'//buf)
ans = getcharQQ()
if (ans .eq. 'q') stop
if (ans .eq. 'y' .or. ans .eq. 'Y') then
write(1,*) 'Mouse move OK (test 4 - Pass)'
else
write(1,*) 'Mouse move Fail'
endif
call settextposition(3,3,pos)
call outtext(' ')
C Test 5: test Cursor Drag and Drop (GETBUTTONPRESS and GETBUTTONRELEASE)
call settextposition(1,1,pos)
call outtext('Press left button while moving cursor ')
call settextposition(3,3,pos)
call outtext(' ')
if (getcharQQ() .eq. 'q') stop
btns.Btn = 0 !left button
ip = getbuttonpress(btns)
ix = btns.x
iy = btns.y
ir = getbuttonrelease(btns)
call settextposition(1,1,pos)
write(buf,'(I3,'', released:'',I3)') ip,ir
call outtext('Left button was pressed:'//buf)
write(buf,'(I3,'','',I3)') ix, iy
call settextposition(2,2,pos)
call outtext('Dragged from:'//buf)
call settextposition(3,3,pos)
write(buf,'(I3,'','',I3)') btns.x, btns.y
call outtext('To:'//buf)
ans = getcharQQ()
if (ans .eq. 'q') stop
if (ans .eq. 'n' .or. ans .eq. 'N') then
write(1,*) 'Mouse drag Fail'
else
write(1,*) 'Mouse drag OK (test 5 - Pass)'
endif
call settextposition(2,2,pos)
call outtext(' ')
call settextposition(3,3,pos)
call outtext(' ')
C Test 6: Making Cursor Invisible (SETPTRVIS(2))
call settextposition(1,1,pos)
call outtext('Is the cursor visible? ')
call setptrvis(2) !hide cursor
ans = getcharQQ()
if (ans .eq. 'q') stop
if (ans .eq. 'y' .or. ans .eq. 'Y') then
write(1,*) 'Cursor visible (SetPtrVis Fail)'
else
write(1,*) 'Cursor visible (test 6 - Pass)'
endif
C Test 7: Making Cursor Visible (SETPTRVIS(1))
C
C Note: if setptrvis(2) is called more than once, setptrvis(1) will need
C to be called more than once to restore visibility.
C It is safe to call setptrvis(1) many times (even if it is not
C necessary)
call settextposition(1,1,pos)
call outtext('Is the cursor visible? ')
call setptrvis(1) !show cursor
ans = getcharQQ()
if (ans .eq. 'q') stop
if (ans .eq. 'y' .or. ans .eq. 'Y') then
write(1,*) 'Cursor visible (test 7 - Pass)'
else
write(1,*) 'Cursor visible (SetPtrVis Fail)'
endif
C Test 8: Get the coordinates of the corners (tests coordinate limits and
C absolute positioning)
call setptrpos(-1,-1)
call getptrpos(pEvent)
write(1,*) 'Upper left is:', pEvent.x, pEvent.y
call setptrpos(-1,1234)
call getptrpos(pEvent)
write(1,*) 'Lower left is:', pEvent.x, pEvent.y
call setptrpos(1234,-1)
call getptrpos(pEvent)
write(1,*) 'Upper right is:', pEvent.x, pEvent.y
call setptrpos(1234,1234)
call getptrpos(pEvent)
write(1,*) 'Lower right is:', pEvent.x, pEvent.y
end