home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / BASIC / MNUSYS11 / MENUSYS.TXT < prev    next >
Text File  |  1993-09-23  |  11KB  |  313 lines

  1. Menusys Menuing System
  2. Text-Mode GUI for PowerBASIC 3.0
  3.  
  4. (C) Copyright 1993 by Tim Gerchmez
  5. ----------------------------------
  6.  
  7.  
  8.               ** Sub and Function Reference **
  9.  
  10.  
  11. Total Routines: 24
  12. -----------------------------------------------------------------------------
  13. * FUNCTION altkey%
  14.  
  15. This function returns the state of the ALT key.  It will return one
  16. if the ALT key is pressed, or zero if it isn't.
  17.  
  18. Example: IF altkey% <> 0 THEN PRINT "ALT Key Pressed!"
  19.  
  20. -----------------------------------------------------------------------------
  21. * SUB dopcopyfrom
  22.  
  23. This routine copies the page zero text screen to page
  24. one, turning off the mouse first if necessary.
  25.  
  26. Example: CALL dopcopyfrom
  27.  
  28. -----------------------------------------------------------------------------
  29. * SUB dopcopyto
  30.  
  31. This routine copies the text screen at page one back
  32. to page zero, turning off the mouse first if necessary.
  33.  
  34. Example: CALL dopcopyto
  35.  
  36. -----------------------------------------------------------------------------
  37. * SUB drawbox (yd%, xd%, tpe%, shadow%, title$)
  38.  
  39. Draws a box with the upper left corner at the current cursor
  40. position.
  41.  
  42. yd% / xd% = Y and X dimensions of the box desired
  43.  
  44. tpe% = border type:
  45. 0 = no border
  46. 1 = single border
  47. 2 = double border
  48.  
  49. shadow% = shadow type:
  50. 0 = no shadow
  51. 1 = left shadow
  52. 2 = right shadow
  53.  
  54. title$ = title for box (set to "" for none)
  55.  
  56. Example: LOCATE 1,1
  57.      CALL drawbox(10, 10, 1, 2, "This is a box")
  58.  
  59. ------------------------------------------------------------------------------
  60. * SUB findfile (fi$, yn%)
  61.  
  62. Searches for the specified path\file in fi$.  If not
  63. found, yn% = 0, else yn% = 1.
  64.  
  65. example: INPUT "Filename ";fi$
  66.      call findfile(fi$, yn%)
  67.      if yn% = 0 then print "File Not Found"
  68.  
  69. -----------------------------------------------------------------------------
  70. * SUB mcheck
  71.  
  72. Checks current position of mouse cursor and state of buttons
  73. and updates the corresponding global variables msy%, msx%, lb%
  74. and rb% (for lb% and rb%, 1 = pressed, 0 = not pressed).
  75.  
  76. msy% = y coordinates of mouse cursor (1-25)
  77. msx% = x coordinates of mouse cursor (1-80)
  78. lb% = left button
  79. rb% = right button
  80.  
  81. Example: CALL mcheck
  82.  
  83. -----------------------------------------------------------------------------
  84. * SUB MENUSYS (menu$(), help$(), menucount%(), menutype%(), topchoice%, bottomchoice%)
  85.  
  86. Displays a pull-down menu at the top of the screen.  DIM menu$
  87. (topcount%, bottomcount%), help$(topcount%, bottomcount%),
  88. menutype%(topcount%, bottomcount%).  Topcount% should correspond
  89. to the number of top (bar) menu choices available, and bottomcount%
  90. to the MAXIMUM number of bottom menu choices available.
  91.  
  92. topchoice% and bottomchoice% will be returned, corresponding to the top
  93. (bar) and bottom (box) menu choices selected by the user.  If the user
  94. presses ESC, bottomchoice% will equal zero.
  95.  
  96. * This is the "main" routine in the MENUSYS Library,
  97. * and the one routine that calls most of the others.
  98.  
  99. Menu Types (for menutype%):
  100. 0 = Available (normal)
  101. 1 = Unavailable (cannot be selected)
  102. 2 = Bullet On
  103. 3 = Bullet Off
  104.  
  105. Use Function ALTKEY in a separate program to determine if the ALT key
  106. is pressed (to call this routine) and/or use the mouse routines to
  107. determine if the mouse cursor is in the top row and proper column
  108. to call this routine.  If not using ALTKEY or mouse cursor to call
  109. MENUSYS, you can set topchoice% to the starting choice number for
  110. the top menu before calling (defaults to menu option one).
  111.  
  112. Menu Selection Columns (for each top item):
  113. 1 = 1-10       2 = 11-20       3 = 21-30       4 = 31-40
  114. 5 = 41-50      6 = 51-60       7 = 61-70       8 = 71-80
  115.  
  116. Example: CALL menusys(menu$(), help$(), menucount%(), menutype%(), topch%, botch%)
  117.      PRINT "You Chose ";topch%; botch%
  118.  
  119. -----------------------------------------------------------------------------
  120. * SUB mhardreset (ms%, nb%)
  121.  
  122. Checks status of mouse and resets if present.  Use this routine
  123. at the beginning of a program to check for the presence of a mouse
  124. and to reset it if present.
  125. Returns ms% = -1 and nb% = number of buttons if mouse driver present
  126. and reset, otherwise ms% = 0.
  127.  
  128. Example: CALL mhardreset(ms%, nb%)
  129.      IF ms%<>0 then print "Mouse Found, with ";nb%;" buttons."
  130.  
  131. -----------------------------------------------------------------------------
  132. * SUB mhide
  133.  
  134. Makes the mouse cursor invisible, and decrements the internal
  135. mouse cursor flag by one.
  136.  
  137. Example: IF mouse% <> 0 THEN CALL mhide
  138.  
  139. -----------------------------------------------------------------------------
  140. * SUB mscrolldown (nls%, uly%, ulx%, lry%, lrx%, atrb%)
  141.  
  142. Scrolls a portion of the text screen down, turning the mouse
  143. cursor off first if necessary.  Set uly% and ulx% to the
  144. coordinates for the upper left corner of the area to scroll,
  145. and lry% and lrx% to the lower right corner of the area to
  146. scroll.  Set atrb% to the attribute to scroll into the blank
  147. area.  nls% = number of lines to scroll down (if 0, the entire
  148. area is blanked).
  149.  
  150. Example: CALL mscrolldown(1, 1, 1, 25, 80, 7)
  151.  
  152. -----------------------------------------------------------------------------
  153. * SUB mscrollup (nls%, uly%, ulx%, lry%, lrx%, atrb%)
  154.  
  155. Scrolls a portion of the text screen up, turning the mouse
  156. cursor off first if necessary.  Set uly% and ulx% to the
  157. coordinates for the upper left corner of the area to scroll,
  158. and lry% and lrx% to the lower right corner of the area to
  159. scroll.  Set atrb% to the attribute to scroll into the blank
  160. area.  nls% = number of lines to scroll up (if 0, the entire
  161. area is blanked).
  162.  
  163. Example: CALL mscrollup(1, 1, 1, 25, 80, 7)
  164.  
  165. -----------------------------------------------------------------------------
  166. * SUB mshow
  167.  
  168. Increments the internal mouse cursor flag, and if flag = 0, makes
  169. the mouse cursor visible.  Flag defaults to -1 when driver is reset,
  170. so this function will usually make the cursor visible on the screen.
  171.  
  172. Example: CALL mshow
  173.  
  174. -----------------------------------------------------------------------------
  175. * SUB mwaitrelease
  176.  
  177. Waits for Left/Right Mouse Button to be Released.
  178.  
  179. Example: CALL mwaitrelease
  180.  
  181. ------------------------------------------------------------------------------
  182. * sub pagecopy(source%, dest%)
  183.  
  184. This routine copies the screen page specified in source% to the page
  185. specified in dest%, and is called by dopcopyfrom and dopcopyto to
  186. save/restore the current text screen.
  187.  
  188. This is a text-mode only imitation of the
  189. QuickBASIC/QBASIC PCOPY command.
  190.  
  191. Example: CALL pagecopy(1, 0)
  192.  
  193. -----------------------------------------------------------------------------
  194. * SUB printbottomhelp (hlp$)
  195.  
  196. Internal routine used by Menusys, but can be used externally as well.
  197. Displays the line of help text in hlp$ on the bottom of the screen.
  198. Blanks the bottom screen line if hlp$ = "-". To skip print, set hlp$
  199. to "".
  200.  
  201.  
  202. Example: hlp$="Press F1 for Help"
  203.      CALL printbottomhelp(hlp$)
  204.  
  205. -----------------------------------------------------------------------------
  206. * SUB readhelp (topchoice%, bottomchoice%)
  207.  
  208. A routine to display context-sensitive help.  Utilized by MENUSYS but can
  209. also be called externally.  The global variable HELPFN$ should be set to
  210. the path\filename of the help file, and PROGNAME$ to the name of the program
  211. that the help is for.  The format of the help files in MENUSYS is:
  212.  
  213. [1/1]
  214.  
  215. HELP TEXT
  216.  
  217. ~~~
  218. [1/2]
  219.  
  220. HELP TEXT
  221.  
  222. ~~~
  223. [1/3]
  224.  
  225. HELP TEXT
  226.  
  227. ~~~
  228.  
  229. The top and bottom menu entries for the help item desired should be in
  230. topchoice% and bottomchoice% before calling.  Notice that each help entry
  231. in the help file has the top/bottom menu entries defined in square brackets,
  232. followed immediately by the help text.  At the end of the help text for each
  233. menu item, there are three tildes in a row.  There can be an unlimited
  234. number of help items in each help file, as long as they follow the above
  235. format (see the example help file included with MENUSYS).  If you use
  236. [0/0] or any other numbers that don't fall in the area of the top/bottom
  237. menu entries, you can call readhelp from the main program to display help
  238. on other program options.  For example, you could CALL READHELP(0,0) and
  239. have a [0/0] entry in your help file.
  240.  
  241. If you don't want MENUSYS to display help for the various pulldown menu
  242. items, just set HELPFN$ to "" before calling.  Also, if READHELP doesn't
  243. find the help file indicated in HELPFN$, it won't crash but it won't
  244. display any help either.  If it finds the help file but not the entry
  245. specified in topchoice%/bottomchoice%, it will display "NO HELP AVAILABLE
  246. FOR THIS MENU ENTRY."
  247.  
  248. Example: PRINT "You Pressed F1!"
  249.      CALL readhelp(0, 0)
  250.  
  251. -----------------------------------------------------------------------------
  252. * SUB readscreen (y%, x%, ch%, atr%, fgd%, bkg%)
  253.  
  254. A routine to read the contents of the screen at the Y (1-25) and X
  255. (1-80) coordinates specified in y% and x%.  The character at the screen
  256. position specified will be returned in ch%, the attribute value in atr%,
  257. the foreground color in fgd%, and the background color in bkg%.
  258.  
  259. Example: CALL readscreen(1, 1, ch%, atr%, fgd%, bkg%)
  260.  
  261. -----------------------------------------------------------------------------
  262. * FUNCTION vidseg&
  263.  
  264. A function to return the correct video segment.  VIDSEG& will equal
  265. &hb800 if color or &hb000 if a monochrome monitor is detected.  These
  266. values can then be used with DEF SEG and an offset to access video
  267. (text) memory directly.
  268.  
  269. Example: IF vidseg& = &Hb800 then print "Color"
  270.  
  271. -----------------------------------------------------------------------------
  272. * SUB writescreen (y%, x%, ch%, atr%, fgd%, bkg%)
  273.  
  274. A routine to store a certain value at a specified screen location.  Set y%
  275. and x% to the Y and X screen coordinates desired, ch% to the character to
  276. store.  Then either set atr% to 0 and fgd% and bkg% to the desired
  277. foreground/background colors, or set atr% to the desired attribute and
  278. ignore the values of fgd% and bkg%, and call this routine.
  279.  
  280. Example: CALL writescreen(1, 1, 32, 0, 7, 1)
  281.  
  282. -----------------------------------------------------------------------------
  283. Internal Routines used by function MENUSYS:
  284.  
  285. * SUB bottomdehilight (top%, bottom%, menu$(), menutype%())
  286.  
  287. This is an internal routine used by MENUSYS to dehighlight
  288. box menu options.
  289.  
  290.  
  291. * SUB bottomhilight (top%, bottom%, menu$(), menutype%())
  292.  
  293. This is an internal routine used by MENUSYS to highlight
  294. box menu options.
  295.  
  296.  
  297. * SUB printbottommenu (top%, menu$(), menucount%(), menutype%(), bcheck$)
  298.  
  299. An internal routine used by MENUSYS to display the bottom (box) menus.
  300.  
  301.  
  302. * SUB printtopmenu (menu$(), hilight%)
  303.  
  304. An internal routine used by MENUSYS to display the top (bar) menu.
  305.  
  306.  
  307. * SUB tophilight (top%, hilight%, menu$())
  308.  
  309. An internal routine used by MENUSYS to highlight entries on the top
  310. (bar) menu.
  311.  
  312. -----------------------------------------------------------------------------
  313.