home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / snip0693.zip / MINNIE.PRG < prev    next >
Text File  |  1993-02-13  |  7KB  |  322 lines

  1. // Here's the Clipper source module for use with MOUSE.ASM:
  2. // MINNIE.PRG
  3. //
  4. // Microsoft Mouse Driver Interface Routines for Clipper 5.0x.
  5. //
  6. // This code is an original work placed into the public domain by
  7. // the author, Todd C. MacDonald.
  8. //
  9. // Assemble the Mouse Driver Interface with "TASM MOUSE".
  10. //
  11. // Compile this module with "CLIPPER MINNIE /N /W /DTEST".  Drop
  12. // the "/DTEST" when you're ready to link it into your app.
  13. //
  14. // Link with "BLINKER FI MINNIE, MOUSE".
  15.  
  16.  
  17. #define K_MS_LEFT       -97
  18. #define K_MS_RIGHT      -98
  19. #define K_MS_BOTH       -99
  20.  
  21. #define MS_RESET        0
  22. #define MS_SHOW         1
  23. #define MS_HIDE         2
  24. #define MS_READ         3
  25. #define MS_SET_POS      4
  26. #define MS_SET_HORIZ    7
  27. #define MS_SET_VERT     8
  28. #define MS_SET_CURS     10
  29.  
  30. #define MS_CURS_WIDTH   8
  31. #define MS_CURS_HEIGHT  8
  32.  
  33.  
  34. STATIC lActive    := .f.
  35. STATIC lVisible   := .f.
  36. STATIC lLpressed  := .f.
  37. STATIC lRpressed  := .f.
  38. STATIC nNbrButtns := 0
  39. STATIC nLastkey   := 0
  40. STATIC nRow       := 0
  41. STATIC nCol       := 0
  42.  
  43.  
  44. #IFDEF TEST
  45.  
  46.  
  47. #include "inkey.ch"
  48.  
  49.  
  50. //-------------------------------------------------------------//
  51.   FUNCTION Test
  52. //-------------------------------------------------------------//
  53.  
  54. LOCAL GetList := {}
  55. LOCAL nKey
  56.  
  57. MsInit()
  58. MsSetCurs( 65280, 4 )
  59. MsSetBound( 0, 0, maxrow(), maxcol() )
  60.  
  61. clear
  62.  
  63. IF MsActive()
  64.  
  65.   @ 0, 0 say 'Row:     Col:     Left Button:          ' + ;
  66.     'Right Button:          Visible:'
  67.  
  68.   @ 1, 0, maxrow() - 1, maxcol() - 1 box '┌─┐│┘─└│ '
  69.  
  70.   MsSetBound( 2, 1, maxrow() - 2, maxcol() - 2 )
  71.   MsSetPos( 2, 1 )
  72.   MsShow()
  73.  
  74.   nKey := MsInkey()
  75.  
  76.   WHILE nKey != K_ESC
  77.  
  78.     IF nKey = K_MS_LEFT
  79.  
  80.       IF !MsVisible()
  81.  
  82.         MsShow()
  83.  
  84.       ENDIF
  85.  
  86.     ELSEIF nKey = K_MS_RIGHT
  87.  
  88.       IF MsVisible()
  89.  
  90.         MsHide()
  91.  
  92.       ENDIF
  93.  
  94.     ENDIF
  95.  
  96.     @ 0,5  say MsRow() pict '99'
  97.     @ 0,14 say MsCol() pict '99'
  98.     @ 0,31 say iif( MsLpressed(), 'Pressed', '       ' )
  99.     @ 0,54 say iif( MsRpressed(), 'Pressed', '       ' )
  100.     @ 0,72 say iif( MsVisible(), 'Yes', 'No ' )
  101.  
  102.     nKey := MsInkey()
  103.  
  104.   END
  105.  
  106.   MsHide()
  107.  
  108. ENDIF
  109.  
  110. MsHide()
  111.  
  112. RETURN nil
  113. //-------------------------------------------------------------//
  114.  
  115.  
  116. #ENDIF
  117.  
  118.  
  119. //-------------------------------------------------------------//
  120.   FUNCTION MsInit()
  121. //-------------------------------------------------------------//
  122.  
  123. MsDriver( MS_RESET )
  124.  
  125. nNbrButtns := MsBX()
  126. lActive    := ( MsAX() = -1 )
  127.  
  128. RETURN nil
  129. //-------------------------------------------------------------//
  130.  
  131.  
  132. //-------------------------------------------------------------//
  133.   FUNCTION MsShow()
  134. //-------------------------------------------------------------//
  135.  
  136. MsDriver( MS_SHOW )
  137.  
  138. lVisible := .t.
  139.  
  140. RETURN nil
  141. //-------------------------------------------------------------//
  142.  
  143.  
  144. //-------------------------------------------------------------//
  145.   FUNCTION MsHide()
  146. //-------------------------------------------------------------//
  147.  
  148. MsDriver( MS_HIDE )
  149.  
  150. lVisible := .f.
  151.  
  152. RETURN nil
  153. //-------------------------------------------------------------//
  154.  
  155.  
  156. //-------------------------------------------------------------//
  157.   FUNCTION MsSetPos( nRow, nCol )
  158. //-------------------------------------------------------------//
  159.  
  160. MsDriver( MS_SET_POS, 0, nCol * MS_CURS_WIDTH, nRow * ;
  161.   MS_CURS_HEIGHT )
  162.  
  163. RETURN nil
  164. //-------------------------------------------------------------//
  165.  
  166.  
  167. //-------------------------------------------------------------//
  168.   FUNCTION MsSetBound( nT, nL, nB, nR )
  169. //-------------------------------------------------------------//
  170.  
  171. MsDriver( MS_SET_HORIZ, 0, nL * MS_CURS_WIDTH,  nR * ;
  172.   MS_CURS_WIDTH  )
  173.  
  174. MsDriver( MS_SET_VERT,  0, nT * MS_CURS_HEIGHT, nB * ;
  175.   MS_CURS_HEIGHT )
  176.  
  177. RETURN nil
  178. //-------------------------------------------------------------//
  179.  
  180.  
  181. //-------------------------------------------------------------//
  182.   FUNCTION MsSetCurs( nScrnMask, nCursMask )
  183. //-------------------------------------------------------------//
  184.  
  185. MsDriver( MS_SET_CURS, 0, nScrnMask, nCursMask )
  186.  
  187. RETURN nil
  188. //-------------------------------------------------------------//
  189.  
  190.  
  191. //-------------------------------------------------------------//
  192.   FUNCTION MsRead()
  193. //-------------------------------------------------------------//
  194.  
  195. MsDriver( MS_READ )
  196.  
  197. lLpressed := ( MsBX() = 1 ) .or. ( MsBX() = 3 )
  198. lRpressed := ( MsBX() = 2 ) .or. ( MsBX() = 3 )
  199.  
  200. nRow      := MsDX() / MS_CURS_HEIGHT
  201. nCol      := MsCX() / MS_CURS_WIDTH
  202.  
  203. RETURN nil
  204. //-------------------------------------------------------------//
  205.  
  206.  
  207. //-------------------------------------------------------------//
  208.   FUNCTION MsInkey( nDelaySecs )
  209. //-------------------------------------------------------------//
  210.  
  211. LOCAL nSecs := seconds()
  212. LOCAL lExit := .f.
  213. LOCAL nKey  := 0
  214.  
  215. nDelaySecs := if( valtype( nDelaySecs ) = 'N', nDelaySecs, -1 )
  216.  
  217. WHILE !lExit
  218.  
  219.   nKey := inkey()
  220.  
  221.   IF nKey != 0
  222.  
  223.     lExit := .t.
  224.  
  225.   ELSE
  226.  
  227.     IF lActive
  228.  
  229.       MsRead()
  230.  
  231.       IF lLpressed .and. lRpressed
  232.  
  233.         nKey  := nLastKey := K_MS_BOTH
  234.         lExit := .t.
  235.  
  236.       ELSEIF lLpressed
  237.  
  238.         nKey  := nLastKey := K_MS_LEFT
  239.         lExit := .t.
  240.  
  241.       ELSEIF lRpressed
  242.  
  243.         nKey  := nLastKey := K_MS_RIGHT
  244.         lExit := .t.
  245.  
  246.       ENDIF
  247.  
  248.     ENDIF
  249.  
  250.   ENDIF
  251.  
  252.   IF nDelaySecs != 0
  253.  
  254.     IF seconds() - nSecs > nDelaySecs
  255.  
  256.       lExit := .t.
  257.  
  258.     ENDIF
  259.  
  260.   ENDIF
  261.  
  262. END
  263.  
  264. RETURN nKey
  265. //-------------------------------------------------------------//
  266.  
  267.  
  268. //-------------------------------------------------------------//
  269.   FUNCTION MsActive()
  270. //-------------------------------------------------------------//
  271.  
  272. RETURN lActive
  273. //-------------------------------------------------------------//
  274.  
  275.  
  276. //-------------------------------------------------------------//
  277.   FUNCTION MsVisible()
  278. //-------------------------------------------------------------//
  279.  
  280. RETURN lVisible
  281. //-------------------------------------------------------------//
  282.  
  283.  
  284. //-------------------------------------------------------------//
  285.   FUNCTION MsLpressed()
  286. //-------------------------------------------------------------//
  287.  
  288. RETURN lLpressed
  289. //-------------------------------------------------------------//
  290.  
  291.  
  292. //-------------------------------------------------------------//
  293.   FUNCTION MsRpressed()
  294. //-------------------------------------------------------------//
  295.  
  296. RETURN lRpressed
  297. //-------------------------------------------------------------//
  298.  
  299.  
  300. //-------------------------------------------------------------//
  301.   FUNCTION MsRow()
  302. //-------------------------------------------------------------//
  303.  
  304. RETURN nRow
  305. //-------------------------------------------------------------//
  306.  
  307.  
  308. //-------------------------------------------------------------//
  309.   FUNCTION MsCol()
  310. //-------------------------------------------------------------//
  311.  
  312. RETURN nCol
  313. //-------------------------------------------------------------//
  314.  
  315.  
  316. //-------------------------------------------------------------//
  317.   FUNCTION MsLastKey()
  318. //-------------------------------------------------------------//
  319.  
  320. RETURN nLastKey
  321. //-------------------------------------------------------------//
  322.