home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / tb / mousetb / mousebox.inc < prev    next >
Text File  |  1993-07-29  |  11KB  |  390 lines

  1. '┌────────────────────────────────────────────────────────────────────────────┐
  2. '│                        MOUSEBOX.INC, Version 1.1                           │
  3. '│               Routinen zur Unterstützung der Microsoft Maus                │
  4. '│                   (oder einer hierzu kompatiblen Maus)                     │
  5. '├────────────────────────────────────────────────────────────────────────────┤
  6. '│                 Copyright (c) 1988,89, 90 by Ralf Krause                   │
  7. '│             Leuchtenberger Str. 7a, D-8480 Weiden i. d. Opf.               │
  8. '├────────────────────────────────────────────────────────────────────────────┤
  9. '│                 Prozeduren/Funktionen und deren Syntax:                    │
  10. '│                                                                            │
  11. '│ InitMouse                 a = FN InitMouse                                 │
  12. '│ ResetMouse                CALL ResetMouse                                  │
  13. '│ ShowCursor                CALL ShowCursor                                  │
  14. '│ HideCursor                CALL HideCursor                                  │
  15. '│ GetXPosition              x = FN GetXPosition                              │
  16. '│ GetYPosition              y = FN GetYPosition                              │
  17. '│ GetXTextPosition          x = FN GetXTextPosition                          │
  18. '│ GetYTextPosition          y = FN GetYTextPosition                          │
  19. '│ LeftButton                a = FN LeftButton                                │
  20. '│ RightButton               a = FN RightButton                               │
  21. '│ MiddleButton              a = FN MiddleButton                              │
  22. '│ MouseMoved                a = FN MouseMoved                                │
  23. '│ MouseLeftMoved            a = FN MouseLeftMoved                            │
  24. '│ MouseRightMoved           a = FN MouseRightMoved                           │
  25. '│ MouseUpMoved              a = FN MouseUpMoved                              │
  26. '│ MouseDownMoved            a = FN MouseDownMoved                            │
  27. '│ SetXYMouse                CALL SetXYMouse(x, y)                            │
  28. '│ LeftButtonPressed         a = FN LeftButtonPressed                         │
  29. '│ RightButtonPressed        a = FN RightButtonPressed                        │
  30. '│ MiddleButtonPressed       a = FN MiddleButtonPressed                       │
  31. '│ LeftButtonReleased        a = FN LeftButtonReleased                        │
  32. '│ RightButtonReleased       a = FN RightButtonReleased                       │
  33. '│ MiddleButtonReleased      a = FN MiddleButtonReleased                      │
  34. '│ SetXRange                 CALL SetXRange(x)                                │
  35. '│ SetYRange                 CALL SetYRange(y)                                │
  36. '│ SetGraphicCursor          CALL SetGraphicCursor(Cursor%(),_                │
  37. '│                                XHotSpot%, YHotSpot%)                       │
  38. '│ SetTextCursor             CALL SetTextCursor(Typ%, TextScreenMask%,_       │
  39. '│                                TextCursorMask%)                            │
  40. '│ GetXMickey                x = FN GetXMickey                                │
  41. '│ GetYMickey                y = FN GetYMickey                                │
  42. '│ SetXYMickey               CALL SetXYMickey(x, y)                           │
  43. '│ SetMouseSpeed             CALL SetMouseSpeed(s)                            │
  44. '│                                                                            │
  45. '└────────────────────────────────────────────────────────────────────────────┘
  46.  
  47. DEFINT i
  48.  
  49. %MouseIntr = &H33                 ' Mouse-Interrupt
  50.  
  51. '
  52. ' InitMouse --> Maustreiber initialisieren
  53. '
  54. DEF FN InitMouse
  55.   REG 1, 0
  56.   CALL INTERRUPT %MouseIntr
  57.   IF REG(1) = - 1 THEN
  58.     FN InitMouse = - 1       ' Mouse-Treiber vorhanden
  59.   ELSE
  60.     FN InitMouse =   0       ' Mouse-Treiber nicht vorhanden
  61.   END IF
  62. END DEF
  63.  
  64. '
  65. ' ResetMouse --> Maustreiber zurücksetzen
  66. '
  67. SUB ResetMouse
  68.   REG 1, 0
  69.   CALL INTERRUPT %MouseIntr
  70. END SUB
  71.  
  72. '
  73. ' ShowCursor --> Mauscursor einschalten
  74. '
  75. SUB ShowCursor
  76.   REG 1, 1
  77.   CALL INTERRUPT %MouseIntr
  78. END SUB
  79.  
  80. '
  81. ' HideCursor --> Mauscursor ausschalten
  82. '
  83. SUB HideCursor
  84.   REG 1, 2
  85.   CALL INTERRUPT %MouseIntr
  86. END SUB
  87.  
  88. '
  89. ' FN GetXPosition --> ermittelt horizontale X-Position,
  90. '
  91. DEF FN GetXPosition
  92.   REG 1, 3
  93.   CALL INTERRUPT %MouseIntr
  94.   FN GetXPosition = REG(3)
  95. END DEF
  96.  
  97. '
  98. ' FN GetYPosition --> ermittelt vertikale Y-Position,
  99. '
  100. DEF FN GetYPosition
  101.   REG 1, 3
  102.   CALL INTERRUPT %MouseIntr
  103.   FN GetYPosition = REG(4)
  104. END DEF
  105.  
  106. '
  107. ' FN GetXTextPosition --> ermittelt horizontale X-Position, es werden
  108. '                         Werte zwischen 1 und 80 zurückgegeben
  109. '
  110. DEF FN GetXTextPosition
  111.   REG 1, 3
  112.   CALL INTERRUPT %MouseIntr
  113.   FN GetXTextPosition = (REG(3) + 8) \ 8
  114. END DEF
  115.  
  116. '
  117. ' FN GetYTextPosition --> ermittelt vertikale Y-Position, es werden
  118. '                         Werte zwischen 1 und 25 zurückgegeben
  119. '
  120. DEF FN GetYTextPosition
  121.   REG 1, 3
  122.   CALL INTERRUPT %MouseIntr
  123.   FN GetYTextPosition = (REG(4) + 8) \ 8
  124. END DEF
  125.  
  126. '
  127. ' FN LeftButton --> testet ob die linke Taste gedrückt ist
  128. '
  129. DEF FN LeftButton
  130.   REG 1, 5
  131.   REG 2, 0
  132.   CALL INTERRUPT %MouseIntr
  133.   IF (REG(1) = 1) THEN
  134.     FN LeftButton = -1
  135.   ELSE
  136.     FN LeftButton = 0
  137.   END IF
  138. END DEF
  139.  
  140. '
  141. ' FN RightButton --> testet ob die rechte Taste gedrückt ist
  142. '
  143. DEF FN RightButton
  144.   REG 1, 5
  145.   REG 2, 1
  146.   CALL INTERRUPT %MouseIntr
  147.   IF (REG(1) = 2) THEN
  148.     FN RightButton = -1
  149.   ELSE
  150.     FN RightButton = 0
  151.   END IF
  152. END DEF
  153.  
  154. '
  155. ' FN MiddleButton --> testet ob die mittlere Taste gedrückt ist
  156. '
  157. DEF FN MiddleButton
  158.   REG 1, 5
  159.   REG 2, 2
  160.   CALL INTERRUPT %MouseIntr
  161.   IF (REG(1) = 3) THEN
  162.     FN MiddleButton = -1
  163.   ELSE
  164.     FN MiddleButton = 0
  165.   END IF
  166. END DEF
  167.  
  168. '
  169. ' FN MouseMoved --> testet ob die Mouse bewegt wurde
  170. '
  171. DEF FN MouseMoved
  172.   REG 1, 11
  173.   CALL INTERRUPT %MouseIntr
  174.   IF (REG(3) <> 0) OR (REG(4) <> 0) THEN
  175.     FN MouseMoved = -1
  176.   ELSE
  177.     FN MouseMoved = 0
  178.   END IF
  179. END DEF
  180.  
  181. '
  182. ' FN MouseLeftMoved --> testet ob die Mouse nach links bewegt wurde
  183. '
  184. DEF FN MouseLeftMoved
  185.   REG 1, 11
  186.   CALL INTERRUPT %MouseIntr
  187.   IF (REG(3) < 0) THEN
  188.     FN MouseLeftMoved = -1
  189.   ELSE
  190.     FN MouseLeftMoved = 0
  191.   END IF
  192. END DEF
  193.  
  194. '
  195. ' FN MouseRightMoved --> testet ob die Mouse nach rechts bewegt wurde
  196. '
  197. DEF FN MouseRightMoved
  198.   REG 1, 11
  199.   CALL INTERRUPT %MouseIntr
  200.   IF (REG(3) > 0) THEN
  201.     FN MouseRightMoved = -1
  202.   ELSE
  203.     FN MouseRightMoved = 0
  204.   END IF
  205. END DEF
  206.  
  207. '
  208. ' FN MouseUpMoved --> testet ob die Mouse nach oben bewegt wurde
  209. '
  210. DEF FN MouseUpMoved
  211.   REG 1, 11
  212.   CALL INTERRUPT %MouseIntr
  213.   IF (REG(4) < 0) THEN
  214.     FN MouseUpMoved = -1
  215.   ELSE
  216.     FN MouseUpMoved = 0
  217.   END IF
  218. END DEF
  219.  
  220. '
  221. ' FN MouseDownMoved --> testet ob die Mouse nach unten bewegt wurde
  222. '
  223. DEF FN MouseDownMoved
  224.   REG 1, 11
  225.   CALL INTERRUPT %MouseIntr
  226.   IF (REG(4) > 0) THEN
  227.     FN MouseDownMoved = -1
  228.   ELSE
  229.     FN MouseDownMoved = 0
  230.   END IF
  231. END DEF
  232.  
  233. '
  234. ' SetXYMouse --> Mauscursor positionieren
  235. '
  236. SUB SetXYMouse(iX,iY)
  237.   REG 1, 4
  238.   REG 3, iX
  239.   REG 4, iY
  240.   CALL INTERRUPT %MouseIntr
  241. END SUB
  242.  
  243. '
  244. ' LeftButtonPressed --> ermittelt wie oft die linke Mouse-Taste
  245. '                       seit der letzten Abfrage gedrückt wurde
  246. '
  247. DEF FN LeftButtonPressed
  248.   REG 1, 5
  249.   REG 2, 0
  250.   CALL INTERRUPT %MouseIntr
  251.   FN LeftButtonPressed = REG(2)
  252. END DEF
  253.  
  254. '
  255. ' RightButtonPressed --> ermittelt wie oft die rechte Mouse-Taste
  256. '                        seit der letzten Abfrage gedrückt wurde
  257. '
  258. DEF FN RightButtonPressed
  259.   REG 1, 5
  260.   REG 2, 1
  261.   CALL INTERRUPT %MouseIntr
  262.   FN RightButtonPressed = REG(2)
  263. END DEF
  264.  
  265. '
  266. ' MiddleButtonPressed --> ermittelt wie oft die mittlere Mouse-Taste
  267. '                         seit der letzten Abfrage gedrückt wurde
  268. '
  269. DEF FN MiddleButtonPressed
  270.   REG 1, 5
  271.   REG 2, 2
  272.   CALL INTERRUPT %MouseIntr
  273.   FN MiddleButtonPressed = REG(2)
  274. END DEF
  275.  
  276. '
  277. ' LeftButtonReleased --> ermittelt wie oft die linke Mouse-Taste
  278. '                        seit der letzten Abfrage losgelassen wurde
  279. '
  280. DEF FN LeftButtonReleased
  281.   REG 1, 6
  282.   REG 2, 0
  283.   CALL INTERRUPT %MouseIntr
  284.   FN LeftButtonReleased = REG(2)
  285. END DEF
  286.  
  287. '
  288. ' RightButtonReleased --> ermittelt wie oft die rechte Mouse-Taste
  289. '                        seit der letzten Abfrage losgelassen wurde
  290. '
  291. DEF FN RightButtonReleased
  292.   REG 1, 6
  293.   REG 2, 1
  294.   CALL INTERRUPT %MouseIntr
  295.   FN RightButtonReleased = REG(2)
  296. END DEF
  297.  
  298. '
  299. ' MiddleButtonReleased --> ermittelt wie oft die mittlere Mouse-Taste
  300. '                         seit der letzten Abfrage losgelassen wurde
  301. '
  302. DEF FN MiddleButtonReleased
  303.   REG 1, 6
  304.   REG 2, 2
  305.   CALL INTERRUPT %MouseIntr
  306.   FN MiddleButtonReleased = REG(2)
  307. END DEF
  308.  
  309. '
  310. ' SetXRange --> minimale und maximale X-Position setzen
  311. '
  312. SUB SetXRange(iXMin, iXMax)
  313.   REG 1, 7
  314.   REG 3, iXMin
  315.   REG 4, iXMax
  316.   CALL INTERRUPT %MouseIntr
  317. END SUB
  318.  
  319. '
  320. ' SetYRange --> minimale und maximale Y-Position setzen
  321. '
  322. SUB SetYRange(iYMin, iYMax)
  323.   REG 1, 8
  324.   REG 3, iYMin
  325.   REG 4, iYMax
  326.   CALL INTERRUPT %MouseIntr
  327. END SUB
  328.  
  329. '
  330. ' SetGraphicCursor --> Graphic Cursor definieren
  331. '
  332. SUB SetGraphicCursor(iGraphicCursor(2), iXHotSpot, iYHotSpot)
  333.   REG 1, 9
  334.   REG 2, iXHotSpot
  335.   REG 3, iYHotSpot
  336.   REG 4, VARPTR(iGraphicCursor(0,0))
  337.   REG 9, VARSEG(iGraphicCursor(0,0))
  338.   CALL INTERRUPT %MouseIntr
  339. END SUB
  340.  
  341. '
  342. ' SetTextCursor --> Text Cursor definieren
  343. '
  344. SUB SetTextCursor(iCursorType, iTextScreenMask, iTextCursorMask)
  345.   REG 1, 10
  346.   REG 2, iCursorType
  347.   REG 3, iTextScreenMask
  348.   REG 4, iTextCursorMask
  349.   CALL INTERRUPT %MouseIntr
  350. END SUB
  351.  
  352. '
  353. ' FN GetXMickey --> horizontalen Mausbewegungs-(Mickey-)Zähler lesen
  354. '
  355. DEF FN GetXMickey
  356.   REG 1, 11
  357.   CALL INTERRUPT %MouseIntr
  358.   FN GetXMickey = REG(3)
  359. END DEF
  360.  
  361. '
  362. ' FN GetYMickey --> vertikalen Mausbewegungs-(Mickey-)Zähler lesen
  363. '
  364. DEF FN GetYMickey
  365.   REG 1, 11
  366.   CALL INTERRUPT %MouseIntr
  367.   FN GetYMickey = REG(4)
  368. END DEF
  369.  
  370. '
  371. ' SetXYMickey --> horizontale und vertikale Mickey-Einheit definieren
  372. '
  373. SUB SetXYMickey(iXMickey, iYMickey)
  374.   REG 1, 15
  375.   REG 3, iXMickey
  376.   REG 4, iYMickey
  377.   CALL INTERRUPT %MouseIntr
  378. END SUB
  379.  
  380. '
  381. ' SetMouseSpeed --> Schwellenwert für doppelte Cursor-Geschwindigkeit in
  382. '                   Mickeys/Sekunde festlegen
  383. '
  384. SUB SetMouseSpeed(iSpeed)
  385.   REG 1, 19
  386.   REG 4, iSpeed
  387.   CALL INTERRUPT %MouseIntr
  388. END SUB
  389. '──────────────────────────────────────────────────────────────────────────────
  390.