home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETLIB.EXE / GETMOUSE.PRG < prev    next >
Encoding:
Text File  |  1992-03-09  |  2.5 KB  |  97 lines

  1. // GetMouse.prg
  2. //
  3. // Get reader implementing mouse
  4.  
  5. #include "GetExit.ch"
  6. #include "Mouse.ch"
  7.  
  8. MEMVAR GetList
  9.  
  10. proc GetMouseReader( oGet )
  11.  
  12. LOCAL nCurrentGet
  13. LOCAL nKey
  14. LOCAL lHadMouse, lHadKey, lLeftPressed, lRightPressed
  15. LOCAL nRow, nCol
  16. LOCAL nMouseGet
  17. LOCAL lWhen
  18. LOCAL lValid
  19.  
  20.   nCurrentGet := Ascan(GetList, {|o| o == oGet })
  21.   IF !(GetMovingTo() == NIL) .AND. nCurrentGet != GetMovingTo()
  22.     IF nCurrentGet > GetMovingTo()
  23.       oGet:exitState := GE_UP
  24.     ELSE
  25.       oGet:exitState := GE_DOWN
  26.     ENDIF
  27.   ELSE
  28.     GetMovingTo(NIL) 
  29.     // read the GET if the WHEN condition is satisfied
  30.     MouseOff()
  31.     lWhen := GetPreValidate(oGet)
  32.     MouseOn()
  33.     IF ( lWhen )
  34.       // activate the GET for reading
  35.       MouseOff()
  36.       oGet:SetFocus()
  37.       MouseOn()
  38.  
  39.       DO WHILE ( oGet:exitState == GE_NOEXIT )
  40.         // check for initial typeout (no editable positions)
  41.         IF ( oGet:typeOut )
  42.           oGet:exitState := GE_ENTER
  43.         ENDIF
  44.  
  45.         // apply keystrokes until exit
  46.         DO WHILE ( oGet:exitState == GE_NOEXIT )
  47.           lHadMouse := .F.
  48.           lHadKey   := .F.
  49.           DO WHILE !lHadKey .AND. !lHadMouse
  50.             nKey := InKey()
  51.             lHadKey := nKey != 0
  52.             IF !lHadKey
  53.               // No key, check mouse
  54.               MouseRead(@lLeftPressed, @lRightPressed, @nRow, @nCol)
  55.               nRow := Int(nRow / M_CURS_HEIGHT)
  56.               nCol := Int(nCol / M_CURS_WIDTH)
  57.               IF lLeftPressed .OR. lRightPressed
  58.                 nMouseGet := Ascan(GetList, ;
  59.                                    {|o| nRow == o:row .AND. ;
  60.                                         nCol >= o:col .AND. ;
  61.                                         nCol <= o:col + ;
  62.                                            Len(Transform(o:Varget(), ;
  63.                                                          o:Picture)) - 1})
  64.  
  65.                 lHadMouse := nMouseGet > 0
  66.               ENDIF
  67.             ENDIF
  68.           ENDDO
  69.  
  70.           IF lHadKey
  71.             MouseOff()
  72.             GetApplyKey(oGet, nKey)
  73.             MouseOn()
  74.           ELSE
  75.             GoToGet(nMouseGet)
  76.           ENDIF
  77.         ENDDO
  78.  
  79.         // disallow exit if the VALID condition is not satisfied
  80.         MouseOff()
  81.         lValid := GetPostValidate(oGet)
  82.         MouseOn()
  83.         IF ( !lValid )
  84.           oGet:exitState := GE_NOEXIT
  85.         ENDIF
  86.       ENDDO
  87.  
  88.       // de-activate the GET
  89.       MouseOff()
  90.       oGet:KillFocus()
  91.       MouseOn()
  92.     ENDIF
  93.   ENDIF
  94.  
  95. RETURN
  96.  
  97.