home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / WNDTOOL5.ZIP / POPLIST.SUB < prev    next >
Text File  |  1989-04-26  |  28KB  |  794 lines

  1. '
  2. '$PAGE
  3. '
  4. '******************************************************************************
  5. '                    Function :                                               *
  6. '                                                                             *
  7. ' Purpose:                                                                    *
  8. '                                                                             *
  9. '                                                                             *
  10. ' Results:                                                                    *
  11. '                                                                             *
  12. ' Usage  :                                                                    *
  13. '                                                                             *
  14. '                                                                             *
  15. ' Date Written : 01/01/89 - Date Tested: 01/01/89 - Author: James P Morgan    *
  16. ' Date Modified:          -            :          -       :                   *
  17. '-----------------------------------------------------------------------------*
  18. ' NOTE:                                                                       *
  19. '******************************************************************************
  20. '                                                                             *
  21. '     SUB PROGRAM NAME          (PARAMETERS)                 STATIC/RECURSIVE *
  22. '-----------------------------------------------------------------------------*
  23. '                                                                             *
  24. '============================================================================
  25. '
  26. SUB    POPLIST(HEADER$,SHOWITEMS%,MAXITEMS%,ITEM$(1),FORE%,BACK%,HFORE%,HBACK%,QUADRANT$,SHADOW%,SELECT.%)  STATIC
  27.  
  28.        DEFINT A-Z                               'make all short intergers by default
  29.  
  30.        SELECT.BASE=1                            'normalize
  31.  
  32.        TEMP.ITEM$=STRING$(255," ")
  33.        ITEM.MIN=LBOUND(ITEM$)                   'adjust for callers OPTION BASE
  34.  
  35.  
  36.        BEGVAL=1
  37.  
  38.        MENU.TOP.ROW=0
  39.        MENU.TOP.LEFT.COL=0
  40.        MENU.BOTTOM.ROW=0
  41.        MENU.BOTTOM.RIGHT.COL=0
  42.  
  43.        BUTTONS%=0                               'assume no mouse support avail
  44.  
  45.        CALL MMCHECK(BUTTONS%)                   'see if mouse support avail
  46.  
  47.        GOSUB POPLIST.MMCURSORON
  48.  
  49.        MOUSECOL=0                               'locate the mouse cursor in upper
  50.        MOUSEROW=0                               'left top corner of screen
  51.  
  52.        CALL MMSETLOC(MOUSECOL,MOUSEROW)         'move the mouse cursor
  53.  
  54.        GOSUB POPLIST.MMCURSOROFF
  55.  
  56.        IF SHOWITEMS%> MAXITEMS% THEN            'we cant show more than whats avail
  57.            SHOWITEMS%=MAXITEMS%
  58.        ENDIF
  59.  
  60. '
  61.        WINDLEN=LEN(HEADER$)                     'assume window length is header length
  62.  
  63. 'Determine width of window from length of longest item
  64.        J.BASE=1
  65.        FOR J=J.BASE TO MAXITEMS%
  66.            J.SUB=(J-J.BASE)+ITEM.MIN
  67.            IF LEN(ITEM$(J.SUB)) > WINDLEN THEN
  68.                WINDLEN=LEN(ITEM$(J.SUB))
  69.            ENDIF
  70.  
  71.        NEXT
  72.  
  73.        LENGTH.MENU.ITEM=WINDLEN                 'this is the length of the longest item
  74.  
  75. 'If Quadrant is in ROW:COL format, extract Row and Column
  76.  
  77.        IF INSTR(QUADRANT$,":")<>0 THEN          'was an absolute row:column specified
  78.            GOSUB POPLIST.GETORD
  79.          GOTO POPLIST.GO1
  80.        ENDIF
  81.  
  82. 'Determine Position based on Quadrant Parameter and size of menu
  83.  
  84.        QUADRANT=VAL(QUADRANT$)                  'The window is to be in 1 of the 5 quadrants
  85.  
  86.        IF QUADRANT <0 OR QUADRANT >4 THEN       'make sure the quadrant is valid
  87.            QUADRANT=0                           'if invalid, default to center of screen
  88.        ENDIF
  89.  
  90.        CALL SETQUAD(QUADRANT,CROW,CCOL,WINDLEN,SHOWITEMS%)
  91.  
  92.        ULR%=CROW-(((SHOWITEMS%+2)/2)-.5)        'the upper left row:column window co-ordinates
  93.        ULC%=CCOL-((WINDLEN/2)-.5)
  94.        LRR=ULR%+SHOWITEMS%+1                    'the lower right window co-ordinates
  95.        LRC=ULC%+WINDLEN-1
  96.  
  97. '
  98. 'Create Window for List
  99. POPLIST.GO1:
  100.        MENU.TOP.ROW=ULR%+2                      'allow for the menu name box above the window
  101.        MENU.TOP.LEFT.COL=ULC%
  102.        MENU.BOTTOM.ROW=LRR
  103.        MENU.BOTTOM.RIGHT.COL=LRC
  104.  
  105.        FRAME%=4
  106.  
  107.        CALL MAKEWIND(ULR%,ULC%,LRR,LRC,FRAME,FORE%,BACK%,GROW,SHADOW%,LABEL$)
  108.  
  109.        TEMPHDR$=SPACE$(WINDLEN)                 'make menu header as big as biggest item
  110.  
  111.        IF LEN(HEADER$)<>WINDLEN THEN            'does the menu header need centering?
  112.             GOSUB POPLIST.PUTHDR                'YES
  113.        ENDIF
  114.  
  115.        ATTR=(HBACK% AND 7)*16+HFORE%            'display the menu header
  116.        ROW=ULR%
  117.        COL=ULC%
  118.        CALL FASTPRT(HEADER$,ROW,COL,ATTR)
  119.  
  120.        ATTR=(BACK% AND 7)*16+FORE%              'bracket the menu header in the window
  121.        ROW=ULR%+1
  122.        COL=ULC%
  123.        DAT$=STRING$(WINDLEN,205)
  124.        CALL FASTPRT(DAT$,ROW,COL,ATTR)
  125.  
  126. 'Set current choice to List Item #1, Set Beginning and Ending values,
  127. 'Display 'More...' message and enter Loop
  128.  
  129.  
  130.        IF (SELECT.%<1) OR (SELECT.%>MAXITEMS%) THEN 'is first item to be displayed valid range?
  131.           SELECT.%=1                                'NO, so display first one by default
  132.        ENDIF
  133.  
  134.        FIRST.SELECT=SELECT.%                        'remember the first item to display
  135.  
  136.        SELECT.%=1                                   'display the first group of items
  137.  
  138.        BEGVAL=SELECT.%                              'starting with the first item
  139.        ENDVAL=SHOWITEMS%                            'and ending with the max we can display at once
  140.  
  141.        GOSUB POPLIST.FILL
  142.  
  143.        IF FIRST.SELECT<>1 THEN                      'do we really want to display another item first?
  144.           TEMP.SELECT=FIRST.SELECT                  'yes, make it so
  145.           GOSUB POPLIST.FOUND.IT
  146.        ENDIF
  147.  
  148. '
  149. POPLIST.LOOP:
  150.        GOSUB POPLIST.PRESS                          'Get KeyPress
  151.  
  152.        IF KP$=CHR$(13) OR KP$=CHR$(27) THEN         'was Enter or ESC key pressed?
  153.           GOTO POPLIST.DONE                         'yes, were are thru
  154.        ENDIF
  155.  
  156.        GOTO POPLIST.LOOP                            'keep waiting for user to press a key
  157.  
  158. '
  159. 'Check for KeyPress and sound error if not UP ARROW, DOWN ARROW, HOME, END, PAGE UP, PAGE DOWN, or RETURN
  160. POPLIST.PRESS:
  161.        GOSUB POPLIST.MMCURSORON
  162.  
  163.        CALL MMGETLOC(MOUSECOL,MOUSEROW)
  164.  
  165.        CALL MMCLICK(LFT%,RGT%)                       'flush any mouse clicks
  166.  
  167.        GOSUB POPLIST.GET.PRESS
  168.  
  169.        IF KP$="" THEN                                'wait for a key or mouse click
  170.            GOTO POPLIST.PRESS
  171.        ENDIF
  172.  
  173.        IF LEN(KP$)=2 THEN                            'was an extended function key pressed?
  174.            GOTO POPLIST.DOWN                         'yes
  175.        ENDIF
  176.  
  177. POPLIST.PRESS.ON:
  178.        IF KP$=CHR$(13) THEN                          'Enter key pressed?
  179.            RETURN
  180.        ENDIF
  181.  
  182.        IF KP$=CHR$(27) THEN                          'ESC key pressed
  183.            SELECT.%=0                                'nothing noted as being selected
  184.          RETURN
  185.        ENDIF
  186.  
  187.        GOSUB POPLIST.FIND.OPTION                     'find the first char of an item that matches key pressed
  188.  
  189.        IF SELECT.%<>SAVE.SELECT THEN                 'was a new item found?
  190.            RETURN                                    'YES
  191.        ENDIF
  192.  
  193.        GOSUB POPLIST.SOUNDOFF                        'NO, a new item not found!
  194.        GOTO POPLIST.PRESS
  195.  
  196. '
  197. 'Process DOWN ARROW KeyPress
  198. POPLIST.DOWN:
  199.        IF ASC(RIGHT$(KP$,1))=80 THEN                 'was cursor down key pressed?
  200.            OLD=SELECT.%                              'this is the current item highlighted
  201.            SELECT.%=SELECT.%+1                       'this is the new item we want highlighted
  202.        ELSE
  203.            GOTO POPLIST.UP                           'NO, see if cursor up
  204.        ENDIF
  205.  
  206.        IF SELECT.% > MAXITEMS% THEN                  'are we at the end of the items?
  207.            IF SHOWITEMS%=MAXITEMS% THEN              'is this a POPMENU
  208.                BEGVAL=1                              'loop back to top of menu items
  209.                OLD=MAXITEMS%                         'point to current item highlighted
  210.                SELECT.%=1                            'point to next item to highlight
  211.                ENDVAL=MAXITEMS%                      'point to last menu item to display
  212.                GOSUB POPLIST.FILL
  213.              RETURN
  214.          ELSE
  215.            SELECT.% = MAXITEMS%                       'cant go past the end!
  216.            GOSUB POPLIST.SOUNDOFF
  217.          ENDIF
  218.        ENDIF
  219.  
  220.        IF (SELECT.% > ENDVAL) AND (SELECT.% = MAXITEMS%) THEN
  221.            BEGVAL=BEGVAL+1
  222.            ENDVAL=ENDVAL+1
  223.            GOSUB POPLIST.FILL
  224.          RETURN
  225.        ENDIF
  226.  
  227. '
  228. ' have we requested an item on the next screen of items
  229. '
  230.        IF (SELECT.% > ENDVAL) AND (SELECT.% <> MAXITEMS%) THEN
  231.            BEGVAL=BEGVAL+1
  232.            ENDVAL=ENDVAL+1
  233.            GOSUB POPLIST.FILL
  234.          RETURN
  235.        ENDIF
  236.  
  237. '
  238. ' highlight the next item
  239.        GOSUB POPLIST.FILL
  240.        RETURN
  241.  
  242. '
  243. 'Process UP ARROW KeyPress
  244. POPLIST.UP:
  245.        IF ASC(RIGHT$(KP$,1))=72 THEN                 'was cursor up key pressed?
  246.            OLD=SELECT.%                              'this is the current item highlighted
  247.            SELECT.%=SELECT.%-1                       'this is the new item we want highlighted
  248.        ELSE
  249.            GOTO POPLIST.PG.UP                        'NO, see if page up
  250.        ENDIF
  251.  
  252.        IF SELECT.% < 1 THEN                          'are we at the top of the items?
  253.            IF SHOWITEMS%=MAXITEMS% THEN              'is this a POPMENU
  254.                BEGVAL=1                              'loop back to bottom of menu items
  255.                OLD=1                                 'point to current highlighted item
  256.                SELECT.%=MAXITEMS%                    'point to next item to highlight
  257.                ENDVAL=MAXITEMS%                      'point to last item to display
  258.                GOSUB POPLIST.FILL
  259.              RETURN
  260.          ELSE
  261.            SELECT.% = 1                               'cant go past the top!
  262.            GOSUB POPLIST.SOUNDOFF
  263.          ENDIF
  264.        ENDIF
  265.  
  266.        IF (SELECT.% < BEGVAL) AND (SELECT.% = 1) THEN
  267.            BEGVAL=BEGVAL-1
  268.            ENDVAL=ENDVAL-1
  269.            GOSUB POPLIST.FILL
  270.          RETURN
  271.        ENDIF
  272.  
  273. '
  274. ' have we requested an item on the next screen of items
  275. '
  276.        IF (SELECT.% < BEGVAL) AND (SELECT.% <> 1) THEN
  277.            BEGVAL=BEGVAL-1
  278.            ENDVAL=ENDVAL-1
  279.            GOSUB POPLIST.FILL
  280.          RETURN
  281.        ENDIF
  282.  
  283. '
  284. ' highlight the next item
  285.        GOSUB POPLIST.FILL
  286.        RETURN
  287.  
  288. '
  289. 'Process PAGE UP KeyPress
  290. POPLIST.PG.UP:
  291.        IF ASC(RIGHT$(KP$,1))=73 THEN                 'was page up  key pressed?
  292.            OLD=SELECT.%                              'this is the current item highlighted
  293.            SELECT.%=SELECT.%-SHOWITEMS%              'this is the new item we want highlighted
  294.        ELSE
  295.            GOTO POPLIST.PG.DN                        'NO, see if cursor down
  296.        ENDIF
  297.  
  298.        IF SELECT.% < 1 THEN                          'are we at the first screen of items?
  299.            KP$=CHR$(0)+CHR$(79)                      'simulate a END key press
  300.            SELECT.%=OLD
  301.          GOTO POPLIST.ENDK
  302.        ENDIF
  303.  
  304.        BEGVAL=BEGVAL-SHOWITEMS%                      'calculate the first and last items in next screen
  305.        ENDVAL=ENDVAL-SHOWITEMS%
  306.  
  307.        IF BEGVAL < 1 THEN                            'we cant go past first item
  308.            BEGVAL=1                                  'point to first item
  309.            ENDVAL=SHOWITEMS%
  310.        ENDIF
  311.  
  312.        GOSUB POPLIST.FILL                            'highlight the item
  313.        RETURN
  314.  
  315. 'Process PAGE DOWN KeyPress
  316. POPLIST.PG.DN:
  317.        IF ASC(RIGHT$(KP$,1))=81 THEN                 'was page down  key pressed?
  318.            OLD=SELECT.%                              'this is the current item highlighted
  319.            SELECT.%=SELECT.%+SHOWITEMS%              'this is the new item we want highlighted
  320.        ELSE
  321.            GOTO POPLIST.HOME                         'NO, see if home pressed
  322.        ENDIF
  323.  
  324.        IF SELECT.% > MAXITEMS% THEN                  'are we at the last screen of items?
  325.            KP$=CHR$(0)+CHR$(71)                      'simulate a HOME key press
  326.            SELECT.%=OLD
  327.          GOTO POPLIST.HOME
  328.        ENDIF
  329.  
  330.        BEGVAL=BEGVAL+SHOWITEMS%                      'calculate the first and last items in next screen
  331.        ENDVAL=ENDVAL+SHOWITEMS%
  332.  
  333.        IF ENDVAL > MAXITEMS% THEN                    'we cant go past the last item
  334.            ENDVAL=MAXITEMS%                          'point to last item
  335.            BEGVAL=ENDVAL-SHOWITEMS%+1
  336.        ENDIF
  337.  
  338.        GOSUB POPLIST.FILL                            'highlight the item
  339.        RETURN
  340.  
  341. '
  342. 'Process HOME KeyPress
  343. POPLIST.HOME:
  344.        IF ASC(RIGHT$(KP$,1))=71 THEN                 'was home key pressed?
  345.            OLD=SELECT.%                              'this is the current item highlighted
  346.            SELECT.%=1                                'display the first group of items
  347.        ELSE
  348.            GOTO POPLIST.ENDK                         'NO, see if end key pressed
  349.        ENDIF
  350.  
  351.        BEGVAL=1                                      'point to the first item
  352.        ENDVAL=BEGVAL+SHOWITEMS%-1                    'and display the first screen of this many items
  353.        GOSUB POPLIST.FILL
  354.        RETURN
  355.  
  356. '
  357. 'Process END KeyPress
  358. POPLIST.ENDK:
  359.        IF ASC(RIGHT$(KP$,1))=79 THEN                 'was end key pressed?
  360.            OLD=SELECT.%                              'this is the current item highlighted
  361.            SELECT.%=MAXITEMS%                        'display the last group of items
  362.        ELSE
  363.            GOTO POPLIST.ERRCHK                       'NO, let user know invalid key pressed
  364.        ENDIF
  365.  
  366.        ENDVAL=MAXITEMS%                              'point to the last item
  367.        BEGVAL=ENDVAL-SHOWITEMS%+1                    'display screen of last group of items
  368.  
  369.        GOSUB POPLIST.FILL
  370.        RETURN
  371.  
  372. '
  373. 'Process ERROR
  374. POPLIST.ERRCHK:
  375.        GOSUB POPLIST.SOUNDOFF                        'let user know problem/error
  376.        GOTO POPLIST.PRESS
  377.  
  378. '
  379. 'Fill Contents of window
  380. POPLIST.FILL:
  381.        IF BEGVAL < 1 THEN                             'make sure we dont go out of bounds
  382.            BEGVAL=1
  383.        ENDIF
  384.  
  385.        IF ENDVAL > MAXITEMS% THEN                     'make sure we dont go past the end of the items
  386.            ENDVAL=MAXITEMS%
  387.        ENDIF
  388.  
  389.        OFFSET=ENDVAL-SELECT.%
  390.  
  391.        IF OFFSET < 0 THEN
  392.            OFFSET = 0
  393.        ELSEIF OFFSET > SHOWITEMS%-1 THEN
  394.            OFFSET = SHOWITEMS%-1
  395.        ENDIF
  396.  
  397.        GOSUB POPLIST.MMCURSOROFF
  398.  
  399.        K=1
  400.        J.BASE=1
  401.  
  402. '
  403. ' display the group of items we need
  404. '
  405.        FOR J=BEGVAL TO ENDVAL
  406.          ATTR=(BACK% AND 7)*16+FORE%
  407.          ROW=(ULR%+1+K)
  408.          COL=ULC%
  409.          DAT$=ITEM$((J-J.BASE)+ITEM.MIN)
  410.          IF LEN(DAT$)<WINDLEN THEN
  411.             DAT$=DAT$+STRING$(WINDLEN-LEN(DAT$)," ")
  412.          ENDIF
  413.  
  414.          CALL FASTPRT(DAT$,ROW,COL,ATTR)
  415.  
  416.          K=K+1
  417.        NEXT
  418.  
  419. '
  420. 'highlight the next item displayed
  421.        ATTR=(FORE% AND 7)*16+BACK%
  422.  
  423.        IF BEGVAL=1 AND SELECT.%=1 THEN
  424.             ROW=ULR%+2
  425.        ELSEIF (SELECT.% >= BEGVAL) AND (SELECT.% <= ENDVAL) THEN
  426.             ROW=ULR%+2+SELECT.%
  427.        ENDIF
  428.  
  429.        IF (ENDVAL=MAXITEMS%) AND (SELECT.%=MAXITEMS%) THEN
  430.             ROW=LRR
  431.        ELSE
  432.             ROW=LRR-OFFSET
  433.        ENDIF
  434.  
  435.        COL=ULC%
  436.        DAT$=ITEM$((SELECT.%-SELECT.BASE)+ITEM.MIN)
  437.        IF LEN(DAT$)<WINDLEN THEN
  438.             DAT$=DAT$+STRING$(WINDLEN-LEN(DAT$)," ")
  439.        ENDIF
  440.  
  441. '
  442. ' display this selected item, and highlight it
  443.  
  444.        CALL FASTPRT(DAT$,ROW,COL,ATTR)
  445.  
  446.        MOUSEROW=(ROW-1)*8                   'if so, put the mouse cursor on the new selection
  447.        MOUSECOL=(COL+(LEN(DAT$)\2)-1)*8
  448.        CALL MMSETLOC(MOUSECOL,MOUSEROW)
  449.  
  450.        GOSUB POPLIST.MORE                   'put arrows on top and bottom of window
  451.        RETURN
  452.  
  453. '
  454. 'Display arrowhead on top or bottom of window as necessary
  455. POPLIST.MORE:
  456.        IF SHOWITEMS%=MAXITEMS% THEN         'are we doing POPMENU
  457.             RETURN                          'yes, all items displayed at once
  458.        ENDIF
  459.  
  460.        MCOL=ULC%+((LRC-ULC%)/2)-3           'calculate the windows upper frame location
  461.  
  462.        DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
  463.  
  464.        MROW=ULR%+1
  465.        GOSUB POPLIST.DISP
  466.  
  467.        MROW=LRR+1
  468.        GOSUB POPLIST.DISP
  469.  
  470.        RETURN
  471.  
  472. '
  473. 'are we on the first screen of items
  474. '
  475. '      IF BEGVAL > 1 THEN
  476. '           MROW=ULR%+1
  477. '           DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
  478. '           GOSUB POPLIST.DISP
  479. '      ENDIF
  480.  
  481. '
  482. 'are we neither at the top nor bottom of the list of items being displayed
  483. '
  484. '      IF ENDVAL < MAXITEMS% THEN
  485. '           MROW=LRR+1
  486. '           DAT$=" "+CHR$(30)+" "+CHR$(205)+" "+CHR$(31)+" "
  487. '           GOSUB POPLIST.DISP
  488. '      ENDIF
  489. '
  490. '      IF SELECT.% = 1 THEN
  491. '           MROW=ULR%+1
  492. '           DAT$=CHR$(205)+CHR$(205)+" "+CHR$(31)+" "+CHR$(205)+CHR$(205)
  493. '           GOSUB POPLIST.DISP
  494. '      ENDIF
  495. '
  496. '      IF SELECT.% = MAXITEMS% THEN
  497. '           MROW=LRR+1
  498. '           DAT$=CHR$(205)+CHR$(205)+" "+CHR$(30)+" "+CHR$(205)+CHR$(205)
  499. '           GOSUB POPLIST.DISP
  500. '      ENDIF
  501.  
  502.  
  503. '
  504. POPLIST.DISP:
  505.        ATTR=(BACK% AND 7)*16+FORE%
  506.        CALL FASTPRT(DAT$,MROW,MCOL,ATTR)
  507.        RETURN
  508.  
  509. '
  510. '
  511. ' Scan the list of items item looking for an item whose fitst character
  512. 'matches the keyboard character the user just typed.
  513. '
  514. POPLIST.FIND.OPTION:
  515.        SAVE.SELECT=SELECT.%                 'save the current item highlighted
  516.        TEMP.SELECT=SELECT.%
  517.        FIRST.CHAR$=KP$                      'this is the character to look for
  518.        COUNT=0                              'how many items have looked at
  519. POPLIST.FIND.LOOP:
  520.        TEMP.SELECT=TEMP.SELECT+1            'look at the item after the current one
  521.        IF TEMP.SELECT>MAXITEMS% THEN        'are we at the end of the list
  522.            TEMP.SELECT=1                    'Yes start back at the first item in the list
  523.        ENDIF
  524.  
  525.        COUNT=COUNT+1                        'we have looked at this many items so far
  526.        IF COUNT>MAXITEMS% THEN              'have we looked at all the items in the list
  527.            RETURN                           'YES
  528.        ENDIF
  529.  
  530.        MID$(TEMP.ITEM$,1)=ITEM$((TEMP.SELECT-SELECT.BASE)+ITEM.MIN)
  531.        LEN.TEMP.ITEM=LEN(ITEM$((TEMP.SELECT-SELECT.BASE)+ITEM.MIN))
  532.  
  533. '
  534. 'scan over leading spaces for this item, up to first character
  535. '
  536.        FOR I=1 TO LEN.TEMP.ITEM
  537.        IF MID$(TEMP.ITEM$,I,1)<>" " THEN
  538.            IF MID$(TEMP.ITEM$,I,1)=FIRST.CHAR$ THEN
  539.                GOTO POPLIST.FOUND.IT        'this one was a match
  540.            ELSE
  541.              GOTO POPLIST.FIND.LOOP         'not this one, keep looking
  542.            ENDIF
  543.        ENDIF
  544.  
  545.        NEXT
  546.  
  547.        GOTO POPLIST.FIND.LOOP               'not this one, keep looking
  548.  
  549. '
  550. POPLIST.FOUND.IT:
  551.        SELECT.%=TEMP.SELECT                   'this is the item to select now
  552.  
  553.        OLD=SELECT.%
  554.        BEGVAL=SELECT.%                        'start the display window with this item
  555.        ENDVAL=(BEGVAL+SHOWITEMS%)-1           'and end with this item
  556.  
  557.        IF ENDVAL > MAXITEMS% THEN             'are there enought items to fill this window
  558.            ENDVAL=MAXITEMS%                   'NO, so display the last group of items
  559.            BEGVAL=(ENDVAL-SHOWITEMS%)+1       'and highlight the one found
  560.        ENDIF
  561.  
  562.        GOSUB POPLIST.FILL                     'display the group of items and highlight one found
  563.        RETURN
  564.  
  565. '
  566. '
  567. ' Look for a keyboard key press or a mouse action and return a 'keystroke'
  568. '
  569. POPLIST.GET.PRESS:
  570.        IF BUTTONS%=0 THEN                     'is a mouse supported?
  571.           GOTO POPLIST.GET.INKEY              'no, just look at the keyboard
  572.        ENDIF
  573.  
  574.        CALL MMGETLOC(MOUSECOL,MOUSEROW)       'get the current mouse cursor scrren location
  575.  
  576.        MOUSEROW=(MOUSEROW\8)+1                'convert row to 80x25 co-ordinates
  577.        MOUSECOL=(MOUSECOL\8)+1                'convert columnto 80x25 co-ordinates
  578.  
  579. '
  580. ' Check if the mouse is still in the window box
  581. '
  582. POPLIST.CHECK.IF.INBOX:
  583.  
  584. '
  585. ' Is the mouse outside the window frame
  586. '
  587.        IF (MOUSEROW<MENU.TOP.ROW) OR (MOUSEROW>MENU.BOTTOM.ROW) THEN
  588.           GOTO POPLIST.OUTSIDE.BOX
  589.        ENDIF
  590.  
  591. '
  592. ' Is the mouse in the box or on the window frame
  593. '
  594.        IF (MOUSECOL>=MENU.TOP.LEFT.COL) AND (MOUSECOL<=MENU.BOTTOM.RIGHT.COL) THEN
  595.           GOTO POPLIST.FOUNDIT
  596.        ENDIF
  597.  
  598. '
  599. ' Mouse cursor is outside the window, did user click any buttons
  600. '
  601. POPLIST.OUTSIDE.BOX:
  602.        CALL MMCLICK(LFT%,RGT%)                'see if left or right button clicked?
  603.        CLICK=LFT%+RGT%
  604.        IF CLICK=0 THEN                        'any button clicked?
  605.            GOTO POPLIST.OUTSIDE.BOX.CONT      'NO
  606.        ENDIF
  607.  
  608. '
  609. 'If any button clicked outside window then simualte an ESC key press
  610. '
  611.        IF (MOUSECOL<MENU.TOP.LEFT.COL-1) OR (MOUSECOL>MENU.BOTTOM.RIGHT.COL+1) THEN
  612.             KP$=CHR$(27)                      'simulate ESC key press
  613.            RETURN
  614.        ENDIF
  615.  
  616. '
  617. ' Mouse was clicked on the top or bottom window frame, get the character under
  618. 'the mouse cursor (on the screen)
  619. '
  620.        SCREEN.CHR=SCREEN(MOUSEROW,MOUSECOL)
  621.  
  622.        KP$=CHR$(0)+CHR$(73)                   'assume 'page up' to be simulated
  623.  
  624.        IF MOUSEROW=MENU.TOP.ROW-1 THEN        'mouse on upper window frame?
  625.            IF SHOWITEMS%<>MAXITEMS% THEN      'are we doing POPMENU
  626.              IF SCREEN.CHR=31 THEN            'NO, user click on 'down' arrow
  627.                    KP$=CHR$(0)+CHR$(81)       'YES, simulate 'page down' keystroke
  628.                  RETURN
  629.              ELSEIF SCREEN.CHR=30 THEN        'was mouse cursor on 'up' character
  630.                  RETURN
  631.              ELSE
  632.                  RETURN
  633.              ENDIF
  634.            ENDIF
  635.        ENDIF
  636.  
  637.        KP$=CHR$(0)+CHR$(81)                   'assume 'page down' to be simulated
  638.  
  639.        IF MOUSEROW=MENU.BOTTOM.ROW+1 THEN     'mouse on bottom window frame?
  640.            IF SHOWITEMS%<>MAXITEMS% THEN      'are we doing POPMENU
  641.              IF SCREEN.CHR=30 THEN            'NO, user click on 'up' arrow
  642.                    KP$=CHR$(0)+CHR$(73)       'YES, simulate 'page up' keystroke
  643.                  RETURN
  644.              ELSEIF SCREEN.CHR=31 THEN        'was mouse on 'down' character
  645.                  RETURN
  646.              ELSE
  647.                  RETURN
  648.              ENDIF
  649.            ENDIF
  650.        ENDIF
  651.  
  652.        KP$=CHR$(27)                           'Simualate an ESC keypress
  653.        RETURN
  654.  
  655. POPLIST.OUTSIDE.BOX.CONT:
  656.        GOSUB POPLIST.MMCURSORON               'turn the mouse cursor on
  657.        GOTO POPLIST.GET.INKEY                 'see if a keyboard key pressed
  658.  
  659. '
  660. POPLIST.FOUNDIT:
  661.        SELECT.%=BEGVAL+(MOUSEROW-MENU.TOP.ROW) 'this is the one we want to highlight now
  662.  
  663.        IF SELECT.%<>OLD THEN                   'are we on the same one as is currently highlighted
  664.             GOSUB POPLIST.FILL                 'NO, so highlight the newone just selected with the mouse
  665.             OLD=SELECT.%
  666.             GOSUB POPLIST.MMCURSOROFF          'turn off the mouse cursor
  667.             CALL MMCLICK(LFT%,RGT%)            'clear any mouse clicks
  668.          GOTO POPLIST.GET.INKEY
  669.        ENDIF
  670.  
  671.        GOSUB POPLIST.MMCURSOROFF               'turn off the mouse cursor
  672.  
  673.        CALL MMCLICK(LFT%,RGT%)                 'see if mouse clicked on the current highlighted item
  674.  
  675.        CLICK=LFT%+RGT%                         'was right or left button clicked?
  676.  
  677.        IF CLICK THEN                           'a button clicked?
  678.           KP$=CHR$(13)                         'YES, simulate a ENTER key press
  679.          RETURN
  680.        ENDIF
  681.  
  682. POPLIST.GET.INKEY:
  683.        KP$=INKEY$                              'get a keyboard keypress character, if one avail.
  684.  
  685.        IF LEN(KP$)=0 THEN                      'keep looking for a mouse or keyboard action
  686.           GOTO POPLIST.GET.PRESS
  687.        ENDIF
  688.  
  689.        RETURN
  690.  
  691. '
  692. '
  693. ' The Window upper left frame co-ordinates were defined
  694. '
  695. POPLIST.GETORD:
  696.        QUADRANT$=LTRIM$(QUADRANT$)             'strip off any leading and trailing spaces
  697.        QUADRANT$=RTRIM$(QUADRANT$)
  698.  
  699.        COLON.LOC=INSTR(QUADRANT$,":")          'find where the row/column separator char is loacted
  700.  
  701.        IF COLON.LOC=1 THEN                     'was a row defined
  702.            QUADRANT$="02"+QUADRANT$            'NO, so default to row 02
  703.            COLON.LOC=3
  704.        ENDIF
  705.  
  706.        ULR%=VAL(LEFT$(QUADRANT$,COLON.LOC-1))  'convert row to a interger. to work with
  707.  
  708.        IF (ULR%<1) OR (ULR%>24) THEN           'is row in valid range of screen co-ordinates
  709.           ULR%=2                               'no, so default to row 02
  710.        ENDIF
  711.  
  712.        IF COLON.LOC=LEN(QUADRANT$) THEN        'was a column co-ordinate defined
  713.           QUADRANT$=QUADRANT$+"00"             'NO, so default to 00
  714.        ENDIF
  715.  
  716.        ULC%=VAL(MID$(QUADRANT$,COLON.LOC+1))   'convert column to interger, to work with
  717.  
  718.        IF (ULC%<1) OR (ULC%>80) THEN           'is the column in a valid range
  719.            GOSUB POPLIST.CENTER.ON.THE.LINE    'NO, so center the window on the row
  720.        ENDIF
  721.  
  722.        QUADRANT.ROW$=STR$(ULR%)                'return the string of the row and column we are working with
  723.        QUADRANT$="0"+RIGHT$(QUADRANT.ROW$,LEN(QUADRANT.ROW$)-1)+":"
  724.        QUADRANT.COL$=STR$(ULC%)
  725.        QUADRANT$=QUADRANT$+"0"+RIGHT$(QUADRANT.COL$,LEN(QUADRANT.COL$)-1)
  726.  
  727.        ULR%=ULR%+1                              'allow for window header frame description
  728.  
  729.        LRR=ULR%+SHOWITEMS%+1                    'calculate the windows lower right row and column co-ord.
  730.        LRC=ULC%+WINDLEN-1
  731.        RETURN
  732.  
  733. POPLIST.CENTER.ON.THE.LINE:
  734.        TEMP.ULC%=40-(LENGTH.MENU.ITEM/2)         'calculate the center point on the row
  735.        IF (ULC%<2) THEN                          'would window be outside screen?
  736.           TEMP.ULC%=2                            'put it back in scrren and allow for frame (but not shadow)
  737.        ENDIF
  738.  
  739.        ULC%=TEMP.ULC%                            'this is the upper left column needed to center this window
  740.  
  741.        RETURN
  742. '
  743. '
  744. ' Center the window frame header, within the window.
  745. '
  746. POPLIST.PUTHDR:
  747.        PAD=(WINDLEN/2)-(LEN(HEADER$)/2)-.5
  748.        MID$(TEMPHDR$,PAD+1,LEN(HEADER$))=HEADER$
  749.        HEADER$=TEMPHDR$
  750.        RETURN
  751.  
  752. '
  753. POPLIST.MMCURSORON:
  754.        IF BUTTONS%=0 THEN                     'is a mouse supported?
  755.            RETURN                             'NO
  756.        ENDIF
  757.  
  758.        IF MOUSE.CURSOR=0 THEN                 'is the mouse off at present?
  759.           CALL MMCURSORON                     'YES, turn it on
  760.           MOUSE.CURSOR=-1
  761.        ENDIF
  762.  
  763.        RETURN
  764.  
  765. POPLIST.MMCURSOROFF:
  766.        IF BUTTONS%=0 THEN                     'is a mouse supported?
  767.            RETURN                             'NO
  768.        ENDIF
  769.  
  770.        IF MOUSE.CURSOR=-1 THEN                'is the mouse on at present?
  771.           CALL MMCURSOROFF                    'YES, turn it off
  772.           MOUSE.CURSOR=0
  773.        ENDIF
  774.  
  775.        RETURN
  776. '
  777. POPLIST.SOUNDOFF:
  778.        SOUND 1000,1
  779.        SOUND 1500,2
  780.        SOUND 500,1
  781.        RETURN
  782.  
  783. '
  784. POPLIST.DONE:
  785.        GOSUB POPLIST.MMCURSOROFF              'turn the mouse off as we leave
  786.  
  787.        TEMP.ITEM$=""                          'free string space
  788.        HEADER$=""
  789.        TEMPHDR$=""
  790.        DAT$=""
  791.  
  792.        EXIT SUB                               'return to caller
  793. END SUB
  794.