home *** CD-ROM | disk | FTP | other *** search
/ Megazine / Megazine-1.iso / PROGRAMA / CLIPPER / CALC223 / FUNMOUSE.PRG < prev    next >
Encoding:
Text File  |  1993-12-16  |  16.2 KB  |  258 lines

  1. * ┌─ Program ────────────────────────────────────────────────────────────────┐
  2. * │  Application: Calculator 2.0                                             │
  3. * │    File Name: FUNMOUSE.PRG  Funcky Mouse Interface for Calculator 2.0    │
  4. * │       Author: Jim Gale                                                   │
  5. * │ Date created: 10-03-93                                                   │
  6. * │ Time created: 11:06:04pm                                                 │
  7. * │    Make File:                                                            │
  8. * │    Exec File:                                                            │
  9. * │    Copyright: 1993 by Touchstone Business Creations                      │
  10. * │                                                                          │
  11. * │        Notes: Compile with /dPM to disable the functions m_install() and │
  12. * │               m_setchars() which *DO NOT CURRENTLY* work with            │
  13. * │               Protected Mode Funcky (FUNCKYX.LIB).  When they do work,   │
  14. * │               recompile without the /dPM.                                │
  15. * │                                                                          │
  16. * │     Protected Mode or without Graphical Cursor:                          │
  17. * │               Clipper FUNMOUSE /oFUNMOUSX /n/w /dPM                      │
  18. * │                                                                          │
  19. * │     Non-Protected Mode with Graphical Cursor:                            │
  20. * │               Clipper FUNMOUSE /n/w                                      │
  21. * │                                                                          │
  22. * └──────────────────────────────────────────────────────────────────────────┘
  23.  
  24. #ifndef PM
  25. Static cOldChars:=""
  26. #endif
  27.  
  28. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  29. * │  Description: Determime if a mouse if present in the system.             │
  30. * │       Author: Jim Gale                                                   │
  31. * │ Date created: 10-30-93                                                   │
  32. * │ Time created: 09:35:00am                                                 │
  33. * │    Copyright: Touchstone Business Creations                              │
  34. * ├──────────────────────────────────────────────────────────────────────────┤
  35. * │     Function: CM_IsMouse()                                               │
  36. * │                                                                          │
  37. * │    Arguments: none                                                       │
  38. * │                                                                          │
  39. * │ Return Value: lMouseExists - logical value representing if a mouse is    │
  40. * │                              present.                                    │
  41. * │     See Also:                                                            │
  42. * │                                                                          │
  43. * └──────────────────────────────────────────────────────────────────────────┘
  44. Function CM_IsMouse()
  45. Return IsMouse()
  46.  
  47. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  48. * │  Description: Report which mouse button is being pressed.                │
  49. * │       Author: Jim Gale                                                   │
  50. * │ Date created: 10-30-93                                                   │
  51. * │ Time created: 09:35:52am                                                 │
  52. * │    Copyright: Touchstone Business Creations                              │
  53. * ├──────────────────────────────────────────────────────────────────────────┤
  54. * │     Function: CM_Button()                                                │
  55. * │                                                                          │
  56. * │    Arguments: none                                                       │
  57. * │                                                                          │
  58. * │ Return Value: nButtonPressed - numeric representing which mouse button   │
  59. * │                                was pressed:                              │
  60. * │                                                                          │
  61. * │               Valid Values are:                                          │
  62. * │                                                                          │
  63. * │                  0 = no button pressed (or mouse not present)            │
  64. * │                  1 = left button pressed                                 │
  65. * │                  2 = right button pressed                                │
  66. * │                                                                          │
  67. * │     See Also:                                                            │
  68. * │                                                                          │
  69. * └──────────────────────────────────────────────────────────────────────────┘
  70. Function CM_Button()
  71. Return Button()
  72.  
  73. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  74. * │  Description: Report the mouse cursor row.                               │
  75. * │       Author: Jim Gale                                                   │
  76. * │ Date created: 10-30-93                                                   │
  77. * │ Time created: 09:39:26am                                                 │
  78. * │    Copyright: Touchstone Business Creations                              │
  79. * ├──────────────────────────────────────────────────────────────────────────┤
  80. * │     Function: CM_Row()                                                   │
  81. * │                                                                          │
  82. * │    Arguments: none                                                       │
  83. * │                                                                          │
  84. * │ Return Value: nMouseRow - numeric representing text row of mouse.        │
  85. * │     See Also:                                                            │
  86. * │                                                                          │
  87. * └──────────────────────────────────────────────────────────────────────────┘
  88. Function CM_Row()
  89. Return M_Row()
  90.  
  91. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  92. * │  Description: Report the mouse cursor column.                            │
  93. * │       Author: Jim Gale                                                   │
  94. * │ Date created: 10-30-93                                                   │
  95. * │ Time created: 09:39:58am                                                 │
  96. * │    Copyright: Touchstone Business Creations                              │
  97. * ├──────────────────────────────────────────────────────────────────────────┤
  98. * │     Function: CM_Col()                                                   │
  99. * │                                                                          │
  100. * │    Arguments: none                                                       │
  101. * │                                                                          │
  102. * │ Return Value: nMouseCol - numeric representing text column of mouse.     │
  103. * │     See Also:                                                            │
  104. * │                                                                          │
  105. * └──────────────────────────────────────────────────────────────────────────┘
  106. Function CM_Col()
  107. Return M_Col()
  108.  
  109. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  110. * │  Description: Turn the mouse cursor on.                                  │
  111. * │       Author: Jim Gale                                                   │
  112. * │ Date created: 10-30-93                                                   │
  113. * │ Time created: 09:40:26am                                                 │
  114. * │    Copyright: Touchstone Business Creations                              │
  115. * ├──────────────────────────────────────────────────────────────────────────┤
  116. * │     Function: CM_On()                                                    │
  117. * │                                                                          │
  118. * │    Arguments: none                                                       │
  119. * │                                                                          │
  120. * │ Return Value: n/a                                                        │
  121. * │     See Also:                                                            │
  122. * │                                                                          │
  123. * └──────────────────────────────────────────────────────────────────────────┘
  124. Function CM_On()
  125. Return M_CsrOn()
  126.  
  127. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  128. * │  Description: Turn the mouse cursor off.                                 │
  129. * │       Author: Jim Gale                                                   │
  130. * │ Date created: 10-30-93                                                   │
  131. * │ Time created: 09:42:50am                                                 │
  132. * │    Copyright: Touchstone Business Creations                              │
  133. * ├──────────────────────────────────────────────────────────────────────────┤
  134. * │     Function: CM_Off()                                                   │
  135. * │                                                                          │
  136. * │    Arguments: none                                                       │
  137. * │                                                                          │
  138. * │ Return Value: n/a                                                        │
  139. * │     See Also:                                                            │
  140. * │                                                                          │
  141. * └──────────────────────────────────────────────────────────────────────────┘
  142. Function CM_Off()
  143. Return M_CsrOff()
  144.  
  145. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  146. * │  Description: Report the state of the cursor and optionally set it.      │
  147. * │       Author: Jim Gale                                                   │
  148. * │ Date created: 10-30-93                                                   │
  149. * │ Time created: 09:44:29am                                                 │
  150. * │    Copyright: Touchstone Business Creations                              │
  151. * ├──────────────────────────────────────────────────────────────────────────┤
  152. * │     Function: CM_Cursor([<lState>])                                      │
  153. * │                                                                          │
  154. * │    Arguments: [<lState>] - new state of cursor (on/off) - optional       │
  155. * │                                                                          │
  156. * │ Return Value: lOldState - old state of cursor (on/off)                   │
  157. * │     See Also:                                                            │
  158. * │                                                                          │
  159. * └──────────────────────────────────────────────────────────────────────────┘
  160. Function CM_Cursor(lNew)
  161. Local lRet:=M_IsCursor()
  162.    If ValType(lNew)="L"
  163.       If(lNew,M_CsrOn(),M_CsrOff())
  164.    Endif
  165. Return lRet
  166.  
  167. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  168. * │  Description: Initialize/Reset mouse system for calculator               │
  169. * │       Author: Jim Gale                                                   │
  170. * │ Date created: 10-30-93                                                   │
  171. * │ Time created: 09:44:42am                                                 │
  172. * │    Copyright: Touchstone Business Creations                              │
  173. * ├──────────────────────────────────────────────────────────────────────────┤
  174. * │     Function: CM_Init()                                                  │
  175. * │                                                                          │
  176. * │    Arguments: none                                                       │
  177. * │                                                                          │
  178. * │ Return Value: NIL                                                        │
  179. * │     See Also:                                                            │
  180. * │                                                                          │
  181. * │        Notes: Since Funcky uses a graphical mouse, the characters that   │
  182. * │               become redefined to make the mouse are the same characters │
  183. * │               that                                                       │
  184. * └──────────────────────────────────────────────────────────────────────────┘
  185. Function CM_Init()
  186. #ifndef PM
  187. Local cChars:=Chr(224)+Chr(225)+Chr(226)+Chr(227)+Chr(228)+Chr(229)+;
  188.               Chr(230)+Chr(231)+Chr(232)
  189. #endif
  190.    M_Reset()
  191. #ifndef PM
  192.    cOldChars:=M_GetChars()
  193.    M_SetChars(cChars)
  194.    M_Install(1)
  195. #endif
  196.    M_CsrOn()
  197.    M_CsrOff()
  198.    M_CsrOn()
  199.    M_CsrOff()
  200. Return NIL
  201.  
  202. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  203. * │  Description: Provide any needed exit support for the mouse.             │
  204. * │       Author: Jim Gale                                                   │
  205. * │ Date created: 10-30-93                                                   │
  206. * │ Time created: 10:23:22am                                                 │
  207. * │    Copyright: Touchstone Business Creations                              │
  208. * ├──────────────────────────────────────────────────────────────────────────┤
  209. * │     Function: CM_Exit()                                                  │
  210. * │                                                                          │
  211. * │    Arguments: none                                                       │
  212. * │                                                                          │
  213. * │ Return Value: NIL                                                        │
  214. * │     See Also:                                                            │
  215. * │                                                                          │
  216. * └──────────────────────────────────────────────────────────────────────────┘
  217. Function CM_Exit()
  218. #ifndef PM
  219.    M_SetChars(cOldChars)
  220. #endif
  221. Return NIL
  222.  
  223. * ┌─ Function ───────────────────────────────────────────────────────────────┐
  224. * │  Description: Wait .2 seconds for a key or until a button is released.   │
  225. * │       Author: Jim Gale                                                   │
  226. * │ Date created: 10-30-93                                                   │
  227. * │ Time created: 09:47:46am                                                 │
  228. * │    Copyright: Touchstone Business Creations                              │
  229. * ├──────────────────────────────────────────────────────────────────────────┤
  230. * │     Function: CM_Wait(<nButton>,<lMousekey>)                             │
  231. * │                                                                          │
  232. * │    Arguments: <nButton>   - button state to wait for.                    │
  233. * │               <lMousekey> - whether to wait until a button is released.  │
  234. * │                                                                          │
  235. * │ Return Value: <nKey>      - numeric representing the key pressed.        │
  236. * │                                                                          │
  237. * │        Notes: This function is called by the calculator after            │
  238. * │               highlighting the button on-screen that was pressed/clicked.│
  239. * │                                                                          │
  240. * │               When a mouse is present, the purpose is to wait until it   │
  241. * │               is released so that drifting of the mouse does not cause   │
  242. * │               unwanted keystrokes.                                       │
  243. * │                                                                          │
  244. * │               Without a mouse present, the purpose is to wait .2 seconds │
  245. * │               for the highlighting effect (unless a key was pressed).    │
  246. * │                                                                          │
  247. * │     See Also:                                                            │
  248. * └──────────────────────────────────────────────────────────────────────────┘
  249. Function CM_Wait(n,lMousekey)
  250. Local nKey:=0
  251.    If lMousekey
  252.       While Button()#n .and. (nKey:=Inkey())=0
  253.       Enddo
  254.    Else
  255.       nKey:=Inkey(.2)
  256.    Endif
  257. Return nKey
  258.